Mercurial > emacs
changeset 51485:f129be4cf98e
Set NLIST_STRUCT from HAVE_NLIST_H. Use
HAVE_STRUCT_NLIST_N_UN_N_NAME, not NLIST_NAME_UNION.
[HAVE_LOCALE_H]: Include locale.h.
(getloadavg) [HAVE_SETLOCALE]: Run sscanf in C locale.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 05 Jun 2003 16:24:51 +0000 |
parents | bd73ed6af906 |
children | f36efdc0ae5e |
files | src/getloadavg.c |
diffstat | 1 files changed, 34 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/getloadavg.c Thu Jun 05 16:24:17 2003 +0000 +++ b/src/getloadavg.c Thu Jun 05 16:24:51 2003 +0000 @@ -1,7 +1,10 @@ /* Get the system load averages. - Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995, 1997 + Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995, 1997, 2003 Free Software Foundation, Inc. + NOTE: The canonical source of this file is maintained with gnulib. + Bugs can be reported to bug-gnulib@gnu.org. + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) @@ -37,11 +40,15 @@ apollo, DGUX, NeXT, or UMAX is defined; or we have libkstat; otherwise, no load average is available. + HAVE_NLIST_H nlist.h is available. NLIST_STRUCT defaults + to this. NLIST_STRUCT Include nlist.h, not a.out.h, and the nlist n_name element is a pointer, not an array. - NLIST_NAME_UNION struct nlist has an n_un member, not n_name. + HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'. LINUX_LDAV_FILE [__linux__]: File containing load averages. + HAVE_LOCALE_H locale.h is available. + HAVE_SETLOCALE The `setlocale' function is available. Specific system predefines this file uses, aside from setting default values if not emacs: @@ -99,9 +106,15 @@ extern int errno; #endif +#ifdef HAVE_LOCALE_H +# include <locale.h> +#endif +#ifndef HAVE_SETLOCALE +# define setlocale(Category, Locale) /* empty */ +#endif + #ifndef HAVE_GETLOADAVG - /* The existing Emacs configuration files define a macro called LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and returns the load average multiplied by 100. What we actually want @@ -288,7 +301,7 @@ /* Sometimes both MIPS and sgi are defined, so FSCALE was just defined above under #ifdef MIPS. But we want the sgi value. */ # undef FSCALE -# define FSCALE 1000.0 +# define FSCALE 1000.0 # endif # if defined (ardent) && defined (titan) @@ -306,9 +319,14 @@ # endif /* Not FSCALE. */ # if !defined (LDAV_CVT) && defined (FSCALE) -# define LDAV_CVT(n) (((double) (n)) / FSCALE) +# define LDAV_CVT(n) (((double) (n)) / FSCALE) # endif +# ifndef NLIST_STRUCT +# if HAVE_NLIST_H +# define NLIST_STRUCT +# endif +# endif # if defined(sgi) || (defined(mips) && !defined(BSD)) # define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31)) @@ -446,7 +464,6 @@ # include <sys/file.h> # endif - /* Avoid static vars inside a function since in HPUX they dump as pure. */ # ifdef NeXT @@ -471,13 +488,13 @@ /* Offset in kmem to seek to read load average, or 0 means invalid. */ static long offset; -#if !defined(VMS) && !defined(sgi) && !defined(__linux__) +# if !defined(VMS) && !defined(sgi) && !defined(__linux__) static struct nlist nl[2]; -#endif /* Not VMS or sgi */ +# endif /* Not VMS or sgi */ -#ifdef SUNOS_5 +# ifdef SUNOS_5 static kvm_t *kd; -#endif /* SUNOS_5 */ +# endif /* SUNOS_5 */ #endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */ @@ -585,8 +602,11 @@ if (count <= 0) return -1; + /* The following sscanf must use the C locale. */ + setlocale (LC_NUMERIC, "C"); count = sscanf (ldavgbuf, "%lf %lf %lf", &load_ave[0], &load_ave[1], &load_ave[2]); + setlocale (LC_NUMERIC, ""); if (count < 1) return -1; @@ -862,13 +882,13 @@ strcpy (nl[0].n_name, LDAV_SYMBOL); strcpy (nl[1].n_name, ""); # else /* NLIST_STRUCT */ -# ifdef NLIST_NAME_UNION +# ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME nl[0].n_un.n_name = LDAV_SYMBOL; nl[1].n_un.n_name = 0; -# else /* not NLIST_NAME_UNION */ +# else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */ nl[0].n_name = LDAV_SYMBOL; nl[1].n_name = 0; -# endif /* not NLIST_NAME_UNION */ +# endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */ # endif /* NLIST_STRUCT */ # ifndef SUNOS_5 @@ -977,7 +997,7 @@ #endif /* ! HAVE_GETLOADAVG */ #ifdef TEST -int +void main (argc, argv) int argc; char **argv;