Back to index

glibc  2.9
sysconf.c
Go to the documentation of this file.
00001 /* Copyright (C) 1993,1995,1996,1997,2002,2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Brendan Kehoe (brendan@zen.org).
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 #include <errno.h>
00021 #include <limits.h>
00022 #include <unistd.h>
00023 #include <stdio.h>
00024 #include <time.h>
00025 #include <sysconfig.h>
00026 
00027 extern int __sysconfig (int);
00028 
00029 /* Get the value of the system variable NAME.  */
00030 long int
00031 __sysconf (name)
00032      int name;
00033 {
00034   switch (name)
00035     {
00036     default:
00037       __set_errno (EINVAL);
00038       return -1;
00039 
00040     case _SC_ARG_MAX:
00041 #ifdef ARG_MAX
00042       return ARG_MAX;
00043 #else
00044       return -1;
00045 #endif
00046 
00047     case _SC_CHILD_MAX:
00048 #ifdef CHILD_MAX
00049       return CHILD_MAX;
00050 #else
00051       return -1;
00052 #endif
00053 
00054     case _SC_CLK_TCK:
00055       return __sysconfig (_CONFIG_CLK_TCK);
00056 
00057     case _SC_NGROUPS_MAX:
00058 #ifdef NGROUPS_MAX
00059       return NGROUPS_MAX;
00060 #else
00061       return -1;
00062 #endif
00063 
00064       /* Both of these are looking for _CONFIG_OPEN_FILES.  */
00065     case _SC_OPEN_MAX:
00066     case _SC_STREAM_MAX:
00067       return __sysconfig (_CONFIG_OPEN_FILES);
00068 
00069     case _SC_TZNAME_MAX:
00070       return __tzname_max ();
00071 
00072     case _SC_JOB_CONTROL:
00073 #ifdef _POSIX_JOB_CONTROL
00074       return 1;
00075 #else
00076       return -1;
00077 #endif
00078 
00079     case _SC_SAVED_IDS:
00080 #ifdef _POSIX_SAVED_IDS
00081       return 1;
00082 #else
00083       return -1;
00084 #endif
00085 
00086     case _SC_REALTIME_SIGNALS:
00087 #ifdef _POSIX_REALTIME_SIGNALS
00088       return 1;
00089 #else
00090       return -1;
00091 #endif
00092 
00093     case _SC_PRIORITY_SCHEDULING:
00094 #ifdef _POSIX_PRIORITY_SCHEDULING
00095       return 1;
00096 #else
00097       return -1;
00098 #endif
00099 
00100     case _SC_TIMERS:
00101 #ifdef _POSIX_TIMERS
00102       return 1;
00103 #else
00104       return -1;
00105 #endif
00106 
00107     case _SC_ASYNCHRONOUS_IO:
00108 #ifdef _POSIX_ASYNCHRONOUS_IO
00109       return 1;
00110 #else
00111       return -1;
00112 #endif
00113 
00114     case _SC_PRIORITIZED_IO:
00115 #ifdef _POSIX_PRIORITIZED_IO
00116       return 1;
00117 #else
00118       return -1;
00119 #endif
00120 
00121     case _SC_SYNCHRONIZED_IO:
00122 #ifdef _POSIX_SYNCHRONIZED_IO
00123       return 1;
00124 #else
00125       return -1;
00126 #endif
00127 
00128     case _SC_FSYNC:
00129 #ifdef _POSIX_FSYNC
00130       return 1;
00131 #else
00132       return -1;
00133 #endif
00134 
00135     case _SC_MAPPED_FILES:
00136 #ifdef _POSIX_MAPPED_FILES
00137       return 1;
00138 #else
00139       return -1;
00140 #endif
00141 
00142     case _SC_MEMLOCK:
00143 #ifdef _POSIX_MEMLOCK
00144       return 1;
00145 #else
00146       return -1;
00147 #endif
00148 
00149     case _SC_MEMLOCK_RANGE:
00150 #ifdef _POSIX_MEMLOCK_RANGE
00151       return 1;
00152 #else
00153       return -1;
00154 #endif
00155 
00156     case _SC_MEMORY_PROTECTION:
00157 #ifdef _POSIX_MEMORY_PROTECTION
00158       return 1;
00159 #else
00160       return -1;
00161 #endif
00162 
00163     case _SC_MESSAGE_PASSING:
00164 #ifdef _POSIX_MESSAGE_PASSING
00165       return 1;
00166 #else
00167       return -1;
00168 #endif
00169 
00170     case _SC_SEMAPHORES:
00171 #ifdef _POSIX_SEMAPHORES
00172       return 1;
00173 #else
00174       return -1;
00175 #endif
00176 
00177     case _SC_SHARED_MEMORY_OBJECTS:
00178 #ifdef _POSIX_SHARED_MEMORY_OBJECTS
00179       return 1;
00180 #else
00181       return -1;
00182 #endif
00183 
00184     case _SC_VERSION:
00185       return _POSIX_VERSION;
00186 
00187     case _SC_PAGESIZE:
00188       return __sysconfig (_CONFIG_PAGESIZE);
00189 
00190     case _SC_AIO_LISTIO_MAX:
00191 #ifdef AIO_LISTIO_MAX
00192       return AIO_LISTIO_MAX;
00193 #else
00194       return -1;
00195 #endif
00196 
00197     case _SC_AIO_MAX:
00198 #ifdef AIO_MAX
00199       return AIO_MAX;
00200 #else
00201       return -1;
00202 #endif
00203 
00204     case _SC_AIO_PRIO_DELTA_MAX:
00205 #ifdef AIO_PRIO_DELTA_MAX
00206       return AIO_PRIO_DELTA_MAX;
00207 #else
00208       return -1;
00209 #endif
00210 
00211     case _SC_DELAYTIMER_MAX:
00212 #ifdef DELAYTIMER_MAX
00213       return DELAYTIMER_MAX;
00214 #else
00215       return -1;
00216 #endif
00217 
00218     case _SC_MQ_OPEN_MAX:
00219 #ifdef MQ_OPEN_MAX
00220       return MQ_OPEN_MAX;
00221 #else
00222       return -1;
00223 #endif
00224 
00225     case _SC_MQ_PRIO_MAX:
00226 #ifdef MQ_PRIO_MAX
00227       return MQ_PRIO_MAX;
00228 #else
00229       return -1;
00230 #endif
00231 
00232     case _SC_RTSIG_MAX:
00233 #ifdef RTSIG_MAX
00234       return RTSIG_MAX;
00235 #else
00236       return -1;
00237 #endif
00238 
00239     case _SC_SEM_NSEMS_MAX:
00240 #ifdef SEM_NSEMS_MAX
00241       return SEM_NSEMS_MAX;
00242 #else
00243       return -1;
00244 #endif
00245 
00246     case _SC_SEM_VALUE_MAX:
00247 #ifdef SEM_VALUE_MAX
00248       return SEM_VALUE_MAX;
00249 #else
00250       return -1;
00251 #endif
00252 
00253     case _SC_SIGQUEUE_MAX:
00254 #ifdef SIGQUEUE_MAX
00255       return SIGQUEUE_MAX;
00256 #else
00257       return -1;
00258 #endif
00259 
00260     case _SC_TIMER_MAX:
00261 #ifdef TIMER_MAX
00262       return TIMER_MAX;
00263 #else
00264       return -1;
00265 #endif
00266 
00267     case _SC_BC_BASE_MAX:
00268 #ifdef BC_BASE_MAX
00269       return BC_BASE_MAX;
00270 #else
00271       return -1;
00272 #endif
00273 
00274     case _SC_BC_DIM_MAX:
00275 #ifdef BC_DIM_MAX
00276       return BC_DIM_MAX;
00277 #else
00278       return -1;
00279 #endif
00280 
00281     case _SC_BC_SCALE_MAX:
00282 #ifdef BC_SCALE_MAX
00283       return BC_SCALE_MAX;
00284 #else
00285       return -1;
00286 #endif
00287 
00288     case _SC_BC_STRING_MAX:
00289 #ifdef BC_STRING_MAX
00290       return BC_STRING_MAX;
00291 #else
00292       return -1;
00293 #endif
00294 
00295     case _SC_EQUIV_CLASS_MAX:
00296 #ifdef EQUIV_CLASS_MAX
00297       return EQUIV_CLASS_MAX;
00298 #else
00299       return -1;
00300 #endif
00301 
00302     case _SC_EXPR_NEST_MAX:
00303 #ifdef EXPR_NEST_MAX
00304       return EXPR_NEST_MAX;
00305 #else
00306       return -1;
00307 #endif
00308 
00309     case _SC_LINE_MAX:
00310 #ifdef LINE_MAX
00311       return LINE_MAX;
00312 #else
00313       return -1;
00314 #endif
00315 
00316     case _SC_RE_DUP_MAX:
00317 #ifdef RE_DUP_MAX
00318       return RE_DUP_MAX;
00319 #else
00320       return -1;
00321 #endif
00322 
00323     case _SC_CHARCLASS_NAME_MAX:
00324 #ifdef CHARCLASS_NAME_MAX
00325       return CHARCLASS_NAME_MAX;
00326 #else
00327       return -1;
00328 #endif
00329 
00330     case _SC_2_VERSION:
00331       /* This is actually supposed to return the version
00332         of the 1003.2 utilities on the system {POSIX2_VERSION}.  */
00333       return _POSIX2_C_VERSION;
00334 
00335     case _SC_2_C_BIND:
00336 #ifdef _POSIX2_C_BIND
00337       return _POSIX2_C_BIND;
00338 #else
00339       return -1;
00340 #endif
00341 
00342     case _SC_2_C_DEV:
00343 #ifdef _POSIX2_C_DEV
00344       return _POSIX2_C_DEV;
00345 #else
00346       return -1;
00347 #endif
00348 
00349     case _SC_2_FORT_DEV:
00350 #ifdef _POSIX2_FORT_DEV
00351       return _POSIX2_FORT_DEV;
00352 #else
00353       return -1;
00354 #endif
00355 
00356     case _SC_2_SW_DEV:
00357 #ifdef _POSIX2_SW_DEV
00358       return _POSIX2_SW_DEV;
00359 #else
00360       return -1;
00361 #endif
00362     }
00363 }
00364 
00365 weak_alias (__sysconf, sysconf)
00366 libc_hidden_def (__sysconf)