- Timestamp:
- 10/14/08 19:40:04 (1 month ago)
- Location:
- Whitix/branches/keobject/user/libc
- Files:
-
- 10 modified
-
include/stdarg.h (modified) (1 diff)
-
include/stdint.h (modified) (1 diff)
-
include/stdlib.h (modified) (1 diff)
-
include/syscalls.h (modified) (2 diffs)
-
include/sysdefs.h (modified) (1 diff)
-
stdio/get.c (modified) (1 diff)
-
stdlib/Makefile (modified) (1 diff)
-
stdlib/env.c (modified) (2 diffs)
-
stdlib/exit.c (modified) (2 diffs)
-
string/str.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/keobject/user/libc/include/stdarg.h
r608 r1136 2 2 #define STDC_STDARG_H 3 3 4 typedef unsigned char*va_list;4 typedef __builtin_va_list va_list; 5 5 6 6 /* Just get the memory location after the last argument */ 7 7 #define va_start(list,lastArg) \ 8 (list=((va_list)&(lastArg)+va_size(lastArg)));8 __builtin_va_start(list, lastArg) 9 9 10 10 /* Must be the other way round because of the comma operator */ 11 11 #define va_arg(list,type) \ 12 (list+=__va_rounded_size(type), \ 13 *((type*)(list-__va_rounded_size(type)))) 12 __builtin_va_arg(list, type) 14 13 15 /* Stacks are int-aligned */ 16 #define __va_rounded_size(type) \ 17 (((sizeof(type)+sizeof(int)-1)/sizeof(int))*sizeof(int)) 18 19 #define va_size(type) \ 20 ((sizeof(type)+sizeof(int)-1) \ 21 & ~(sizeof(int)-1)) 22 23 #define va_copy(dst,src) ((void)((dst)=(src))) 14 #define va_copy(dst,src) __builtin_va_copy(dst, src) 24 15 25 16 /* Just for a certain cleanliness */ 26 #define va_end(list) 17 #define va_end(list) __builtin_va_end(list) 27 18 28 19 #endif -
Whitix/branches/keobject/user/libc/include/stdint.h
r608 r1136 3 3 4 4 typedef long int intmax_t; 5 typedef unsigned long long uintmax_t; 5 6 6 7 #include <inttypes.h> -
Whitix/branches/keobject/user/libc/include/stdlib.h
r910 r1136 75 75 typedef long int int_fast32_t; 76 76 77 #define alloca(size) __builtin_alloca(size) 78 77 79 #endif -
Whitix/branches/keobject/user/libc/include/syscalls.h
r912 r1136 12 12 #endif 13 13 14 #ifndef BYTE15 typedef unsigned char BYTE;16 #endif17 18 14 /* Some useful structures for syscalls */ 19 15 20 16 struct DirEntry 21 17 { 22 DWORD vNodeNum; 23 DWORD offset; 24 WORD length; 18 unsigned long vNodeNum; 19 unsigned long offset; 20 unsigned short length; 21 unsigned short type; 25 22 char name[1]; 26 23 }; … … 33 30 struct Stat 34 31 { 35 DWORDsize;36 DWORDvNum;37 DWORDmode;32 unsigned long size; 33 unsigned long vNum; 34 unsigned long mode; 38 35 unsigned long aTime,cTime,mTime; 39 36 }; -
Whitix/branches/keobject/user/libc/include/sysdefs.h
r912 r1136 16 16 SYSCALL(14,int,SysChangeDir,4,(char* newDir)); 17 17 SYSCALL(15,int,SysChangeRoot,4,(char* newRoot)); 18 SYSCALL(16,int,SysMount,16,(char* mountPoint,char* deviceName,char* fsName,void* data));18 SYSCALL(16,int,SysMount,16,(char* deviceName,char* mountName,char* fsName,void* data)); 19 19 SYSCALL(17,int,SysUnmount,4,(char* mountPoint)); 20 20 SYSCALL(18,int,SysGetDirEntries,12,(int fd,void* entries,unsigned long numBytes)); -
Whitix/branches/keobject/user/libc/stdio/get.c
r910 r1136 94 94 }else{ 95 95 printf("ungetc: TODO\n"); 96 exit(0); 96 97 } 97 98 -
Whitix/branches/keobject/user/libc/stdlib/Makefile
r684 r1136 1 1 include ../make.inc 2 2 3 OBJS = alloca.omem.o exit.o atoi.o div.o math.o system.o qsort.o env.o time.o rand.o bsearch.o3 OBJS = mem.o exit.o atoi.o div.o math.o system.o qsort.o env.o time.o rand.o bsearch.o 4 4 5 5 build: $(OBJS) -
Whitix/branches/keobject/user/libc/stdlib/env.c
r910 r1136 9 9 return NULL; 10 10 11 printf("getenv(%s)\n", name); 11 // if (!strcmp(name, "LDEMULATION")) 12 // return "elf_i386"; 13 14 // printf("getenv(%s)\n", name); 12 15 return NULL; 13 16 } … … 15 18 int putenv(const char* name) 16 19 { 17 printf("putenv(%s)\n", name);20 // printf("putenv(%s)\n", name); 18 21 return 0; 19 22 } -
Whitix/branches/keobject/user/libc/stdlib/exit.c
r910 r1136 6 6 { 7 7 printf("Abnormal program termination from %#X\n",__builtin_return_address(0)); 8 9 /* FIXME: TEMP */ 10 DWORD* esp; 11 12 asm volatile("mov %%esp, %%eax" : "=a"(esp)); 13 14 int i; 15 16 for (i=0; i<10; i++) 17 { 18 printf("%#X\n", *esp++); 19 } 20 8 21 SysExit(1); 9 22 } … … 16 29 int atexit(void (*function)()) 17 30 { 31 printf("atexit(%#X)\n", function); 18 32 return 0; 19 33 } -
Whitix/branches/keobject/user/libc/string/str.c
r910 r1136 74 74 int strncmp(const char* s1,const char* s2,size_t num) 75 75 { 76 char result=0; 77 78 while (num) 79 { 80 if ((result=*s1-*s2++) || !*s1++) 81 break; 82 83 --num; 84 } 85 86 return result; 76 unsigned char c1, c2; 77 78 while (num-- > 0) 79 { 80 c1 = (unsigned char)*s1++; 81 c2 = (unsigned char)*s2++; 82 83 if (c1 != c2) 84 return c1-c2; 85 86 if (c1 == '\0') 87 return 0; 88 } 89 90 return 0; 87 91 } 88 92 … … 261 265 void perror(const char* string) 262 266 { 263 fprintf(stderr,"%s: %s \n",string,strerror(errno));267 fprintf(stderr,"%s: %s (from %#X)\n",string,strerror(errno), __builtin_return_address(0)); 264 268 } 265 269 … … 440 444 } 441 445 442 unsigned long int strtoul(const char *nptr, char **endptr, int base) 446 unsigned long int strtoul(const char *str, char **endptr, int base) 447 { 448 int negative=0; 449 unsigned long number = 0; 450 451 while (isspace(str)) 452 str++; 453 454 /* Optional sign */ 455 switch (*str) 456 { 457 case '-': 458 negative=1; 459 case '+': 460 str++; 461 } 462 463 if (!(base & ~0x10)) 464 { 465 base += 10; 466 if (*str == '0') 467 { 468 base -=2; 469 str++; 470 471 if (tolower(*str) == 'x') 472 { 473 ++str; 474 base += base; 475 } 476 } 477 478 if (base > 16) 479 base = 16; 480 } 481 482 if (((unsigned)(base - 2)) < 35) 483 { 484 unsigned long cutOffDigit, cutOff; /* Use. ULONG_MAX */ 485 486 do 487 { 488 unsigned char digit; 489 490 if ((*str - '0') <= 9) 491 digit = *str - '0'; 492 else if (*str >= 'A') 493 digit = tolower(*str)-'a'+10; 494 else 495 digit = 40; 496 497 if (digit >= base) 498 break; 499 500 ++str; 501 502 number = number*base + digit; 503 } while(1); 504 } 505 506 if (endptr) 507 *endptr=str; 508 509 return negative ? (unsigned long)(-((long)number)) : number; 510 } 511 512 unsigned long long int strtoull(const char *nptr, char **endptr, int base) 443 513 { 444 514 TODO; 445 } 446 447 unsigned long long int strtoull(const char *nptr, char **endptr, int base) 448 { 449 TODO; 515 while (1); 450 516 } 451 517 … … 743 809 } 744 810 811 int strcmpi(const char* s1, const char* s2) 812 { 813 return strncasecmp(s1, s2, ~0); 814 } 815 745 816 size_t strxfrm(char* dest, const char* src, size_t n) 746 817 {
