stdlib.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* stdlib.h <ndf@linux.mit.edu> */
  2. #include <features.h>
  3. #include <sys/types.h>
  4. #ifndef __STDLIB_H
  5. #define __STDLIB_H
  6. /* Don't overwrite user definitions of NULL */
  7. #ifndef NULL
  8. #define NULL ((void *) 0)
  9. #endif
  10. /* For program termination */
  11. #define EXIT_FAILURE 1
  12. #define EXIT_SUCCESS 0
  13. /* Call all functions registered with `atexit' and `on_exit',
  14. * in the reverse of the order in which they were registered
  15. * perform stdio cleanup, and terminate program execution with STATUS. */
  16. extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
  17. /* Register a function to be called when `exit' is called. */
  18. extern int atexit __P ((void (*__func) (void)));
  19. /* Abort execution and generate a core-dump. */
  20. extern void abort __P ((void)) __attribute__ ((__noreturn__));
  21. extern void * malloc __P ((size_t));
  22. extern void * calloc __P ((size_t, size_t));
  23. extern void free __P ((void *));
  24. extern void * realloc __P ((void *, size_t));
  25. #ifdef DEBUG_MALLOC
  26. extern void * malloc_dbg __P ((size_t, char* func, char* file, int line));
  27. extern void * calloc_dbg __P ((size_t, size_t, char* func, char* file, int line));
  28. extern void free_dbg __P ((void *, char* func, char* file, int line));
  29. extern void * realloc_dbg __P ((void *, size_t, char* func, char* file, int line));
  30. #define malloc(x) malloc_dbg((x),__FUNCTION__,__FILE__,__LINE__)
  31. #define calloc(x,y) calloc_dbg((x),(y),__FUNCTION__,__FILE__,__LINE__)
  32. #define free(x) free_dbg((x),__FUNCTION__,__FILE__,__LINE__)
  33. #define realloc(x) realloc((x),__FUNCTION__,__FILE__,__LINE__)
  34. #endif
  35. extern int rand __P ((void));
  36. extern void srand __P ((unsigned int seed));
  37. extern long strtol __P ((const char * nptr, char ** endptr, int base));
  38. extern unsigned long strtoul __P ((const char * nptr,
  39. char ** endptr, int base));
  40. #ifndef __HAS_NO_FLOATS__
  41. extern float strtod __P ((const char * nptr, char ** endptr));
  42. #endif
  43. extern char *getenv __P ((__const char *__name));
  44. extern int putenv __P ((__const char *__string));
  45. extern int setenv __P ((__const char *__name, __const char *__value,
  46. int __replace));
  47. extern int system __P ((__const char *__command));
  48. extern int qsort __P ((char *base, int num, int size, int (*cmp)()));
  49. extern char * gcvt __P ((float number, size_t ndigit, char * buf));
  50. #define atof(x) strtod((x),(char**)0)
  51. #define atoi(x) (int)strtol((x),(char**)0,10)
  52. #define atol(x) strtol((x),(char**)0,10)
  53. char* itoa(int i);
  54. /* Returned by `div'. */
  55. typedef struct
  56. {
  57. int quot; /* Quotient. */
  58. int rem; /* Remainder. */
  59. } div_t;
  60. /* Returned by `ldiv'. */
  61. typedef struct
  62. {
  63. long int quot; /* Quotient. */
  64. long int rem; /* Remainder. */
  65. } ldiv_t;
  66. #endif /* __STDLIB_H */