about summary refs log tree commit diff
path: root/stdlib/stdlib.h
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-09-17 20:23:15 +0000
committerRoland McGrath <roland@gnu.org>1995-09-17 20:23:15 +0000
commit60478656fad8d8a487e9bc52d025f69767c3262b (patch)
tree0ae0836023f1c2f80064e7611f91d19c482208d9 /stdlib/stdlib.h
parent9fd18b6c1b397e1af82a0b544f10f946c73864b6 (diff)
downloadglibc-60478656fad8d8a487e9bc52d025f69767c3262b.tar.gz
glibc-60478656fad8d8a487e9bc52d025f69767c3262b.tar.xz
glibc-60478656fad8d8a487e9bc52d025f69767c3262b.zip
Sat Sep 16 17:47:19 1995 Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>
	* elf/elf.h (AT_GID): Fix typo: Read -> Real.

	* misc/efgvt_r.c: New file.  Reentrant version of [efg]cvt functions.
	* misc/efgcvt.c: Rewrite to use reentrant functions.
	* misc/hsearch_r.c: New file.  Reentrant version of functions from
	hsearch family.
	* misc/hsearch.c, misc/tsearch.c: New files.
	* misc/Makefile (routines): Add efgcvt_r, hsearch_r, hsearch, tsearch.

	* posix/unistd.h (ttyname_r): Add prototype for new function.

	* stdlib/drand48_r.c, stdlib/erand48_r.c, stdlib/jrand48_r.c,
	stdlib/lrand48_r.c, stdlib/mrand48_r.c, stdlib/nrand48_r.c,
	stdlib/seed48_r.c, stdlib/srand48_r.c, stdlib/lcong48_r.c,
	stdlib/drand48-iter.c: New files implementing reentrant versions
	of functions from drand48 family.
	* stdlib/seed48.c, stdlib/drand48.c, stdlib/erand48.c,
	stdlib/jrand48.c, stdlib/lrand48.c, stdlib/mrand48.c,
	stdlib/nrand48.c, stdlib/srand48.c, stdlib/lcong48.c:
	Rewrite to use reentrant versions.
	* stdlib/a64l.c, stdlib/l64a.c: New files.  Implement a64l()
	and l64a() functions from SysV library.
	* stdlib/Makefile (routines): Add drand48_r, erand48_r, lrand48_r,
	nrand48_r, mrand48_r, jrand48_r, srand48_r, seed48_r, lcong48_r,
	drand48-iter, a64l, l64a.
	* stdlib/stdlib.h: Declare them.

	* stdlib/random_r.c: New file.  Reentrant version of functions
	from random family.
	* stdlib/stdlib.h: Declare them.
	* stdlib/random.c: Rewrite to use reentrant functions.

	* string/strerror_r.c: New file.  Reentrant version.
	* string/strerror.c: Change for new _strerror_internal form.
	* string/Makefile (routines): Add strerror_r.

	* sysdeps/generic/dl-sysdep.c (_dl_sysdep_start): Set default
	value of user_entry to `_start'.
	Close AT_ENTRY case with `break'.

	* sysdeps/generic/strstr.c: New and much faster implementation
	by Stephen R. van den Berg.

	* sysdeps/generic/_strerror.c: _strerror_internal now takes
	three argument and has and explicit buffer length.
	* sysdeps/mach/_strerror.c: Change for new interface with three
	arguments.
	* stdio/perror.c, stdio/vfprintf.c: Callers changed.
	
	* sysdeps/mach/hurd/ttyname_r.c: New file.  Reentrant version.
	* sysdeps/posix/ttyname_r.c: New file.  Reentrant version.
	* sysdeps/stub/ttyname_r: New file.  Define as dummy function.

	* sysdeps/posix/utimes.c: Include <utime.h> for prototype.
	(utimes): First parameter to utime must be file, not path.

	* sysdeps/posix/sysconf.c (__sysconf): Test for CLK_TCK in case
	_SC_CLK_TCK and return it when available.
	Test for STREAM_MAX in case _SC_STREAM_MAX and return it when
	available.
	Add case for _SC_2_LOCALEDEF which is now available.

	* posix/sys/types.h [__USE_SVID] (key_t): New type.
	* sysvipc/Makefile, sysvipc/ftok.c, sysvipc/sys/ipc.h,
	sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h,
	sysdeps/stub/sys/msq_buf.h, sysdeps/stub/sys/sem_buf.h,
	sysdeps/stub/sys/shm_buf.h, sysdeps/stub/sys/ipc_buf.h,
	sysdeps/stub/semctl.c, sysdeps/stub/semget.c, sysdeps/stub/semop.c,
	sysdeps/stub/shmat.c, sysdeps/stub/shmctl.c, sysdeps/stub/shmdt.c,
	sysdeps/stub/shmget.c, sysdeps/stub/msgctl.c, sysdeps/stub/msgget.c,
	sysdeps/stub/msgrcv.c, sysdeps/stub/msgsnd.c: New files.
	Add implementation of System V IPC.
