mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 00:56:41 +00:00
parent
b84c42944a
commit
d0438d2d08
@ -82,7 +82,7 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
|
||||
inline _LIBCPP_HIDE_FROM_ABI
|
||||
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
|
||||
const size_t buff_size = 256;
|
||||
if ((*strp = (char*)malloc(buff_size)) == NULL) {
|
||||
if ((*strp = (char*)malloc(buff_size)) == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char
|
||||
va_end(ap_copy);
|
||||
|
||||
if ((size_t)str_size >= buff_size) {
|
||||
if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) {
|
||||
if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
|
||||
|
@ -15,13 +15,13 @@
|
||||
// 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 locale_t duplocale(locale_t) { return nullptr; }
|
||||
|
||||
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 newlocale(int, const char*, locale_t) { return nullptr; }
|
||||
|
||||
inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; }
|
||||
inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return nullptr; }
|
||||
|
||||
#define LC_COLLATE_MASK (1 << LC_COLLATE)
|
||||
#define LC_CTYPE_MASK (1 << LC_CTYPE)
|
||||
|
@ -94,11 +94,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
|
||||
|
||||
static void
|
||||
__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
|
||||
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, NULL, NULL);
|
||||
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, nullptr, nullptr);
|
||||
}
|
||||
|
||||
static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
|
||||
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);
|
||||
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr);
|
||||
}
|
||||
|
||||
#else // <- Add other operating systems here
|
||||
|
@ -1004,7 +1004,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {
|
||||
# warning ctype<char>::classic_table() is not implemented
|
||||
printf("ctype<char>::classic_table() is not implemented\n");
|
||||
abort();
|
||||
return NULL;
|
||||
return nullptr;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
@ -48,7 +48,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(
|
||||
size_t dest_remaining = max_dest_chars - dest_converted;
|
||||
|
||||
if (dst == nullptr) {
|
||||
result = mbrtowc(NULL, *src + source_converted, source_remaining, ps);
|
||||
result = mbrtowc(nullptr, *src + source_converted, source_remaining, ps);
|
||||
} else if (dest_remaining >= source_remaining) {
|
||||
// dst has enough space to translate in-place.
|
||||
result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps);
|
||||
@ -86,7 +86,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(
|
||||
|
||||
if (dst) {
|
||||
if (result == terminated_sequence)
|
||||
*src = NULL;
|
||||
*src = nullptr;
|
||||
else
|
||||
*src += source_converted;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(
|
||||
size_t dest_remaining = dst_size_bytes - dest_converted;
|
||||
|
||||
if (dst == nullptr) {
|
||||
result = wcrtomb(NULL, c, ps);
|
||||
result = wcrtomb(nullptr, c, ps);
|
||||
} else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) {
|
||||
// dst has enough space to translate in-place.
|
||||
result = wcrtomb(dst + dest_converted, c, ps);
|
||||
@ -82,7 +82,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(
|
||||
|
||||
if (c == L'\0') {
|
||||
if (dst)
|
||||
*src = NULL;
|
||||
*src = nullptr;
|
||||
return dest_converted;
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
|
||||
std::string current_loc_name(setlocale(LC_ALL, 0));
|
||||
|
||||
// Check for errors.
|
||||
if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == NULL) {
|
||||
if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == nullptr) {
|
||||
errno = EINVAL;
|
||||
return (locale_t)0;
|
||||
} else {
|
||||
for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) {
|
||||
if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == NULL) {
|
||||
if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == nullptr) {
|
||||
setlocale(LC_ALL, current_loc_name.c_str());
|
||||
errno = EINVAL;
|
||||
return (locale_t)0;
|
||||
@ -74,12 +74,12 @@ locale_t uselocale(locale_t newloc) {
|
||||
if (newloc) {
|
||||
// Set locales and check for errors.
|
||||
bool is_error =
|
||||
(newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||
|
||||
(newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||
|
||||
(newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||
|
||||
(newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||
|
||||
(newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||
|
||||
(newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);
|
||||
(newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == nullptr) ||
|
||||
(newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == nullptr) ||
|
||||
(newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == nullptr) ||
|
||||
(newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == nullptr) ||
|
||||
(newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == nullptr) ||
|
||||
(newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == nullptr);
|
||||
|
||||
if (is_error) {
|
||||
setlocale(LC_ALL, current_loc_name.c_str());
|
||||
|
@ -17,13 +17,13 @@
|
||||
// a pointer to a malloc'd string in *sptr.
|
||||
// If return >= 0, use free to delete *sptr.
|
||||
int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) {
|
||||
*sptr = NULL;
|
||||
*sptr = nullptr;
|
||||
// Query the count required.
|
||||
va_list ap_copy;
|
||||
va_copy(ap_copy, ap);
|
||||
_LIBCPP_DIAGNOSTIC_PUSH
|
||||
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
|
||||
int count = vsnprintf(NULL, 0, format, ap_copy);
|
||||
int count = vsnprintf(nullptr, 0, format, ap_copy);
|
||||
_LIBCPP_DIAGNOSTIC_POP
|
||||
va_end(ap_copy);
|
||||
if (count < 0)
|
||||
@ -81,7 +81,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,
|
||||
// if result > 0, it's the size in bytes of that character.
|
||||
// othewise if result is zero it indicates the null character has been found.
|
||||
// otherwise it's an error and errno may be set.
|
||||
size_t char_size = mbrtowc(dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps);
|
||||
size_t char_size = mbrtowc(dst ? dst + dest_converted : nullptr, *src + source_converted, source_remaining, ps);
|
||||
// Don't do anything to change errno from here on.
|
||||
if (char_size > 0) {
|
||||
source_remaining -= char_size;
|
||||
@ -95,7 +95,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,
|
||||
}
|
||||
if (dst) {
|
||||
if (have_result && result == terminated_sequence)
|
||||
*src = NULL;
|
||||
*src = nullptr;
|
||||
else
|
||||
*src += source_converted;
|
||||
}
|
||||
@ -141,7 +141,7 @@ size_t wcsnrtombs(char* __restrict dst,
|
||||
if (dst)
|
||||
result = wcrtomb_s(&char_size, dst + dest_converted, dest_remaining, c, ps);
|
||||
else
|
||||
result = wcrtomb_s(&char_size, NULL, 0, c, ps);
|
||||
result = wcrtomb_s(&char_size, nullptr, 0, c, ps);
|
||||
// If result is zero there is no error and char_size contains the
|
||||
// size of the multi-byte-sequence converted.
|
||||
// Otherwise result indicates an errno type error.
|
||||
@ -161,7 +161,7 @@ size_t wcsnrtombs(char* __restrict dst,
|
||||
}
|
||||
if (dst) {
|
||||
if (terminator_found)
|
||||
*src = NULL;
|
||||
*src = nullptr;
|
||||
else
|
||||
*src = *src + source_converted;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
|
||||
|
||||
int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)(void)) {
|
||||
if (!InitOnceExecuteOnce(
|
||||
(PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), NULL))
|
||||
(PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), nullptr))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user