From dfafb0735f09d65a392d03a2d1ad3d0b934981da Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 14 Jan 2018 18:40:59 -0600 Subject: 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 --- libgcompat/alias.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 libgcompat/alias.h (limited to 'libgcompat/alias.h') diff --git a/libgcompat/alias.h b/libgcompat/alias.h new file mode 100644 index 0000000..3f54672 --- /dev/null +++ b/libgcompat/alias.h @@ -0,0 +1,9 @@ +#ifndef _ALIAS_H_ +#define _ALIAS_H_ + +#define alias(old, new) \ + extern __typeof(old) new __attribute__((__alias__(#old))) +#define weak_alias(old, new) \ + extern __typeof(old) new __attribute__((weak, __alias__(#old))) + +#endif /* _ALIAS_H_ */ -- cgit v1.2.3-60-g2f50