[10/11] allocate_once: Apply asm redirection before first use
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
Compilers may not be able to apply asm redirections to functions
after these functions are used for the first time, e.g. clang 13.
---
include/allocate_once.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Comments
On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote:
>Compilers may not be able to apply asm redirections to functions
>after these functions are used for the first time, e.g. clang 13.
Ditto. You may say 15. This fixed a dozen errors like:
In file included from alloc_buffer_alloc_array.c:19:
../include/alloc_buffer.h:382:20: error: cannot apply asm label to function after its first use
libc_hidden_proto (__libc_alloc_buffer_allocate)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:613:58: note: expanded from macro 'libc_hidden_proto'
# define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
~~~~~~~~~~~~~~^~~~~~~~~~~~~~
./../include/libc-symbols.h:513:19: note: expanded from macro 'hidden_proto'
__hidden_proto (name, , __GI_##name, ##attrs)
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:519:33: note: expanded from macro '__hidden_proto'
extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from alloc_buffer_alloc_array.c:19:
../include/alloc_buffer.h:383:20: error: cannot apply asm label to function after its first use
libc_hidden_proto (__libc_alloc_buffer_copy_bytes)
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../include/libc-symbols.h:613:58: note: expanded from macro 'libc_hidden_proto'
Reviewed-by: Fangrui Song <maskray@google.com>
@@ -27,6 +27,9 @@ void *__libc_allocate_once_slow (void **__place,
void (*__deallocate) (void *__closure,
void *__ptr),
void *__closure);
+#ifndef _ISOMAC
+libc_hidden_proto (__libc_allocate_once_slow)
+#endif
/* Return an a pointer to an allocated and initialized data structure.
If this function returns a non-NULL value, the caller can assume
@@ -88,8 +91,4 @@ allocate_once (void **__place, void *(*__allocate) (void *__closure),
__closure);
}
-#ifndef _ISOMAC
-libc_hidden_proto (__libc_allocate_once_slow)
-#endif
-
#endif /* _ALLOCATE_ONCE_H */