Back to index

glibc  2.9
getsysstats.c
Go to the documentation of this file.
00001 /* Determine various system internal values, Linux/Sparc version.
00002    Copyright (C) 1999 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Andreas Schwab <schwab@suse.de> and
00005                 Jakub Jelinek <jj@ultra.linux.cz>
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; if not, write to the Free
00019    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020    02111-1307 USA.  */
00021 
00022 
00023 /* We need to define a special parser for /proc/cpuinfo.  */
00024 #define GET_NPROCS_PARSER(FP, BUFFER, RESULT)                           \
00025   do                                                             \
00026     {                                                            \
00027       (RESULT) = 0;                                              \
00028       /* Find the line that contains the information about the number of  \
00029         active cpus.  We don't have to fear extremely long lines since         \
00030         the kernel will not generate them.  8192 bytes are really       \
00031         enough.  */                                              \
00032       while (fgets_unlocked (BUFFER, sizeof (BUFFER), FP) != NULL)      \
00033        if (sscanf (BUFFER, "ncpus active : %d", &(RESULT)) == 1)        \
00034          break;                                                  \
00035     }                                                            \
00036   while (0)
00037 
00038 
00039 /* On the Sparc we can distinguish between the number of configured and
00040    active cpus.  */
00041 #define GET_NPROCS_CONF_PARSER(FP, BUFFER, RESULT)                     \
00042   do                                                            \
00043     {                                                           \
00044       (RESULT) = 0;                                             \
00045       /* Find the line that contains the information about the number of \
00046         probed cpus.  We don't have to fear extremely long lines since        \
00047         the kernel will not generate them.  8192 bytes are really      \
00048         enough.  */                                             \
00049       while (fgets_unlocked ((BUFFER), sizeof (BUFFER), (FP)) != NULL)        \
00050        if (sscanf (buffer, "ncpus probed : %d", &(RESULT)) == 1)       \
00051          break;                                                 \
00052     }                                                           \
00053   while (0)
00054 
00055 #include <sysdeps/unix/sysv/linux/getsysstats.c>