Diffstat (limited to 'stdlib/stdlib.h')
-rw-r--r--stdlib/stdlib.h109
1 files changed, 108 insertions, 1 deletions
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 2a3cf8ec5f..c6c504a143 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -198,7 +198,83 @@ extern __inline __ptr_t initstate (unsigned int __seed,
 extern __inline __ptr_t setstate (__ptr_t __statebuf)
 { return __setstate (__statebuf); }
 #endif /* Optimizing GCC >=2.  */
-#endif /* Use BSD.  */
+
+#ifdef __USE_REENTRANT
+/* Reentrant versions of the `random' family of functions.
+   These functions all use the following data structure to contain
+   state, rather than global state variables.  */
+
+struct random_data
+  {
+    long int *fptr;		/* Front pointer.  */
+    long int *rptr;		/* Rear pointer.  */
+    long int *state;		/* Array of state values.  */
+    int rand_type;		/* Type of random number generator.  */
+    int rand_deg;		/* Degree of random number generator.  */
+    int rand_sep;		/* Distance between front and rear.  */
+    long int *end_ptr;		/* Pointer behind state table.  */
+  };
+
+extern int __random_r __P ((struct random_data *__buf, long int *__result));
+extern int __srandom_r __P ((unsigned int __seed, struct random_data *__buf));
+extern int __initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
+			       size_t __statelen, struct random_data *__buf));
+extern int __setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
+
+extern int random_r __P ((struct random_data *__buf, long int *__result));
+extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf));
+extern int initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
+			     size_t __statelen, struct random_data *__buf));
+extern int setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
+#endif	/* __USE_REENTRANT.  */
+#endif	/* Use BSD.  */
+
+
+#ifdef	__USE_SVID
+/* System V style 48-bit random number generator functions.  */
+
+/* Data structure for communication with thread safe versions.  */
+struct drand48_data
+  {
+    unsigned short int X[3];	/* Current state.  */
+    unsigned short int a[3];	/* Factor in congruential formula.  */
+    unsigned short int c;	/* Additive const. in congruential formula.  */
+    unsigned short int old_X[3]; /* Old state.  */
+    int init;			/* Flag for initializing.  */
+  };
+
+/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */
+extern double drand48 __P ((void));
+extern int drand48_r __P ((struct drand48_data *__buffer, double *__result));
+extern double erand48 __P ((unsigned short int __xsubi[3]));
+extern int erand48_r __P ((unsigned short int __xsubi[3],
+			   struct drand48_data *__buffer, double *__result));
+/* Return non-negative, long integer in [0,2^31).  */
+extern long lrand48 __P ((void));
+extern int lrand48_r __P ((struct drand48_data *__buffer, long *__result));
+extern long nrand48 __P ((unsigned short int __xsubi[3]));
+extern int nrand48_r __P ((unsigned short int __xsubi[3],
+			   struct drand48_data *__buffer, long *__result));
+/* Return signed, long integers in [-2^31,2^31).  */
+extern long mrand48 __P ((void));
+extern int mrand48_r __P ((struct drand48_data *__buffer, long *__result));
+extern long jrand48 __P ((unsigned short int __xsubi[3]));
+extern int jrand48_r __P ((unsigned short int __xsubi[3],
+			   struct drand48_data *__buffer, long *__result));
+/* Seed random number generator.  */
+extern void srand48 __P ((long __seedval));
+extern int srand48_r __P ((long __seedval, struct drand48_data *__buffer));
+extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
+extern int seed48_r __P ((unsigned short int __seed16v[3],
+			  struct drand48_data *__buffer));
+extern void lcong48 __P ((unsigned short int __param[7]));
+extern int lcong48_r __P ((unsigned short int __param[7],
+			   struct drand48_data *__buffer));
+
+/* Internal function to compute next state of the generator.  */
+extern int __drand48_iterate __P ((unsigned short int __xsubi[3],
+				   struct drand48_data *__buffer));
+#endif	/* __USE_SVID.  */
 
 
 /* Allocate SIZE bytes of memory.  */
@@ -268,7 +344,10 @@ extern int system __P ((__const char *__command));
 
 
 /* Shorthand for type of comparison functions.  */
+#ifndef __COMPAR_FN_T
+#define __COMPAR_FN_T
 typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
+#endif
 
 #ifdef	__USE_GNU
 typedef __compar_fn_t comparison_fn_t;
@@ -308,6 +387,34 @@ extern __CONSTVALUE div_t div __P ((int __numer, int __denom));
 extern __CONSTVALUE ldiv_t ldiv __P ((long int __numer, long int __denom));
 
 
+#ifdef __USE_SVID
+/* Convert floating point numbers to strings.  The returned values are
+   valid only until another call to the same function.  */
+
+/* Convert VALUE to a string with NDIGIT digits and return a pointer to
+   this.  Set *DECPT with the position of the decimal character and *SIGN
+   with the sign of the number.  */
+char *ecvt __P ((double __value, int __ndigit, int *__decpt, int *sign));
+
+/* Convert VALUE to a string rounded to NDIGIT decimal digits.  Set *DECPT
+   with the position of the decimal character and *SIGN with the sign of
+   the number.  */
+char *fcvt __P ((double __value, int __ndigit, int *__decpt, int *sign));
+
+/* If possible convert VALUE to a string with NDIGIT significant digits.
+   Otherwise use exponential representation.  The resulting string will
+   be written to BUF.  */
+char *gcvt __P ((double __value, int __ndigit, char *__buf));
+
+/* Reentrant version of the functions above which provide their own
+   buffers.  */
+int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
+		 char *__buf, int *__len));
+int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
+		 char *__buf, int *__len));
+#endif
+
+
 /* Return the length of the multibyte character
    in S, which is no longer than N.  */
 extern int mblen __P ((__const char *__s, size_t __n));