setos

拙OS
Log | Files | Refs | LICENSE

libc.h (1154B)


      1 #define NULL 0L
      2 
      3 typedef unsigned char          uint8;
      4 typedef unsigned short int     uint16;
      5 typedef unsigned int           uint32;
      6 typedef unsigned long long int uint64;
      7 typedef long long int          int64;
      8 typedef unsigned long long int uintptr;
      9 
     10 typedef struct {
     11 	char ename[1024];
     12 } error;
     13 
     14 extern error err;
     15 
     16 // Strcpy copies null terminated string s2 to s1 and returns s1.
     17 // Caller should allocate enough memory at s1.
     18 char *strcpy(char *s1, char *s2);
     19 
     20 typedef struct Memblock {
     21 	void *start, *end;
     22 } Memblock;
     23 
     24 typedef struct Memmap {
     25 	Memblock *freespace;
     26 	int      nfreespace;
     27 	Memblock *allocated;
     28 	int      nallocated;
     29 } Memmap;
     30 
     31 extern Memmap memmap;
     32 
     33 void *malloc(uintptr);
     34 void *memset(void *s, int c, uintptr n);
     35 
     36 /*
     37 typedef char *va_list;
     38 // ABI is different from plan9.
     39 #define va_start(list, start) list = (char *)((int64 *)&(start)+1)
     40 // list += 8 on a 64-bit machine.
     41 #define va_arg(list, mode) \
     42 	((sizeof(mode) == 1) ? ((list += 8), (mode *) list)[-8]:\
     43 	(sizeof(mode) == 2) ? ((list += 8), (mode *) list)[-4]:\
     44 	(sizeof(mode) == 4) ? ((list += 8), (mode *) list)[-2]:\
     45 	((list += 8), (mode *) list)[-1])
     46 #define va_end(list)
     47 */