NetBSD build fixes (#2366)

This commit is contained in:
nia 2021-11-29 10:53:18 +01:00 committed by GitHub
parent c3746d629f
commit eeeefa4532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 3 deletions

View File

@ -320,6 +320,8 @@ find_function(setlocale)
find_function(snprintf_l)
find_function(uselocale)
find_function(popcount32)
find_function(futimens)
find_function(futimes)
@ -368,7 +370,7 @@ if(USE_PTHREADS)
endif()
endif()
if(HAVE_NEWLOCALE AND HAVE_FREELOCALE AND HAVE_USELOCALE OR APPLE)
if(HAVE_NEWLOCALE AND HAVE_FREELOCALE OR APPLE)
list(APPEND FUNCTION_DEFINES HAVE_LOCALE)
if (HAVE_SNPRINTF_L)
list(APPEND FUNCTION_DEFINES HAVE_SNPRINTF_L)

View File

@ -10,11 +10,13 @@
CXX_GUARD_START
#ifndef HAVE_POPCOUNT32
static inline uint32_t popcount32(unsigned bits) {
bits = bits - ((bits >> 1) & 0x55555555);
bits = (bits & 0x33333333) + ((bits >> 2) & 0x33333333);
return (((bits + (bits >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
}
#endif
static inline unsigned clz32(uint32_t bits) {
#if defined(__GNUC__) || __clang__

View File

@ -94,6 +94,8 @@ static inline int ThreadSetName(const char* name) {
#elif defined(__HAIKU__)
rename_thread(find_thread(NULL), name);
return 0;
#elif defined(__NetBSD__)
return pthread_setname_np(pthread_self(), "%s", (void *) name);
#elif defined(HAVE_PTHREAD_SETNAME_NP)
return pthread_setname_np(pthread_self(), name);
#else

View File

@ -119,4 +119,10 @@
#cmakedefine USE_ZLIB
#endif
// HAVE flags
#ifndef HAVE_POPCOUNT32
#cmakedefine HAVE_POPCOUNT32
#endif
#endif

View File

@ -10,7 +10,7 @@
int ftostr_l(char* restrict str, size_t size, float f, locale_t locale) {
#ifdef HAVE_SNPRINTF_L
return snprintf_l(str, size, locale, "%.*g", FLT_DIG, f);
#elif defined(HAVE_LOCALE)
#elif defined(HAVE_USELOCALE)
locale_t old = uselocale(locale);
int res = snprintf(str, size, "%.*g", FLT_DIG, f);
uselocale(old);
@ -28,7 +28,7 @@ int ftostr_l(char* restrict str, size_t size, float f, locale_t locale) {
#ifndef HAVE_STRTOF_L
float strtof_l(const char* restrict str, char** restrict end, locale_t locale) {
#ifdef HAVE_LOCALE
#ifdef HAVE_USELOCALE
locale_t old = uselocale(locale);
float res = strtof(str, end);
uselocale(old);