Back to index

glibc  2.9
Classes | Defines | Typedefs | Functions | Variables
stdlib.h File Reference
#include <features.h>
#include <stddef.h>

Go to the source code of this file.

Classes

struct  div_t
struct  ldiv_t

Defines

#define __need_size_t
#define __need_wchar_t
#define __need_NULL
#define _STDLIB_H   1
#define __ldiv_t_defined   1
#define RAND_MAX   2147483647
#define EXIT_FAILURE   1 /* Failing exit status. */
#define EXIT_SUCCESS   0 /* Successful exit status. */
#define MB_CUR_MAX   (__ctype_get_mb_cur_max ())
#define __malloc_and_calloc_defined
#define __COMPAR_FN_T

Typedefs

typedef int(* __compar_fn_t )(__const void *, __const void *)

Functions

size_t __ctype_get_mb_cur_max (void) __THROW __wur
__BEGIN_NAMESPACE_STD double atof (__const char *__nptr) __THROW __attribute_pure__ __nonnull((1)) __wur
int atoi (__const char *__nptr) __THROW __attribute_pure__ __nonnull((1)) __wur
long int atol (__const char *__nptr) __THROW __attribute_pure__ __nonnull((1)) __wur
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD double 
strtod (__const char *__restrict __nptr, char **__restrict __endptr) __THROW __nonnull((1)) __wur
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD long int 
strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW __nonnull((1)) __wur
unsigned long int strtoul (__const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW __nonnull((1)) __wur
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD int 
rand (void) __THROW
void srand (unsigned int __seed) __THROW
__BEGIN_NAMESPACE_STD void * malloc (size_t __size) __THROW __attribute_malloc__ __wur
void * calloc (size_t __nmemb, size_t __size) __THROW __attribute_malloc__ __wur
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD void * 
realloc (void *__ptr, size_t __size) __THROW __attribute_warn_unused_result__
void free (void *__ptr) __THROW
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD void 
abort (void) __THROW __attribute__((__noreturn__))
int atexit (void(*__func)(void)) __THROW __nonnull((1))
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD void 
exit (int __status) __THROW __attribute__((__noreturn__))
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD char * 
getenv (__const char *__name) __THROW __nonnull((1)) __wur
__END_NAMESPACE_STD char * __secure_getenv (__const char *__name) __THROW __nonnull((1)) __wur
__BEGIN_NAMESPACE_STD int system (__const char *__command) __wur
__BEGIN_NAMESPACE_STD void * bsearch (__const void *__key, __const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1
void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1
void int abs (int __x) __THROW __attribute__((__const__)) __wur
long int labs (long int __x) __THROW __attribute__((__const__)) __wur
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD div_t 
div (int __numer, int __denom) __THROW __attribute__((__const__)) __wur
ldiv_t ldiv (long int __numer, long int __denom) __THROW __attribute__((__const__)) __wur
__END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD int 
mblen (__const char *__s, size_t __n) __THROW __wur
int mbtowc (wchar_t *__restrict __pwc, __const char *__restrict __s, size_t __n) __THROW __wur
int wctomb (char *__s, wchar_t __wchar) __THROW __wur
size_t mbstowcs (wchar_t *__restrict __pwcs, __const char *__restrict __s, size_t __n) __THROW
size_t wcstombs (char *__restrict __s, __const wchar_t *__restrict __pwcs, size_t __n) __THROW

Variables

__BEGIN_NAMESPACE_STD void __wur

Class Documentation

struct div_t

Definition at line 98 of file stdlib.h.

Class Members
int quot
int rem
struct ldiv_t

Definition at line 106 of file stdlib.h.

Class Members
long int quot
long int rem

Define Documentation

#define __COMPAR_FN_T

Definition at line 669 of file stdlib.h.

#define __ldiv_t_defined   1

Definition at line 111 of file stdlib.h.

Definition at line 468 of file stdlib.h.

#define __need_NULL

Definition at line 31 of file stdlib.h.

#define __need_size_t

Definition at line 28 of file stdlib.h.

#define __need_wchar_t

Definition at line 30 of file stdlib.h.

#define _STDLIB_H   1

Definition at line 38 of file stdlib.h.

#define EXIT_FAILURE   1 /* Failing exit status. */

Definition at line 134 of file stdlib.h.

#define EXIT_SUCCESS   0 /* Successful exit status. */

Definition at line 135 of file stdlib.h.

Definition at line 139 of file stdlib.h.

#define RAND_MAX   2147483647

Definition at line 129 of file stdlib.h.


Typedef Documentation

typedef int(* __compar_fn_t)(__const void *, __const void *)

Definition at line 670 of file stdlib.h.


Function Documentation

Definition at line 45 of file broken_cur_max.c.

{
  union locale_data_value u;

  u.string = nl_langinfo (_NL_CTYPE_MB_CUR_MAX);
  return ((size_t []) { 1, 1, 1, 2, 2, 3, 4 })[u.word];
}

Here is the call graph for this function:

__END_NAMESPACE_STD char* __secure_getenv ( __const char *  __name)

Definition at line 37 of file dl-machine.c.

{
  _exit (127);
}

Here is the call graph for this function:

void int abs ( int  __x) const

Definition at line 25 of file abs.c.

{
  return i < 0 ? -i : i;
}

Here is the caller graph for this function:

int atexit ( void(*)(void)  __func)

Definition at line 49 of file atexit.c.

{
  return __cxa_atexit ((void (*) (void *)) func, NULL,
                     &__dso_handle == NULL ? NULL : __dso_handle);
}

Here is the caller graph for this function:

__BEGIN_NAMESPACE_STD double atof ( __const char *  __nptr)
int atoi ( __const char *  __nptr)
long int atol ( __const char *  __nptr)
__BEGIN_NAMESPACE_STD void* bsearch ( __const void *  __key,
__const void *  __base,
size_t  __nmemb,
size_t  __size,
__compar_fn_t  __compar 
)
void* calloc ( size_t  __nmemb,
size_t  __size 
)

Definition at line 113 of file dl-minimal.c.

{
  /* New memory from the trivial malloc above is always already cleared.
     (We make sure that's true in the rare occasion it might not be,
     by clearing memory in free, below.)  */
  size_t bytes = nmemb * size;

#define HALF_SIZE_T (((size_t) 1) << (8 * sizeof (size_t) / 2))
  if (__builtin_expect ((nmemb | size) >= HALF_SIZE_T, 0)
      && size != 0 && bytes / size != nmemb)
    return NULL;

  return malloc (bytes);
}

Here is the call graph for this function:

__END_NAMESPACE_STD __BEGIN_NAMESPACE_STD div_t div ( int  __numer,
int  __denom 
) const

Definition at line 55 of file div.c.

{
  div_t result;

  result.quot = numer / denom;
  result.rem = numer % denom;

  /* The ANSI standard says that |QUOT| <= |NUMER / DENOM|, where
     NUMER / DENOM is to be computed in infinite precision.  In
     other words, we should always truncate the quotient towards
     zero, never -infinity.  Machine division and remainer may
     work either way when one or both of NUMER or DENOM is
     negative.  If only one is negative and QUOT has been
     truncated towards -infinity, REM will have the same sign as
     DENOM and the opposite sign of NUMER; if both are negative
     and QUOT has been truncated towards -infinity, REM will be
     positive (will have the opposite sign of NUMER).  These are
     considered `wrong'.  If both are NUM and DENOM are positive,
     RESULT will always be positive.  This all boils down to: if
     NUMER >= 0, but REM < 0, we got the wrong answer.  In that
     case, to get the right answer, add 1 to QUOT and subtract
     DENOM from REM.  */

  if (numer >= 0 && result.rem < 0)
    {
      ++result.quot;
      result.rem -= denom;
    }

  return result;
}

Here is the caller graph for this function:

Definition at line 33 of file exit.c.

{
  /* We do it this way to handle recursive calls to exit () made by
     the functions registered with `atexit' and `on_exit'. We call
     everyone on the list and use the status value in the last
     exit (). */
  while (__exit_funcs != NULL)
    {
      struct exit_function_list *old;

      while (__exit_funcs->idx > 0)
       {
         const struct exit_function *const f =
           &__exit_funcs->fns[--__exit_funcs->idx];
         switch (f->flavor)
           {
             void (*atfct) (void);
             void (*onfct) (int status, void *arg);
             void (*cxafct) (void *arg, int status);

           case ef_free:
           case ef_us:
             break;
           case ef_on:
             onfct = f->func.on.fn;
#ifdef PTR_DEMANGLE
             PTR_DEMANGLE (onfct);
#endif
             onfct (status, f->func.on.arg);
             break;
           case ef_at:
             atfct = f->func.at;
#ifdef PTR_DEMANGLE
             PTR_DEMANGLE (atfct);
#endif
             atfct ();
             break;
           case ef_cxa:
             cxafct = f->func.cxa.fn;
#ifdef PTR_DEMANGLE
             PTR_DEMANGLE (cxafct);
#endif
             cxafct (f->func.cxa.arg, status);
             break;
           }
       }

      old = __exit_funcs;
      __exit_funcs = __exit_funcs->next;
      if (__exit_funcs != NULL)
       /* Don't free the last element in the chain, this is the statically
          allocate element.  */
       free (old);
    }

  RUN_HOOK (__libc_atexit, ());

  _exit (status);
}
void free ( void *  __ptr)

Definition at line 130 of file dl-minimal.c.

{
  /* We can free only the last block allocated.  */
  if (ptr == alloc_last_block)
    {
      /* Since this is rare, we clear the freed block here
        so that calloc can presume malloc returns cleared memory.  */
      memset (alloc_last_block, '\0', alloc_ptr - alloc_last_block);
      alloc_ptr = alloc_last_block;
    }
}

Here is the call graph for this function:

long int labs ( long int  __x) const

Definition at line 26 of file labs.c.

{
  return i < 0 ? -i : i;
}
ldiv_t ldiv ( long int  __numer,
long int  __denom 
) const

Definition at line 24 of file ldiv.c.

{
  ldiv_t result;

  result.quot = numer / denom;
  result.rem = numer % denom;

  /* The ANSI standard says that |QUOT| <= |NUMER / DENOM|, where
     NUMER / DENOM is to be computed in infinite precision.  In
     other words, we should always truncate the quotient towards
     zero, never -infinity.  Machine division and remainer may
     work either way when one or both of NUMER or DENOM is
     negative.  If only one is negative and QUOT has been
     truncated towards -infinity, REM will have the same sign as
     DENOM and the opposite sign of NUMER; if both are negative
     and QUOT has been truncated towards -infinity, REM will be
     positive (will have the opposite sign of NUMER).  These are
     considered `wrong'.  If both are NUM and DENOM are positive,
     RESULT will always be positive.  This all boils down to: if
     NUMER >= 0, but REM < 0, we got the wrong answer.  In that
     case, to get the right answer, add 1 to QUOT and subtract
     DENOM from REM.  */

  if (numer >= 0 && result.rem < 0)
    {
      ++result.quot;
      result.rem -= denom;
    }

  return result;
}
__BEGIN_NAMESPACE_STD void* malloc ( size_t  __size)

Definition at line 104 of file dl-minimal.c.

{
  return __libc_memalign (sizeof (double), n);
}

Here is the call graph for this function:

size_t mbstowcs ( wchar_t *__restrict  __pwcs,
__const char *__restrict  __s,
size_t  __n 
)
int mbtowc ( wchar_t *__restrict  __pwc,
__const char *__restrict  __s,
size_t  __n 
)
void qsort ( void *  __base,
size_t  __nmemb,
size_t  __size,
__compar_fn_t  __compar 
)

Here is the caller graph for this function:

Definition at line 26 of file rand.c.

{
  return (int) __random ();
}

Here is the caller graph for this function:

__END_NAMESPACE_STD __BEGIN_NAMESPACE_STD void* realloc ( void *  __ptr,
size_t  __size 
)

Definition at line 144 of file dl-minimal.c.

{
  if (ptr == NULL)
    return malloc (n);
  assert (ptr == alloc_last_block);
  size_t old_size = alloc_ptr - alloc_last_block;
  alloc_ptr = alloc_last_block;
  void *new = malloc (n);
  return new != ptr ? memcpy (new, ptr, old_size) : new;
}

Here is the call graph for this function:

void srand ( unsigned int  __seed)

Here is the caller graph for this function:

__END_NAMESPACE_STD __BEGIN_NAMESPACE_STD double strtod ( __const char *__restrict  __nptr,
char **__restrict  __endptr 
)

Here is the caller graph for this function:

__END_NAMESPACE_STD __BEGIN_NAMESPACE_STD long int strtol ( __const char *__restrict  __nptr,
char **__restrict  __endptr,
int  __base 
)

Here is the caller graph for this function:

unsigned long int strtoul ( __const char *__restrict  __nptr,
char **__restrict  __endptr,
int  __base 
)
__BEGIN_NAMESPACE_STD int system ( __const char *  __command)
size_t wcstombs ( char *__restrict  __s,
__const wchar_t *__restrict  __pwcs,
size_t  __n 
)

Here is the caller graph for this function:

int wctomb ( char *  __s,
wchar_t  __wchar 
)

Definition at line 38 of file wctomb.c.

{
  /* If S is NULL the function has to return null or not null
     depending on the encoding having a state depending encoding or
     not.  */
  if (s == NULL)
    {
      const struct gconv_fcts *fcts;

      /* Get the conversion functions.  */
      fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));

      /* This is an extension in the Unix standard which does not directly
        violate ISO C.  */
      memset (&__wctomb_state, '\0', sizeof __wctomb_state);

      return fcts->tomb->__stateful;
    }

  return __wcrtomb (s, wchar, &__wctomb_state);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 685 of file stdlib.h.