[libcxx-commits] [libcxx] 21d9282 - libcxx: Don't apply ABI tags to extern "C" fns
Sam James via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 24 23:35:39 PST 2023
Author: Arsen Arsenović
Date: 2023-01-25T07:35:33Z
New Revision: 21d9282ae2b6e1e7dfbabfd87f6208c3bdff8ea4
URL: https://github.com/llvm/llvm-project/commit/21d9282ae2b6e1e7dfbabfd87f6208c3bdff8ea4
DIFF: https://github.com/llvm/llvm-project/commit/21d9282ae2b6e1e7dfbabfd87f6208c3bdff8ea4.diff
LOG: libcxx: Don't apply ABI tags to extern "C" fns
GCC rejects ABI tags on non mangled functions, as they would otherwise
be a no-op. This commit replaces such instances with equivalent
_LIBCPP_HIDE_FROM_ABI constants but without ABI tags attached.
.../include/c++/v1/__support/musl/xlocale.h:28:68: error: 'abi_tag'
attribute applied to extern "C" declaration 'long long int
strtoll_l(const char*, char**, int, locale_t)'
28 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
| ^
Bug: https://bugs.gentoo.org/869038
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D142415
Added:
Modified:
libcxx/include/__config
libcxx/include/__support/android/locale_bionic.h
libcxx/include/__support/musl/xlocale.h
libcxx/include/__support/openbsd/xlocale.h
libcxx/include/__support/xlocale/__nop_locale_mgmt.h
libcxx/include/__support/xlocale/__posix_l_fallback.h
libcxx/include/__support/xlocale/__strtonum_fallback.h
Removed:
################################################################################
diff --git a/libcxx/include/__config b/libcxx/include/__config
index e8a993f769b52..40c9deb622951 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -629,7 +629,11 @@ typedef __char32_t char32_t;
# else
# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
# endif
-# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
+
+// This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern
+// "C" function, as those lack mangling.
+# define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
# ifdef _LIBCPP_BUILDING_LIBRARY
# if _LIBCPP_ABI_VERSION > 1
diff --git a/libcxx/include/__support/android/locale_bionic.h b/libcxx/include/__support/android/locale_bionic.h
index 5f4a89a7c61e8..30e345cf9ee1c 100644
--- a/libcxx/include/__support/android/locale_bionic.h
+++ b/libcxx/include/__support/android/locale_bionic.h
@@ -46,18 +46,15 @@ extern "C" {
extern "C" {
#endif
-inline _LIBCPP_HIDE_FROM_ABI float
-strtof_l(const char* __nptr, char** __endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C float strtof_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtof(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI double
-strtod_l(const char* __nptr, char** __endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C double strtod_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtod(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI long
-strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtol(__nptr, __endptr, __base);
}
diff --git a/libcxx/include/__support/musl/xlocale.h b/libcxx/include/__support/musl/xlocale.h
index 4ff07ba685c55..fe1dcf61a59d5 100644
--- a/libcxx/include/__support/musl/xlocale.h
+++ b/libcxx/include/__support/musl/xlocale.h
@@ -24,28 +24,24 @@
extern "C" {
#endif
-inline _LIBCPP_HIDE_FROM_ABI long long
-strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI unsigned long long
-strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
+strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtoull(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI long long
-wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI unsigned long long
-wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoull(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI long double
-wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
return ::wcstold(__nptr, __endptr);
}
diff --git a/libcxx/include/__support/openbsd/xlocale.h b/libcxx/include/__support/openbsd/xlocale.h
index 0269e8133b9f5..b969ae9d106a7 100644
--- a/libcxx/include/__support/openbsd/xlocale.h
+++ b/libcxx/include/__support/openbsd/xlocale.h
@@ -20,18 +20,14 @@
extern "C" {
#endif
-
-inline _LIBCPP_HIDE_FROM_ABI long
-strtol_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtol(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI unsigned long
-strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtoul(__nptr, __endptr, __base);
}
-
#ifdef __cplusplus
}
#endif
diff --git a/libcxx/include/__support/xlocale/__nop_locale_mgmt.h b/libcxx/include/__support/xlocale/__nop_locale_mgmt.h
index 23727a5a3be6a..4b3caa895fe59 100644
--- a/libcxx/include/__support/xlocale/__nop_locale_mgmt.h
+++ b/libcxx/include/__support/xlocale/__nop_locale_mgmt.h
@@ -19,24 +19,13 @@ extern "C" {
// Patch over lack of extended locale support
typedef void *locale_t;
-inline _LIBCPP_HIDE_FROM_ABI locale_t
-duplocale(locale_t) {
- return NULL;
-}
-
-inline _LIBCPP_HIDE_FROM_ABI void
-freelocale(locale_t) {
-}
-
-inline _LIBCPP_HIDE_FROM_ABI locale_t
-newlocale(int, const char *, locale_t) {
- return NULL;
-}
-
-inline _LIBCPP_HIDE_FROM_ABI locale_t
-uselocale(locale_t) {
- return NULL;
-}
+inline _LIBCPP_HIDE_FROM_ABI_C locale_t duplocale(locale_t) { return NULL; }
+
+inline _LIBCPP_HIDE_FROM_ABI_C void freelocale(locale_t) {}
+
+inline _LIBCPP_HIDE_FROM_ABI_C locale_t newlocale(int, const char*, locale_t) { return NULL; }
+
+inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; }
#define LC_COLLATE_MASK (1 << LC_COLLATE)
#define LC_CTYPE_MASK (1 << LC_CTYPE)
diff --git a/libcxx/include/__support/xlocale/__posix_l_fallback.h b/libcxx/include/__support/xlocale/__posix_l_fallback.h
index 8196c2362c71c..774081a8a46fd 100644
--- a/libcxx/include/__support/xlocale/__posix_l_fallback.h
+++ b/libcxx/include/__support/xlocale/__posix_l_fallback.h
@@ -27,144 +27,83 @@
extern "C" {
#endif
-inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) {
- return ::isalnum(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isalnum_l(int __c, locale_t) { return ::isalnum(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) {
- return ::isalpha(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isalpha_l(int __c, locale_t) { return ::isalpha(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isblank_l(int __c, locale_t) {
- return ::isblank(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isblank_l(int __c, locale_t) { return ::isblank(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) {
- return ::iscntrl(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) {
- return ::isdigit(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isdigit_l(int __c, locale_t) { return ::isdigit(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) {
- return ::isgraph(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isgraph_l(int __c, locale_t) { return ::isgraph(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) {
- return ::islower(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int islower_l(int __c, locale_t) { return ::islower(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) {
- return ::isprint(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isprint_l(int __c, locale_t) { return ::isprint(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) {
- return ::ispunct(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int ispunct_l(int __c, locale_t) { return ::ispunct(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) {
- return ::isspace(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isspace_l(int __c, locale_t) { return ::isspace(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) {
- return ::isupper(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isupper_l(int __c, locale_t) { return ::isupper(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {
- return ::isxdigit(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
- return ::toupper(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int toupper_l(int __c, locale_t) { return ::toupper(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
- return ::tolower(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int tolower_l(int __c, locale_t) { return ::tolower(__c); }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {
- return ::iswalnum(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswalnum_l(wint_t __c, locale_t) { return ::iswalnum(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) {
- return ::iswalpha(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswblank_l(wint_t __c, locale_t) {
- return ::iswblank(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswblank_l(wint_t __c, locale_t) { return ::iswblank(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) {
- return ::iswcntrl(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswcntrl_l(wint_t __c, locale_t) { return ::iswcntrl(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) {
- return ::iswdigit(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) {
- return ::iswgraph(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswgraph_l(wint_t __c, locale_t) { return ::iswgraph(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) {
- return ::iswlower(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) {
- return ::iswprint(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswpunct_l(wint_t __c, locale_t) {
- return ::iswpunct(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswpunct_l(wint_t __c, locale_t) { return ::iswpunct(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswspace_l(wint_t __c, locale_t) {
- return ::iswspace(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswspace_l(wint_t __c, locale_t) { return ::iswspace(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswupper_l(wint_t __c, locale_t) {
- return ::iswupper(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswupper_l(wint_t __c, locale_t) { return ::iswupper(__c); }
-inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {
- return ::iswxdigit(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C int iswxdigit_l(wint_t __c, locale_t) { return ::iswxdigit(__c); }
-inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
- return ::towupper(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); }
-inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {
- return ::towlower(__c);
-}
+inline _LIBCPP_HIDE_FROM_ABI_C wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); }
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI int
-strcoll_l(const char *__s1, const char *__s2, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C int strcoll_l(const char* __s1, const char* __s2, locale_t) {
return ::strcoll(__s1, __s2);
}
-inline _LIBCPP_HIDE_FROM_ABI size_t
-strxfrm_l(char *__dest, const char *__src, size_t __n, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C size_t strxfrm_l(char* __dest, const char* __src, size_t __n, locale_t) {
return ::strxfrm(__dest, __src, __n);
}
-inline _LIBCPP_HIDE_FROM_ABI size_t
-strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
- locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C size_t
+strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm, locale_t) {
return ::strftime(__s, __max, __format, __tm);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI int
-wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) {
return ::wcscoll(__ws1, __ws2);
}
-inline _LIBCPP_HIDE_FROM_ABI size_t
-wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) {
return ::wcsxfrm(__dest, __src, __n);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
diff --git a/libcxx/include/__support/xlocale/__strtonum_fallback.h b/libcxx/include/__support/xlocale/__strtonum_fallback.h
index d1ef8aaa83495..ae8e13a75849e 100644
--- a/libcxx/include/__support/xlocale/__strtonum_fallback.h
+++ b/libcxx/include/__support/xlocale/__strtonum_fallback.h
@@ -26,44 +26,38 @@
extern "C" {
#endif
-inline _LIBCPP_HIDE_FROM_ABI float
-strtof_l(const char *__nptr, char **__endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C float strtof_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtof(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI double
-strtod_l(const char *__nptr, char **__endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C double strtod_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtod(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI long double
-strtold_l(const char *__nptr, char **__endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long double strtold_l(const char* __nptr, char** __endptr, locale_t) {
return ::strtold(__nptr, __endptr);
}
-inline _LIBCPP_HIDE_FROM_ABI long long
-strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI unsigned long long
-strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
+strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
return ::strtoull(__nptr, __endptr, __base);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline _LIBCPP_HIDE_FROM_ABI long long
-wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoll(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI unsigned long long
-wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
+wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
return ::wcstoull(__nptr, __endptr, __base);
}
-inline _LIBCPP_HIDE_FROM_ABI long double
-wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
+inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
return ::wcstold(__nptr, __endptr);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
More information about the libcxx-commits
mailing list