From 04d1ae8c4ed0c8545710bcccc7c3103cc3bb1003 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 1 Aug 1999 22:23:36 +0000 Subject: [PATCH] Update from main line. --- ChangeLog | 63 ++++++++ Makerules | 3 +- include/stdlib.h | 3 + include/sys/sysinfo.h | 18 +++ manual/time.texi | 7 +- misc/efgcvt.c | 8 +- misc/efgcvt_r.c | 8 +- misc/qefgcvt.c | 10 +- misc/qefgcvt_r.c | 10 +- nis/nss_compat/compat-initgroups.c | 4 +- nis/nss_nis/nis-initgroups.c | 4 +- sysdeps/generic/e_lgammal_r.c | 1 + sysdeps/generic/putenv.c | 4 +- sysdeps/generic/setenv.c | 152 +++++++++++--------- sysdeps/generic/sys/sysinfo.h | 6 +- sysdeps/i386/bits/string.h | 2 +- sysdeps/libm-i387/e_pow.S | 3 +- sysdeps/libm-i387/e_powf.S | 2 +- sysdeps/libm-i387/e_powl.S | 3 +- sysdeps/libm-ieee754/e_gammal_r.c | 53 ++----- sysdeps/unix/sysv/linux/alpha/getsysstats.c | 54 +++++++ sysdeps/unix/sysv/linux/getsysstats.c | 69 +++++++-- sysdeps/unix/sysv/linux/sys/sysinfo.h | 6 +- 23 files changed, 338 insertions(+), 155 deletions(-) create mode 100644 include/sys/sysinfo.h create mode 100644 sysdeps/unix/sysv/linux/alpha/getsysstats.c diff --git a/ChangeLog b/ChangeLog index d1cbdc0add3..dd047d72302 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,69 @@ * string/bits/string2.h (__strcpy_small): Fix a typo. +1999-07-31 Ulrich Drepper + + * sysdeps/i386/fpu/e_pow.S: Use addl %esp instead of pop. + * sysdeps/i386/fpu/e_powf.S: Likewise. + * sysdeps/i386/fpu/e_powl.S: Likewise. [PR libc/1213]. + + * sysdeps/generic/e_lgammal_r.c: Set *signgam to zero. + * sysdeps/generic/e_gammal_r.c: Likewise. [PR libc/1212]. + +1999-07-30 Andreas Schwab + + * sysdeps/unix/sysv/linux/getsysstats.c (GET_NPROCS_PARSER): New + definition. + (__get_nprocs): Use it. + (__get_nprocs_conf): Define as separate function if + GET_NPROCS_CONF_PARSER is defined. + * sysdeps/unix/sysv/linux/alpha/getsysstats.c: New file. + + * include/sys/sysinfo.h: New file. + * sysdeps/generic/sys/sysinfo.h: Remove declaration of internal + interface. + * sysdeps/unix/sysv/linux/sys/sysinfo.h: Likewise. + +1999-07-30 Andreas Schwab + + * Makerules: Put sysd-versions and Versions.all on + postclean-generated instead of common-generated. + +1999-07-29 Andreas Jaeger + + * manual/time.texi (Basic CPU Time): Note that clock_t can wrap + around and CLOCKS_PER_SEC is 1e6. + +1999-07-29 Andreas Schwab + + * misc/efgcvt.c (NDIGIT_MAX): Provide precomputed constants for + all floating point formats supported by gcc. Error out for + unhandled precisions. + * misc/efgcvt_r.c (NDIGIT_MAX): Likewise. + * misc/qefgcvt.c (NDIGIT_MAX): Likewise. + * misc/qefgcvt_r.c (NDIGIT_MAX): Likewise. + +1999-07-29 Ulrich Drepper + + * sysdeps/generic/setenv.c: Move setenv code in new function + __add_to_environ. Add new parameter specifying already + constructed string for the environment. + (setenv): Call __add_to_environ with new parameter set to NULL. + (unsetenv): Really test all elements for duplicated name. Missed those + cases where the two are following each other. + * sysdeps/generic/putenv.c: Use __add_to_environ instead of setenv. + * include/stdlib.h: Add prototype of __add_to_environ. + * stdlib/tst-environ.c: New file. + * stdlib/Makefile (tests): Add tst-environ. + + * sysdeps/i386/bits/string.h (__memset_cc): Fix typo in last patch. + + * nis/nss_nis/nis-initgroups.c (_nss_nis_initgroups): Correct size + argument in realloc call. + * nis/nss_compat/compat-initgroups.c (_nss_compat_initgroups): + Likewise. + Reported by Danny Braniss . + 1999-07-28 Ulrich Drepper * misc/efgcvt.c: Use IEEE 854 formula to compute the number of digits diff --git a/Makerules b/Makerules index 90b05870aa1..4d6a48742c7 100644 --- a/Makerules +++ b/Makerules @@ -269,7 +269,8 @@ ifdef sysd-dirs-done ifeq ($(versioning),yes) -include $(common-objpfx)sysd-versions $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions -common-generated += $(version-maps) sysd-versions Versions.all +common-generated += $(version-maps) +postclean-generated += sysd-versions Versions.all ifndef avoid-generated ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs)) diff --git a/include/stdlib.h b/include/stdlib.h index c15d364c6ef..187c4585d83 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -46,6 +46,9 @@ extern char *__canonicalize_file_name __P ((__const char *__name)); extern char *__realpath __P ((__const char *__name, char *__resolved)); extern int __ptsname_r __P ((int __fd, char *__buf, size_t __buflen)); extern int __getpt __P ((void)); + +extern int __add_to_environ (const char *name, const char *value, + const char *combines, int replace); #endif #undef __Need_M_And_C diff --git a/include/sys/sysinfo.h b/include/sys/sysinfo.h new file mode 100644 index 00000000000..9d1549d2256 --- /dev/null +++ b/include/sys/sysinfo.h @@ -0,0 +1,18 @@ +#ifndef _SYS_SYSINFO_H +#include_next + +/* Now we define the internal interface. */ + +/* Return number of configured processors. */ +extern int __get_nprocs_conf __P ((void)); + +/* Return number of available processors. */ +extern int __get_nprocs __P ((void)); + +/* Return number of physical pages of memory in the system. */ +extern int __get_phys_pages __P ((void)); + +/* Return number of available physical pages of memory in the system. */ +extern int __get_avphys_pages __P ((void)); + +#endif /* sys/sysinfo.h */ diff --git a/manual/time.texi b/manual/time.texi index 463814dae3a..b45a33b5ce5 100644 --- a/manual/time.texi +++ b/manual/time.texi @@ -95,11 +95,16 @@ to @code{double}, as in the example above, makes sure that operations such as arithmetic and printing work properly and consistently no matter what the underlying representation is. +Note that the clock can wrap around. On a 32bit system with +@code{CLOCKS_PER_SEC} set to one million a wrap around happens after +around 36 minutes. + @comment time.h @comment ISO @deftypevr Macro int CLOCKS_PER_SEC The value of this macro is the number of clock ticks per second measured -by the @code{clock} function. +by the @code{clock} function. POSIX requires that this value is one +million independend of the actual resolution. @end deftypevr @comment time.h diff --git a/misc/efgcvt.c b/misc/efgcvt.c index dc711c63dcd..37b4bc01636 100644 --- a/misc/efgcvt.c +++ b/misc/efgcvt.c @@ -33,8 +33,14 @@ # define MAXDIG (NDIGIT_MAX + 3) # if DBL_MANT_DIG == 53 # define NDIGIT_MAX 17 +# elif DBL_MANT_DIG == 24 +# define NDIGIT_MAX 9 +# elif DBL_MANT_DIG == 56 +# define NDIGIT_MAX 18 # else -/* See IEEE 854 5.6, table 2 for this formula. */ +/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a + compile time constant here, so we cannot use it. */ +# error "NDIGIT_MAX must be precomputed" # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) # endif #endif diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c index d73fd22f70f..80770e6a827 100644 --- a/misc/efgcvt_r.c +++ b/misc/efgcvt_r.c @@ -32,8 +32,14 @@ # define FLOAT_NAME_EXT # if DBL_MANT_DIG == 53 # define NDIGIT_MAX 17 +# elif DBL_MANT_DIG == 24 +# define NDIGIT_MAX 9 +# elif DBL_MANT_DIG == 56 +# define NDIGIT_MAX 18 # else -/* See IEEE 854 5.6, table 2 for this formula. */ +/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a + compile time constant here, so we cannot use it. */ +# error "NDIGIT_MAX must be precomputed" # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) # endif #endif diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c index faf788aa5d4..63fc764121b 100644 --- a/misc/qefgcvt.c +++ b/misc/qefgcvt.c @@ -28,8 +28,16 @@ #define MAXDIG (NDIGIT_MAX + 12) #if LDBL_MANT_DIG == 64 # define NDIGIT_MAX 21 +#elif LDBL_MANT_DIG == 53 +# define NDIGIT_MAX 17 +#elif LDBL_MANT_DIG == 113 +# define NDIGIT_MAX 36 +#elif LDBL_MANT_DIG == 56 +# define NDIGIT_MAX 18 #else -/* See IEEE 854 5.6, table 2 for this formula. */ +/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a + compile time constant here, so we cannot use it. */ +# error "NDIGIT_MAX must be precomputed" # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0))) #endif diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c index 5ff8110e3bb..040193b612d 100644 --- a/misc/qefgcvt_r.c +++ b/misc/qefgcvt_r.c @@ -26,8 +26,16 @@ #define FLOAT_NAME_EXT l #if LDBL_MANT_DIG == 64 # define NDIGIT_MAX 21 +#elif LDBL_MANT_DIG == 53 +# define NDIGIT_MAX 17 +#elif LDBL_MANT_DIG == 113 +# define NDIGIT_MAX 36 +#elif LDBL_MANT_DIG == 56 +# define NDIGIT_MAX 18 #else -/* See IEEE 854 5.6, table 2 for this formula. */ +/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a + compile time constant here, so we cannot use it. */ +# error "NDIGIT_MAX must be precomputed" # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0))) #endif diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c index a0c3455eb61..47b395ede6c 100644 --- a/nis/nss_compat/compat-initgroups.c +++ b/nis/nss_compat/compat-initgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -620,7 +620,7 @@ _nss_compat_initgroups (const char *user, gid_t group, long int *start, if (*start == *size && limit <= 0) { /* Need a bigger buffer. */ - groups = realloc (groups, *size * sizeof (*groups)); + groups = realloc (groups, 2 * *size * sizeof (*groups)); if (groups == NULL) goto done; *size *= 2; diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c index b69fea4e85f..c5577c9cedc 100644 --- a/nis/nss_nis/nis-initgroups.c +++ b/nis/nss_nis/nis-initgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -174,7 +174,7 @@ _nss_nis_initgroups (const char *user, gid_t group, long int *start, if (*start == *size && limit <= 0) { /* Need a bigger buffer. */ - groups = realloc (groups, *size * sizeof (*groups)); + groups = realloc (groups, 2 * *size * sizeof (*groups)); if (groups == NULL) goto done; *size *= 2; diff --git a/sysdeps/generic/e_lgammal_r.c b/sysdeps/generic/e_lgammal_r.c index 0c1bc661ad7..eea3d48d2aa 100644 --- a/sysdeps/generic/e_lgammal_r.c +++ b/sysdeps/generic/e_lgammal_r.c @@ -5,6 +5,7 @@ long double __ieee754_lgammal_r (long double x, int *signgamp) { + *signgamp = 0; fputs ("__ieee754_lgammal_r not implemented\n", stderr); __set_errno (ENOSYS); return 0.0; diff --git a/sysdeps/generic/putenv.c b/sysdeps/generic/putenv.c index 3fcd5f93a8d..75fafad06d3 100644 --- a/sysdeps/generic/putenv.c +++ b/sysdeps/generic/putenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 94, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1991, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -64,7 +64,7 @@ putenv (string) memcpy (name, string, name_end - string); name[name_end - string] = '\0'; #endif - return __setenv (name, name_end + 1, 1); + return __add_to_environ (name, NULL, string, 1); } __unsetenv (string); diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c index a5818d03bfa..fc58e9b3463 100644 --- a/sysdeps/generic/setenv.c +++ b/sysdeps/generic/setenv.c @@ -16,23 +16,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Issues: - - 1. putenv must not use setenv since the string provided by the user - must be used, not a copy - - 2. a common function should determine the place where to insert the - new entry and if necessary take care of extending the array - - 3. It must be kept track of whether an entry was inserted via putenv - or setenv. In the former case the entry must not be put into - the search tree since removing it could mean it will not be - available anymore (e.g., when allocated on the stack) - - To handle this an array parallel to the __environ array must specify - whether the entry was added via putenv or not -*/ - #if HAVE_CONFIG_H # include #endif @@ -117,16 +100,23 @@ static void *known_values; static char **last_environ; +/* This function is used by `setenv' and `putenv'. The difference between + the two functions is that for the former must create a new string which + is then placed in the environment, while the argument of `putenv' + must be used directly. This is all complicated by the fact that we try + to reuse values once generated for a `setenv' call since we can never + free the strings. */ int -setenv (name, value, replace) +__add_to_environ (name, value, combined, replace) const char *name; const char *value; + const char *combined; int replace; { register char **ep; register size_t size; const size_t namelen = strlen (name); - const size_t vallen = strlen (value) + 1; + const size_t vallen = value != NULL ? strlen (value) + 1 : 0; LOCK; @@ -156,37 +146,49 @@ setenv (name, value, replace) return -1; } - /* See whether the value is already known. */ + /* If the whole entry is given add it. */ + if (combined != NULL) + /* We must not add the string to the search tree since it belongs + to the user. */ + new_environ[size] = (char *) combined; + else + { + /* See whether the value is already known. */ #ifdef USE_TSEARCH - new_value = alloca (namelen + 1 + vallen); + new_value = (char *) alloca (namelen + 1 + vallen); # ifdef _LIBC - __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), - value, vallen); + __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), + value, vallen); # else - memcpy (new_value, name, namelen); - new_value[namelen] = '='; - memcpy (&new_value[namelen + 1], value, vallen); + memcpy (new_value, name, namelen); + new_value[namelen] = '='; + memcpy (&new_value[namelen + 1], value, vallen); # endif - new_environ[size] = KNOWN_VALUE (new_value); - if (new_environ[size] == NULL) -#endif - { - new_environ[size] = malloc (namelen + 1 + vallen); + new_environ[size] = KNOWN_VALUE (new_value); if (new_environ[size] == NULL) +#endif { - __set_errno (ENOMEM); - UNLOCK; - return -1; - } + new_environ[size] = (char *) malloc (namelen + 1 + vallen); + if (new_environ[size] == NULL) + { + __set_errno (ENOMEM); + UNLOCK; + return -1; + } #ifdef USE_TSEARCH - memcpy (new_environ[size], new_value, namelen + 1 + vallen); + memcpy (new_environ[size], new_value, namelen + 1 + vallen); #else - memcpy (new_environ[size], name, namelen); - new_environ[size][namelen] = '='; - memcpy (&new_environ[size][namelen + 1], value, vallen); + memcpy (new_environ[size], name, namelen); + new_environ[size][namelen] = '='; + memcpy (&new_environ[size][namelen + 1], value, vallen); #endif + /* And save the value now. We cannot do this when we remove + the string since then we cannot decide whether it is a + user string or not. */ + STORE_VALUE (new_environ[size]); + } } if (__environ != last_environ) @@ -199,43 +201,47 @@ setenv (name, value, replace) } else if (replace) { - char *new_value; char *np; - /* The existing string is too short; malloc a new one. */ + /* Use the user string if given. */ + if (combined != NULL) + np = (char *) combined; + else + { #ifdef USE_TSEARCH - new_value = alloca (namelen + 1 + vallen); + char *new_value = alloca (namelen + 1 + vallen); # ifdef _LIBC - __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), - value, vallen); + __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), + value, vallen); # else - memcpy (new_value, name, namelen); - new_value[namelen] = '='; - memcpy (&new_value[namelen + 1], value, vallen); + memcpy (new_value, name, namelen); + new_value[namelen] = '='; + memcpy (&new_value[namelen + 1], value, vallen); # endif - np = KNOWN_VALUE (new_value); - if (np == NULL) -#endif - { - np = malloc (namelen + 1 + vallen); + np = KNOWN_VALUE (new_value); if (np == NULL) +#endif { - UNLOCK; - return -1; - } + np = malloc (namelen + 1 + vallen); + if (np == NULL) + { + UNLOCK; + return -1; + } #ifdef USE_TSEARCH - memcpy (np, new_value, namelen + 1 + vallen); + memcpy (np, new_value, namelen + 1 + vallen); #else - memcpy (np, name, namelen); - np[namelen] = '='; - memcpy (&np[namelen + 1], value, vallen); + memcpy (np, name, namelen); + np[namelen] = '='; + memcpy (&np[namelen + 1], value, vallen); #endif + /* And remember the value. */ + STORE_VALUE (np); + } } - /* Keep the old value around. */ - STORE_VALUE (*ep); *ep = np; } @@ -244,6 +250,15 @@ setenv (name, value, replace) return 0; } +int +setenv (name, value, replace) + const char *name; + const char *value; + int replace; +{ + return __add_to_environ (name, value, NULL, replace); +} + void unsetenv (name) const char *name; @@ -253,20 +268,20 @@ unsetenv (name) LOCK; - for (ep = __environ; *ep != NULL; ++ep) + ep = __environ; + while (*ep != NULL) if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { /* Found it. Remove this pointer by moving later ones back. */ char **dp = ep; - /* Store the value so that we can reuse it later. */ - STORE_VALUE (*ep); - do dp[0] = dp[1]; while (*dp++); /* Continue the loop in case NAME appears again. */ } + else + ++ep; UNLOCK; } @@ -281,12 +296,7 @@ clearenv () if (__environ == last_environ && __environ != NULL) { - /* We allocated this environment so we can free it. Store all the - strings. */ - char **ep = __environ; - while (*ep != NULL) - STORE_VALUE (*ep++); - + /* We allocated this environment so we can free it. */ free (__environ); last_environ = NULL; } diff --git a/sysdeps/generic/sys/sysinfo.h b/sysdeps/generic/sys/sysinfo.h index 8100b0d056e..d79087b80ac 100644 --- a/sysdeps/generic/sys/sysinfo.h +++ b/sysdeps/generic/sys/sysinfo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,20 +22,16 @@ #include /* Return number of configured processors. */ -extern int __get_nprocs_conf __P ((void)); extern int get_nprocs_conf __P ((void)); /* Return number of available processors. */ -extern int __get_nprocs __P ((void)); extern int get_nprocs __P ((void)); /* Return number of physical pages of memory in the system. */ -extern int __get_phys_pages __P ((void)); extern int get_phys_pages __P ((void)); /* Return number of available physical pages of memory in the system. */ -extern int __get_avphys_pages __P ((void)); extern int get_avphys_pages __P ((void)); #endif /* sys/sysinfo.h */ diff --git a/sysdeps/i386/bits/string.h b/sysdeps/i386/bits/string.h index 5f4f58a6db5..44d6f8ba434 100644 --- a/sysdeps/i386/bits/string.h +++ b/sysdeps/i386/bits/string.h @@ -207,7 +207,7 @@ __memset_cc (void *__s, unsigned long int __pattern, size_t __n) return __s; case 3: __u->__usi = __pattern; - __u = __extension__ ((void *) __u + 1); + __u = __extension__ ((void *) __u + 2); __u->__uc = __pattern; return __s; case 4: diff --git a/sysdeps/libm-i387/e_pow.S b/sysdeps/libm-i387/e_pow.S index 6b20482319f..75b39e4884d 100644 --- a/sysdeps/libm-i387/e_pow.S +++ b/sysdeps/libm-i387/e_pow.S @@ -311,8 +311,7 @@ ENTRY(__ieee754_pow) ret 22: fstp %st(0) -23: popl %eax - popl %edx +23: addl $8, %esp // Don't use 2 x pop 24: fldl MO(zero) ret diff --git a/sysdeps/libm-i387/e_powf.S b/sysdeps/libm-i387/e_powf.S index 9ea41ba3c97..c023c11e65f 100644 --- a/sysdeps/libm-i387/e_powf.S +++ b/sysdeps/libm-i387/e_powf.S @@ -303,7 +303,7 @@ ENTRY(__ieee754_powf) ret 22: fstp %st(0) -23: popl %eax +23: addl $4, %esp // Don't use pop. 24: fldl MO(zero) ret diff --git a/sysdeps/libm-i387/e_powl.S b/sysdeps/libm-i387/e_powl.S index e733e522c85..769be4c1976 100644 --- a/sysdeps/libm-i387/e_powl.S +++ b/sysdeps/libm-i387/e_powl.S @@ -298,8 +298,7 @@ ENTRY(__ieee754_powl) ret 22: fstp %st(0) -23: popl %eax - popl %edx +23: addl $8, %esp // Don't use 2 x pop 24: fldl MO(zero) ret diff --git a/sysdeps/libm-ieee754/e_gammal_r.c b/sysdeps/libm-ieee754/e_gammal_r.c index 104992450b7..1c45c8421bb 100644 --- a/sysdeps/libm-ieee754/e_gammal_r.c +++ b/sysdeps/libm-ieee754/e_gammal_r.c @@ -1,50 +1,15 @@ -/* Implementation of gamma function according to ISO C. - Copyright (C) 1997, 1999 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - #include -#include - +#include +#include long double __ieee754_gammal_r (long double x, int *signgamp) { - /* We don't have a real gamma implementation now. We'll use lgamma - and the exp function. But due to the required boundary - conditions we must check some values separately. */ - u_int32_t es, hx, lx; - - GET_LDOUBLE_WORDS (es, hx, lx, x); - - if (((es & 0x7fff) | hx | lx) == 0) - { - /* Return value for x == 0 is NaN with invalid exception. */ - *signgamp = 0; - return x / x; - } - if ((hx & 0x8000) != 0 && (hx & 0x7fff) != 0x7fff && __rintl (x) == x) - { - /* Return value for integer x < 0 is NaN with invalid exception. */ - *signgamp = 0; - return (x - x) / (x - x); - } - - /* XXX FIXME. */ - return __ieee754_expl (__ieee754_lgammal_r (x, signgamp)); + *signgamp = 0; + fputs ("__ieee754_gammal_r not implemented\n", stderr); + __set_errno (ENOSYS); + return 0.0; } + +stub_warning (__ieee754_gammal_r) +#include diff --git a/sysdeps/unix/sysv/linux/alpha/getsysstats.c b/sysdeps/unix/sysv/linux/alpha/getsysstats.c new file mode 100644 index 00000000000..8588903c89f --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/getsysstats.c @@ -0,0 +1,54 @@ +/* Determine various system internal values, Linux/Alpha version. + Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +/* We need to define a special parser for /proc/cpuinfo. */ +#define GET_NPROCS_PARSER(FP, BUFFER, RESULT) \ + do \ + { \ + (RESULT) = 0; \ + /* Find the line that contains the information about the number of \ + active cpus. We don't have to fear extremely long lines since \ + the kernel will not generate them. 8192 bytes are really \ + enough. */ \ + while (fgets_unlocked (BUFFER, sizeof (BUFFER), FP) != NULL) \ + if (sscanf (BUFFER, "CPUs probed %*d active %d", &(RESULT)) == 1) \ + break; \ + } \ + while (0) + + +/* On the Alpha we can distinguish between the number of configured and + active cpus. */ +#define GET_NPROCS_CONF_PARSER(FP, BUFFER, RESULT) \ + do \ + { \ + (RESULT) = 0; \ + /* Find the line that contains the information about the number of \ + probed cpus. We don't have to fear extremely long lines since \ + the kernel will not generate them. 8192 bytes are really \ + enough. */ \ + while (fgets_unlocked ((BUFFER), sizeof (BUFFER), (FP)) != NULL) \ + if (sscanf (buffer, "CPUs probed %d", &(RESULT)) == 1) \ + break; \ + } \ + while (0) + +#include diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index 58f55ac99c5..be23753d2ff 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -1,5 +1,5 @@ /* Determine various system internal values, Linux version. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -67,6 +67,25 @@ get_proc_path (char *buffer, size_t bufsize) But not all systems have support for the /proc filesystem. If it is not available we simply return 1 since there is no way. */ + +/* Other architectures use different formats for /proc/cpuinfo. This + provides a hook for alternative parsers. */ +#ifndef GET_NPROCS_PARSER +# define GET_NPROCS_PARSER(FP, BUFFER, RESULT) \ + do \ + { \ + (RESULT) = 0; \ + /* Read all lines and count the lines starting with the string \ + "processor". We don't have to fear extremely long lines since \ + the kernel will not generate them. 8192 bytes are really \ + enough. */ \ + while (fgets_unlocked (BUFFER, sizeof (BUFFER), FP) != NULL) \ + if (strncmp (BUFFER, "processor", 9) == 0) \ + ++(RESULT); \ + } \ + while (0) +#endif + int __get_nprocs () { @@ -89,15 +108,7 @@ __get_nprocs () fp = fopen (proc_cpuinfo, "r"); if (fp != NULL) { - result = 0; - /* Read all lines and count the lines starting with the - string "processor". We don't have to fear extremely long - lines since the kernel will not generate them. 8192 - bytes are really enough. */ - while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL) - if (strncmp (buffer, "processor", 9) == 0) - ++result; - + GET_NPROCS_PARSER (fp, buffer, result); fclose (fp); } } @@ -106,12 +117,46 @@ __get_nprocs () } weak_alias (__get_nprocs, get_nprocs) + +#ifdef GET_NPROCS_CONF_PARSER +/* On some architectures it is possible to distinguish between configured + and active cpus. */ +int +__get_nprocs_conf () +{ + FILE *fp; + char buffer[8192]; + char *proc_path; + int result = 1; + + /* XXX Here will come a test for the new system call. */ + + /* Get mount point of proc filesystem. */ + proc_path = get_proc_path (buffer, sizeof buffer); + + /* If we haven't found an appropriate entry return 1. */ + if (proc_path != NULL) + { + char *proc_cpuinfo = alloca (strlen (proc_path) + sizeof ("/cpuinfo")); + __stpcpy (__stpcpy (proc_cpuinfo, proc_path), "/cpuinfo"); + + fp = fopen (proc_cpuinfo, "r"); + if (fp != NULL) + { + GET_NPROCS_CONF_PARSER (fp, buffer, result); + fclose (fp); + } + } + + return result; +} +#else /* As far as I know Linux has no separate numbers for configured and available processors. So make the `get_nprocs_conf' function an alias. */ strong_alias (__get_nprocs, __get_nprocs_conf) -weak_alias (__get_nprocs, get_nprocs_conf) - +#endif +weak_alias (__get_nprocs_conf, get_nprocs_conf) /* General function to get information about memory status from proc filesystem. */ diff --git a/sysdeps/unix/sysv/linux/sys/sysinfo.h b/sysdeps/unix/sysv/linux/sys/sysinfo.h index dc435d66512..2c17cf2a69a 100644 --- a/sysdeps/unix/sysv/linux/sys/sysinfo.h +++ b/sysdeps/unix/sysv/linux/sys/sysinfo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -31,20 +31,16 @@ extern int sysinfo __P ((struct sysinfo *__info)); /* Return number of configured processors. */ -extern int __get_nprocs_conf __P ((void)); extern int get_nprocs_conf __P ((void)); /* Return number of available processors. */ -extern int __get_nprocs __P ((void)); extern int get_nprocs __P ((void)); /* Return number of physical pages of memory in the system. */ -extern int __get_phys_pages __P ((void)); extern int get_phys_pages __P ((void)); /* Return number of available physical pages of memory in the system. */ -extern int __get_avphys_pages __P ((void)); extern int get_avphys_pages __P ((void)); __END_DECLS -- 2.47.3