stdlib.h 2.1 KB

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