summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/utmp/utent.c7
-rw-r--r--libc/stdlib/random.c7
-rw-r--r--libc/stdlib/random_r.c129
-rw-r--r--libc/sysdeps/linux/common/getdents.c1
-rw-r--r--libc/sysdeps/linux/common/getdents64.c2
-rw-r--r--libc/sysdeps/linux/common/mmap64.c1
-rw-r--r--libc/sysdeps/linux/hppa/bits/setjmp.h2
-rw-r--r--libc/sysdeps/linux/mips/sys/tas.h33
8 files changed, 87 insertions, 95 deletions
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index c1d8d6fa2..aa74cb544 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -108,7 +108,7 @@ struct utmp *getutent(void)
}
/* Locking is done in __getutent */
-struct utmp *getutid (const struct utmp *utmp_entry)
+struct utmp attribute_hidden *__getutid (const struct utmp *utmp_entry)
{
struct utmp *lutmp;
@@ -133,6 +133,7 @@ struct utmp *getutid (const struct utmp *utmp_entry)
return NULL;
}
+strong_alias(__getutid,getutid)
/* Locking is done in __getutent */
struct utmp *getutline(const struct utmp *utmp_entry)
@@ -150,6 +151,8 @@ struct utmp *getutline(const struct utmp *utmp_entry)
return NULL;
}
+extern struct utmp *__getutid (__const struct utmp *__id) attribute_hidden;
+
struct utmp *pututline (const struct utmp *utmp_entry)
{
LOCK;
@@ -157,7 +160,7 @@ struct utmp *pututline (const struct utmp *utmp_entry)
the file pointer where they want it, everything will work out. */
lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
- if (getutid(utmp_entry) != NULL) {
+ if (__getutid(utmp_entry) != NULL) {
lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
return NULL;
diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c
index b0a00e15c..3ffa50690 100644
--- a/libc/stdlib/random.c
+++ b/libc/stdlib/random.c
@@ -22,6 +22,9 @@
* Rewritten to use reentrant functions by Ulrich Drepper, 1995.
*/
+#define random_r __random_r
+#define srandom_r __srandom_r
+
#define _GNU_SOURCE
#include <features.h>
#include <limits.h>
@@ -243,7 +246,7 @@ char * setstate (char *arg_state)
rear pointers can't wrap on the same call by not testing the rear
pointer if the front one has wrapped. Returns a 31-bit random number. */
-long int random ()
+long int attribute_hidden __random (void)
{
int32_t retval;
@@ -252,4 +255,4 @@ long int random ()
__pthread_mutex_unlock(&lock);
return retval;
}
-
+strong_alias(__random,random)
diff --git a/libc/stdlib/random_r.c b/libc/stdlib/random_r.c
index fce3a98ab..9e203f0d5 100644
--- a/libc/stdlib/random_r.c
+++ b/libc/stdlib/random_r.c
@@ -123,6 +123,66 @@ static const struct random_poly_info random_poly_info =
+/* If we are using the trivial TYPE_0 R.N.G., just do the old linear
+ congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
+ same in all the other cases due to all the global variables that have been
+ set up. The basic operation is to add the number at the rear pointer into
+ the one at the front pointer. Then both pointers are advanced to the next
+ location cyclically in the table. The value returned is the sum generated,
+ reduced to 31 bits by throwing away the "least random" low bit.
+ Note: The code takes advantage of the fact that both the front and
+ rear pointers can't wrap on the same call by not testing the rear
+ pointer if the front one has wrapped. Returns a 31-bit random number. */
+
+int attribute_hidden __random_r(struct random_data *buf, int32_t *result)
+{
+ int32_t *state;
+
+ if (buf == NULL || result == NULL)
+ goto fail;
+
+ state = buf->state;
+
+ if (buf->rand_type == TYPE_0)
+ {
+ int32_t val = state[0];
+ val = ((state[0] * 1103515245) + 12345) & 0x7fffffff;
+ state[0] = val;
+ *result = val;
+ }
+ else
+ {
+ int32_t *fptr = buf->fptr;
+ int32_t *rptr = buf->rptr;
+ int32_t *end_ptr = buf->end_ptr;
+ int32_t val;
+
+ val = *fptr += *rptr;
+ /* Chucking least random bit. */
+ *result = (val >> 1) & 0x7fffffff;
+ ++fptr;
+ if (fptr >= end_ptr)
+ {
+ fptr = state;
+ ++rptr;
+ }
+ else
+ {
+ ++rptr;
+ if (rptr >= end_ptr)
+ rptr = state;
+ }
+ buf->fptr = fptr;
+ buf->rptr = rptr;
+ }
+ return 0;
+
+fail:
+ __set_errno (EINVAL);
+ return -1;
+}
+strong_alias(__random_r,random_r)
+
/* Initialize the random number generator based on the given seed. If the
type is the trivial no-state-information type, just remember the seed.
Otherwise, initializes state[] based on the given "seed" via a linear
@@ -131,7 +191,7 @@ static const struct random_poly_info random_poly_info =
information a given number of times to get rid of any initial dependencies
introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
for default usage relies on values produced by this routine. */
-int srandom_r (unsigned int seed, struct random_data *buf)
+int attribute_hidden __srandom_r (unsigned int seed, struct random_data *buf)
{
int type;
int32_t *state;
@@ -176,7 +236,7 @@ int srandom_r (unsigned int seed, struct random_data *buf)
while (--kc >= 0)
{
int32_t discard;
- (void) random_r (buf, &discard);
+ (void) __random_r (buf, &discard);
}
done:
@@ -185,6 +245,7 @@ done:
fail:
return -1;
}
+strong_alias(__srandom_r,srandom_r)
/* Initialize the state information in the given array of N bytes for
future random number generation. Based on the number of bytes we
@@ -237,7 +298,7 @@ int initstate_r (seed, arg_state, n, buf)
buf->state = state;
- srandom_r (seed, buf);
+ __srandom_r (seed, buf);
state[-1] = TYPE_0;
if (type != TYPE_0)
@@ -301,65 +362,3 @@ fail:
__set_errno (EINVAL);
return -1;
}
-
-/* If we are using the trivial TYPE_0 R.N.G., just do the old linear
- congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
- same in all the other cases due to all the global variables that have been
- set up. The basic operation is to add the number at the rear pointer into
- the one at the front pointer. Then both pointers are advanced to the next
- location cyclically in the table. The value returned is the sum generated,
- reduced to 31 bits by throwing away the "least random" low bit.
- Note: The code takes advantage of the fact that both the front and
- rear pointers can't wrap on the same call by not testing the rear
- pointer if the front one has wrapped. Returns a 31-bit random number. */
-
-int random_r (buf, result)
- struct random_data *buf;
- int32_t *result;
-{
- int32_t *state;
-
- if (buf == NULL || result == NULL)
- goto fail;
-
- state = buf->state;
-
- if (buf->rand_type == TYPE_0)
- {
- int32_t val = state[0];
- val = ((state[0] * 1103515245) + 12345) & 0x7fffffff;
- state[0] = val;
- *result = val;
- }
- else
- {
- int32_t *fptr = buf->fptr;
- int32_t *rptr = buf->rptr;
- int32_t *end_ptr = buf->end_ptr;
- int32_t val;
-
- val = *fptr += *rptr;
- /* Chucking least random bit. */
- *result = (val >> 1) & 0x7fffffff;
- ++fptr;
- if (fptr >= end_ptr)
- {
- fptr = state;
- ++rptr;
- }
- else
- {
- ++rptr;
- if (rptr >= end_ptr)
- rptr = state;
- }
- buf->fptr = fptr;
- buf->rptr = rptr;
- }
- return 0;
-
-fail:
- __set_errno (EINVAL);
- return -1;
-}
-
diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c
index 623041866..876420664 100644
--- a/libc/sysdeps/linux/common/getdents.c
+++ b/libc/sysdeps/linux/common/getdents.c
@@ -26,7 +26,6 @@
#include <unistd.h>
#include <sys/param.h>
#include <sys/types.h>
-#include "sysdep.h"
#include <sys/syscall.h>
diff --git a/libc/sysdeps/linux/common/getdents64.c b/libc/sysdeps/linux/common/getdents64.c
index 7b4c0d4ce..e45d9d364 100644
--- a/libc/sysdeps/linux/common/getdents64.c
+++ b/libc/sysdeps/linux/common/getdents64.c
@@ -25,7 +25,6 @@
#include <stdint.h>
#include <string.h>
#include <unistd.h>
-#include "sysdep.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/syscall.h>
@@ -110,4 +109,3 @@ ssize_t attribute_hidden __getdents64 (int fd, char *buf, size_t nbytes)
return(__getdents(fd, buf, nbytes));
}
#endif /* __UCLIBC_HAS_LFS__ */
-
diff --git a/libc/sysdeps/linux/common/mmap64.c b/libc/sysdeps/linux/common/mmap64.c
index 969e1e227..7f329c6c9 100644
--- a/libc/sysdeps/linux/common/mmap64.c
+++ b/libc/sysdeps/linux/common/mmap64.c
@@ -22,7 +22,6 @@
#include <features.h>
#include <errno.h>
#include <unistd.h>
-#include "sysdep.h"
#include <sys/mman.h>
diff --git a/libc/sysdeps/linux/hppa/bits/setjmp.h b/libc/sysdeps/linux/hppa/bits/setjmp.h
index 253e92603..4395b8f56 100644
--- a/libc/sysdeps/linux/hppa/bits/setjmp.h
+++ b/libc/sysdeps/linux/hppa/bits/setjmp.h
@@ -40,6 +40,6 @@ typedef double __jmp_buf[21];
/* Test if longjmp to JMPBUF would unwind the frame containing a local
variable at ADDRESS. */
#define _JMPBUF_UNWINDS(_jmpbuf, _address) \
- ((void *)(_address) > (void *)(_jmpbuf[JB_SP]))
+ ((void *)(_address) > (void *)(((unsigned long *) _jmpbuf)[JB_SP]))
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/mips/sys/tas.h b/libc/sysdeps/linux/mips/sys/tas.h
index 0c81dc2de..1183b867b 100644
--- a/libc/sysdeps/linux/mips/sys/tas.h
+++ b/libc/sysdeps/linux/mips/sys/tas.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000.
@@ -22,7 +22,6 @@
#include <features.h>
#include <sgidefs.h>
-#include <sys/sysmips.h>
__BEGIN_DECLS
@@ -34,24 +33,26 @@ extern int _test_and_set (int *p, int v) __THROW;
# define _EXTERN_INLINE extern __inline
# endif
-# if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
-
_EXTERN_INLINE int
-_test_and_set (int *p, int v) __THROW
+__NTH (_test_and_set (int *p, int v))
{
int r, t;
__asm__ __volatile__
- ("1:\n\t"
- "ll %0,%3\n\t"
+ ("/* Inline test and set */\n"
+ "1:\n\t"
".set push\n\t"
- ".set noreorder\n\t"
+#if _MIPS_SIM == _ABIO32
+ ".set mips2\n\t"
+#endif
+ "ll %0,%3\n\t"
+ "move %1,%4\n\t"
"beq %0,%4,2f\n\t"
- " move %1,%4\n\t"
- ".set pop\n\t"
"sc %1,%2\n\t"
+ ".set pop\n\t"
"beqz %1,1b\n"
- "2:\n"
+ "2:\n\t"
+ "/* End test and set */"
: "=&r" (r), "=&r" (t), "=m" (*p)
: "m" (*p), "r" (v)
: "memory");
@@ -59,16 +60,6 @@ _test_and_set (int *p, int v) __THROW
return r;
}
-# else /* !(_MIPS_ISA >= _MIPS_ISA_MIPS2) */
-
-_EXTERN_INLINE int
-_test_and_set (int *p, int v) __THROW
-{
- return sysmips (MIPS_ATOMIC_SET, (int) p, v, 0);
-}
-
-# endif /* !(_MIPS_ISA >= _MIPS_ISA_MIPS2) */
-
#endif /* __USE_EXTERN_INLINES */
__END_DECLS