Index: branches/xZenu/src/modules/klibc/strcpy.c =================================================================== --- branches/xZenu/src/modules/klibc/strcpy.c (revision 0) +++ branches/xZenu/src/modules/klibc/strcpy.c (revision 1292) @@ -0,0 +1,20 @@ +/* + * strcpy.c + * + * strcpy() + */ + +#include + +char *strcpy(char *dst, const char *src) +{ + char *q = dst; + const char *p = src; + char ch; + + do { + *q++ = ch = *p++; + } while (ch); + + return dst; +} Index: branches/xZenu/src/modules/klibc/Makefile =================================================================== --- branches/xZenu/src/modules/klibc/Makefile (revision 1291) +++ branches/xZenu/src/modules/klibc/Makefile (revision 1292) @@ -8,19 +8,20 @@ DIR = klibc -MODULE_OBJS = klibc \ +MODULE_OBJS = klibc zalloc\ __ashldi3 __ashrdi3 __clzsi2 __divdi3 __divsi3 \ __lshrdi3 __moddi3 __modsi3 __udivdi3 \ __udivmoddi4 __udivmodsi4 __udivsi3 \ __umoddi3 __umodsi3 \ - strntoumax strntoimax atol atoll \ + strntoumax strntoimax atoi atol atoll \ strcasecmp strncasecmp strlcat strndup strnlen \ strsep strtoimax strtok_r strtok strtol strtoll \ strtotimespec strtotimeval \ strtoul strtoull strtoumax strxspn strpbrk \ bsearch calloc \ jrand48 lrand48 mrand48 srand48 nrand48 seed48 \ - memccpy memchr memmem memmove memrchr memswap \ + memccpy memcpy memset bzero memchr memmem memmove memrchr memswap memcmp \ + strcmp strncmp strcpy strncpy strlcpy strstr strncat strcat strdup strncasecmp strchr strlen \ qsort sha1hash onexit atexit exit \ snprintf vsnprintf sscanf vsscanf\ fwrite fprintf vfprintf printf Index: branches/xZenu/src/modules/klibc/strlcpy.c =================================================================== --- branches/xZenu/src/modules/klibc/strlcpy.c (revision 0) +++ branches/xZenu/src/modules/klibc/strlcpy.c (revision 1292) @@ -0,0 +1,26 @@ +/* + * strlcpy.c + */ + +#include + +size_t strlcpy(char *dst, const char *src, size_t size) +{ + size_t bytes = 0; + char *q = dst; + const char *p = src; + char ch; + + while ((ch = *p++)) { + if (bytes + 1 < size) + *q++ = ch; + + bytes++; + } + + /* If size == 0 there is no space for a final null... */ + if (size) + *q = '\0'; + + return bytes; +} Index: branches/xZenu/src/modules/klibc/strcat.c =================================================================== --- branches/xZenu/src/modules/klibc/strcat.c (revision 0) +++ branches/xZenu/src/modules/klibc/strcat.c (revision 1292) @@ -0,0 +1,11 @@ +/* + * strcat.c + */ + +#include + +char *strcat(char *dst, const char *src) +{ + strcpy(strchr(dst, '\0'), src); + return dst; +} Index: branches/xZenu/src/modules/klibc/strlen.c =================================================================== --- branches/xZenu/src/modules/klibc/strlen.c (revision 0) +++ branches/xZenu/src/modules/klibc/strlen.c (revision 1292) @@ -0,0 +1,13 @@ +/* + * strlen() + */ + +#include + +size_t strlen(const char *s) +{ + const char *ss = s; + while (*ss) + ss++; + return ss - s; +} Index: branches/xZenu/src/modules/klibc/strcmp.c =================================================================== --- branches/xZenu/src/modules/klibc/strcmp.c (revision 0) +++ branches/xZenu/src/modules/klibc/strcmp.c (revision 1292) @@ -0,0 +1,21 @@ +/* + * strcmp.c + */ + +#include + +int strcmp(const char *s1, const char *s2) +{ + const unsigned char *c1 = (const unsigned char *)s1; + const unsigned char *c2 = (const unsigned char *)s2; + unsigned char ch; + int d = 0; + + while (1) { + d = (int)(ch = *c1++) - (int)*c2++; + if (d || !ch) + break; + } + + return d; +} Index: branches/xZenu/src/modules/klibc/bzero.c =================================================================== --- branches/xZenu/src/modules/klibc/bzero.c (revision 0) +++ branches/xZenu/src/modules/klibc/bzero.c (revision 1292) @@ -0,0 +1,6 @@ +#include + +void bzero(void *dst, size_t n) +{ + memset(dst, 0, n); +} Index: branches/xZenu/src/modules/klibc/strdup.c =================================================================== --- branches/xZenu/src/modules/klibc/strdup.c (revision 1291) +++ branches/xZenu/src/modules/klibc/strdup.c (revision 1292) @@ -2,7 +2,8 @@ * strdup.c */ -#include "libsaio.h" +#include +#include char *strdup(const char *s) { Index: branches/xZenu/src/modules/klibc/zalloc.c =================================================================== --- branches/xZenu/src/modules/klibc/zalloc.c (revision 0) +++ branches/xZenu/src/modules/klibc/zalloc.c (revision 1292) @@ -0,0 +1,331 @@ +/* + * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights + * Reserved. This file contains Original Code and/or Modifications of + * Original Code as defined in and that are subject to the Apple Public + * Source License Version 2.0 (the "License"). You may not use this file + * except in compliance with the License. Please obtain a copy of the + * License at http://www.apple.com/publicsource and read it before using + * this file. + * + * The Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * Copyright 1993 NeXT Computer, Inc. + * All rights reserved. + * + * Sam's simple memory allocator. + * + */ + +#include "libsa.h" +//#include "saio_internal.h" - Azi: needed for ZDEBUG (printf) +#include "memory.h" + +#define ZDEBUG 0 //Azi: booter doesn't load with this enabled; instant reboot at "boot1: ..." + +#if ZDEBUG +int zout; +#endif + +typedef struct { + char * start; + size_t size; +} zmem; + +static zmem * zalloced; +static zmem * zavailable; +static short availableNodes, allocedNodes, totalNodes; +static char * zalloc_base; +static char * zalloc_end; +static void (*zerror)(char *, size_t, const char *, int); + +static void zallocate(char * start,int size); +static void zinsert(zmem * zp, int ndx); +static void zdelete(zmem * zp, int ndx); +static void zcoalesce(void); + +#if ZDEBUG +size_t zalloced_size; +#endif + +#define ZALLOC_NODES 16384 + +static void malloc_error(char *addr, size_t size, const char *file, int line) +{ +#ifdef i386 + asm volatile ("hlt"); +#endif +} + + + +// define the block of memory that the allocator will use +void malloc_init(char * start, int size, int nodes, void (*malloc_err_fn)(char *, size_t, const char *, int)) +{ + zalloc_base = start ? start : (char *)ZALLOC_ADDR; + totalNodes = nodes ? nodes : ZALLOC_NODES; + zalloced = (zmem *) zalloc_base; + zavailable = (zmem *) zalloc_base + sizeof(zmem) * totalNodes; + zavailable[0].start = (char *)zavailable + sizeof(zmem) * totalNodes; + if (size == 0) size = ZALLOC_LEN; + zavailable[0].size = size - (zavailable[0].start - zalloc_base); + zalloc_end = zalloc_base + size; + availableNodes = 1; + allocedNodes = 0; + zerror = malloc_err_fn ? malloc_err_fn : malloc_error; +} + +#define BEST_FIT 1 + +#undef malloc +void *malloc(size_t size) +{ + return safe_malloc(size, __FILE__, __LINE__); +} + +void * safe_malloc(size_t size, const char *file, int line) +{ + int i; +#if BEST_FIT + int bestFit; + size_t smallestSize; +#endif + char * ret = 0; + + if ( !zalloc_base ) + { + // this used to follow the bss but some bios' corrupted it... + malloc_init((char *)ZALLOC_ADDR, ZALLOC_LEN, ZALLOC_NODES, malloc_error); + } + + size = ((size + 0xf) & ~0xf); + + if (size == 0) { + if (zerror) (*zerror)((char *)0xdeadbeef, 0, file, line); + } +#if BEST_FIT + smallestSize = 0; + bestFit = -1; +#endif + + for (i = 0; i < availableNodes; i++) + { + // find node with equal size, or if not found, + // then smallest node that fits. + if ( zavailable[i].size == size ) + { + zallocate(ret = zavailable[i].start, size); + zdelete(zavailable, i); availableNodes--; + goto done; + } +#if BEST_FIT + else + { + if ((zavailable[i].size > size) && + ((smallestSize == 0) || + (zavailable[i].size < smallestSize))) + { + bestFit = i; + smallestSize = zavailable[i].size; + } + } + +#else + else if ( zavailable[i].size > size ) + { + zallocate(ret = zavailable[i].start, size); + zavailable[i].start += size; + zavailable[i].size -= size; + goto done; + } +#endif + } +#if BEST_FIT + if (bestFit != -1) + { + zallocate(ret = zavailable[bestFit].start, size); + zavailable[bestFit].start += size; + zavailable[bestFit].size -= size; + } +#endif + +done: + if ((ret == 0) || (ret + size >= zalloc_end)) + { + if (zerror) (*zerror)(ret, size, file, line); + } + if (ret != 0) + { + bzero(ret, size); + } +#if ZDEBUG + zalloced_size += size; +#endif + return (void *) ret; +} + +void free(void * pointer) +{ + unsigned long rp; + int i, found = 0; + size_t tsize = 0; + char * start = pointer; + +#if i386 + // Get return address of our caller, + // in case we have to report an error below. + asm volatile ("movl %%esp, %%eax\n\t" + "subl $4, %%eax\n\t" + "movl 0(%%eax), %%eax" : "=a" (rp) ); +#else + rp = 0; +#endif + + if ( !start ) return; + + for (i = 0; i < allocedNodes; i++) + { + if ( zalloced[i].start == start ) + { + tsize = zalloced[i].size; +#if ZDEBUG + zout -= tsize; + printf(" zz out %d\n",zout); +#endif + zdelete(zalloced, i); allocedNodes--; + found = 1; +#if ZDEBUG + memset(pointer, 0x5A, tsize); +#endif + break; + } + } + if ( !found ) { + if (zerror) (*zerror)(pointer, rp, "free", 0); + else return; + } +#if ZDEBUG + zalloced_size -= tsize; +#endif + + for (i = 0; i < availableNodes; i++) + { + if ((start + tsize) == zavailable[i].start) // merge it in + { + zavailable[i].start = start; + zavailable[i].size += tsize; + zcoalesce(); + return; + } + + if ((i > 0) && + (zavailable[i-1].start + zavailable[i-1].size == start)) + { + zavailable[i-1].size += tsize; + zcoalesce(); + return; + } + + if ((start + tsize) < zavailable[i].start) + { + if (++availableNodes > totalNodes) { + if (zerror) (*zerror)((char *)0xf000f000, 0, "free", 0); + } + zinsert(zavailable, i); + zavailable[i].start = start; + zavailable[i].size = tsize; + return; + } + } + + if (++availableNodes > totalNodes) { + if (zerror) (*zerror)((char *)0xf000f000, 1, "free", 0); + } + zavailable[i].start = start; + zavailable[i].size = tsize; + zcoalesce(); + return; +} + +static void +zallocate(char * start,int size) +{ +#if ZDEBUG + zout += size; + printf(" alloc %d, total 0x%x\n",size,zout); +#endif + zalloced[allocedNodes].start = start; + zalloced[allocedNodes].size = size; + if (++allocedNodes > totalNodes) { + if (zerror) (*zerror)((char *)0xf000f000, 2, "zallocate", 0); + }; +} + +static void +zinsert(zmem * zp, int ndx) +{ + int i; + zmem *z1, *z2; + + i = totalNodes-2; + z1 = zp + i; + z2 = z1 + 1; + + for (; i >= ndx; i--, z1--, z2--) + { + *z2 = *z1; + } +} + +static void +zdelete(zmem * zp, int ndx) +{ + int i; + zmem *z1, *z2; + + z1 = zp + ndx; + z2 = z1 + 1; + + for (i = ndx; i < totalNodes-1; i++, z1++, z2++) + { + *z1 = *z2; + } +} + +static void +zcoalesce(void) +{ + int i; + + for (i = 0; i < availableNodes-1; i++) + { + if ( zavailable[i].start + zavailable[i].size == + zavailable[i+1].start ) + { + zavailable[i].size += zavailable[i+1].size; + zdelete(zavailable, i+1); availableNodes--; + return; + } + } +} + +/* This is the simplest way possible. Should fix this. */ +void * realloc(void * start, size_t newsize) +{ + void * newstart = safe_malloc(newsize, __FILE__, __LINE__); + bcopy(start, newstart, newsize); + free(start); + return newstart; +} Index: branches/xZenu/src/modules/klibc/strchr.c =================================================================== --- branches/xZenu/src/modules/klibc/strchr.c (revision 0) +++ branches/xZenu/src/modules/klibc/strchr.c (revision 1292) @@ -0,0 +1,18 @@ +/* + * strchr.c + */ + +#include + +char *strchr(const char *s, int c) +{ + while (*s != (char)c) { + if (!*s) + return NULL; + s++; + } + + return (char *)s; +} + +//__ALIAS(char *, index, (const char *, int), strchr) Index: branches/xZenu/src/modules/klibc/memcpy.c =================================================================== --- branches/xZenu/src/modules/klibc/memcpy.c (revision 0) +++ branches/xZenu/src/modules/klibc/memcpy.c (revision 1292) @@ -0,0 +1,29 @@ +/* + * memcpy.c + */ + +#include +#include + +void *memcpy(void *dst, const void *src, size_t n) +{ + const char *p = src; + char *q = dst; +#if defined(__i386__) + size_t nl = n >> 2; + asm volatile ("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb":"+c" (nl), + "+S"(p), "+D"(q) + :"r"(n & 3)); +#elif defined(__x86_64__) + size_t nq = n >> 3; + asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c" + (nq), "+S"(p), "+D"(q) + :"r"((uint32_t) (n & 7))); +#else + while (n--) { + *q++ = *p++; + } +#endif + + return dst; +} Index: branches/xZenu/src/modules/klibc/strstr.c =================================================================== --- branches/xZenu/src/modules/klibc/strstr.c (revision 0) +++ branches/xZenu/src/modules/klibc/strstr.c (revision 1292) @@ -0,0 +1,11 @@ +/* + * strstr.c + */ + +#include +void *memmem(const void *haystack, size_t n, const void *needle, size_t m); +char *strstr(const char *haystack, const char *needle) +{ + return (char *)memmem(haystack, strlen(haystack), needle, + strlen(needle)); +} Index: branches/xZenu/src/modules/klibc/strncpy.c =================================================================== --- branches/xZenu/src/modules/klibc/strncpy.c (revision 0) +++ branches/xZenu/src/modules/klibc/strncpy.c (revision 1292) @@ -0,0 +1,24 @@ +/* + * strncpy.c + */ + +#include + +char *strncpy(char *dst, const char *src, size_t n) +{ + char *q = dst; + const char *p = src; + char ch; + + while (n) { + n--; + *q++ = ch = *p++; + if (!ch) + break; + } + + /* The specs say strncpy() fills the entire buffer with NUL. Sigh. */ + memset(q, 0, n); + + return dst; +} Index: branches/xZenu/src/modules/klibc/strncat.c =================================================================== --- branches/xZenu/src/modules/klibc/strncat.c (revision 0) +++ branches/xZenu/src/modules/klibc/strncat.c (revision 1292) @@ -0,0 +1,21 @@ +/* + * strncat.c + */ + +#include + +char *strncat(char *dst, const char *src, size_t n) +{ + char *q = strchr(dst, '\0'); + const char *p = src; + char ch; + + while (n--) { + *q++ = ch = *p++; + if (!ch) + return dst; + } + *q = '\0'; + + return dst; +} Index: branches/xZenu/src/modules/klibc/memcmp.c =================================================================== --- branches/xZenu/src/modules/klibc/memcmp.c (revision 0) +++ branches/xZenu/src/modules/klibc/memcmp.c (revision 1292) @@ -0,0 +1,19 @@ +/* + * memcmp.c + */ + +#include + +int memcmp(const void *s1, const void *s2, size_t n) +{ + const unsigned char *c1 = s1, *c2 = s2; + int d = 0; + + while (n--) { + d = (int)*c1++ - (int)*c2++; + if (d) + break; + } + + return d; +} Index: branches/xZenu/src/modules/klibc/strncmp.c =================================================================== --- branches/xZenu/src/modules/klibc/strncmp.c (revision 0) +++ branches/xZenu/src/modules/klibc/strncmp.c (revision 1292) @@ -0,0 +1,21 @@ +/* + * strncmp.c + */ + +#include + +int strncmp(const char *s1, const char *s2, size_t n) +{ + const unsigned char *c1 = (const unsigned char *)s1; + const unsigned char *c2 = (const unsigned char *)s2; + unsigned char ch; + int d = 0; + + while (n--) { + d = (int)(ch = *c1++) - (int)*c2++; + if (d || !ch) + break; + } + + return d; +} Index: branches/xZenu/src/modules/klibc/memset.c =================================================================== --- branches/xZenu/src/modules/klibc/memset.c (revision 0) +++ branches/xZenu/src/modules/klibc/memset.c (revision 1292) @@ -0,0 +1,30 @@ +/* + * memset.c + */ + +#include +#include + +void *memset(void *dst, int c, size_t n) +{ + char *q = dst; + +#if defined(__i386__) + size_t nl = n >> 2; + asm volatile ("cld ; rep ; stosl ; movl %3,%0 ; rep ; stosb" + : "+c" (nl), "+D" (q) + : "a" ((unsigned char)c * 0x01010101U), "r" (n & 3)); +#elif defined(__x86_64__) + size_t nq = n >> 3; + asm volatile ("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb" + :"+c" (nq), "+D" (q) + : "a" ((unsigned char)c * 0x0101010101010101U), + "r" ((uint32_t) n & 7)); +#else + while (n--) { + *q++ = c; + } +#endif + + return dst; +} Index: branches/xZenu/src/arch/i386/boot2/Makefile =================================================================== --- branches/xZenu/src/arch/i386/boot2/Makefile (revision 1291) +++ branches/xZenu/src/arch/i386/boot2/Makefile (revision 1292) @@ -131,7 +131,7 @@ @${MACHOCONV} $(SYMROOT)/boot2.sys $(SYMROOT)/boot &> /dev/null @echo "\t******* Patching at $(PATCH_ADDR) ******" - @stat -f%z $(SYMROOT)/boot | perl -ane "print pack('V',@F[0]);" | dd conv=notrunc of=${SYMROOT}/boot.sys bs=1 count=4 seek=$(PATCH_ADDR) &> /dev/null + @stat -f %z $(SYMROOT)/boot | perl -ane "print pack('V',@F[0]);" | dd conv=notrunc of=${SYMROOT}/boot.sys bs=1 count=4 seek=$(PATCH_ADDR) &> /dev/null @echo "\t[MACHOCONV] boot" @${MACHOCONV} $(SYMROOT)/boot.sys $(SYMROOT)/boot Index: branches/xZenu/src/arch/i386/cdboot/Makefile =================================================================== --- branches/xZenu/src/arch/i386/cdboot/Makefile (revision 1291) +++ branches/xZenu/src/arch/i386/cdboot/Makefile (revision 1292) @@ -18,7 +18,7 @@ @dd if=$(SYMROOT)/boot of=$(SYMROOT)/cdboot conv=sync bs=2k seek=1 &> /dev/null @# Update cdboot with boot file size info - @stat -f%z $(SYMROOT)/boot \ + @stat -f %z $(SYMROOT)/boot \ | perl -ane "print pack('V',@F[0]);" \ | dd of=$(SYMROOT)/cdboot bs=1 count=4 seek=2044 conv=notrunc &> /dev/null Index: branches/xZenu/src/arch/i386/libsa/string.c =================================================================== --- branches/xZenu/src/arch/i386/libsa/string.c (revision 1291) +++ branches/xZenu/src/arch/i386/libsa/string.c (revision 1292) @@ -25,40 +25,8 @@ #include "libsa.h" -void * memset(void * dst, int val, size_t len) -{ - asm volatile ( "rep; stosb" - : "=c" (len), "=D" (dst) - : "0" (len), "1" (dst), "a" (val) - : "memory" ); - - return dst; -} - -#if 0 -void * memcpy(void * dst, const void * src, size_t len) -{ - asm volatile ( "rep; movsb" - : "=c" (len), "=D" (dst), "=S" (src) - : "0" (len), "1" (dst), "2" (src) - : "memory" ); - - return dst; -} - void bcopy(const void * src, void * dst, size_t len) { - memcpy(dst, src, len); -} - -void bzero(void * dst, size_t len) -{ - memset(dst, 0, len); -} - -#else -void * memcpy(void * dst, const void * src, size_t len) -{ asm volatile ( "cld \n\t" "movl %%ecx, %%edx \n\t" "shrl $2, %%ecx \n\t" @@ -66,139 +34,20 @@ "movl %%edx, %%ecx \n\t" "andl $3, %%ecx \n\t" "rep; movsb \n\t" - : "=D" (dst) - : "c" (len), "D" (dst), "S" (src) - : "memory", "%edx" ); - - return dst; -} - -void bcopy(const void * src, void * dst, size_t len) -{ - asm volatile ( "cld \n\t" - "movl %%ecx, %%edx \n\t" - "shrl $2, %%ecx \n\t" - "rep; movsl \n\t" - "movl %%edx, %%ecx \n\t" - "andl $3, %%ecx \n\t" - "rep; movsb \n\t" : : "c" (len), "D" (dst), "S" (src) : "memory", "%edx" ); } -void bzero(void * dst, size_t len) -{ - asm volatile ( "xorl %%eax, %%eax \n\t" - "cld \n\t" - "movl %%ecx, %%edx \n\t" - "shrl $2, %%ecx \n\t" - "rep; stosl \n\t" - "movl %%edx, %%ecx \n\t" - "andl $3, %%ecx \n\t" - "rep; stosb \n\t" - : - : "c" (len), "D" (dst) - : "memory", "%eax" ); -} -#endif - /* #if DONT_USE_GCC_BUILT_IN_STRLEN */ #define tolower(c) ((int)((c) & ~0x20)) #define toupper(c) ((int)((c) | 0x20)) -size_t strlen(const char * s) -{ - int n = 0; - while (*s++) n++; - return(n); -} - /*#endif*/ -/* NOTE: Moved from ntfs.c */ -int -memcmp(const void *p1, const void *p2, size_t len) -{ - while (len--) { - if (*(const char*)(p1++) != *(const char*)(p2++)) - return -1; - } - return 0; -} int -strcmp(const char * s1, const char * s2) -{ - while (*s1 && (*s1 == *s2)) { - s1++; - s2++; - } - return (*s1 - *s2); -} - -int strncmp(const char * s1, const char * s2, size_t len) -{ - register int n = len; - while (--n >= 0 && *s1 == *s2++) - if (*s1++ == '\0') - return(0); - return(n<0 ? 0 : *s1 - *--s2); -} - -char * -strcpy(char * s1, const char * s2) -{ - register char *ret = s1; - while (*s1++ = *s2++) - continue; - return ret; -} - -char * -strncpy(char * s1, const char * s2, size_t n) -{ - register char *ret = s1; - while (n && (*s1++ = *s2++)) - n--; - return ret; -} - -size_t -strlcpy(char * s1, const char * s2, size_t n) -{ - while (n && (*s1++ = *s2++)) - n--; - if (!n) *--s1=0; - return strlen(s2); -} - -char * -strstr(const char *in, const char *str) -{ - char c; - size_t len; - - c = *str++; - if (!c) - return (char *) in; // Trivial empty string case - - len = strlen(str); - do { - char sc; - - do { - sc = *in++; - if (!sc) - return (char *) 0; - } while (sc != c); - } while (strncmp(in, str, len) != 0); - - return (char *) (in - 1); -} - -int ptol(const char *str) { register int c = *str; @@ -210,63 +59,7 @@ else c = 0; return c; } - -int -atoi(const char *str) -{ - register int sum = 0; - while (*str == ' ' || *str == '\t') - str++; - while (*str >= '0' && *str <= '9') { - sum *= 10; - sum += *str++ - '0'; - } - return sum; -} - -char *strncat(char *s1, const char *s2, size_t n) -{ - register char *ret = s1; - while (*s1) - s1++; - while (n-- && *s2) - *s1++ = *s2++; - *s1 = '\0'; - return ret; -} - -char *strcat(char *s1, const char *s2) -{ - return(strncat(s1, s2, strlen(s2))); -} - -char *strdup(const char *s1) -{ - return strcpy(malloc(strlen(s1) + 1), s1); -} - -#if STRNCASECMP -int strncasecmp(const char *s1, const char *s2, size_t len) -{ - register int n = len; - while (--n >= 0 && tolower(*s1) == tolower(*s2++)) - if (*s1++ == '\0') - return(0); - return(n<0 ? 0 : tolower(*s1) - tolower(*--s2)); -} -#endif - -char* strchr(const char *str, int c) -{ - do - { - if(*str == c) - return (char*)str; - } - while(*(str++)); - - return 0; -} + char* strbreak(const char *str, char **next, long *len) { Index: branches/xZenu/src/arch/i386/libsa/Makefile =================================================================== --- branches/xZenu/src/arch/i386/libsa/Makefile (revision 1291) +++ branches/xZenu/src/arch/i386/libsa/Makefile (revision 1292) @@ -21,7 +21,7 @@ INC = -I. -I$(SYMROOT) -I$(LIBSAIODIR) -I${SRCROOT}/include -OBJECTS = prf printf zalloc \ +OBJECTS = prf printf \ string strtol error \ setjmp qsort efi_tables