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.
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>.
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.
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
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
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 */
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
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.
@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
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
@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
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
@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
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
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.
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:
@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
@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
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
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
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.
@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
@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.
@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.
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
@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
-
-
-
/* 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.
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. */
stub_warning (get_phys_pages)
-int
+long int
__get_avphys_pages ()
{
/* We have no general way to determine this value. */
-/* 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
Boston, MA 02111-1307, USA. */
#ifndef _SYS_SYSINFO_H
-
#define _SYS_SYSINFO_H 1
+
#include <features.h>
/* Return number of configured processors. */
/* 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 */
/* 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.
/* 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);
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)
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)
-/* 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
Boston, MA 02111-1307, USA. */
#ifndef _SYS_SYSINFO_H
-
#define _SYS_SYSINFO_H 1
+
#include <features.h>
/* Get sysinfo structure from kernel header. */
/* 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