rev |
line source |
pascal@19515
|
1 // This file is distributed under GPL
|
pascal@19515
|
2 //
|
pascal@19515
|
3 // Bare bones of C runtime library
|
pascal@19515
|
4
|
pascal@19515
|
5 #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs))
|
pascal@19515
|
6 #define FP_SEG(fp) ((unsigned) (void _seg*) (void far*)(fp))
|
pascal@19515
|
7 #define FP_OFF(fp) ((unsigned) (fp))
|
pascal@19515
|
8
|
pascal@19515
|
9 const unsigned MIN_STACK = 0x400;
|
pascal@19515
|
10 const unsigned MAX_MALLOC = 0xF000;
|
pascal@19515
|
11
|
pascal@19538
|
12 const A_RDONLY = 1; // for fileattr()
|
pascal@19538
|
13 const A_HIDDEN = 2;
|
pascal@19538
|
14 const A_SYSTEM = 4;
|
pascal@19538
|
15 const A_LABEL = 8;
|
pascal@19538
|
16 const A_DIRECTORY = 16;
|
pascal@19538
|
17 const A_ARCHIVE = 32;
|
pascal@19538
|
18
|
pascal@19538
|
19
|
pascal@19515
|
20 const O_RDONLY = 0; // for open()
|
pascal@19515
|
21 const O_BINARY = 0;
|
pascal@19515
|
22
|
pascal@19515
|
23 extern char text_start; extern char text_end;
|
pascal@19515
|
24 extern char data_start; extern char data_end;
|
pascal@19515
|
25 extern char bss_start; extern char bss_end;
|
pascal@19515
|
26 extern char* heap_top;
|
pascal@19515
|
27
|
pascal@19515
|
28 extern int ximage_size, ximage_fd;
|
pascal@19515
|
29
|
pascal@19515
|
30 void parse_cmdline();
|
pascal@19538
|
31 extern "C" char* strcpy(const char* a,const char* b);
|
pascal@19538
|
32 extern "C" char* strcat(const char* a,const char* b);
|
pascal@19538
|
33 extern "C" char* strcatb(const char* a,const char* b);
|
pascal@19515
|
34 extern "C" int strhead(const char* a,const char* b);
|
pascal@19538
|
35 extern "C" int fileattr(const char* name);
|
pascal@19546
|
36 //extern "C" int open(const char* name, int flags);
|
pascal@19546
|
37 extern "C" int open(const char* name);
|
pascal@19515
|
38 extern "C" int close(int fd);
|
pascal@19515
|
39 extern "C" void exit(int n);
|
pascal@19515
|
40 extern "C" void abort();
|
pascal@19515
|
41 extern "C" int read(int fd, void* data, int sz);
|
pascal@19515
|
42 extern "C" int write(int fd, const void* data, int sz);
|
pascal@19571
|
43 extern "C" long lseekset(int fd, long sz);
|
pascal@19515
|
44 extern "C" void* malloc(unsigned sz);
|
pascal@19515
|
45 extern "C" void puts(const char* s);
|
pascal@19515
|
46 extern "C" void putsz(const char* s);
|
pascal@19515
|
47 extern "C" unsigned long strtol(const char *s);
|
pascal@19515
|
48
|
pascal@19515
|
49 // Extensions
|
pascal@19515
|
50 //static void barrier() {}
|
pascal@19515
|
51 //static void cli() { asm { cli } }
|
pascal@19515
|
52 //static void sti() { asm { sti } }
|
pascal@19515
|
53 #define barrier() do {} while(0)
|
pascal@19515
|
54 #define cli() do { asm { cli } } while(0)
|
pascal@19515
|
55 #define sti() do { asm { sti } } while(0)
|
pascal@19515
|
56 #define int3() do { asm { db 0cch } } while(0)
|
pascal@19515
|
57 #define nop() do { asm { db 90h } } while(0)
|
pascal@19515
|
58 extern char no_exit;
|
pascal@19515
|
59 extern "C" int die(const char* msg);
|
pascal@19515
|
60 extern "C" char* malloc_or_die(unsigned size);
|
pascal@19538
|
61 extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m);
|