Subversion Repositories Kolibri OS

Rev

Rev 7520 | 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();
7537 siemargl 34
extern int   wtmalloc_poiner_check(void *ptr);
35
extern void  wtmalloc_freelist_print();
7520 siemargl 36
 
37
#ifdef USESYSALLOC
38
#define malloc(x) sysmalloc(x)
39
#define free(x)   sysfree(x)
40
#define realloc(x,y) sysrealloc(x,y)
41
#define calloc(x,y) syscalloc(x,y)
42
#else
43
#define malloc(x) wtmalloc(x)
44
#define free(x)   wtfree(x)
45
#define realloc(x,y) wtrealloc(x,y)
46
#define calloc(x,y) wtcalloc(x,y)
47
#endif
48
 
49
 
696 andrew_pro 50
extern int rand (void);
51
extern void srand (unsigned int seed);
52
 
6424 siemargl 53
double strtod (const char* str, char** endptr);
54
long double strtold (const char* str, char** endptr);
55
float strtof (const char* str, char** endptr);
6443 siemargl 56
long int strtol (const char* str, char** endptr, int base);
57
#define strtoul(s, ep, b) ((unsigned long int)strtol(s, ep, b))
6424 siemargl 58
 
59
 
7172 siemargl 60
void exit (int status); /* close console if was initialized, also stay window [finished] when status is error < 0 */
6433 siemargl 61
#define abort() exit(-1)
62
 
63
typedef struct {
64
  int quot;
65
  int rem;
66
} div_t;
67
 
68
typedef div_t ldiv_t;
69
 
70
div_t div (int numer, int denom);
71
#define ldiv(a, b) div(a, b)
72
#define atol(a) atoi(a)
6443 siemargl 73
#define atof(a) strtod(a, NULL)
6433 siemargl 74
 
6443 siemargl 75
 
76
 
6433 siemargl 77
#endif