Back to index

glibc  2.9
sysconf.c
Go to the documentation of this file.
00001 /* Copyright (C) 1992, 1995, 1996, 1997, 2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ian Lance Taylor (ian@airs.com).
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /* On Ultrix we can use the getsysinfo call to get the right return
00021    value for _SC_CHILD_MAX.  Everything else is from <sys/param.h>,
00022    which the default sysconf already knows how to handle.  */
00023 
00024 #include <unistd.h>
00025 #include <errno.h>
00026 
00027 /* This is an Ultrix header file.  */
00028 #include <sys/sysinfo.h>
00029 
00030 extern int __getsysinfo (unsigned int op, void *buffer,
00031                       size_t nbytes, int *start, void *arg);
00032 extern long int __default_sysconf (int name);
00033 
00034 long int
00035 __sysconf (name)
00036      int name;
00037 {
00038   if (name == _SC_CHILD_MAX)
00039     {
00040       int save = errno;
00041       int start = 0;
00042       int ret;
00043 
00044       /* getsysinfo returns the number of values it put into the
00045         buffer, or 0 if not available, or -1 on error.  */
00046       if (__getsysinfo (GSI_MAX_UPROCS, &ret, sizeof (ret), &start,
00047                      (void *) 0) > 0)
00048        {
00049          __set_errno (save);
00050          return ret;
00051        }
00052 
00053       __set_errno (save);
00054     }
00055 
00056   return __default_sysconf (name);
00057 }
00058 
00059 #define __sysconf __default_sysconf
00060 
00061 #include <sysdeps/posix/sysconf.c>