summaryrefslogtreecommitdiff
path: root/libgcompat/resolv.c
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-14 18:40:59 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-14 18:57:52 -0600
commitdfafb0735f09d65a392d03a2d1ad3d0b934981da (patch)
treef5a1c49f22df2e72494cd114785763b111d6924a /libgcompat/resolv.c
parentd40369b0e09e4e2228ebff305067ec2d99220848 (diff)
downloadgcompat-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/resolv.c')
-rw-r--r--libgcompat/resolv.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libgcompat/resolv.c b/libgcompat/resolv.c
index 3566dcd..7ad984f 100644
--- a/libgcompat/resolv.c
+++ b/libgcompat/resolv.c
@@ -9,7 +9,9 @@
#include <resolv.h> /* res_state */
#include <string.h> /* memcpy, memset */
-static inline int res_ninit(res_state statp)
+#include "alias.h" /* weak_alias */
+
+static inline int __res_ninit(res_state statp)
{
int rc = res_init();
if (statp != &_res) {
@@ -17,8 +19,9 @@ static inline int res_ninit(res_state statp)
}
return rc;
}
+weak_alias(__res_ninit, res_ninit);
-static inline int res_nclose(res_state statp)
+static inline int __res_nclose(res_state statp)
{
if (!statp) {
return -1;
@@ -28,8 +31,4 @@ static inline int res_nclose(res_state statp)
}
return 0;
}
-
-extern __typeof(res_ninit) __res_ninit
- __attribute__((weak, alias("res_ninit")));
-extern __typeof(res_nclose) __res_nclose
- __attribute__((weak, alias("res_nclose")));
+weak_alias(__res_nclose, res_nclose);