diff options
author | Samuel Holland <samuel@sholland.org> | 2018-01-14 18:40:59 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-01-14 18:57:52 -0600 |
commit | dfafb0735f09d65a392d03a2d1ad3d0b934981da (patch) | |
tree | f5a1c49f22df2e72494cd114785763b111d6924a /libgcompat/string.c | |
parent | d40369b0e09e4e2228ebff305067ec2d99220848 (diff) | |
download | gcompat-dfafb0735f09d65a392d03a2d1ad3d0b934981da.tar.gz gcompat-dfafb0735f09d65a392d03a2d1ad3d0b934981da.tar.bz2 gcompat-dfafb0735f09d65a392d03a2d1ad3d0b934981da.tar.xz gcompat-dfafb0735f09d65a392d03a2d1ad3d0b934981da.zip |
libgcompat: Add and use a macro for defining symbol aliases
* Prefer providing the underscore-prefixed symbol as the strong
definition.
* Do not use a weak alias if the alias is also underscore-prefixed.
* Make libgcompat objects depend on the new header.
[NOTE: I originally took the weak_alias macro from musl's libc.h, but
it's trivial and the same pattern already in use. If desired, I
can add the musl copyright notice.]
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'libgcompat/string.c')
-rw-r--r-- | libgcompat/string.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libgcompat/string.c b/libgcompat/string.c index 60f61fc..7ca0bf6 100644 --- a/libgcompat/string.c +++ b/libgcompat/string.c @@ -2,6 +2,8 @@ #include <stdlib.h> /* strto[u?]ll */ #include <string.h> /* memcpy, strcpy, strncat, strndup */ +#include "alias.h" /* weak_alias */ + /* "Checked" memcpy */ void *__memcpy_chk(void *dest, const void *src, size_t len, size_t destlen) { @@ -60,7 +62,7 @@ char *__strndup(const char *str, size_t count) /* The existance of this method, and the fact it is used in real code, gives * me nightmares. */ -void *rawmemchr(const void *s, int c) +void *__rawmemchr(const void *s, int c) { const unsigned char *haystack = s; unsigned char needle = (unsigned char) c; @@ -68,9 +70,7 @@ void *rawmemchr(const void *s, int c) ; return (void *) haystack; } - -extern __typeof(rawmemchr) __rawmemchr - __attribute__((weak, alias("rawmemchr"))); +weak_alias(__rawmemchr, rawmemchr); /* Another useless __ alias */ char *__strtok_r(char *str, const char *delim, char **saveptr) |