Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7540 leency 1
#ifndef stdlib_h
2
#define stdlib_h
3
#include "kolibrisys.h"
4
 
5
#define	RAND_MAX	65535
6
#ifndef NULL
7
# define NULL ((void*)0)
8
#endif
9
 
10
#define abs(i) (((i)<0)?(-(i)):(i))
11
#define labs(li) abs(li)
12
 
13
#define min(a, b) ((a)<(b) ? (a) : (b))
14
#define max(a, b) ((a)>(b) ? (a) : (b))
15
 
16
 
17
extern int atoib(char *s,int b);
18
extern int atoi(char *s);
19
extern char *itoab(unsigned int n,char* s,int  b);
20
extern char *__itoa(int n,char* s);
21
 
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);
27
 
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
extern void  wtmalloc_freelist_print();
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
 
50
extern int rand (void);
51
extern void srand (unsigned int seed);
52
 
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);
56
long int strtol (const char* str, char** endptr, int base);
57
#define strtoul(s, ep, b) ((unsigned long int)strtol(s, ep, b))
58
 
59
 
60
void exit (int status); /* close console if was initialized, also stay window [finished] when status is error < 0 */
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)
73
#define atof(a) strtod(a, NULL)
74
 
75
 
76
 
77
#endif