diff --git a/src/libc.c b/src/libc.c index b3f90cede..adef2ef84 100644 --- a/src/libc.c +++ b/src/libc.c @@ -182,8 +182,10 @@ int C_RLIMIT_NTHR() { #endif } -#ifdef LC_GLOBAL_LOCALE locale_t C_LC_GLOBAL_LOCALE() { + // LC_GLOBAL_LOCALE is usually -1, but not always (e.g. under NetBSD). +#ifdef LC_GLOBAL_LOCALE return LC_GLOBAL_LOCALE; -} #endif + return (locale_t)-1; +} diff --git a/src/locale.rs b/src/locale.rs index 1beff696a..0f69fa589 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -65,11 +65,7 @@ unsafe fn read_locale() -> Option { extern "C" { fn localeconv_l(loc: libc::locale_t) -> *const libc::lconv; } - /// Rust libc does not provide LC_GLOBAL_LOCALE, but it is usually -1. #[cfg(not(target_os = "netbsd"))] - const LC_GLOBAL_LOCALE: libc::locale_t = (-1_isize) as libc::locale_t; - // On NetBSD it's not. - #[cfg(target_os = "netbsd")] let LC_GLOBAL_LOCALE: libc::locale_t = unsafe { crate::libc::C_LC_GLOBAL_LOCALE() }; const empty: [libc::c_char; 1] = [0];