wok-current view linld/stuff/src/CRTL.H @ rev 21757
tazboot: spave 40k+ for zImage
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Jun 24 16:31:09 2019 +0200 (2019-06-24) |
parents | 87b6697bb350 |
children | 6e3d30b3031f |
line source
1 // This file is distributed under GPL
2 //
3 // Bare bones of C runtime library
5 #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs))
6 #define FP_SEG(fp) ((unsigned) (void _seg*) (void far*)(fp))
7 #define FP_OFF(fp) ((unsigned) (fp))
8 #define NULL 0
10 const unsigned MIN_STACK = 0x400;
11 const unsigned MAX_MALLOC = 0xF000;
13 const char O_RDONLY = 0; // for open()
14 const char O_BINARY = 0;
16 extern char text_start; extern char text_end;
17 extern char data_start; extern char data_end;
18 extern char bss_start; extern char bss_end;
19 extern char* heap_top;
20 extern char xfer_buf[4096];
22 void parse_cmdline();
23 extern _fastcall void strcatb(const char* a,const char* b);
24 extern _fastcall void strcpy(const char* a,const char* b);
25 extern _fastcall int strdup(const char* a);
26 #ifdef USE_ARGSTR
27 extern _fastcall int argstr(const char *s, const char keywords[], const char **var);
28 extern _fastcall int argnum(char *s, const char keywords[], unsigned long *var);
29 extern _fastcall void set_cmdline(const char *filename);
30 #define strhead(a,b) (strstr(a,b) != (int) (a))
31 #else
32 extern _fastcall int strhead(const char* a,const char* head);
33 #endif
34 extern _fastcall int fileexist(const char* name);
35 //extern "C" int open(const char* name, int flags);
36 extern _fastcall int open(const char* name);
37 extern _fastcall int close(int fd);
38 extern _fastcall int moverm(struct image_himem *m);
39 extern _fastcall int readrm(struct image_himem *m, int sz);
40 extern _fastcall int read(int fd, void* data, int sz);
41 extern _fastcall long lseekcur(int fd, int whence);
42 extern _fastcall int puts(const char* s);
43 extern _fastcall unsigned long strtol(const char *s);
45 // Extensions
46 #define cli() do { asm { cli } } while(0)
47 #define sti() do { asm { sti } } while(0)
48 #define int3() do { asm { db 0cch } } while(0)
49 #define nop() do { asm { db 90h } } while(0)
50 extern char no_exit;
51 extern _fastcall int die(const char* msg);
52 //extern "C" char* malloc_or_die(unsigned size);
53 //extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m);
54 extern _fastcall int malloc_or_die(unsigned size);
55 extern _fastcall int malloc_bufv_or_die(struct image_himem *m);