Back to index

glibc  2.9
Defines | Functions | Variables
tst-typesizes.c File Reference
#include <stdio.h>
#include <pthreadP.h>
#include <semaphore.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define T(t, c)   { #t, c, sizeof (t) }
#define TEST_TYPE(name)
#define TEST_TYPE2(name, internal)
#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Variables

struct {
const char * name
size_t expected
size_t is
types []

Define Documentation

#define T (   t,
  c 
)    { #t, c, sizeof (t) }
#define TEST_FUNCTION   do_test ()

Definition at line 95 of file tst-typesizes.c.

#define TEST_TYPE (   name)
Value:
printf ("%s: ", #name);                                              \
  if (sizeof (name) != sizeof (((name *) 0)->__size))                       \
    {                                                                \
      printf ("expected %zu, is %zu\n",                                     \
             sizeof (((name *) 0)->__size), sizeof (name));                 \
      result = 1;                                                    \
    }                                                                \
  else									      \
    puts ("OK")
#define TEST_TYPE2 (   name,
  internal 
)
Value:
printf ("%s: ", #name);                                              \
  if (sizeof (((name *) 0)->__size) < sizeof (internal))                    \
    {                                                                \
      printf ("expected %zu, is %zu\n",                                     \
             sizeof (((name *) 0)->__size), sizeof (internal));             \
      result = 1;                                                    \
    }                                                                \
  else									      \
    puts ("OK")

Function Documentation

static int do_test ( void  ) [static]

Definition at line 45 of file tst-typesizes.c.

{
  int result = 0;

#define TEST_TYPE(name) \
  printf ("%s: ", #name);                                            \
  if (sizeof (name) != sizeof (((name *) 0)->__size))                       \
    {                                                                \
      printf ("expected %zu, is %zu\n",                                     \
             sizeof (((name *) 0)->__size), sizeof (name));                 \
      result = 1;                                                    \
    }                                                                \
  else                                                               \
    puts ("OK")

  TEST_TYPE (pthread_mutex_t);
  TEST_TYPE (pthread_cond_t);
  TEST_TYPE (pthread_rwlock_t);

#define TEST_TYPE2(name, internal)                                   \
  printf ("%s: ", #name);                                            \
  if (sizeof (((name *) 0)->__size) < sizeof (internal))                    \
    {                                                                \
      printf ("expected %zu, is %zu\n",                                     \
             sizeof (((name *) 0)->__size), sizeof (internal));             \
      result = 1;                                                    \
    }                                                                \
  else                                                               \
    puts ("OK")

  TEST_TYPE2 (pthread_attr_t, struct pthread_attr);
  TEST_TYPE2 (pthread_mutexattr_t, struct pthread_mutexattr);
  TEST_TYPE2 (pthread_condattr_t, struct pthread_condattr);
  TEST_TYPE2 (pthread_rwlockattr_t, struct pthread_rwlockattr);
  TEST_TYPE2 (pthread_barrier_t, struct pthread_barrier);
  TEST_TYPE2 (pthread_barrierattr_t, struct pthread_barrierattr);
  TEST_TYPE2 (sem_t, struct new_sem);
  TEST_TYPE2 (sem_t, struct old_sem);

  for (size_t i = 0; i < sizeof (types) / sizeof (types[0]); ++i)
    if (types[i].expected != types[i].is)
      {
       printf ("%s: expected %zu, is %zu\n",
              types[i].name, types[i].expected, types[i].is);
       result = 1;
      }

  return result;
}

Here is the call graph for this function:


Variable Documentation

struct { ... } types[] [static]