diff options
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/_strtod.c | 10 | ||||
-rw-r--r-- | libc/stdlib/malloc-standard/malloc.c | 10 | ||||
-rw-r--r-- | libc/stdlib/malloc/memalign.c | 6 | ||||
-rw-r--r-- | libc/stdlib/stdlib.c | 2 |
4 files changed, 18 insertions, 10 deletions
diff --git a/libc/stdlib/_strtod.c b/libc/stdlib/_strtod.c index c4c79e511..483551e64 100644 --- a/libc/stdlib/_strtod.c +++ b/libc/stdlib/_strtod.c @@ -256,7 +256,7 @@ __fpmax_t attribute_hidden __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endp } #endif - number = 0.; + number = (__fpmax_t)0; #ifdef _STRTOD_NEED_NUM_DIGITS num_digits = -1; #endif @@ -339,7 +339,7 @@ __fpmax_t attribute_hidden __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endp while ((pos[j] | 0x20) == nan_inf_str[i+1+j]) { ++j; if (!nan_inf_str[i+1+j]) { - number = i / 0.; + number = i / (__fpmax_t)0.; if (negative) { /* Correct for sign. */ number = -number; } @@ -414,7 +414,7 @@ __fpmax_t attribute_hidden __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endp } #ifdef _STRTOD_ZERO_CHECK - if (number == 0.) { + if (number == (__fpmax_t)0.) { goto DONE; } #endif @@ -515,7 +515,7 @@ float __XL_NPP(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM ) x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG ); y = (float) x; - __fp_range_check(y, x); + __fp_range_check((__fpmax_t)y, x); return y; #endif @@ -549,7 +549,7 @@ double __XL_NPP(strtod)(const Wchar *__restrict str, x = __XL_NPP(__strtofpmax)(str, endptr, 0 __LOCALE_ARG ); y = (double) x; - __fp_range_check(y, x); + __fp_range_check((__fpmax_t)y, x); return y; #endif diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c index cecea87ec..e51bc6610 100644 --- a/libc/stdlib/malloc-standard/malloc.c +++ b/libc/stdlib/malloc-standard/malloc.c @@ -29,7 +29,7 @@ __UCLIBC_MUTEX_INIT(__malloc_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP); struct malloc_state __malloc_state; /* never directly referenced */ /* forward declaration */ -static int __malloc_largebin_index(unsigned int sz); +static int __malloc_largebin_index(unsigned long sz); #ifdef __UCLIBC_MALLOC_DEBUGGING__ @@ -755,10 +755,10 @@ static void* __malloc_alloc(size_t nb, mstate av) Compute index for size. We expect this to be inlined when compiled with optimization, else not, which works out well. */ -static int __malloc_largebin_index(unsigned int sz) +static int __malloc_largebin_index(unsigned long sz) { - unsigned int x = sz >> SMALLBIN_WIDTH; - unsigned int m; /* bit position of highest set bit of m */ + unsigned long x = sz >> SMALLBIN_WIDTH; + unsigned long m; /* bit position of highest set bit of m */ if (x >= 0x10000) return NBINS-1; @@ -776,7 +776,7 @@ static int __malloc_largebin_index(unsigned int sz) S. Warren Jr's book "Hacker's Delight". */ - unsigned int n = ((x - 0x100) >> 16) & 8; + unsigned long n = ((x - 0x100) >> 16) & 8; x <<= n; m = ((x - 0x1000) >> 16) & 4; n += m; diff --git a/libc/stdlib/malloc/memalign.c b/libc/stdlib/malloc/memalign.c index 665f20cfb..54f6dbc6c 100644 --- a/libc/stdlib/malloc/memalign.c +++ b/libc/stdlib/malloc/memalign.c @@ -11,6 +11,7 @@ * Written by Miles Bader <miles@gnu.org> */ +#include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/mman.h> @@ -38,6 +39,11 @@ memalign (size_t alignment, size_t size) unsigned long tot_addr, tot_end_addr, addr, end_addr; struct heap_free_area **heap = &__malloc_heap; + if (unlikely(size > PTRDIFF_MAX)) { + __set_errno(ENOMEM); + return NULL; + } + /* Make SIZE something we like. */ size = HEAP_ADJUST_SIZE (size); diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c index f5936630c..c45dd53a5 100644 --- a/libc/stdlib/stdlib.c +++ b/libc/stdlib/stdlib.c @@ -822,6 +822,7 @@ libc_hidden_def(_stdlib_mb_cur_max) #endif +#if defined(L_mblen) || defined(L_mbtowc) || defined(L_wctomb) #ifdef __UCLIBC_HAS_LOCALE__ /* * The following function return 1 if the encoding is stateful, 0 if stateless. @@ -844,6 +845,7 @@ static __always_inline int is_stateful(unsigned char encoding) #else #define is_stateful(encoding) 0 #endif +#endif /**********************************************************************/ #ifdef L_mblen |