Subversion Repositories Kolibri OS

Rev

Rev 7184 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
647 andrew_pro 1
#ifndef stdlib_h
2
#define stdlib_h
3
#include "kolibrisys.h"
4
 
696 andrew_pro 5
#define	RAND_MAX	65535
6433 siemargl 6
#ifndef NULL
7
# define NULL ((void*)0)
8
#endif
696 andrew_pro 9
 
215 victor 10
#define abs(i) (((i)<0)?(-(i)):(i))
6433 siemargl 11
#define labs(li) abs(li)
215 victor 12
 
7184 siemargl 13
#define min(a, b) ((a)<(b) ? (a) : (b))
14
#define max(a, b) ((a)>(b) ? (a) : (b))
15
 
16
 
215 victor 17
extern int atoib(char *s,int b);
18
extern int atoi(char *s);
6443 siemargl 19
extern char *itoab(unsigned int n,char* s,int  b);
20
extern char *__itoa(int n,char* s);
611 andrew_pro 21
 
7520 siemargl 22
// function using KOS syscalls
23
extern void* stdcall sysmalloc(dword size);
24
extern void  stdcall sysfree(void *pointer);
25
extern void* stdcall sysrealloc(void* pointer,dword size);
26
extern void* syscalloc (size_t num, size_t size);
696 andrew_pro 27
 
7520 siemargl 28
// suballocator functions
29
extern void* wtmalloc(size_t size);
30
extern void  wtfree(void *pointer);
31
extern void* wtrealloc(void* pointer, size_t size);
32
extern void* wtcalloc (size_t num, size_t size);
33
extern int   wtmalloc_freelist_check();
34
extern int wtmalloc_poiner_check(void *ptr);
35
 
36
#ifdef USESYSALLOC
37
#define malloc(x) sysmalloc(x)
38
#define free(x)   sysfree(x)
39
#define realloc(x,y) sysrealloc(x,y)
40
#define calloc(x,y) syscalloc(x,y)
41
#else
42
#define malloc(x) wtmalloc(x)
43
#define free(x)   wtfree(x)
44
#define realloc(x,y) wtrealloc(x,y)
45
#define calloc(x,y) wtcalloc(x,y)
46
#endif
47
 
48
 
696 andrew_pro 49
extern int rand (void);
50
extern void srand (unsigned int seed);
51
 
6424 siemargl 52
double strtod (const char* str, char** endptr);
53
long double strtold (const char* str, char** endptr);
54
float strtof (const char* str, char** endptr);
6443 siemargl 55
long int strtol (const char* str, char** endptr, int base);
56
#define strtoul(s, ep, b) ((unsigned long int)strtol(s, ep, b))
6424 siemargl 57
 
58
 
7172 siemargl 59
void exit (int status); /* close console if was initialized, also stay window [finished] when status is error < 0 */
6433 siemargl 60
#define abort() exit(-1)
61
 
62
typedef struct {
63
  int quot;
64
  int rem;
65
} div_t;
66
 
67
typedef div_t ldiv_t;
68
 
69
div_t div (int numer, int denom);
70
#define ldiv(a, b) div(a, b)
71
#define atol(a) atoi(a)
6443 siemargl 72
#define atof(a) strtod(a, NULL)
6433 siemargl 73
 
6443 siemargl 74
 
75
 
6433 siemargl 76
#endif