summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/_strtod.c7
-rw-r--r--libc/stdlib/arc4random.c27
-rw-r--r--libc/stdlib/drand48-iter.c4
-rw-r--r--libc/stdlib/drand48.c4
-rw-r--r--libc/stdlib/erand48.c4
-rw-r--r--libc/stdlib/erand48_r.c3
-rw-r--r--libc/stdlib/jrand48.c4
-rw-r--r--libc/stdlib/jrand48_r.c3
-rw-r--r--libc/stdlib/lrand48.c4
-rw-r--r--libc/stdlib/malloc/memalign.c3
-rw-r--r--libc/stdlib/mrand48.c4
-rw-r--r--libc/stdlib/nrand48.c4
-rw-r--r--libc/stdlib/nrand48_r.c3
-rw-r--r--libc/stdlib/seed48.c4
-rw-r--r--libc/stdlib/srand48.c4
-rw-r--r--libc/stdlib/stdlib.c28
16 files changed, 22 insertions, 88 deletions
diff --git a/libc/stdlib/_strtod.c b/libc/stdlib/_strtod.c
index dc5d55743..1d58258e7 100644
--- a/libc/stdlib/_strtod.c
+++ b/libc/stdlib/_strtod.c
@@ -544,7 +544,6 @@ libc_hidden_def(__XL_NPP(strtof))
#define Wchar char
#endif
-libc_hidden_proto(__XL_NPP(strtod))
double __XL_NPP(strtod)(const Wchar *__restrict str,
Wchar **__restrict endptr __LOCALE_PARAM )
{
@@ -562,7 +561,9 @@ double __XL_NPP(strtod)(const Wchar *__restrict str,
return y;
#endif
}
-libc_hidden_def(__XL_NPP(strtod))
+#ifdef L_strtod
+libc_hidden_def(strtod)
+#endif
#endif
#endif
@@ -580,7 +581,6 @@ libc_hidden_def(__XL_NPP(strtod))
#define Wchar char
#endif
-libc_hidden_proto(__XL_NPP(strtold))
long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr __LOCALE_PARAM )
{
#if FPMAX_TYPE == 3
@@ -597,7 +597,6 @@ long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr __LOCALE_PARAM
return y;
#endif
}
-libc_hidden_def(__XL_NPP(strtold))
#endif
#endif
diff --git a/libc/stdlib/arc4random.c b/libc/stdlib/arc4random.c
index 97f318a57..c7aed66b6 100644
--- a/libc/stdlib/arc4random.c
+++ b/libc/stdlib/arc4random.c
@@ -54,8 +54,7 @@ static __inline__ uint8_t arc4_getbyte(struct arc4_stream *);
static __inline__ uint32_t arc4_getword(struct arc4_stream *);
static __inline__ void
-arc4_init(as)
- struct arc4_stream *as;
+arc4_init(struct arc4_stream *as)
{
int n;
@@ -66,10 +65,7 @@ arc4_init(as)
}
static __inline__ void
-arc4_addrandom(as, dat, datlen)
- struct arc4_stream *as;
- u_char *dat;
- int datlen;
+arc4_addrandom(struct arc4_stream *as, u_char *dat, int datlen)
{
int n;
uint8_t si;
@@ -86,8 +82,7 @@ arc4_addrandom(as, dat, datlen)
}
static void
-arc4_stir(as)
- struct arc4_stream *as;
+arc4_stir(struct arc4_stream *as)
{
int fd;
struct {
@@ -137,8 +132,7 @@ arc4_stir(as)
}
static __inline__ uint8_t
-arc4_getbyte(as)
- struct arc4_stream *as;
+arc4_getbyte(struct arc4_stream *as)
{
uint8_t si, sj;
@@ -152,8 +146,7 @@ arc4_getbyte(as)
}
static __inline__ uint32_t
-arc4_getword(as)
- struct arc4_stream *as;
+arc4_getword(struct arc4_stream *as)
{
uint32_t val;
val = arc4_getbyte(as) << 24;
@@ -163,8 +156,8 @@ arc4_getword(as)
return val;
}
-void
-arc4random_stir(void)
+static void
+__arc4random_stir(void)
{
if (!rs_initialized) {
arc4_init(&rs);
@@ -172,13 +165,13 @@ arc4random_stir(void)
}
arc4_stir(&rs);
}
-libc_hidden_def(arc4random_stir)
+strong_alias(__arc4random_stir,arc4random_stir)
void
arc4random_addrandom(u_char *dat, int datlen)
{
if (!rs_initialized)
- arc4random_stir();
+ __arc4random_stir();
arc4_addrandom(&rs, dat, datlen);
}
@@ -186,7 +179,7 @@ uint32_t
arc4random(void)
{
if (!rs_initialized)
- arc4random_stir();
+ __arc4random_stir();
return arc4_getword(&rs);
}
diff --git a/libc/stdlib/drand48-iter.c b/libc/stdlib/drand48-iter.c
index 221cbe08f..7d705adca 100644
--- a/libc/stdlib/drand48-iter.c
+++ b/libc/stdlib/drand48-iter.c
@@ -21,15 +21,15 @@
#include <stdlib.h>
#include <limits.h>
#include <stdint.h>
+#include <stdlib.h>
#include <sys/types.h>
/* Global state for non-reentrant functions. */
-struct drand48_data __libc_drand48_data attribute_hidden;
+struct drand48_data __libc_drand48_data;
#ifdef __UCLIBC_MJN3_ONLY__
#warning turn int __drand48_iterate into void
#endif /* __UCLIBC_MJN3_ONLY__ */
-int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer)
{
uint64_t X;
diff --git a/libc/stdlib/drand48.c b/libc/stdlib/drand48.c
index 8c9017b11..c53dcfbfc 100644
--- a/libc/stdlib/drand48.c
+++ b/libc/stdlib/drand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
double drand48 (void)
{
double result;
diff --git a/libc/stdlib/erand48.c b/libc/stdlib/erand48.c
index ee28d9635..f3603cde0 100644
--- a/libc/stdlib/erand48.c
+++ b/libc/stdlib/erand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
double erand48 (unsigned short int xsubi[3])
{
double result;
diff --git a/libc/stdlib/erand48_r.c b/libc/stdlib/erand48_r.c
index e36e73eb2..bd40a3488 100644
--- a/libc/stdlib/erand48_r.c
+++ b/libc/stdlib/erand48_r.c
@@ -21,9 +21,6 @@
#include <stdlib.h>
#include <limits.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
int erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result)
{
union ieee754_double temp;
diff --git a/libc/stdlib/jrand48.c b/libc/stdlib/jrand48.c
index 163c5408e..8a06ced56 100644
--- a/libc/stdlib/jrand48.c
+++ b/libc/stdlib/jrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int jrand48 (unsigned short int xsubi[3])
{
long int result;
diff --git a/libc/stdlib/jrand48_r.c b/libc/stdlib/jrand48_r.c
index 24f7075f5..5652d1016 100644
--- a/libc/stdlib/jrand48_r.c
+++ b/libc/stdlib/jrand48_r.c
@@ -19,9 +19,6 @@
#include <stdlib.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
int jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
diff --git a/libc/stdlib/lrand48.c b/libc/stdlib/lrand48.c
index a0b15caff..915638b80 100644
--- a/libc/stdlib/lrand48.c
+++ b/libc/stdlib/lrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int lrand48 (void)
{
long int result;
diff --git a/libc/stdlib/malloc/memalign.c b/libc/stdlib/malloc/memalign.c
index 6826d623a..5edd6e1cd 100644
--- a/libc/stdlib/malloc/memalign.c
+++ b/libc/stdlib/malloc/memalign.c
@@ -14,13 +14,12 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <sys/param.h> /* MAX */
#include "malloc.h"
#include "heap.h"
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-
/*
______________________ TOTAL _________________________
/ \
diff --git a/libc/stdlib/mrand48.c b/libc/stdlib/mrand48.c
index b209acd57..6f7cf734c 100644
--- a/libc/stdlib/mrand48.c
+++ b/libc/stdlib/mrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int mrand48 (void)
{
long int result;
diff --git a/libc/stdlib/nrand48.c b/libc/stdlib/nrand48.c
index 97c197caa..5183484fa 100644
--- a/libc/stdlib/nrand48.c
+++ b/libc/stdlib/nrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int nrand48 (unsigned short int xsubi[3])
{
long int result;
diff --git a/libc/stdlib/nrand48_r.c b/libc/stdlib/nrand48_r.c
index 0710e90ef..b8ed0eb31 100644
--- a/libc/stdlib/nrand48_r.c
+++ b/libc/stdlib/nrand48_r.c
@@ -19,9 +19,6 @@
#include <stdlib.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
int nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
diff --git a/libc/stdlib/seed48.c b/libc/stdlib/seed48.c
index 9ff8a480a..a62dc2e64 100644
--- a/libc/stdlib/seed48.c
+++ b/libc/stdlib/seed48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
unsigned short int *
seed48 (unsigned short int seed16v[3])
{
diff --git a/libc/stdlib/srand48.c b/libc/stdlib/srand48.c
index 817d068c3..f55374371 100644
--- a/libc/stdlib/srand48.c
+++ b/libc/stdlib/srand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
void srand48 (long seedval)
{
srand48_r (seedval, &__libc_drand48_data);
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index 4d608eeac..cd9a0cac6 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -286,11 +286,11 @@ long atol(const char *nptr)
{
return strtol(nptr, (char **) NULL, 10);
}
-libc_hidden_def(atol)
#if UINT_MAX == ULONG_MAX
#undef atoi
extern __typeof(atol) atoi;
+/* the one in stdlib.h is not enough due to prototype mismatch */
libc_hidden_proto(atoi)
strong_alias(atol,atoi)
libc_hidden_def(atoi)
@@ -339,10 +339,13 @@ strong_alias(strtol,strtoimax)
#undef strtoll
#endif
extern __typeof(__XL_NPP(strtol)) __XL_NPP(strtoll);
+/* the one in stdlib.h is not enough due to prototype mismatch */
+#ifdef L_strtol
libc_hidden_proto(__XL_NPP(strtoll))
+#endif
strong_alias(__XL_NPP(strtol),__XL_NPP(strtoll))
+#ifdef L_strtol
libc_hidden_def(__XL_NPP(strtoll))
-#if !defined(L_strtol_l)
strong_alias(strtol,strtoq)
#endif
#endif
@@ -353,16 +356,14 @@ strong_alias(strtol,strtoq)
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(strtoll))
long long __XL_NPP(strtoll)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
{
return (long long) __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 1 __LOCALE_ARG);
}
+#ifdef L_strtoll
libc_hidden_def(__XL_NPP(strtoll))
-
-#if !defined(L_strtoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
strong_alias(strtoll,strtoimax)
#endif
@@ -375,7 +376,6 @@ strong_alias(strtoll,strtoq)
/**********************************************************************/
#if defined(L_strtoul) || defined(L_strtoul_l)
-libc_hidden_proto(__XL_NPP(strtoul))
unsigned long __XL_NPP(strtoul)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
@@ -395,9 +395,7 @@ strong_alias(strtoul,strtoumax)
#undef strtoull
#endif
extern __typeof(__XL_NPP(strtoul)) __XL_NPP(strtoull);
-libc_hidden_proto(__XL_NPP(strtoull))
strong_alias(__XL_NPP(strtoul),__XL_NPP(strtoull))
-libc_hidden_def(__XL_NPP(strtoull))
#if !defined(L_strtoul_l)
strong_alias(strtoul,strtouq)
#endif
@@ -410,14 +408,12 @@ strong_alias(strtoul,strtouq)
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(strtoull))
unsigned long long __XL_NPP(strtoull)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(strtoull))
#if !defined(L_strtoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -1047,13 +1043,11 @@ size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
/**********************************************************************/
#if defined(L_wcstol) || defined(L_wcstol_l)
-libc_hidden_proto(__XL_NPP(wcstol))
long __XL_NPP(wcstol)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base __LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 1 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstol))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstol_l)
strong_alias(wcstol,wcstoimax)
@@ -1066,9 +1060,7 @@ strong_alias(wcstol,wcstoimax)
#undef wcstoll
#endif
extern __typeof(__XL_NPP(wcstol)) __XL_NPP(wcstoll);
-libc_hidden_proto(__XL_NPP(wcstoll))
strong_alias(__XL_NPP(wcstol),__XL_NPP(wcstoll))
-libc_hidden_def(__XL_NPP(wcstoll))
#endif
#endif
@@ -1077,14 +1069,12 @@ libc_hidden_def(__XL_NPP(wcstoll))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(wcstoll))
long long __XL_NPP(wcstoll)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return (long long) __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 1 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoll))
#if !defined(L_wcstoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -1099,14 +1089,12 @@ strong_alias(wcstoll,wcstoq)
/**********************************************************************/
#if defined(L_wcstoul) || defined(L_wcstoul_l)
-libc_hidden_proto(__XL_NPP(wcstoul))
unsigned long __XL_NPP(wcstoul)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoul))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstoul_l)
strong_alias(wcstoul,wcstoumax)
@@ -1119,9 +1107,7 @@ strong_alias(wcstoul,wcstoumax)
#undef wcstoull
#endif
extern __typeof(__XL_NPP(wcstoul)) __XL_NPP(wcstoull);
-libc_hidden_proto(__XL_NPP(wcstoull))
strong_alias(__XL_NPP(wcstoul),__XL_NPP(wcstoull))
-libc_hidden_def(__XL_NPP(wcstoull))
#endif
#endif
@@ -1130,14 +1116,12 @@ libc_hidden_def(__XL_NPP(wcstoull))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(wcstoull))
unsigned long long __XL_NPP(wcstoull)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoull))
#if !defined(L_wcstoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)