Subversion Repositories Kolibri OS

Rev

Rev 9811 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef _STDLIB_H_
  2. #define _STDLIB_H_
  3.  
  4. #include <stddef.h>
  5.  
  6. #define RAND_MAX 65535
  7. #ifndef NULL
  8. #define NULL ((void*)0)
  9. #endif
  10.  
  11. #define min(a, b) ((a) < (b) ? (a) : (b))
  12. #define max(a, b) ((a) > (b) ? (a) : (b))
  13.  
  14. typedef struct {
  15.     int quot;
  16.     int rem;
  17. } div_t;
  18.  
  19. typedef struct {
  20.     long quot;
  21.     long rem;
  22. } ldiv_t;
  23.  
  24. typedef struct {
  25.     long long quot;
  26.     long long rem;
  27. } lldiv_t;
  28.  
  29. static inline div_t div(int num, int den)
  30. {
  31.     return (div_t) { num / den, num % den };
  32. }
  33.  
  34. static inline ldiv_t ldiv(long num, long den)
  35. {
  36.     return (ldiv_t) { num / den, num % den };
  37. }
  38.  
  39. static inline lldiv_t lldiv(long long num, long long den)
  40. {
  41.     return (lldiv_t) { num / den, num % den };
  42. }
  43.  
  44. DLLAPI void* malloc(size_t size);
  45. DLLAPI void* calloc(size_t num, size_t size);
  46. DLLAPI void* realloc(void* ptr, size_t newsize);
  47. DLLAPI void free(void* ptr);
  48.  
  49. DLLAPI long int strtol(const char* str, char** endptr, int base);
  50.  
  51. DLLAPI void exit(int status);
  52.  
  53. DLLAPI void srand(unsigned s);
  54. DLLAPI int rand(void);
  55.  
  56. DLLAPI void __assert_fail(const char* expr, const char* file, int line, const char* func);
  57. DLLAPI void qsort(void* base0, size_t n, size_t size, int (*compar)(const void*, const void*));
  58.  
  59. DLLAPI double strtod(const char* s, char** sret);
  60. DLLAPI double atof(const char* ascii);
  61.  
  62. DLLAPI int atoi(const char* s);
  63. DLLAPI long atol(const char*);
  64. DLLAPI long long atoll(const char*);
  65. DLLAPI void itoa(int n, char* s);
  66.  
  67. DLLAPI int abs(int);
  68. DLLAPI long labs(long);
  69. DLLAPI long long llabs(long long);
  70.  
  71. #endif
  72.