diff --git a/include/stdlib.h b/include/stdlib.h --- a/include/stdlib.h +++ b/include/stdlib.h @@ -330,18 +330,21 @@ * parameter, and both are different from the ones expected by the historical * FreeBSD qsort_r() interface. * - * Apply a workaround where we explicitly link against the historical - * interface, qsort_r@FBSD_1.0, in case when qsort_r() is called with - * the last parameter with a function pointer that exactly matches the - * historical FreeBSD qsort_r() comparator signature, so applications - * written for the historical interface can continue to work without - * modification. + * Apply a workaround where we explicitly link against the historical interface, + * qsort_r@FBSD_1.0, in case when qsort_r() is called with the last parameter + * with a function pointer that exactly matches the historical FreeBSD qsort_r() + * comparator signature, so applications written for the historical interface + * can continue to work without modification. Toolchains that don't support + * symbol versioning don't define __sym_compat, so only provide this symbol in + * supported environments. */ -#if defined(__generic) || defined(__cplusplus) +#ifdef __sym_compat +#if (defined(__generic) || defined(__cplusplus)) void __qsort_r_compat(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); __sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0); #endif +#endif #if defined(__generic) && !defined(__cplusplus) #define qsort_r(base, nel, width, arg4, arg5) \ __generic(arg5, int (*)(void *, const void *, const void *), \ diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -90,9 +90,19 @@ #define __compiler_membar() __asm __volatile(" " : : : "memory") #define __CC_SUPPORTS___INLINE 1 +#define __CC_SUPPORTS_SYMVER 1 #endif /* __GNUC__ */ +/* + * TinyC pretends to be gcc 9.3. This is generally good enough to support + * everything FreeBSD... Except it doesn't support versionsed symbols via + * the .symver assembler directive. + */ +#ifdef __TINYC__ +#undef __CC_SUPPORTS_SYMVER +#endif + /* * The __CONCAT macro is used to concatenate parts of symbol names, e.g. * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. @@ -369,10 +379,12 @@ __asm__(".section .gnu.warning." #sym); \ __asm__(".asciz \"" msg "\""); \ __asm__(".previous") +#ifdef __CC_SUPPORTS_SYMVER #define __sym_compat(sym,impl,verid) \ __asm__(".symver " #impl ", " #sym "@" #verid) #define __sym_default(sym,impl,verid) \ __asm__(".symver " #impl ", " #sym "@@@" #verid) +#endif #else #define __weak_reference(sym,alias) \ __asm__(".weak alias"); \ @@ -381,10 +393,12 @@ __asm__(".section .gnu.warning.sym"); \ __asm__(".asciz \"msg\""); \ __asm__(".previous") +#ifdef __CC_SUPPORTS_SYMVER #define __sym_compat(sym,impl,verid) \ __asm__(".symver impl, sym@verid") #define __sym_default(impl,sym,verid) \ __asm__(".symver impl, sym@@@verid") +#endif #endif /* __STDC__ */ #define __GLOBL(sym) __asm__(".globl " __XSTRING(sym))