Update.
* sysdeps/generic/getsysstat.c: Change return value of get_phys_pages and get_avphys_page to long int. * sysdeps/unix/sysv/linux/getsysstat.c: Likewise. * include/sys/sysinfo.h: Likewise. * sysdeps/generic/sys/sysinfo.h: Likewise. * sysdeps/unix/sysv/linux/sys/sysinfo.h: Likewise.
This commit is contained in:
parent
5b8d5ae180
commit
e4cf522929
@ -1,5 +1,12 @@
|
||||
2001-02-11 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* sysdeps/generic/getsysstat.c: Change return value of get_phys_pages
|
||||
and get_avphys_page to long int.
|
||||
* sysdeps/unix/sysv/linux/getsysstat.c: Likewise.
|
||||
* include/sys/sysinfo.h: Likewise.
|
||||
* sysdeps/generic/sys/sysinfo.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/sys/sysinfo.h: Likewise.
|
||||
|
||||
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Fail if we
|
||||
cannot return as many values as the user asked for.
|
||||
|
||||
|
24
PROJECTS
24
PROJECTS
@ -1,6 +1,6 @@
|
||||
Open jobs for finishing GNU libc:
|
||||
---------------------------------
|
||||
Status: December 1998
|
||||
Status: February 2001
|
||||
|
||||
If you have time and talent to take over any of the jobs below please
|
||||
contact <bug-glibc@gnu.org>.
|
||||
@ -77,6 +77,9 @@ contact <bug-glibc@gnu.org>.
|
||||
|
||||
It is planned to do a complete rewrite.
|
||||
|
||||
*** We have no multibyte character support. But a rewrite is still
|
||||
necessary.
|
||||
|
||||
|
||||
[11] Write access function for netmasks, bootparams, and automount
|
||||
databases for nss_files and nss_db module.
|
||||
@ -84,24 +87,20 @@ contact <bug-glibc@gnu.org>.
|
||||
hard and not all services must be supported at once.
|
||||
|
||||
|
||||
[14] We need to write a library for on-the-fly transformation of streams
|
||||
of text. In fact, this would be a recode-library (you know, GNU recode).
|
||||
This is needed in several places in the GNU libc and I already have
|
||||
rather concrete plans but so far no possibility to start this.
|
||||
|
||||
*** The library is available, now it remains to be used in the streams.
|
||||
|
||||
|
||||
[15] Cleaning up the header files. Ideally, each header style should
|
||||
follow the "good examples". Each variable and function should have
|
||||
a short description of the function and its parameters. The prototypes
|
||||
should always contain variable names which can help to identify their
|
||||
meaning; better than
|
||||
|
||||
int foo __P ((int, int, int, int));
|
||||
int foo (int, int, int, int);
|
||||
|
||||
Blargh!
|
||||
|
||||
*** The conformtest.pl tool helps cleaning the namespace. As far as
|
||||
known the prototypes all contain parameter names. But maybe some
|
||||
comments can be improved.
|
||||
|
||||
|
||||
[16] The libio stream file functions should be extended in a way to use
|
||||
mmap to map the file and use it as the buffer to user sees. For
|
||||
@ -194,7 +193,4 @@ contact <bug-glibc@gnu.org>.
|
||||
user should be preferred even if the last user spent more time.
|
||||
|
||||
|
||||
[26] Improve the AIO implementation so that threads do not immediately
|
||||
terminate if no more requests are available. Let them sleep for a
|
||||
while and wake them up on demand. If after a while no request arrived
|
||||
they really can die.
|
||||
[26] ...done
|
||||
|
@ -10,9 +10,9 @@ extern int __get_nprocs_conf (void);
|
||||
extern int __get_nprocs (void);
|
||||
|
||||
/* Return number of physical pages of memory in the system. */
|
||||
extern int __get_phys_pages (void);
|
||||
extern long int __get_phys_pages (void);
|
||||
|
||||
/* Return number of available physical pages of memory in the system. */
|
||||
extern int __get_avphys_pages (void);
|
||||
extern long int __get_avphys_pages (void);
|
||||
|
||||
#endif /* sys/sysinfo.h */
|
||||
|
@ -140,6 +140,34 @@ syntax errors (@pxref{File Name Errors}), plus @code{ENOTDIR} if the
|
||||
file @var{filename} is not a directory.
|
||||
@end deftypefun
|
||||
|
||||
@comment unistd.h
|
||||
@comment XPG
|
||||
@deftypefun int fchdir (int @var{filedes})
|
||||
This function is used to set the process's working directory to
|
||||
directory associated with the file descriptor @var{filedes}.
|
||||
|
||||
The normal, successful return value from @code{fchdir} is @code{0}. A
|
||||
value of @code{-1} is returned to indicate an error. The following
|
||||
@code{errno} error conditions are defined for this function:
|
||||
|
||||
@table @code
|
||||
@item EACCES
|
||||
Read permission is denied for the directory named by @code{dirname}.
|
||||
|
||||
@item EBADF
|
||||
The @var{filedes} argument is not a valid file descriptor.
|
||||
|
||||
@item ENOTDIR
|
||||
The file descriptor @var{filedes} is not associated with a directory.
|
||||
|
||||
@item EINTR
|
||||
The function call was interrupt by a signal.
|
||||
|
||||
@item EIO
|
||||
An I/O error occurred.
|
||||
@end table
|
||||
@end deftypefun
|
||||
|
||||
|
||||
@node Accessing Directories
|
||||
@section Accessing Directories
|
||||
@ -206,7 +234,7 @@ type of the appropriate size
|
||||
This is the type of the file, possibly unknown. The following constants
|
||||
are defined for its value:
|
||||
|
||||
@table @code
|
||||
@vtable @code
|
||||
@item DT_UNKNOWN
|
||||
The type is unknown. On some systems this is the only value returned.
|
||||
|
||||
@ -227,24 +255,34 @@ A character device.
|
||||
|
||||
@item DT_BLK
|
||||
A block device.
|
||||
@end table
|
||||
@end vtable
|
||||
|
||||
This member is a BSD extension. On systems where it is used, it
|
||||
This member is a BSD extension. The symbol @code{_DIRENT_HAVE_D_TYPE}
|
||||
is defined if this member is available. On systems where it is used, it
|
||||
corresponds to the file type bits in the @code{st_mode} member of
|
||||
@code{struct statbuf}. On other systems it will always be DT_UNKNOWN.
|
||||
These two macros convert between @code{d_type} values and @code{st_mode}
|
||||
values:
|
||||
@code{struct statbuf}. If the value cannot be determine the member
|
||||
value is DT_UNKNOWN. These two macros convert between @code{d_type}
|
||||
values and @code{st_mode} values:
|
||||
|
||||
@comment dirent.h
|
||||
@comment BSD
|
||||
@deftypefun int IFTODT (mode_t @var{mode})
|
||||
This returns the @code{d_type} value corresponding to @var{mode}.
|
||||
@end deftypefun
|
||||
|
||||
@comment dirent.h
|
||||
@comment BSD
|
||||
@deftypefun mode_t DTTOIF (int @var{dtype})
|
||||
This returns the @code{st_mode} value corresponding to @var{dtype}.
|
||||
@end deftypefun
|
||||
@end table
|
||||
|
||||
This structure may contain additional members in the future.
|
||||
This structure may contain additional members in the future. Their
|
||||
availability is always announced in the compilation environment by a
|
||||
macro names @code{_DIRENT_HAVE_D_xxx} where @code{xxx} is replaced by
|
||||
the name of the new member. For instance, the member @code{d_reclen}
|
||||
available on some systems is announced through the macro
|
||||
@code{_DIRENT_HAVE_D_RECLEN}.
|
||||
|
||||
When a file has multiple names, each name has its own directory entry.
|
||||
The only way you can tell that the directory entries belong to a
|
||||
@ -304,6 +342,24 @@ and the @code{opendir} function in terms of the @code{open} function.
|
||||
file descriptors are closed on @code{exec} (@pxref{Executing a File}).
|
||||
@end deftypefun
|
||||
|
||||
In some situations it can be desirable to get hold of the file
|
||||
descriptor which is created by the @code{opendir} call. For instance,
|
||||
to switch the current working directory to the directory just read the
|
||||
@code{fchdir} function could be used. Historically the @code{DIR} type
|
||||
was exposed and programs could access the fields. This does not happen
|
||||
in the GNU C library. Instead a separate function is provided to allow
|
||||
access.
|
||||
|
||||
@comment dirent.h
|
||||
@comment GNU
|
||||
@deftypefun int dirfd (DIR *@var{dirstream})
|
||||
The function @code{dirfd} returns the file descriptor associated with
|
||||
the directory stream @var{dirstream}. This descriptor can be used until
|
||||
the directory is closed with @code{closedir}. If the directory stream
|
||||
implementation is not using file descriptors the return value is
|
||||
@code{-1}.
|
||||
@end deftypefun
|
||||
|
||||
@node Reading/Closing Directory
|
||||
@subsection Reading and Closing a Directory Stream
|
||||
|
||||
|
@ -1401,3 +1401,22 @@ processors and so the call
|
||||
@noindent
|
||||
returns the number of processors which are currently inline (i.e.,
|
||||
available).
|
||||
|
||||
@cindex load average
|
||||
Before starting more threads it should be checked whether the processors
|
||||
are not already overused. Unix systems calculate something called the
|
||||
@dfn{load average}. This is a number indicating how many processes were
|
||||
running. This number is average over different periods of times
|
||||
(normally 1, 5, and 15 minutes).
|
||||
|
||||
@comment stdlib.h
|
||||
@comment BSD
|
||||
@deftypefun int getloadavg (double @var{loadavg}[], int @var{nelem})
|
||||
This function gets the 1, 5 and 15 minute load averages of the
|
||||
system. The values are placed in @var{loadavg}. @code{getloadavg} will
|
||||
place at most @var{nelem} elements into the array but never more than
|
||||
three elements. The return value is the number of elements written to
|
||||
@var{loadavg}, or -1 on error.
|
||||
|
||||
This function is declared in @file{stdlib.h}.
|
||||
@end deftypefun
|
||||
|
@ -15,7 +15,6 @@ can make changes.
|
||||
machine type
|
||||
* Filesystem Handling:: Controlling/querying mounts
|
||||
* System Parameters:: Getting and setting various system parameters
|
||||
* Load Average:: Getting the system load average
|
||||
@end menu
|
||||
|
||||
To get information on parameters of the system that are built into the
|
||||
@ -1193,23 +1192,3 @@ parameters are:
|
||||
@item
|
||||
@code{bdflush}
|
||||
@end itemize
|
||||
|
||||
@node Load Average
|
||||
@section Getting the system load average
|
||||
|
||||
This section describes the @code{getloadavg} function, which gets the 1, 5
|
||||
and 15 minute load averages of the system. The load average is the number of
|
||||
processes in the system run queue, averaged over various periods of time
|
||||
(1, 5 and 15 minutes in this case).
|
||||
|
||||
The symbols used in this section are declared in the file @file{stdlib.h}.
|
||||
|
||||
@comment stdlib.h
|
||||
@comment BSD
|
||||
@deftypefun int getloadavg (double @var{loadavg}[], int @var{nelem})
|
||||
This function gets the 1, 5 and 15 minute load averages of the system. The
|
||||
values are placed in @var{loadavg}. The function will place at most
|
||||
@var{nelem} elements into the array, @var{loadavg}. Never are there more
|
||||
than three elements returned and possibly less than @var{nelem}. The return
|
||||
value is the number of elements written to @var{loadavg}, or -1 on error.
|
||||
@end deftypefun
|
||||
|
@ -59,7 +59,7 @@ Pass to another daemon
|
||||
Discard
|
||||
@end itemize
|
||||
|
||||
Syslogd can also handle messages from other systems. It listens on the
|
||||
Syslogd can also handle messages from other systems. It listens on the
|
||||
@code{syslog} UDP port as well as the local socket for messages.
|
||||
|
||||
Syslog can handle messages from the kernel itself. But the kernel
|
||||
@ -158,7 +158,7 @@ to identify the source of the message, and people conventionally set it
|
||||
to the name of the program that will submit the messages.
|
||||
|
||||
@code{openlog} may or may not open the @file{/dev/log} socket, depending
|
||||
on @var{option}. If it does, it tries to open it and connect it as a
|
||||
on @var{option}. If it does, it tries to open it and connect it as a
|
||||
stream socket. If that doesn't work, it tries to open it and connect it
|
||||
as a datagram socket. The socket has the ``Close on Exec'' attribute,
|
||||
so the kernel will close it if the process performs an exec.
|
||||
@ -166,7 +166,7 @@ so the kernel will close it if the process performs an exec.
|
||||
You don't have to use @code{openlog}. If you call @code{syslog} without
|
||||
having called @code{openlog}, @code{syslog} just opens the connection
|
||||
implicitly and uses defaults for the information in @var{ident} and
|
||||
@var{options}.
|
||||
@var{options}.
|
||||
|
||||
@var{options} is a bit string, with the bits as defined by the following
|
||||
single bit masks:
|
||||
@ -243,7 +243,7 @@ writing to the Unix domain socket @code{/dev/log}.
|
||||
|
||||
@code{syslog} submits the message with the facility and priority indicated
|
||||
by @var{facility_priority}. The macro @code{LOG_MAKEPRI} generates a
|
||||
facility/priority from a facility and a priority, as in the following
|
||||
facility/priority from a facility and a priority, as in the following
|
||||
example:
|
||||
|
||||
@smallexample
|
||||
@ -255,7 +255,7 @@ The possible values for the facility code are (macros):
|
||||
@c Internally, there is also LOG_KERN, but LOG_KERN == 0, which means
|
||||
@c if you try to use it here, just selects default.
|
||||
|
||||
@table @code
|
||||
@vtable @code
|
||||
@item LOG_USER
|
||||
A miscellaneous user process
|
||||
@item LOG_MAIL
|
||||
@ -294,15 +294,15 @@ Locally defined
|
||||
Locally defined
|
||||
@item LOG_LOCAL7
|
||||
Locally defined
|
||||
@end table
|
||||
@end vtable
|
||||
|
||||
Results are undefined if the facility code is anything else.
|
||||
|
||||
@strong{note:} Syslog recognizes one other facility code: that of the
|
||||
kernel. But you can't specify that facility code with these functions.
|
||||
If you try, it looks the same to @code{syslog} as if you are requesting
|
||||
the default facility. But you wouldn't want to anyway, because any
|
||||
program that uses the GNU C library is not the kernel.
|
||||
@strong{note:} @code{syslog} recognizes one other facility code: that of
|
||||
the kernel. But you can't specify that facility code with these
|
||||
functions. If you try, it looks the same to @code{syslog} as if you are
|
||||
requesting the default facility. But you wouldn't want to anyway,
|
||||
because any program that uses the GNU C library is not the kernel.
|
||||
|
||||
You can use just a priority code as @var{facility_priority}. In that
|
||||
case, @code{syslog} assumes the default facility established when the
|
||||
@ -310,7 +310,7 @@ Syslog connection was opened. @xref{Syslog Example}.
|
||||
|
||||
The possible values for the priority code are (macros):
|
||||
|
||||
@table @code
|
||||
@vtable @code
|
||||
@item LOG_EMERG
|
||||
The message says the system is unusable.
|
||||
@item LOG_ALERT
|
||||
@ -327,7 +327,7 @@ The message describes a normal but important event.
|
||||
The message is purely informational.
|
||||
@item LOG_DEBUG
|
||||
The message is only for debugging purposes.
|
||||
@end table
|
||||
@end vtable
|
||||
|
||||
Results are undefined if the priority code is anything else.
|
||||
|
||||
@ -354,8 +354,8 @@ Example:
|
||||
@smallexample
|
||||
|
||||
#include <syslog.h>
|
||||
syslog(LOG_MAKEPRI(LOG_LOCAL1, LOG_ERROR),
|
||||
"Unable to make network connection to %s. Error=%m", host);
|
||||
syslog (LOG_MAKEPRI(LOG_LOCAL1, LOG_ERROR),
|
||||
"Unable to make network connection to %s. Error=%m", host);
|
||||
|
||||
@end smallexample
|
||||
|
||||
@ -364,8 +364,7 @@ syslog(LOG_MAKEPRI(LOG_LOCAL1, LOG_ERROR),
|
||||
|
||||
@comment syslog.h
|
||||
@comment BSD
|
||||
@deftypefun void vsyslog (int @var{facility_priority}, char *@var{format},
|
||||
__gnuc_va_list arglist)
|
||||
@deftypefun void vsyslog (int @var{facility_priority}, char *@var{format}, va_list arglist)
|
||||
|
||||
This is functionally identical to @code{syslog}, with the BSD style variable
|
||||
length argument.
|
||||
@ -381,7 +380,7 @@ The symbols referred to in this section are declared in the file
|
||||
|
||||
@comment syslog.h
|
||||
@comment BSD
|
||||
@deftypefun void closelog ()
|
||||
@deftypefun void closelog (void)
|
||||
|
||||
@code{closelog} closes the current Syslog connection, if there is one.
|
||||
This include closing the @file{dev/log} socket, if it is open.
|
||||
@ -444,7 +443,7 @@ on for a certain priority and all priorities above it:
|
||||
LOG_UPTO(LOG_ERROR)
|
||||
@end smallexample
|
||||
|
||||
The unfortunate naming of the macro is due to the fact that internally,
|
||||
The unfortunate naming of the macro is due to the fact that internally,
|
||||
higher numbers are used for lower message priorities.
|
||||
|
||||
@end deftypefun
|
||||
@ -462,16 +461,13 @@ in the example does nothing.
|
||||
@smallexample
|
||||
#include <syslog.h>
|
||||
|
||||
setlogmask(LOG_UPTO(LOG_NOTICE));
|
||||
setlogmask (LOG_UPTO (LOG_NOTICE));
|
||||
|
||||
openlog("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
|
||||
openlog ("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
|
||||
|
||||
syslog(LOG_NOTICE, "Program started by User %d", getuid());
|
||||
syslog(LOG_INFO, "A tree falls in a forest");
|
||||
syslog (LOG_NOTICE, "Program started by User %d", getuid ());
|
||||
syslog (LOG_INFO, "A tree falls in a forest");
|
||||
|
||||
closelog();
|
||||
closelog ();
|
||||
|
||||
@end smallexample
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* getsysstats - Determine various system internal values, stub version.
|
||||
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
|
||||
@ -44,7 +44,7 @@ weak_alias (__get_nprocs, get_nprocs)
|
||||
link_warning (get_nprocs, "warning: get_nprocs will always return 1")
|
||||
|
||||
|
||||
int
|
||||
long int
|
||||
__get_phys_pages ()
|
||||
{
|
||||
/* We have no general way to determine this value. */
|
||||
@ -56,7 +56,7 @@ weak_alias (__get_phys_pages, get_phys_pages)
|
||||
stub_warning (get_phys_pages)
|
||||
|
||||
|
||||
int
|
||||
long int
|
||||
__get_avphys_pages ()
|
||||
{
|
||||
/* We have no general way to determine this value. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996, 1997, 1999, 2000, 2001 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
|
||||
@ -17,8 +17,8 @@
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _SYS_SYSINFO_H
|
||||
|
||||
#define _SYS_SYSINFO_H 1
|
||||
|
||||
#include <features.h>
|
||||
|
||||
/* Return number of configured processors. */
|
||||
@ -29,9 +29,9 @@ extern int get_nprocs (void) __THROW;
|
||||
|
||||
|
||||
/* Return number of physical pages of memory in the system. */
|
||||
extern int get_phys_pages (void) __THROW;
|
||||
extern long int get_phys_pages (void) __THROW;
|
||||
|
||||
/* Return number of available physical pages of memory in the system. */
|
||||
extern int get_avphys_pages (void) __THROW;
|
||||
extern long int get_avphys_pages (void) __THROW;
|
||||
|
||||
#endif /* sys/sysinfo.h */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Determine various system internal values, Linux version.
|
||||
Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
|
||||
@ -203,14 +203,14 @@ weak_alias (__get_nprocs_conf, get_nprocs_conf)
|
||||
|
||||
/* General function to get information about memory status from proc
|
||||
filesystem. */
|
||||
static int
|
||||
static long int
|
||||
internal_function
|
||||
phys_pages_info (const char *format)
|
||||
{
|
||||
FILE *fp;
|
||||
char buffer[8192];
|
||||
const char *proc_path;
|
||||
int result = -1;
|
||||
long int result = -1;
|
||||
|
||||
/* Get mount point of proc filesystem. */
|
||||
proc_path = get_proc_path (buffer, sizeof buffer);
|
||||
@ -258,12 +258,12 @@ phys_pages_info (const char *format)
|
||||
|
||||
But not all systems have support for the /proc filesystem. If it
|
||||
is not available we return -1 as an error signal. */
|
||||
int
|
||||
long int
|
||||
__get_phys_pages ()
|
||||
{
|
||||
/* XXX Here will come a test for the new system call. */
|
||||
|
||||
return phys_pages_info ("MemTotal: %d kB");
|
||||
return phys_pages_info ("MemTotal: %ld kB");
|
||||
}
|
||||
weak_alias (__get_phys_pages, get_phys_pages)
|
||||
|
||||
@ -279,12 +279,12 @@ weak_alias (__get_phys_pages, get_phys_pages)
|
||||
|
||||
But not all systems have support for the /proc filesystem. If it
|
||||
is not available we return -1 as an error signal. */
|
||||
int
|
||||
long int
|
||||
__get_avphys_pages ()
|
||||
{
|
||||
/* XXX Here will come a test for the new system call. */
|
||||
|
||||
return phys_pages_info ("MemFree: %d kB");
|
||||
return phys_pages_info ("MemFree: %ld kB");
|
||||
}
|
||||
weak_alias (__get_avphys_pages, get_avphys_pages)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1996, 1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996, 1999, 2001 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
|
||||
@ -17,8 +17,8 @@
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _SYS_SYSINFO_H
|
||||
|
||||
#define _SYS_SYSINFO_H 1
|
||||
|
||||
#include <features.h>
|
||||
|
||||
/* Get sysinfo structure from kernel header. */
|
||||
@ -38,10 +38,10 @@ extern int get_nprocs (void) __THROW;
|
||||
|
||||
|
||||
/* Return number of physical pages of memory in the system. */
|
||||
extern int get_phys_pages (void) __THROW;
|
||||
extern long int get_phys_pages (void) __THROW;
|
||||
|
||||
/* Return number of available physical pages of memory in the system. */
|
||||
extern int get_avphys_pages (void) __THROW;
|
||||
extern long int get_avphys_pages (void) __THROW;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user