Back to index

glibc  2.9
Defines | Functions | Variables
tst-sysconf.c File Reference
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define N_(name, pos)   { _POSIX_##name, #name, _SC_##name, pos, false }
#define NP(name)   N_ (name, true)
#define N(name)   N_ (name, false)
#define N2(name)   { _POSIX2_##name, #name, _SC_2_##name, false, true }
#define nposix_options   (sizeof (posix_options) / sizeof (posix_options[0]))
#define STDVER   200112L
#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Variables

struct {
long int _P_val
const char * name
int _SC_val
bool positive
bool posix2
posix_options []

Define Documentation

#define N (   name)    N_ (name, false)
#define N2 (   name)    { _POSIX2_##name, #name, _SC_2_##name, false, true }
#define N_ (   name,
  pos 
)    { _POSIX_##name, #name, _SC_##name, pos, false }
#define NP (   name)    N_ (name, true)
#define nposix_options   (sizeof (posix_options) / sizeof (posix_options[0]))

Definition at line 67 of file tst-sysconf.c.

#define STDVER   200112L
#define TEST_FUNCTION   do_test ()

Definition at line 113 of file tst-sysconf.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 70 of file tst-sysconf.c.

{
  int result = 0;

  for (int i = 0; i < nposix_options; ++i)
    {
      long int scret = sysconf (posix_options[i]._SC_val);

      if (scret == 0)
       {
         printf ("sysconf(_SC_%s%s) returned zero\n",
                posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
         result = 1;
       }
      if (posix_options[i]._P_val != 0 && posix_options[i]._P_val != scret)
       {
         printf ("sysconf(_SC_%s%s) = %ld does not match _POSIX%s_%s = %ld\n",
                posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
                scret,
                posix_options[i].posix2 ? "2" : "", posix_options[i].name,
                posix_options[i]._P_val);
         result = 1;
       }
      else if (posix_options[i].positive && scret < 0)
       {
         printf ("sysconf(_SC_%s%s) must be > 0\n",
                posix_options[i].posix2 ? "2_" : "", posix_options[i].name);
         result = 1;
       }

#define STDVER 200112L
      if (scret > 0 && scret != STDVER && !posix_options[i].positive)
       {
         printf ("sysconf(_SC_%s%s) must be %ldL\n",
                posix_options[i].posix2 ? "2_" : "", posix_options[i].name,
                STDVER);
         result = 1;
       }
    }

  return result;
}

Here is the call graph for this function:


Variable Documentation

struct { ... } posix_options[] [static]