From 61eb22d3a8e9bb9c339bdbe907a85656823f4c7e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 16 Sep 1997 00:42:43 +0000 Subject: Update. 1997-09-16 02:14 Ulrich Drepper Implementation of Hesiod NSS module by Mark Kettenis. * hesiod/Makefile: New file. * hesiod/hesiod.c: New file. * hesiod/hesiod.h: New file. * hesiod/hesiod_p.h: New file. * hesiod/libnss_hesiod.map: New file. * hesiod/nss_hesiod/hesiod-grp.c: New file. * hesiod/nss_hesiod/hesiod-pwd.c: New file. * hesiod/nss_hesiod/hesiod-service.c: New file. * sysdeps/unix/inet/Subdirs: Add hesiod. * shlib-versions: Add version number for libnss_hesiod. * libio/iolibio.h: Remove definition of _IO_* macros. * libio/fileops.c: Define close, fstat, lseek, read, and write as macros to use __ protected versions. Use those functions instead of _IO_* functions. * libio/iopopen.c: Define _IO_close to close. * manual/math.texi: Explain the use of the optimizing inline functions. Describe rand_r function and tell about SysV RNGs in introduction. * resolv/res_send.c (res_send): Use socklen_t type for `fromlen' variable. * string/Makefile (tests): Add noinl-tester. * string/noinl-tester.c: New file. * string/tester.c: Add more stpcpy tests for constant arguments for all short lengths. * string/string.h: Always declare __bzero. Describe __NO_STRING_INLINES. Always include . * string/bits/string2.h: Add warning about direct use. Change __strcpy_small and __stpcpy_small implementation to use macros and provide alternative for platforms which cannot do unaligned stores. * sysdeps/i386/bits/string.h: Don't define anything is __NO_STRING_INLINES is defined. * sysdeps/i386/i486/bits/string.h: Change __strcpy_small and __stpcpy_small implementation to use macros and provide alternative for platforms which cannot do unaligned stores. * sysdeps/alpha/bzero.S: Define bzero as weak alias of __bzero. * sysdeps/generic/bzero.c: Likewise. * sysdeps/i386/bzero.c: Likewise. * sysdeps/i386/i586/bzero.S: Likewise. * sysdeps/vax/bzero.s: Likewise. * sysdeps/generic/bits/select.h: Don't use ugly casts to access array. * sysdeps/i386/bits/select.h: Likewise. * sysdeps/i386/fpu/bits/mathinline.c (__finite): Relax register constraints a bit. Don't define and test for _BITS_MATHINLINE_H. Emit warning if used directly and not through math.h. * sysdeps/i386/i486/atomicity.h: Change return type of compare_and_swap to char to get better code. Fix typo. * sysdeps/stub/atomicity.h: Fix typo. 1997-09-14 Andreas Schwab * sysdeps/generic/stpcpy.c: #undef stpcpy and __stpcpy. 1997-09-14 Andreas Schwab * string/bits/string2.h: Add prototypes to avoid warning. 1997-09-14 Andreas Schwab * string/bits/string2.h (strsep): Fix handling of empty REJECT. (__strsep_1c): Handle NULL and empty string. (__strsep_g): Likewise. 1997-09-13 Andreas Schwab * catgets/Makefile (extra-objs): Set this instead of generated. * md5-crypt/Makefile (extra-objs): Add all object file variants of onlymd5-entry. 1997-09-12 Andreas Schwab * sysdeps/generic/sysd-stdio.c (__stdio_read): Fix typo in last change. 1997-09-12 Andreas Schwab * sysdeps/m68k/m68020/atomicity.h: New file. 1997-09-15 05:11 Ulrich Drepper * posix/Makefile (distribute): Add globtest.c and globtest.sh. Compile and run globtest if not cross-compiling. * posix/globtest.c: New file. * posix/globtest.sh: New file. * posix/glob.c: Pretty print preprocessor stuff. (glob_in_dir): If PATTERN is not really a pattern still check whether it is a real file in the current directory and return error if not. Reported by Eugene Mamchits . * libio/fileops.c (_IO_file_sync): Acquire lock before doing the work. * libio/ioseekoff.c (_IO_seekoff): Likewise. * libio/ioseekpos.c (_IO_seekpos): Likewise. 1997-09-13 18:06 Ulrich Drepper * configure.in: Prevent configuration for unsupported platforms. 1997-09-13 04:07 Ulrich Drepper * elf/rtld.c (dl_main): Make sure we always have a file argument by testing for < 2 arguments after recognizing the options. 1997-09-12 11:47 Fila Kolodny * string/bits/string2.h (__strsep_1c): Cast out const from __retval. (__strsep_g): Likewise. --- manual/math.texi | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'manual') diff --git a/manual/math.texi b/manual/math.texi index 2b7cb82f5e..15a2075d33 100644 --- a/manual/math.texi +++ b/manual/math.texi @@ -54,6 +54,7 @@ in case of double using @code{double} is a good compromise. constant. * FP Comparison Functions:: Special functions to compare floating-point numbers. +* FP Function Optimizations:: Fast code or small code. * Trig Functions:: Sine, cosine, and tangent. * Inverse Trig Functions:: Arc sine, arc cosine, and arc tangent. * Exponents and Logarithms:: Also includes square root. @@ -704,6 +705,35 @@ that the comparison for equality and unequality do @emph{not} throw an exception if one of the arguments is an unordered value. +@node FP Function Optimizations +@section Is Fast Code or Small Code preferred? +@cindex Optimization + +If an application uses many floating point function it is often the case +that the costs for the function calls itseld are not neglectable. +Modern processor implementation often can execute the operation itself +very fast but the call means a disturbance of the control flow. + +For this reason the GNU C Library provides optimizations for many of the +frequently used math functions. When the GNU CC is used and the user +activates the optimizer several new inline functions and macros get +defined. These new functions and macros have the same names as the +library function and so get used instead of the later. In case of +inline functions the compiler will decide whether it is reasonable to +use the inline function and this decision is usually correct. + +For the generated code this means that no calls to the library functions +are necessary. This increases the speed significantly. But the +drawback is that the code size increases and this increase is not always +neglectable. + +In cases where the inline functions and macros are not wanted the symbol +@code{__NO_MATH_INLINES} should be defined before any system header is +included. This will make sure only library functions are used. Of +course it can be determined for each single file in the project whether +giving this option is preferred or not. + + @node Trig Functions @section Trigonometric Functions @cindex trigonometric functions @@ -1430,8 +1460,14 @@ the same seed, used in different C libraries or on different CPU types, will give you different random numbers. The GNU library supports the standard @w{ISO C} random number functions -plus another set derived from BSD. We recommend you use the standard -ones, @code{rand} and @code{srand}. +plus two other sets derived from BSD and SVID. We recommend you use the +standard ones, @code{rand} and @code{srand} if only a small number of +random bits are required. The SVID functions provide an interface which +allows better randon number generator algorithms and they return up to +48 random bits in one calls and they also return random floating-point +numbers if wanted. The SVID function might not be available on some BSD +derived systems but since they are required in the XPG they are +available on all Unix-conformant systems. @menu * ISO Random:: @code{rand} and friends. @@ -1478,6 +1514,30 @@ To produce truly random numbers (not just pseudo-random), do @code{srand (time (0))}. @end deftypefun +A completely broken interface was designed by the POSIX.1 committee to +support reproducible random numbers in multi-threaded programs. + +@comment stdlib.h +@comment POSIX.1 +@deftypefun int rand_r (unsigned int *@var{seed}) +This function returns a random number in the range 0 to @code{RAND_MAX} +just as @code{rand} does. But this function does not keep an internal +state for the RNG. Instead the @code{unsigned int} variable pointed to +by the argument @var{seed} is the only state. Before the value is +returned the state will be updated so that the next call will return a +new number. + +I.e., the state of the RNG can only have as much bits as the type +@code{unsigned int} has. This is far too few to provide a good RNG. +This interface is broken by design. + +If the program requires reproducible random numbers in multi-threaded +programs the reentrant SVID functions are probably a better choice. But +these functions are GNU extensions and therefore @code{rand_r}, as being +standardized in POSIX.1, should always be kept as a default method. +@end deftypefun + + @node BSD Random @subsection BSD Random Number Functions -- cgit 1.4.1