stdlib.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
  14. extern int atexit __P ((void (*__func) (void)));
  15. extern void * malloc __P ((size_t));
  16. extern void * calloc __P ((size_t, size_t));
  17. extern void free __P ((void *));
  18. extern void * realloc __P ((void *, size_t));
  19. #ifdef DEBUG_MALLOC
  20. extern void * malloc_dbg __P ((size_t, char* func, char* file, int line));
  21. extern void * calloc_dbg __P ((size_t, size_t, char* func, char* file, int line));
  22. extern void free_dbg __P ((void *, char* func, char* file, int line));
  23. extern void * realloc_dbg __P ((void *, size_t, char* func, char* file, int line));
  24. #define malloc(x) malloc_dbg((x),__FUNCTION__,__FILE__,__LINE__)
  25. #define calloc(x,y) calloc_dbg((x),(y),__FUNCTION__,__FILE__,__LINE__)
  26. #define free(x) free_dbg((x),__FUNCTION__,__FILE__,__LINE__)
  27. #define realloc(x) realloc((x),__FUNCTION__,__FILE__,__LINE__)
  28. #endif
  29. extern int rand __P ((void));
  30. extern void srand __P ((unsigned int seed));
  31. extern long strtol __P ((const char * nptr, char ** endptr, int base));
  32. extern unsigned long strtoul __P ((const char * nptr,
  33. char ** endptr, int base));
  34. #ifndef __HAS_NO_FLOATS__
  35. extern float strtod __P ((const char * nptr, char ** endptr));
  36. #endif
  37. extern char *getenv __P ((__const char *__name));
  38. extern int putenv __P ((__const char *__string));
  39. extern int setenv __P ((__const char *__name, __const char *__value,
  40. int __replace));
  41. extern int system __P ((__const char *__command));
  42. extern int qsort __P ((char *base, int num, int size, int (*cmp)()));
  43. extern char * gcvt __P ((float number, size_t ndigit, char * buf));
  44. #define atof(x) strtod((x),(char**)0)
  45. #define atoi(x) (int)strtol((x),(char**)0,10)
  46. #define atol(x) strtol((x),(char**)0,10)
  47. /* Returned by `div'. */
  48. typedef struct
  49. {
  50. int quot; /* Quotient. */
  51. int rem; /* Remainder. */
  52. } div_t;
  53. /* Returned by `ldiv'. */
  54. typedef struct
  55. {
  56. long int quot; /* Quotient. */
  57. long int rem; /* Remainder. */
  58. } ldiv_t;
  59. #endif /* __STDLIB_H */