build: Swap symbol and alias arguments order in macros creating aliases

The current order is rather confusing, pass the real symbol first
and the alias we want to create next.
This commit is contained in:
Guillem Jover 2024-02-14 03:39:16 +01:00
parent 19e06407eb
commit f050160976
5 changed files with 29 additions and 29 deletions

View File

@ -38,47 +38,47 @@
#endif
#if defined(__APPLE__)
#define libbsd_strong_alias(alias, symbol) \
#define libbsd_strong_alias(symbol, alias) \
__asm__(".globl _" #alias); \
__asm__(".set _" #alias ", _" #symbol); \
extern __typeof(symbol) alias
#elif !defined(_MSC_VER)
#define libbsd_strong_alias(alias, symbol) \
#define libbsd_strong_alias(symbol, alias) \
extern __typeof__(symbol) alias __attribute__((__alias__(#symbol)))
#endif
#ifdef __ELF__
# if __has_attribute(symver)
/* The symver attribute is supported since gcc 10.x. */
#define libbsd_symver_default(alias, symbol, version) \
#define libbsd_symver_default(symbol, alias, version) \
extern __typeof__(symbol) symbol \
__attribute__((__symver__(#alias "@@" #version)))
#define libbsd_symver_variant(alias, symbol, version) \
#define libbsd_symver_variant(symbol, alias, version) \
extern __typeof__(symbol) symbol \
__attribute__((__symver__(#alias "@" #version)))
#define libbsd_symver_weak(alias, symbol, version) \
#define libbsd_symver_weak(symbol, alias, version) \
extern __typeof__(symbol) symbol \
__attribute__((__symver__(#alias "@" #version), __weak__))
# else
#define libbsd_symver_default(alias, symbol, version) \
#define libbsd_symver_default(symbol, alias, version) \
__asm__(".symver " #symbol "," #alias "@@" #version)
#define libbsd_symver_variant(alias, symbol, version) \
#define libbsd_symver_variant(symbol, alias, version) \
__asm__(".symver " #symbol "," #alias "@" #version)
#define libbsd_symver_weak(alias, symbol, version) \
libbsd_symver_variant(alias, symbol, version); \
#define libbsd_symver_weak(symbol, alias, version) \
libbsd_symver_variant(symbol, alias, version); \
extern __typeof__(symbol) alias \
__attribute__((__weak__))
# endif
#else
#define libbsd_symver_default(alias, symbol, version) \
libbsd_strong_alias(alias, symbol)
#define libbsd_symver_default(symbol, alias, version) \
libbsd_strong_alias(symbol, alias)
#define libbsd_symver_variant(alias, symbol, version)
#define libbsd_symver_variant(symbol, alias, version)
#define libbsd_symver_weak(alias, symbol, version)
#define libbsd_symver_weak(symbol, alias, version)
#endif
#endif

View File

@ -37,7 +37,7 @@ libbsd_MD5Init(MD5_CTX *context)
libbsd_link_warning(MD5Init,
"The MD5Init() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5Init, libbsd_MD5Init, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5Init, MD5Init, LIBBSD_0.0);
void
libbsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
@ -47,7 +47,7 @@ libbsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
libbsd_link_warning(MD5Update,
"The MD5Update() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5Update, libbsd_MD5Update, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5Update, MD5Update, LIBBSD_0.0);
void
libbsd_MD5Pad(MD5_CTX *context)
@ -57,7 +57,7 @@ libbsd_MD5Pad(MD5_CTX *context)
libbsd_link_warning(MD5Pad,
"The MD5Pad() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5Pad, libbsd_MD5Pad, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5Pad, MD5Pad, LIBBSD_0.0);
void
libbsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
@ -67,7 +67,7 @@ libbsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
libbsd_link_warning(MD5Final,
"The MD5Final() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5Final, libbsd_MD5Final, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5Final, MD5Final, LIBBSD_0.0);
void
libbsd_MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
@ -77,7 +77,7 @@ libbsd_MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
libbsd_link_warning(MD5Transform,
"The MD5Transform() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5Transform, libbsd_MD5Transform, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5Transform, MD5Transform, LIBBSD_0.0);
char *
libbsd_MD5End(MD5_CTX *context, char *buf)
@ -87,7 +87,7 @@ libbsd_MD5End(MD5_CTX *context, char *buf)
libbsd_link_warning(MD5End,
"The MD5End() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5End, libbsd_MD5End, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5End, MD5End, LIBBSD_0.0);
char *
libbsd_MD5File(const char *filename, char *buf)
@ -97,7 +97,7 @@ libbsd_MD5File(const char *filename, char *buf)
libbsd_link_warning(MD5File,
"The MD5File() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5File, libbsd_MD5File, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5File, MD5File, LIBBSD_0.0);
char *
libbsd_MD5FileChunk(const char *filename, char *buf, off_t offset, off_t length)
@ -107,7 +107,7 @@ libbsd_MD5FileChunk(const char *filename, char *buf, off_t offset, off_t length)
libbsd_link_warning(MD5FileChunk,
"The MD5FileChunk() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5FileChunk, libbsd_MD5FileChunk, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5FileChunk, MD5FileChunk, LIBBSD_0.0);
char *
libbsd_MD5Data(const uint8_t *data, size_t len, char *buf)
@ -117,4 +117,4 @@ libbsd_MD5Data(const uint8_t *data, size_t len, char *buf)
libbsd_link_warning(MD5Data,
"The MD5Data() function in libbsd is a deprecated wrapper, "
"use libmd instead.");
libbsd_symver_weak(MD5Data, libbsd_MD5Data, LIBBSD_0.0);
libbsd_symver_weak(libbsd_MD5Data, MD5Data, LIBBSD_0.0);

View File

@ -289,17 +289,17 @@ setproctitle_impl(const char *fmt, ...)
*++nul = '\0';
}
}
libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5);
libbsd_symver_default(setproctitle_impl, setproctitle, LIBBSD_0.5);
/* The original function introduced in 0.2 was a stub, it only got implemented
* in 0.5, make the implementation available in the old version as an alias
* for code linking against that version, and change the default to use the
* new version, so that new code depends on the implemented version. */
#if defined(libbsd_strong_alias)
libbsd_strong_alias(setproctitle_stub, setproctitle_impl);
libbsd_strong_alias(setproctitle_impl, setproctitle_stub);
#else
void
setproctitle_stub(const char *fmt, ...)
__attribute__((__alias__("setproctitle_impl")));
#endif
libbsd_symver_variant(setproctitle, setproctitle_stub, LIBBSD_0.2);
libbsd_symver_variant(setproctitle_stub, setproctitle, LIBBSD_0.2);

View File

@ -570,7 +570,7 @@ strnunvis_openbsd(char *dst, const char *src, size_t dlen)
{
return strnunvisx(dst, dlen, src, 0);
}
libbsd_symver_default(strnunvis, strnunvis_openbsd, LIBBSD_0.2);
libbsd_symver_default(strnunvis_openbsd, strnunvis, LIBBSD_0.2);
int
strnunvis_netbsd(char *, size_t, const char *);
@ -579,4 +579,4 @@ strnunvis_netbsd(char *dst, size_t dlen, const char *src)
{
return strnunvisx(dst, dlen, src, 0);
}
libbsd_symver_variant(strnunvis, strnunvis_netbsd, LIBBSD_0.9.1);
libbsd_symver_variant(strnunvis_netbsd, strnunvis, LIBBSD_0.9.1);

View File

@ -739,7 +739,7 @@ strnvis_openbsd(char *mbdst, const char *mbsrc, size_t dlen, int flags)
{
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
}
libbsd_symver_default(strnvis, strnvis_openbsd, LIBBSD_0.2);
libbsd_symver_default(strnvis_openbsd, strnvis, LIBBSD_0.2);
int
strnvis_netbsd(char *, size_t, const char *, int);
@ -748,7 +748,7 @@ strnvis_netbsd(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
}
libbsd_symver_variant(strnvis, strnvis_netbsd, LIBBSD_0.9.1);
libbsd_symver_variant(strnvis_netbsd, strnvis, LIBBSD_0.9.1);
int
stravis(char **mbdstp, const char *mbsrc, int flags)