Index: trunk/i386/modules/include/modules =================================================================== --- trunk/i386/modules/include/modules (revision 0) +++ trunk/i386/modules/include/modules (revision 777) @@ -0,0 +1,104 @@ +extern "C" { +/* + * Module Loading functionality + * Copyright 2009 Evan Lojewski. All rights reserved. + * + */ + +#include +#include + + +// There is a bug with the module system / rebasing / binding +// that causes static variables to be incorrectly rebased or bound +// Disable static variables for the moment +// #define static + +#ifndef __BOOT_MODULES_H +#define __BOOT_MODULES_H + +#define SYMBOLS_MODULE "Symbols.dylib" + +#define SYMBOL_LOOKUP_SYMBOL "_lookup_symbol" +#define STUB_ENTRY_SIZE 6 + +#define SECT_NON_LAZY_SYMBOL_PTR "__nl_symbol_ptr" +#define SECT_SYMBOL_STUBS "__symbol_stub" + + +#define VALID_FUNCTION(__x__) (__x__ && (void*)__x__ != (void*)0xFFFFFFFF) + +extern unsigned long long textAddress; +extern unsigned long long textSection; + + +typedef struct symbolList_t +{ + char* symbol; + unsigned int addr; + struct symbolList_t* next; +} symbolList_t; + +typedef struct moduleList_t +{ + char* module; + unsigned int version; + unsigned int compat; + struct moduleList_t* next; +} moduleList_t; + +typedef struct callbackList_t +{ + void(*callback)(void*, void*, void*, void*); + struct callbackList_t* next; +} callbackList_t; + +typedef struct moduleHook_t +{ + const char* name; + callbackList_t* callbacks; + struct moduleHook_t* next; +} moduleHook_t; + + + +int init_module_system(); +void load_all_modules(); + +/* + * Modules Interface + * execute_hook + * Exexutes a registered hook. All callbaks are + * called in the same order that they were added + * + * register_hook_callback + * registers a void function to be executed when a + * hook is executed. + */ +int execute_hook(const char* name, void*, void*, void*, void*); +void register_hook_callback(const char* name, void(*callback)(void*, void*, void*, void*)); + + +int load_module(char* module); +int is_module_loaded(const char* name); +void module_loaded(const char* name/*, uint32_t version, uint32_t compat*/); + +long long add_symbol(char* symbol, long long addr, char is64); + +void* parse_mach(void* binary, + int(*dylib_loader)(char*), + long long(*symbol_handler)(char*, long long, char) + ); + +unsigned int handle_symtable(uint32_t base, struct symtab_command* symtabCommand, + long long(*symbol_handler)(char*, long long, char), + char is64); + +unsigned int lookup_all_symbols(const char* name); + +int replace_function(const char* symbol, void* newAddress); + +//extern unsigned int (*lookup_symbol)(const char*); + +#endif /* __BOOT_MODULES_H */ +} \ No newline at end of file Index: trunk/i386/modules/include/types.h =================================================================== --- trunk/i386/modules/include/types.h (revision 0) +++ trunk/i386/modules/include/types.h (revision 777) @@ -0,0 +1,16 @@ +#ifndef _TYPES_H_ +#define _TYPES_H_ + +typedef unsigned char UInt8; +typedef signed char SInt8; + +typedef unsigned short UInt16; +typedef signed short SInt16; + +typedef unsigned int UInt32; +typedef signed int SInt32; + +typedef unsigned long long UInt64; +typedef signed long long SInt64; + +#endif /* _TYPES_H_ */ \ No newline at end of file Index: trunk/i386/modules/MakeInc.dir =================================================================== --- trunk/i386/modules/MakeInc.dir (revision 0) +++ trunk/i386/modules/MakeInc.dir (revision 777) @@ -0,0 +1,55 @@ +include ../../MakePaths.dir +include ../../MakeInc.dir + +OBJROOT=../../../obj/i386/$(DIR) +SYMROOT=../../../sym/i386/ +DSTROOT=../../../dst/i386/ + + +UTILDIR = ../../util +LIBSADIR = ../../libsa +LIBSAIODIR = ../../libsaio +BOOT2DIR = ../../boot2 + +MODULE_DEPENDENCIES := $(foreach x,$(MODULE_DEPENDENCIES),-weak_library $(SYMROOT)/modules/$(x).dylib) + + +INSTALLDIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone + +dylib: ${MODULE_OBJS} dylib_final + +dylib_final: + @rm -rf $(SYMROOT)/$(MODULE_NAME).dylib #ensure module doesn't link with old version of self + @echo "\t[LD] $(MODULE_NAME).dylib" + + @ld -arch i386 \ + -alias $(MODULE_START) start \ + -dylib -read_only_relocs suppress \ + -S -x -Z -dead_strip_dylibs \ + -no_uuid \ + -current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \ + -final_output $(MODULE_NAME) \ + -L$(OBJROOT)/ \ + -L$(OBJROOT)/../ \ + -L$(SYMROOT)/ \ + $(OBJROOT)/*.o \ + -weak_library $(OBJROOT)/../../boot2/Symbols_LINKER_ONLY.dylib \ + $(MODULE_DEPENDENCIES) \ + -macosx_version_min 10.6 \ + -o $(SYMROOT)/modules/$(MODULE_NAME).dylib + + @cp -rf include/* ../module_includes/ &> /dev/null || true + +%.o: %.c + @echo "\t[CC] $<" + @$(CC) $(CPPFLAGS) $(CFLAGS) -I../include/ -Iinclude/ -I../module_includes/ -D__KLIBC__ $(DEFINES) -c "$<" $(INC) -o "$(OBJROOT)/$@" + +%.o: %.cpp + @echo "\t[CPP] $<" + @$(CPP) $(CPPFLAGS) $(CFLAGS) -I../include/ -Iinclude/ -I../module_includes/ -D__KLIBC__ $(DEFINES) -c "$<" $(INC) -o "$(OBJROOT)/$@" + + + + +# dependencies +#-include $(OBJROOT)/Makedep Index: trunk/i386/modules/klibc/strndup.c =================================================================== --- trunk/i386/modules/klibc/strndup.c (revision 0) +++ trunk/i386/modules/klibc/strndup.c (revision 777) @@ -0,0 +1,16 @@ +/* + * strndup.c + */ + +#include "libsaio.h" + +char *strndup(const char *s, size_t n) +{ + int l = n > strlen(s) ? strlen(s) + 1 : n + 1; + char *d = malloc(l); + + if (d) + memcpy(d, s, l); + d[n] = '\0'; + return d; +} Index: trunk/i386/modules/klibc/sha1hash.c =================================================================== --- trunk/i386/modules/klibc/sha1hash.c (revision 0) +++ trunk/i386/modules/klibc/sha1hash.c (revision 777) @@ -0,0 +1,319 @@ +/* +SHA-1 in C +By Steve Reid +100% Public Domain + +----------------- +Modified 7/98 +By James H. Brown +Still 100% Public Domain + +Corrected a problem which generated improper hash values on 16 bit machines +Routine SHA1Update changed from + void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int +len) +to + void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned +long len) + +The 'len' parameter was declared an int which works fine on 32 bit machines. +However, on 16 bit machines an int is too small for the shifts being done +against +it. This caused the hash function to generate incorrect values if len was +greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update(). + +Since the file IO in main() reads 16K at a time, any file 8K or larger would +be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million +"a"s). + +I also changed the declaration of variables i & j in SHA1Update to +unsigned long from unsigned int for the same reason. + +These changes should make no difference to any 32 bit implementations since +an +int and a long are the same size in those environments. + +-- +I also corrected a few compiler warnings generated by Borland C. +1. Added #include for exit() prototype +2. Removed unused variable 'j' in SHA1Final +3. Changed exit(0) to return(0) at end of main. + +ALL changes I made can be located by searching for comments containing 'JHB' +----------------- +Modified 8/98 +By Steve Reid +Still 100% public domain + +1- Removed #include and used return() instead of exit() +2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall) +3- Changed email address from steve@edmweb.com to sreid@sea-to-sky.net + +----------------- +Modified 4/01 +By Saul Kravitz +Still 100% PD +Modified to run on Compaq Alpha hardware. + +----------------- +Modified 2/03 +By H. Peter Anvin +Still 100% PD +Modified to run on any hardware with and +Changed the driver program + +*/ + +/* +Test Vectors (from FIPS PUB 180-1) +"abc" + A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D +"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" + 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 +A million repetitions of "a" + 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F +*/ + +/* #define SHA1HANDSOFF */ + +#include +#include +#include +#include /* For htonl/ntohl/htons/ntohs */ + +/* #include */ /* prototype for exit() - JHB */ +/* Using return() instead of exit() - SWR */ + +typedef struct { + uint32_t state[5]; + uint32_t count[2]; + unsigned char buffer[64]; +} SHA1_CTX; + +void SHA1Transform(uint32_t state[5], unsigned char buffer[64]); +void SHA1Init(SHA1_CTX* context); +void SHA1Update(SHA1_CTX* context, unsigned char* data, uint32_t len); /* +JHB */ +void SHA1Final(unsigned char digest[20], SHA1_CTX* context); + +#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) + +/* blk0() and blk() perform the initial expand. */ +/* I got the idea of expanding during the round function from SSLeay */ +#define blk0(i) (block->l[i] = ntohl(block->l[i])) +#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ + ^block->l[(i+2)&15]^block->l[i&15],1)) + +/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ +#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); +#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); +#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); +#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); + + +#ifdef VERBOSE /* SAK */ +void SHAPrintContext(SHA1_CTX *context, char *msg){ + printf("%s (%d,%d) %x %x %x %x %x\n", + msg, + context->count[0], context->count[1], + context->state[0], + context->state[1], + context->state[2], + context->state[3], + context->state[4]); +} +#endif + +/* Hash a single 512-bit block. This is the core of the algorithm. */ + +void SHA1Transform(uint32_t state[5], unsigned char buffer[64]) +{ +uint32_t a, b, c, d, e; +typedef union { + unsigned char c[64]; + uint32_t l[16]; +} CHAR64LONG16; +CHAR64LONG16* block; +#ifdef SHA1HANDSOFF +static unsigned char workspace[64]; + block = (CHAR64LONG16*)workspace; + memcpy(block, buffer, 64); +#else + block = (CHAR64LONG16*)buffer; +#endif + /* Copy context->state[] to working vars */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + /* 4 rounds of 20 operations each. Loop unrolled. */ + R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + /* Wipe variables */ + a = b = c = d = e = 0; +} + + +/* SHA1Init - Initialize new context */ + +void SHA1Init(SHA1_CTX* context) +{ + /* SHA1 initialization constants */ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; +} + + +/* Run your data through this. */ + +void SHA1Update(SHA1_CTX* context, unsigned char* data, uint32_t len) /* +JHB */ +{ +uint32_t i, j; /* JHB */ + +#ifdef VERBOSE + SHAPrintContext(context, "before"); +#endif + j = (context->count[0] >> 3) & 63; + if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; + context->count[1] += (len >> 29); + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64-j)); + SHA1Transform(context->state, context->buffer); + for ( ; i + 63 < len; i += 64) { + SHA1Transform(context->state, &data[i]); + } + j = 0; + } + else i = 0; + memcpy(&context->buffer[j], &data[i], len - i); +#ifdef VERBOSE + SHAPrintContext(context, "after "); +#endif +} + + +/* Add padding and return the message digest. */ + +void SHA1Final(unsigned char digest[20], SHA1_CTX* context) +{ +uint32_t i; /* JHB */ +unsigned char finalcount[8]; + + for (i = 0; i < 8; i++) { + finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } + SHA1Update(context, (unsigned char *)"\200", 1); + while ((context->count[0] & 504) != 448) { + SHA1Update(context, (unsigned char *)"\0", 1); + } + SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() +*/ + for (i = 0; i < 20; i++) { + digest[i] = (unsigned char) + ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + /* Wipe variables */ + i = 0; /* JHB */ + memset(context->buffer, 0, 64); + memset(context->state, 0, 20); + memset(context->count, 0, 8); + memset(finalcount, 0, 8); /* SWR */ +#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */ + SHA1Transform(context->state, context->buffer); +#endif +} + +/*************************************************************/ + +/* This is not quite the MIME base64 algorithm: it uses _ instead of /, + and instead of padding the output with = characters we just make the + output shorter. */ +char *mybase64(uint8_t digest[20]) +{ + static const char charz[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; + uint8_t input[21]; + static char output[28]; + int i, j; + uint8_t *p; + char *q; + uint32_t bv; + + memcpy(input, digest, 20); + input[20] = 0; /* Pad to multiple of 3 bytes */ + + p = input; q = output; + for ( i = 0 ; i < 7 ; i++ ) { + bv = (p[0] << 16) | (p[1] << 8) | p[2]; + p += 3; + for ( j = 0 ; j < 4 ; j++ ) { + *q++ = charz[(bv >> 18) & 0x3f]; + bv <<= 6; + } + } + *--q = '\0'; /* The last character is not significant */ + return output; +} + +#if 0 +int main(int argc, char** argv) +{ + int i; + SHA1_CTX context; + uint8_t digest[20], buffer[16384]; + FILE* file; + + if (argc < 2) { + file = stdin; + } + else { + if (!(file = fopen(argv[1], "rb"))) { + fputs("Unable to open file.", stderr); + return(-1); + } + } + SHA1Init(&context); + while (!feof(file)) { /* note: what if ferror(file) */ + i = fread(buffer, 1, 16384, file); + SHA1Update(&context, buffer, i); + } + SHA1Final(digest, &context); + fclose(file); + + puts(mybase64(digest)); + + return 0; +} +#endif Index: trunk/i386/modules/klibc/strtox.c =================================================================== --- trunk/i386/modules/klibc/strtox.c (revision 0) +++ trunk/i386/modules/klibc/strtox.c (revision 777) @@ -0,0 +1,16 @@ +/* + * strtox.c + * + * strto...() functions, by macro definition + */ + +#include +#include +#include + +extern uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n); + +TYPE NAME(const char *nptr, char **endptr, int base) +{ + return (TYPE) strntoumax(nptr, endptr, base, ~(size_t) 0); +} Index: trunk/i386/modules/klibc/__clzsi2.c =================================================================== --- trunk/i386/modules/klibc/__clzsi2.c (revision 0) +++ trunk/i386/modules/klibc/__clzsi2.c (revision 777) @@ -0,0 +1,36 @@ +/* + * libgcc/__clzsi2.c + * + * Returns the leading number of 0 bits in the argument + */ + +#include +#include + +uint32_t __clzsi2(uint32_t v) +{ + int p = 31; + + if (v & 0xffff0000) { + p -= 16; + v >>= 16; + } + if (v & 0xff00) { + p -= 8; + v >>= 8; + } + if (v & 0xf0) { + p -= 4; + v >>= 4; + } + if (v & 0xc) { + p -= 2; + v >>= 2; + } + if (v & 0x2) { + p -= 1; + v >>= 1; + } + + return p; +} Index: trunk/i386/modules/klibc/strcasecmp.c =================================================================== --- trunk/i386/modules/klibc/strcasecmp.c (revision 0) +++ trunk/i386/modules/klibc/strcasecmp.c (revision 777) @@ -0,0 +1,24 @@ +/* + * strcasecmp.c + */ + +#include +#include + +int strcasecmp(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) { + /* toupper() expects an unsigned char (implicitly cast to int) + as input, and returns an int, which is exactly what we want. */ + d = toupper(ch = *c1++) - toupper(*c2++); + if (d || !ch) + break; + } + + return d; +} Index: trunk/i386/modules/klibc/__udivdi3.c =================================================================== --- trunk/i386/modules/klibc/__udivdi3.c (revision 0) +++ trunk/i386/modules/klibc/__udivdi3.c (revision 777) @@ -0,0 +1,13 @@ +/* + * arch/i386/libgcc/__divdi3.c + */ + +#include +#include + +extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); + +uint64_t __udivdi3(uint64_t num, uint64_t den) +{ + return __udivmoddi4(num, den, NULL); +} Index: trunk/i386/modules/klibc/memmove.c =================================================================== --- trunk/i386/modules/klibc/memmove.c (revision 0) +++ trunk/i386/modules/klibc/memmove.c (revision 777) @@ -0,0 +1,36 @@ +/* + * memmove.c + */ + +#include "libsaio.h" + +void *memmove(void *dst, const void *src, size_t n) +{ + const char *p = src; + char *q = dst; +#if defined(__i386__) || defined(__x86_64__) + if (q < p) { + asm volatile("cld; rep; movsb" + : "+c" (n), "+S"(p), "+D"(q)); + } else { + p += (n - 1); + q += (n - 1); + asm volatile("std; rep; movsb; cld" + : "+c" (n), "+S"(p), "+D"(q)); + } +#else + if (q < p) { + while (n--) { + *q++ = *p++; + } + } else { + p += n; + q += n; + while (n--) { + *--q = *--p; + } + } +#endif + + return dst; +} Index: trunk/i386/modules/klibc/strtotimespec.c =================================================================== --- trunk/i386/modules/klibc/strtotimespec.c (revision 0) +++ trunk/i386/modules/klibc/strtotimespec.c (revision 777) @@ -0,0 +1,5 @@ +#define NAME strtotimespec +#define TIMEX struct timespec +#define FSEC tv_nsec +#define DECIMALS 9 +#include "strtotimex.c" Index: trunk/i386/modules/klibc/limits.h =================================================================== --- trunk/i386/modules/klibc/limits.h (revision 0) +++ trunk/i386/modules/klibc/limits.h (revision 777) @@ -0,0 +1,6 @@ + +#define CHAR_BIT 8 + +#define UCHAR_MAX 255u +#define INT_MAX 2147483647 +#define UINT_MAX 4294967295u \ No newline at end of file Index: trunk/i386/modules/klibc/onexit.c =================================================================== --- trunk/i386/modules/klibc/onexit.c (revision 0) +++ trunk/i386/modules/klibc/onexit.c (revision 777) @@ -0,0 +1,22 @@ +/* + * onexit.c + */ + +#include "libsaio.h" +#include "atexit.h" + +int on_exit(void (*fctn) (int, void *), void *arg) +{ + struct atexit *as = malloc(sizeof(struct atexit)); + + if (!as) + return -1; + + as->fctn = fctn; + as->arg = arg; + + as->next = __atexit_list; + __atexit_list = as; + + return 0; +} Index: trunk/i386/modules/klibc/exit.c =================================================================== --- trunk/i386/modules/klibc/exit.c (revision 0) +++ trunk/i386/modules/klibc/exit.c (revision 777) @@ -0,0 +1,30 @@ +/* + * exit.c + * + * exit(), including the handling of the atexit chain. + */ + +#include +#include +#include +#include "atexit.h" + +/* Link chain for atexit/on_exit */ +struct atexit *__atexit_list; + +void exit(int rv) +{ + struct atexit *ap; + + for (ap = __atexit_list; ap; ap = ap->next) { + /* This assumes extra args are harmless. They should + be in all normal C ABIs, but if an architecture has + some particularly bizarre ABI this might be worth + watching out for. */ + ap->fctn(rv, ap->arg); + } + + /* Handle any library destructors if we ever start using them... */ + + _exit(rv); +} Index: trunk/i386/modules/klibc/jrand48.c =================================================================== --- trunk/i386/modules/klibc/jrand48.c (revision 0) +++ trunk/i386/modules/klibc/jrand48.c (revision 777) @@ -0,0 +1,24 @@ +/* + * jrand48.c + */ + +#include +#include + +long jrand48(unsigned short xsubi[3]) +{ + uint64_t x; + + /* The xsubi[] array is littleendian by spec */ + x = (uint64_t) (uint16_t) xsubi[0] + + ((uint64_t) (uint16_t) xsubi[1] << 16) + + ((uint64_t) (uint16_t) xsubi[2] << 32); + + x = (0x5deece66dULL * x) + 0xb; + + xsubi[0] = (unsigned short)(uint16_t) x; + xsubi[1] = (unsigned short)(uint16_t) (x >> 16); + xsubi[2] = (unsigned short)(uint16_t) (x >> 32); + + return (long)(int32_t) (x >> 16); +} Index: trunk/i386/modules/klibc/memchr.c =================================================================== --- trunk/i386/modules/klibc/memchr.c (revision 0) +++ trunk/i386/modules/klibc/memchr.c (revision 777) @@ -0,0 +1,19 @@ +/* + * memchr.c + */ + +#include +#include + +void *memchr(const void *s, int c, size_t n) +{ + const unsigned char *sp = s; + + while (n--) { + if (*sp == (unsigned char)c) + return (void *)sp; + sp++; + } + + return NULL; +} Index: trunk/i386/modules/klibc/lrand48.c =================================================================== --- trunk/i386/modules/klibc/lrand48.c (revision 0) +++ trunk/i386/modules/klibc/lrand48.c (revision 777) @@ -0,0 +1,13 @@ +/* + * lrand48.c + */ + +#include +#include + +extern unsigned short __rand48_seed[3]; /* Common with mrand48.c, srand48.c */ + +long lrand48(void) +{ + return (uint32_t) jrand48(__rand48_seed) >> 1; +} Index: trunk/i386/modules/klibc/mrand48.c =================================================================== --- trunk/i386/modules/klibc/mrand48.c (revision 0) +++ trunk/i386/modules/klibc/mrand48.c (revision 777) @@ -0,0 +1,13 @@ +/* + * mrand48.c + */ + +#include +#include + +extern unsigned short __rand48_seed[3]; /* Common with lrand48.c, srand48.c */ + +long mrand48(void) +{ + return jrand48(__rand48_seed); +} Index: trunk/i386/modules/klibc/nrand48.c =================================================================== --- trunk/i386/modules/klibc/nrand48.c (revision 0) +++ trunk/i386/modules/klibc/nrand48.c (revision 777) @@ -0,0 +1,11 @@ +/* + * nrand48.c + */ + +#include +#include + +long nrand48(unsigned short xsubi[3]) +{ + return (long)((uint32_t) jrand48(xsubi) >> 1); +} Index: trunk/i386/modules/klibc/srand48.c =================================================================== --- trunk/i386/modules/klibc/srand48.c (revision 0) +++ trunk/i386/modules/klibc/srand48.c (revision 777) @@ -0,0 +1,15 @@ +/* + * srand48.c + */ + +#include +#include + +extern unsigned short __rand48_seed[3]; /* Common with mrand48.c, lrand48.c */ + +void srand48(long seedval) +{ + __rand48_seed[0] = 0x330e; + __rand48_seed[1] = (unsigned short)seedval; + __rand48_seed[2] = (unsigned short)((uint32_t) seedval >> 16); +} Index: trunk/i386/modules/klibc/__udivsi3.c =================================================================== --- trunk/i386/modules/klibc/__udivsi3.c (revision 0) +++ trunk/i386/modules/klibc/__udivsi3.c (revision 777) @@ -0,0 +1,13 @@ +/* + * libgcc/__divsi3.c + */ + +#include +#include + +extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); + +uint32_t __udivsi3(uint32_t num, uint32_t den) +{ + return __udivmodsi4(num, den, NULL); +} Index: trunk/i386/modules/klibc/klibc.c =================================================================== --- trunk/i386/modules/klibc/klibc.c (revision 0) +++ trunk/i386/modules/klibc/klibc.c (revision 777) @@ -0,0 +1,36 @@ +/* + * klibc.c + * + * glue + initialization + */ + +#include "libsaio.h" + +int _DefaultRuneLocale; // todo: fixme + +void klibc_start() +{ +} + +void _exit() +{ +} + +char __toupper(char c) +{ + return ((c) & ~32); +} + +void __divide_error() +{ + stop("Divide by 0\n"); +} + +// hack +int +__maskrune(int _c, unsigned long _f) +{ + return 0; + //return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) : + // _CurrentRuneLocale->__runetype[_c]) & _f; +} Index: trunk/i386/modules/klibc/__ashldi3.c =================================================================== --- trunk/i386/modules/klibc/__ashldi3.c (revision 0) +++ trunk/i386/modules/klibc/__ashldi3.c (revision 777) @@ -0,0 +1,23 @@ +/* + * libgcc/__ashldi3.c + */ + +#include +#include + +uint64_t __ashldi3(uint64_t v, int cnt) +{ + int c = cnt & 31; + uint32_t vl = (uint32_t) v; + uint32_t vh = (uint32_t) (v >> 32); + + if (cnt & 32) { + vh = (vl << c); + vl = 0; + } else { + vh = (vh << c) + (vl >> (32 - c)); + vl = (vl << c); + } + + return ((uint64_t) vh << 32) + vl; +} Index: trunk/i386/modules/klibc/Makefile =================================================================== --- trunk/i386/modules/klibc/Makefile (revision 0) +++ trunk/i386/modules/klibc/Makefile (revision 777) @@ -0,0 +1,64 @@ +MODULE_NAME = klibc +MODULE_VERSION = "1.5.20" +MODULE_COMPAT_VERSION = "1.5.20" +MODULE_START = _$(MODULE_NAME)_start +MODULE_DEPENDENCIES = + +DIR = klibc + +MODULE_OBJS = klibc.o \ + __ashldi3.o __ashrdi3.o __clzsi2.o __divdi3.o __divsi3.o \ + __lshrdi3.o __moddi3.o __modsi3.o __udivdi3.o \ + __udivmoddi4.o __udivmodsi4.o __udivsi3.o \ + __umoddi3.o __umodsi3.o \ + strntoumax.o strntoimax.o atoi.o atol.o atoll.o \ + strcasecmp.o strncasecmp.o strdup.o strlcat.o strndup.o strnlen.o \ + strsep.o strtoimax.o strtok_r.o strtok.o strtol.o strtoll.o strtotimespec.o strtotimeval.o \ + strtoul.o strtoull.o strtoumax.o strxspn.o strpbrk.o \ + bsearch.o calloc.o \ + jrand48.o lrand48.o mrand48.o srand48.o nrand48.o seed48.o \ + memccpy.o memchr.o memmem.o memmove.o memrchr.o memswap.o \ + qsort.o sha1hash.o onexit.o atexit.o exit.o \ + snprintf.o vsnprintf.o sscanf.o vsscanf.o\ + +OPTIM = -Os -Oz +DEBUG = -DNOTHING +#DEBUG = -DDEBUG_HELLO_WORLD=1 +CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \ + -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \ + -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \ + -fno-builtin $(OMIT_FRAME_POINTER_CFLAG) \ + -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ + -march=pentium4 -msse2 -mfpmath=sse -msoft-float -fno-common + +DEFINES= +CONFIG = hd +INC = -I. -I.. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(BOOT2DIR) +ifneq "" "$(wildcard /bin/mkdirs)" + MKDIRS = /bin/mkdirs +else + MKDIRS = /bin/mkdir -p +endif +AS = as +LD = ld +# LIBS= -lc_static +LIBS= + +VPATH = $(OBJROOT):$(SYMROOT) + + + + +SFILES = +CFILES = +HFILES = +EXPORTED_HFILES = +INSTALLED_HFILES = +OTHERFILES = Makefile +ALLSRC = $(SFILES) $(CFILES) \ + $(HFILES) $(OTHERFILES) +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) + +all embedtheme optionrom: dylib + +include ../MakeInc.dir \ No newline at end of file Index: trunk/i386/modules/klibc/strtotimeval.c =================================================================== --- trunk/i386/modules/klibc/strtotimeval.c (revision 0) +++ trunk/i386/modules/klibc/strtotimeval.c (revision 777) @@ -0,0 +1,5 @@ +#define NAME strtotimeval +#define TIMEX struct timeval +#define FSEC tv_usec +#define DECIMALS 6 +#include "strtotimex.c" Index: trunk/i386/modules/klibc/memrchr.c =================================================================== --- trunk/i386/modules/klibc/memrchr.c (revision 0) +++ trunk/i386/modules/klibc/memrchr.c (revision 777) @@ -0,0 +1,19 @@ +/* + * memrchr.c + */ + +#include +#include + +void *memrchr(const void *s, int c, size_t n) +{ + const unsigned char *sp = (const unsigned char *)s + n - 1; + + while (n--) { + if (*sp == (unsigned char)c) + return (void *)sp; + sp--; + } + + return NULL; +} Index: trunk/i386/modules/klibc/__umoddi3.c =================================================================== --- trunk/i386/modules/klibc/__umoddi3.c (revision 0) +++ trunk/i386/modules/klibc/__umoddi3.c (revision 777) @@ -0,0 +1,16 @@ +/* + * arch/i386/libgcc/__umoddi3.c + */ + +#include +#include + +extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); + +uint64_t __umoddi3(uint64_t num, uint64_t den) +{ + uint64_t v; + + (void)__udivmoddi4(num, den, &v); + return v; +} Index: trunk/i386/modules/klibc/memswap.c =================================================================== --- trunk/i386/modules/klibc/memswap.c (revision 0) +++ trunk/i386/modules/klibc/memswap.c (revision 777) @@ -0,0 +1,24 @@ +/* + * memswap() + * + * Swaps the contents of two nonoverlapping memory areas. + * This really could be done faster... + */ + +#include + +void memswap(void *m1, void *m2, size_t n) +{ + char *p = m1; + char *q = m2; + char tmp; + + while (n--) { + tmp = *p; + *p = *q; + *q = tmp; + + p++; + q++; + } +} Index: trunk/i386/modules/klibc/atoll.c =================================================================== --- trunk/i386/modules/klibc/atoll.c (revision 0) +++ trunk/i386/modules/klibc/atoll.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE long long +#define NAME atoll +#include "atox.c" Index: trunk/i386/modules/klibc/strlcat.c =================================================================== --- trunk/i386/modules/klibc/strlcat.c (revision 0) +++ trunk/i386/modules/klibc/strlcat.c (revision 777) @@ -0,0 +1,30 @@ +/* + * strlcat.c + */ + +#include + +size_t strlcat(char *dst, const char *src, size_t size) +{ + size_t bytes = 0; + char *q = dst; + const char *p = src; + char ch; + + while (bytes < size && *q) { + q++; + bytes++; + } + if (bytes == size) + return (bytes + strlen(src)); + + while ((ch = *p++)) { + if (bytes + 1 < size) + *q++ = ch; + + bytes++; + } + + *q = '\0'; + return bytes; +} Index: trunk/i386/modules/klibc/memmem.c =================================================================== --- trunk/i386/modules/klibc/memmem.c (revision 0) +++ trunk/i386/modules/klibc/memmem.c (revision 777) @@ -0,0 +1,52 @@ +/* + * memmem.c + * + * Find a byte string inside a longer byte string + * + * This uses the "Not So Naive" algorithm, a very simple but + * usually effective algorithm, see: + * + * http://www-igm.univ-mlv.fr/~lecroq/string/ + */ + +#include + +void *memmem(const void *haystack, size_t n, const void *needle, size_t m) +{ + const unsigned char *y = (const unsigned char *)haystack; + const unsigned char *x = (const unsigned char *)needle; + + size_t j, k, l; + + if (m > n || !m || !n) + return NULL; + + if (1 != m) { + if (x[0] == x[1]) { + k = 2; + l = 1; + } else { + k = 1; + l = 2; + } + + j = 0; + while (j <= n - m) { + if (x[1] != y[j + 1]) { + j += k; + } else { + if (!memcmp(x + 2, y + j + 2, m - 2) + && x[0] == y[j]) + return (void *)&y[j]; + j += l; + } + } + } else + do { + if (*y == *x) + return (void *)y; + y++; + } while (--n); + + return NULL; +} Index: trunk/i386/modules/klibc/strsep.c =================================================================== --- trunk/i386/modules/klibc/strsep.c (revision 0) +++ trunk/i386/modules/klibc/strsep.c (revision 777) @@ -0,0 +1,21 @@ +/* + * strsep.c + */ + +#include + +char *strsep(char **stringp, const char *delim) +{ + char *s = *stringp; + char *e; + + if (!s) + return NULL; + + e = strpbrk(s, delim); + if (e) + *e++ = '\0'; + + *stringp = e; + return s; +} Index: trunk/i386/modules/klibc/strdup.c =================================================================== --- trunk/i386/modules/klibc/strdup.c (revision 0) +++ trunk/i386/modules/klibc/strdup.c (revision 777) @@ -0,0 +1,16 @@ +/* + * strdup.c + */ + +#include "libsaio.h" + +char *strdup(const char *s) +{ + int l = strlen(s) + 1; + char *d = malloc(l); + + if (d) + memcpy(d, s, l); + + return d; +} Index: trunk/i386/modules/klibc/__umodsi3.c =================================================================== --- trunk/i386/modules/klibc/__umodsi3.c (revision 0) +++ trunk/i386/modules/klibc/__umodsi3.c (revision 777) @@ -0,0 +1,16 @@ +/* + * libgcc/__umodsi3.c + */ + +#include +#include + +extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); + +uint32_t __umodsi3(uint32_t num, uint32_t den) +{ + uint32_t v; + + (void)__udivmodsi4(num, den, &v); + return v; +} Index: trunk/i386/modules/klibc/strtotimex.c =================================================================== --- trunk/i386/modules/klibc/strtotimex.c (revision 0) +++ trunk/i386/modules/klibc/strtotimex.c (revision 777) @@ -0,0 +1,42 @@ +/* + * strtotimex.c + * + * Nonstandard function which takes a string and converts it to a + * struct timespec/timeval. Returns a pointer to the first non-numeric + * character in the string. + * + */ + +#include +#include +#include +#include +#include + +uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n); + +char *NAME(const char *str, TIMEX * ts) +{ + int n; + char *s, *s0; + __typeof__(ts->FSEC) fs; /* Fractional seconds */ + + ts->tv_sec = strntoumax(str, &s, 10, ~(size_t) 0); + fs = 0; + + if (*s == '.') { + s0 = s + 1; + + fs = strntoumax(s0, &s, 10, DECIMALS); + n = s - s0; + + while (isdigit(*s)) + s++; + + for (; n < DECIMALS; n++) + fs *= 10; + } + + ts->FSEC = fs; + return s; +} Index: trunk/i386/modules/klibc/strtok.c =================================================================== --- trunk/i386/modules/klibc/strtok.c (revision 0) +++ trunk/i386/modules/klibc/strtok.c (revision 777) @@ -0,0 +1,12 @@ +/* + * strtok.c + */ + +#include + +char *strtok(char *s, const char *delim) +{ + static char *holder; + + return strtok_r(s, delim, &holder); +} Index: trunk/i386/modules/klibc/vsnprintf.c =================================================================== --- trunk/i386/modules/klibc/vsnprintf.c (revision 0) +++ trunk/i386/modules/klibc/vsnprintf.c (revision 777) @@ -0,0 +1,483 @@ +/* + * vsnprintf.c + * + * vsnprintf(), from which the rest of the printf() + * family is built + */ + +#include "libsaio.h" +#include "limits.h" +enum flags { + FL_ZERO = 0x01, /* Zero modifier */ + FL_MINUS = 0x02, /* Minus modifier */ + FL_PLUS = 0x04, /* Plus modifier */ + FL_TICK = 0x08, /* ' modifier */ + FL_SPACE = 0x10, /* Space modifier */ + FL_HASH = 0x20, /* # modifier */ + FL_SIGNED = 0x40, /* Number is signed */ + FL_UPPER = 0x80 /* Upper case digits */ +}; + +/* These may have to be adjusted on certain implementations */ +enum ranks { + rank_char = -2, + rank_short = -1, + rank_int = 0, + rank_long = 1, + rank_longlong = 2 +}; + +#define MIN_RANK rank_char +#define MAX_RANK rank_longlong + +#define INTMAX_RANK rank_longlong +#define SIZE_T_RANK rank_long +#define PTRDIFF_T_RANK rank_long + +#define EMIT(x) ({ if (o nchars) { + while (width > nchars) { + EMIT(' '); + width--; + } + } + + /* Emit nondigits */ + if (minus) + EMIT('-'); + else if (flags & FL_PLUS) + EMIT('+'); + else if (flags & FL_SPACE) + EMIT(' '); + + if ((flags & FL_HASH) && base == 16) { + EMIT('0'); + EMIT((flags & FL_UPPER) ? 'X' : 'x'); + } + + /* Emit zero padding */ + if ((flags & (FL_MINUS | FL_ZERO)) == FL_ZERO && width > ndigits) { + while (width > nchars) { + EMIT('0'); + width--; + } + } + + /* Generate the number. This is done from right to left. */ + q += ndigits; /* Advance the pointer to end of number */ + o += ndigits; + qq = q; + oo = o; /* Temporary values */ + + b4tick = tickskip; + while (ndigits > 0) { + if (!b4tick--) { + qq--; + oo--; + ndigits--; + if (oo < n) + *qq = '_'; + b4tick = tickskip - 1; + } + qq--; + oo--; + ndigits--; + if (oo < n) + *qq = digits[val % base]; + val /= base; + } + + /* Emit late space padding */ + while ((flags & FL_MINUS) && width > nchars) { + EMIT(' '); + width--; + } + + return o; +} + +int vsnprintf(char *buffer, size_t n, const char *format, va_list ap) +{ + const char *p = format; + char ch; + char *q = buffer; + size_t o = 0; /* Number of characters output */ + uintmax_t val = 0; + int rank = rank_int; /* Default rank */ + int width = 0; + int prec = -1; + int base; + size_t sz; + enum flags flags = 0; + enum { + st_normal, /* Ground state */ + st_flags, /* Special flags */ + st_width, /* Field width */ + st_prec, /* Field precision */ + st_modifiers /* Length or conversion modifiers */ + } state = st_normal; + const char *sarg; /* %s string argument */ + char carg; /* %c char argument */ + int slen; /* String length */ + + while ((ch = *p++)) { + switch (state) { + case st_normal: + if (ch == '%') { + state = st_flags; + flags = 0; + rank = rank_int; + width = 0; + prec = -1; + } else { + EMIT(ch); + } + break; + + case st_flags: + switch (ch) { + case '-': + flags |= FL_MINUS; + break; + case '+': + flags |= FL_PLUS; + break; + case '\'': + flags |= FL_TICK; + break; + case ' ': + flags |= FL_SPACE; + break; + case '#': + flags |= FL_HASH; + break; + case '0': + flags |= FL_ZERO; + break; + default: + state = st_width; + p--; /* Process this character again */ + break; + } + break; + + case st_width: + if (ch >= '0' && ch <= '9') { + width = width * 10 + (ch - '0'); + } else if (ch == '*') { + width = va_arg(ap, int); + if (width < 0) { + width = -width; + flags |= FL_MINUS; + } + } else if (ch == '.') { + prec = 0; /* Precision given */ + state = st_prec; + } else { + state = st_modifiers; + p--; /* Process this character again */ + } + break; + + case st_prec: + if (ch >= '0' && ch <= '9') { + prec = prec * 10 + (ch - '0'); + } else if (ch == '*') { + prec = va_arg(ap, int); + if (prec < 0) + prec = -1; + } else { + state = st_modifiers; + p--; /* Process this character again */ + } + break; + + case st_modifiers: + switch (ch) { + /* Length modifiers - nonterminal sequences */ + case 'h': + rank--; /* Shorter rank */ + break; + case 'l': + rank++; /* Longer rank */ + break; + case 'j': + rank = INTMAX_RANK; + break; + case 'z': + rank = SIZE_T_RANK; + break; + case 't': + rank = PTRDIFF_T_RANK; + break; + case 'L': + case 'q': + rank += 2; + break; + default: + /* Output modifiers - terminal sequences */ + + /* Next state will be normal */ + state = st_normal; + + /* Canonicalize rank */ + if (rank < MIN_RANK) + rank = MIN_RANK; + else if (rank > MAX_RANK) + rank = MAX_RANK; + + switch (ch) { + case 'P': /* Upper case pointer */ + flags |= FL_UPPER; + /* fall through */ + case 'p': /* Pointer */ + base = 16; + prec = (CHAR_BIT*sizeof(void *)+3)/4; + flags |= FL_HASH; + val = (uintmax_t)(uintptr_t) + va_arg(ap, void *); + goto is_integer; + + case 'd': /* Signed decimal output */ + case 'i': + base = 10; + flags |= FL_SIGNED; + switch (rank) { + case rank_char: + /* Yes, all these casts are + needed... */ + val = (uintmax_t)(intmax_t) + (signed char) + va_arg(ap, signed int); + break; + case rank_short: + val = (uintmax_t)(intmax_t) + (signed short) + va_arg(ap, signed int); + break; + case rank_int: + val = (uintmax_t)(intmax_t) + va_arg(ap, signed int); + break; + case rank_long: + val = (uintmax_t)(intmax_t) + va_arg(ap, signed long); + break; + case rank_longlong: + val = (uintmax_t)(intmax_t) + va_arg(ap, + signed long long); + break; + } + goto is_integer; + case 'o': /* Octal */ + base = 8; + goto is_unsigned; + case 'u': /* Unsigned decimal */ + base = 10; + goto is_unsigned; + case 'X': /* Upper case hexadecimal */ + flags |= FL_UPPER; + /* fall through */ + case 'x': /* Hexadecimal */ + base = 16; + goto is_unsigned; + + is_unsigned: + switch (rank) { + case rank_char: + val = (uintmax_t) + (unsigned char) + va_arg(ap, unsigned + int); + break; + case rank_short: + val = (uintmax_t) + (unsigned short) + va_arg(ap, unsigned + int); + break; + case rank_int: + val = (uintmax_t) + va_arg(ap, unsigned + int); + break; + case rank_long: + val = (uintmax_t) + va_arg(ap, unsigned + long); + break; + case rank_longlong: + val = (uintmax_t) + va_arg(ap, unsigned + long long); + break; + } + /* fall through */ + + is_integer: + sz = format_int(q, (o < n) ? n - o : 0, + val, flags, base, + width, prec); + q += sz; + o += sz; + break; + + case 'c': /* Character */ + carg = (char)va_arg(ap, int); + sarg = &carg; + slen = 1; + goto is_string; + case 's': /* String */ + sarg = va_arg(ap, const char *); + sarg = sarg ? sarg : "(null)"; + slen = strlen(sarg); + goto is_string; + + is_string: + { + char sch; + int i; + + if (prec != -1 && slen > prec) + slen = prec; + + if (width > slen + && !(flags & FL_MINUS)) { + char pad = + (flags & FL_ZERO) ? + '0' : ' '; + while (width > slen) { + EMIT(pad); + width--; + } + } + for (i = slen; i; i--) { + sch = *sarg++; + EMIT(sch); + } + if (width > slen + && (flags & FL_MINUS)) { + while (width > slen) { + EMIT(' '); + width--; + } + } + } + break; + + case 'n': + { + /* Output the number of + characters written */ + + switch (rank) { + case rank_char: + *va_arg(ap, + signed char *) + = o; + break; + case rank_short: + *va_arg(ap, + signed short *) + = o; + break; + case rank_int: + *va_arg(ap, + signed int *) + = o; + break; + case rank_long: + *va_arg(ap, + signed long *) + = o; + break; + case rank_longlong: + *va_arg(ap, + signed long long *) + = o; + break; + } + } + break; + + default: /* Anything else, including % */ + EMIT(ch); + break; + } + } + } + } + + /* Null-terminate the string */ + if (o < n) + *q = '\0'; /* No overflow */ + else if (n > 0) + buffer[n - 1] = '\0'; /* Overflow - terminate at end of buffer */ + + return o; +} Index: trunk/i386/modules/klibc/strtoimax.c =================================================================== --- trunk/i386/modules/klibc/strtoimax.c (revision 0) +++ trunk/i386/modules/klibc/strtoimax.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE intmax_t +#define NAME strtoimax +#include "strtox.c" Index: trunk/i386/modules/klibc/atexit.c =================================================================== --- trunk/i386/modules/klibc/atexit.c (revision 0) +++ trunk/i386/modules/klibc/atexit.c (revision 777) @@ -0,0 +1,16 @@ +/* + * atexit.c + */ + +#include + +int atexit(void (*fctn) (void)) +{ + return 0; +} + +int __cxa_atexit(void (*fctn) (void)) +{ + return 0; + //return on_exit((void (*)(int, void *))fctn, NULL); +} Index: trunk/i386/modules/klibc/atol.c =================================================================== --- trunk/i386/modules/klibc/atol.c (revision 0) +++ trunk/i386/modules/klibc/atol.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE long +#define NAME atol +#include "atox.c" Index: trunk/i386/modules/klibc/vsscanf.c =================================================================== --- trunk/i386/modules/klibc/vsscanf.c (revision 0) +++ trunk/i386/modules/klibc/vsscanf.c (revision 777) @@ -0,0 +1,395 @@ +/* + * vsscanf.c + * + * vsscanf(), from which the rest of the scanf() + * family is built + */ + +#include "libsaio.h" +#include "limits.h" +extern uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n); + +#ifndef LONG_BIT +#define LONG_BIT (CHAR_BIT*sizeof(long)) +#endif + +enum flags { + FL_SPLAT = 0x01, /* Drop the value, do not assign */ + FL_INV = 0x02, /* Character-set with inverse */ + FL_WIDTH = 0x04, /* Field width specified */ + FL_MINUS = 0x08, /* Negative number */ +}; + +enum ranks { + rank_char = -2, + rank_short = -1, + rank_int = 0, + rank_long = 1, + rank_longlong = 2, + rank_ptr = INT_MAX /* Special value used for pointers */ +}; + +#define MIN_RANK rank_char +#define MAX_RANK rank_longlong + +#define INTMAX_RANK rank_longlong +#define SIZE_T_RANK rank_long +#define PTRDIFF_T_RANK rank_long + +enum bail { + bail_none = 0, /* No error condition */ + bail_eof, /* Hit EOF */ + bail_err /* Conversion mismatch */ +}; + +static inline const char *skipspace(const char *p) +{ + while (isspace((unsigned char)*p)) + p++; + return p; +} + +#undef set_bit +static inline void set_bit(unsigned long *bitmap, unsigned int bit) +{ + bitmap[bit / LONG_BIT] |= 1UL << (bit % LONG_BIT); +} + +#undef test_bit +static inline int test_bit(unsigned long *bitmap, unsigned int bit) +{ + return (int)(bitmap[bit / LONG_BIT] >> (bit % LONG_BIT)) & 1; +} + +int vsscanf(const char *buffer, const char *format, va_list ap) +{ + const char *p = format; + char ch; + unsigned char uc; + const char *q = buffer; + const char *qq; + uintmax_t val = 0; + int rank = rank_int; /* Default rank */ + unsigned int width = UINT_MAX; + int base; + enum flags flags = 0; + enum { + st_normal, /* Ground state */ + st_flags, /* Special flags */ + st_width, /* Field width */ + st_modifiers, /* Length or conversion modifiers */ + st_match_init, /* Initial state of %[ sequence */ + st_match, /* Main state of %[ sequence */ + st_match_range, /* After - in a %[ sequence */ + } state = st_normal; + char *sarg = NULL; /* %s %c or %[ string argument */ + enum bail bail = bail_none; + int sign; + int converted = 0; /* Successful conversions */ + unsigned long matchmap[((1 << CHAR_BIT) + (LONG_BIT - 1)) / LONG_BIT]; + int matchinv = 0; /* Is match map inverted? */ + unsigned char range_start = 0; + + while ((ch = *p++) && !bail) { + switch (state) { + case st_normal: + if (ch == '%') { + state = st_flags; + flags = 0; + rank = rank_int; + width = UINT_MAX; + } else if (isspace((unsigned char)ch)) { + q = skipspace(q); + } else { + if (*q == ch) + q++; + else + bail = bail_err; /* Match failure */ + } + break; + + case st_flags: + switch (ch) { + case '*': + flags |= FL_SPLAT; + break; + case '0'...'9': + width = (ch - '0'); + state = st_width; + flags |= FL_WIDTH; + break; + default: + state = st_modifiers; + p--; /* Process this character again */ + break; + } + break; + + case st_width: + if (ch >= '0' && ch <= '9') { + width = width * 10 + (ch - '0'); + } else { + state = st_modifiers; + p--; /* Process this character again */ + } + break; + + case st_modifiers: + switch (ch) { + /* Length modifiers - nonterminal sequences */ + case 'h': + rank--; /* Shorter rank */ + break; + case 'l': + rank++; /* Longer rank */ + break; + case 'j': + rank = INTMAX_RANK; + break; + case 'z': + rank = SIZE_T_RANK; + break; + case 't': + rank = PTRDIFF_T_RANK; + break; + case 'L': + case 'q': + rank = rank_longlong; /* long double/long long */ + break; + + default: + /* Output modifiers - terminal sequences */ + /* Next state will be normal */ + state = st_normal; + + /* Canonicalize rank */ + if (rank < MIN_RANK) + rank = MIN_RANK; + else if (rank > MAX_RANK) + rank = MAX_RANK; + + switch (ch) { + case 'P': /* Upper case pointer */ + case 'p': /* Pointer */ + rank = rank_ptr; + base = 0; + sign = 0; + goto scan_int; + + case 'i': /* Base-independent integer */ + base = 0; + sign = 1; + goto scan_int; + + case 'd': /* Decimal integer */ + base = 10; + sign = 1; + goto scan_int; + + case 'o': /* Octal integer */ + base = 8; + sign = 0; + goto scan_int; + + case 'u': /* Unsigned decimal integer */ + base = 10; + sign = 0; + goto scan_int; + + case 'x': /* Hexadecimal integer */ + case 'X': + base = 16; + sign = 0; + goto scan_int; + + case 'n': /* # of characters consumed */ + val = (q - buffer); + goto set_integer; + + scan_int: + q = skipspace(q); + if (!*q) { + bail = bail_eof; + break; + } + val = + strntoumax(q, (char **)&qq, base, + width); + if (qq == q) { + bail = bail_err; + break; + } + q = qq; + if (!(flags & FL_SPLAT)) + converted++; + /* fall through */ + + set_integer: + if (!(flags & FL_SPLAT)) { + switch (rank) { + case rank_char: + *va_arg(ap, + unsigned char *) + = val; + break; + case rank_short: + *va_arg(ap, + unsigned short + *) = val; + break; + case rank_int: + *va_arg(ap, + unsigned int *) + = val; + break; + case rank_long: + *va_arg(ap, + unsigned long *) + = val; + break; + case rank_longlong: + *va_arg(ap, + unsigned long + long *) = val; + break; + case rank_ptr: + *va_arg(ap, void **) = + (void *) + (uintptr_t)val; + break; + } + } + break; + + case 'c': /* Character */ + /* Default width == 1 */ + width = (flags & FL_WIDTH) ? width : 1; + if (flags & FL_SPLAT) { + while (width--) { + if (!*q) { + bail = bail_eof; + break; + } + } + } else { + sarg = va_arg(ap, char *); + while (width--) { + if (!*q) { + bail = bail_eof; + break; + } + *sarg++ = *q++; + } + if (!bail) + converted++; + } + break; + + case 's': /* String */ + uc = 1; /* Anything nonzero */ + if (flags & FL_SPLAT) { + while (width-- && (uc = *q) && + !isspace(uc)) { + q++; + } + } else { + char *sp; + sp = sarg = va_arg(ap, char *); + while (width-- && (uc = *q) && + !isspace(uc)) { + *sp++ = uc; + q++; + } + if (sarg != sp) { + /* Terminate output */ + *sp = '\0'; + converted++; + } + } + if (!uc) + bail = bail_eof; + break; + + case '[': /* Character range */ + sarg = (flags & FL_SPLAT) ? NULL + : va_arg(ap, char *); + state = st_match_init; + matchinv = 0; + memset(matchmap, 0, sizeof matchmap); + break; + + case '%': /* %% sequence */ + if (*q == '%') + q++; + else + bail = bail_err; + break; + + default: /* Anything else */ + /* Unknown sequence */ + bail = bail_err; + break; + } + } + break; + + case st_match_init: /* Initial state for %[ match */ + if (ch == '^' && !(flags & FL_INV)) { + matchinv = 1; + } else { + set_bit(matchmap, (unsigned char)ch); + state = st_match; + } + break; + + case st_match: /* Main state for %[ match */ + if (ch == ']') { + goto match_run; + } else if (ch == '-') { + range_start = (unsigned char)ch; + state = st_match_range; + } else { + set_bit(matchmap, (unsigned char)ch); + } + break; + + case st_match_range: /* %[ match after - */ + if (ch == ']') { + /* - was last character */ + set_bit(matchmap, (unsigned char)'-'); + goto match_run; + } else { + int i; + for (i = range_start; i < (unsigned char)ch; + i++) + set_bit(matchmap, i); + state = st_match; + } + break; + + match_run: /* Match expression finished */ + qq = q; + uc = 1; /* Anything nonzero */ + while (width && (uc = *q) + && test_bit(matchmap, uc)^matchinv) { + if (sarg) + *sarg++ = uc; + q++; + } + if (q != qq && sarg) { + *sarg = '\0'; + converted++; + } else { + bail = bail_err; + } + if (!uc) + bail = bail_eof; + break; + } + } + + if (bail == bail_eof && !converted) + converted = -1; /* Return EOF (-1) */ + + return converted; +} Index: trunk/i386/modules/klibc/atexit.h =================================================================== --- trunk/i386/modules/klibc/atexit.h (revision 0) +++ trunk/i386/modules/klibc/atexit.h (revision 777) @@ -0,0 +1,18 @@ +/* + * atexit.h + * + * atexit()/on_exit() internal definitions + */ + +#ifndef ATEXIT_H +#define ATEXIT_H + +struct atexit { + void (*fctn) (int, void *); + void *arg; /* on_exit() parameter */ + struct atexit *next; +}; + +extern struct atexit *__atexit_list; + +#endif /* ATEXIT_H */ Index: trunk/i386/modules/klibc/snprintf.c =================================================================== --- trunk/i386/modules/klibc/snprintf.c (revision 0) +++ trunk/i386/modules/klibc/snprintf.c (revision 777) @@ -0,0 +1,17 @@ +/* + * snprintf.c + */ + +#include "libsaio.h" +extern int vsnprintf(char *buffer, size_t n, const char *format, va_list ap); + +int snprintf(char *buffer, size_t n, const char *format, ...) +{ + va_list ap; + int rv; + + va_start(ap, format); + rv = vsnprintf(buffer, n, format, ap); + va_end(ap); + return rv; +} Index: trunk/i386/modules/klibc/strtoumax.c =================================================================== --- trunk/i386/modules/klibc/strtoumax.c (revision 0) +++ trunk/i386/modules/klibc/strtoumax.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE uintmax_t +#define NAME strtoumax +#include "strtox.c" Index: trunk/i386/modules/klibc/bsearch.c =================================================================== --- trunk/i386/modules/klibc/bsearch.c (revision 0) +++ trunk/i386/modules/klibc/bsearch.c (revision 777) @@ -0,0 +1,26 @@ +/* + * bsearch.c + */ + +#include + +void *bsearch(const void *key, const void *base, size_t nmemb, + size_t size, int (*cmp) (const void *, const void *)) +{ + while (nmemb) { + size_t mididx = nmemb / 2; + const void *midobj = base + mididx * size; + int diff = cmp(key, midobj); + + if (diff == 0) + return (void *)midobj; + + if (diff > 0) { + base = midobj + size; + nmemb -= mididx + 1; + } else + nmemb = mididx; + } + + return NULL; +} Index: trunk/i386/modules/klibc/strntoimax.c =================================================================== --- trunk/i386/modules/klibc/strntoimax.c (revision 0) +++ trunk/i386/modules/klibc/strntoimax.c (revision 777) @@ -0,0 +1,15 @@ +/* + * strntoimax.c + * + * strntoimax() + */ + +#include +#include + +extern uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n); + +intmax_t strntoimax(const char *nptr, char **endptr, int base, size_t n) +{ + return (intmax_t) strntoumax(nptr, endptr, base, n); +} Index: trunk/i386/modules/klibc/atox.c =================================================================== --- trunk/i386/modules/klibc/atox.c (revision 0) +++ trunk/i386/modules/klibc/atox.c (revision 777) @@ -0,0 +1,16 @@ +/* + * atox.c + * + * atoi(), atol(), atoll() + */ + +#include +#include +#include + +extern uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n); + +TYPE NAME(const char *nptr) +{ + return (TYPE) strntoumax(nptr, (char **)NULL, 10, ~(size_t) 0); +} Index: trunk/i386/modules/klibc/strtoul.c =================================================================== --- trunk/i386/modules/klibc/strtoul.c (revision 0) +++ trunk/i386/modules/klibc/strtoul.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE unsigned long +#define NAME strtoul +#include "strtox.c" Index: trunk/i386/modules/klibc/sscanf.c =================================================================== --- trunk/i386/modules/klibc/sscanf.c (revision 0) +++ trunk/i386/modules/klibc/sscanf.c (revision 777) @@ -0,0 +1,17 @@ +/* + * sscanf() + */ + +#include "libsaio.h" +extern int vsscanf(const char *buffer, const char *format, va_list ap); +int sscanf(const char *str, const char *format, ...) +{ + va_list ap; + int rv; + + va_start(ap, format); + rv = vsscanf(str, format, ap); + va_end(ap); + + return rv; +} Index: trunk/i386/modules/klibc/__divdi3.c =================================================================== --- trunk/i386/modules/klibc/__divdi3.c (revision 0) +++ trunk/i386/modules/klibc/__divdi3.c (revision 777) @@ -0,0 +1,29 @@ +/* + * arch/i386/libgcc/__divdi3.c + */ + +#include +#include + +extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); + +int64_t __divdi3(int64_t num, int64_t den) +{ + int minus = 0; + int64_t v; + + if (num < 0) { + num = -num; + minus = 1; + } + if (den < 0) { + den = -den; + minus ^= 1; + } + + v = __udivmoddi4(num, den, NULL); + if (minus) + v = -v; + + return v; +} Index: trunk/i386/modules/klibc/strncasecmp.c =================================================================== --- trunk/i386/modules/klibc/strncasecmp.c (revision 0) +++ trunk/i386/modules/klibc/strncasecmp.c (revision 777) @@ -0,0 +1,24 @@ +/* + * strncasecmp.c + */ + +#include +#include + +int strncasecmp(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--) { + /* toupper() expects an unsigned char (implicitly cast to int) + as input, and returns an int, which is exactly what we want. */ + d = toupper(ch = *c1++) - toupper(*c2++); + if (d || !ch) + break; + } + + return d; +} Index: trunk/i386/modules/klibc/strntoumax.c =================================================================== --- trunk/i386/modules/klibc/strntoumax.c (revision 0) +++ trunk/i386/modules/klibc/strntoumax.c (revision 777) @@ -0,0 +1,73 @@ +/* + * strntoumax.c + * + * The strntoumax() function and associated + */ +#include "libsaio.h" + +static inline int digitval(int ch) +{ + if (ch >= '0' && ch <= '9') { + return ch - '0'; + } else if (ch >= 'A' && ch <= 'Z') { + return ch - 'A' + 10; + } else if (ch >= 'a' && ch <= 'z') { + return ch - 'a' + 10; + } else { + return -1; + } +} + +uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n) +{ + int minus = 0; + uintmax_t v = 0; + int d; + + while (n && isspace((unsigned char)*nptr)) { + nptr++; + n--; + } + + /* Single optional + or - */ + if (n) { + char c = *nptr; + if (c == '-' || c == '+') { + minus = (c == '-'); + nptr++; + n--; + } + } + + if (base == 0) { + if (n >= 2 && nptr[0] == '0' && + (nptr[1] == 'x' || nptr[1] == 'X')) { + n -= 2; + nptr += 2; + base = 16; + } else if (n >= 1 && nptr[0] == '0') { + n--; + nptr++; + base = 8; + } else { + base = 10; + } + } else if (base == 16) { + if (n >= 2 && nptr[0] == '0' && + (nptr[1] == 'x' || nptr[1] == 'X')) { + n -= 2; + nptr += 2; + } + } + + while (n && (d = digitval(*nptr)) >= 0 && d < base) { + v = v * base + d; + n--; + nptr++; + } + + if (endptr) + *endptr = (char *)nptr; + + return minus ? -v : v; +} Index: trunk/i386/modules/klibc/strpbrk.c =================================================================== --- trunk/i386/modules/klibc/strpbrk.c (revision 0) +++ trunk/i386/modules/klibc/strpbrk.c (revision 777) @@ -0,0 +1,14 @@ +/* + * strpbrk + */ + +#include + +#include "strxspn.h" + +char *strpbrk(const char *s, const char *accept) +{ + const char *ss = s + __strxspn(s, accept, 1); + + return *ss ? (char *)ss : NULL; +} Index: trunk/i386/modules/klibc/strtoull.c =================================================================== --- trunk/i386/modules/klibc/strtoull.c (revision 0) +++ trunk/i386/modules/klibc/strtoull.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE unsigned long long +#define NAME strtoull +#include "strtox.c" Index: trunk/i386/modules/klibc/__ashrdi3.c =================================================================== --- trunk/i386/modules/klibc/__ashrdi3.c (revision 0) +++ trunk/i386/modules/klibc/__ashrdi3.c (revision 777) @@ -0,0 +1,23 @@ +/* + * libgcc/__ashrdi3.c + */ + +#include +#include + +uint64_t __ashrdi3(uint64_t v, int cnt) +{ + int c = cnt & 31; + uint32_t vl = (uint32_t) v; + uint32_t vh = (uint32_t) (v >> 32); + + if (cnt & 32) { + vl = ((int32_t) vh >> c); + vh = (int32_t) vh >> 31; + } else { + vl = (vl >> c) + (vh << (32 - c)); + vh = ((int32_t) vh >> c); + } + + return ((uint64_t) vh << 32) + vl; +} Index: trunk/i386/modules/klibc/seed48.c =================================================================== --- trunk/i386/modules/klibc/seed48.c (revision 0) +++ trunk/i386/modules/klibc/seed48.c (revision 777) @@ -0,0 +1,16 @@ +/* + * seed48.c + */ + +#include "libsaio.h" + +unsigned short __rand48_seed[3]; + +unsigned short *seed48(const unsigned short xsubi[3]) +{ + static unsigned short oldseed[3]; + memcpy(oldseed, __rand48_seed, sizeof __rand48_seed); + memcpy(__rand48_seed, xsubi, sizeof __rand48_seed); + + return oldseed; +} Index: trunk/i386/modules/klibc/__divsi3.c =================================================================== --- trunk/i386/modules/klibc/__divsi3.c (revision 0) +++ trunk/i386/modules/klibc/__divsi3.c (revision 777) @@ -0,0 +1,29 @@ +/* + * libgcc/__divsi3.c + */ + +#include +#include + +extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); + +int32_t __divsi3(int32_t num, int32_t den) +{ + int minus = 0; + int32_t v; + + if (num < 0) { + num = -num; + minus = 1; + } + if (den < 0) { + den = -den; + minus ^= 1; + } + + v = __udivmodsi4(num, den, NULL); + if (minus) + v = -v; + + return v; +} Index: trunk/i386/modules/klibc/LICENSE =================================================================== --- trunk/i386/modules/klibc/LICENSE (revision 0) +++ trunk/i386/modules/klibc/LICENSE (revision 777) @@ -0,0 +1,73 @@ +This license applies to all files in directory and its subdirectories, +unless otherwise noted in individual files. + + +Some files are derived from files derived from the include/ directory +of the Linux kernel, and are licensed under the terms of the GNU +General Public License, version 2, as released by the Free Software +Foundation, Inc.; incorporated herein by reference. + + ----- + +Some files are derived from files copyrighted by the Regents of The +University of California, and are available under the following +license: + +Note: The advertising clause in the license appearing on BSD Unix +files was officially rescinded by the Director of the Office of +Technology Licensing of the University of California on July 22 +1999. He states that clause 3 is "hereby deleted in its entirety." + + * Copyright (c) + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + + ----- + +For all remaining files, the following license applies: + + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * Any copyright notice(s) and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Index: trunk/i386/modules/klibc/strtoll.c =================================================================== --- trunk/i386/modules/klibc/strtoll.c (revision 0) +++ trunk/i386/modules/klibc/strtoll.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE signed long long +#define NAME strtoll +#include "strtox.c" Index: trunk/i386/modules/klibc/version =================================================================== --- trunk/i386/modules/klibc/version (revision 0) +++ trunk/i386/modules/klibc/version (revision 777) @@ -0,0 +1 @@ +1.5.20 Index: trunk/i386/modules/klibc/__lshrdi3.c =================================================================== --- trunk/i386/modules/klibc/__lshrdi3.c (revision 0) +++ trunk/i386/modules/klibc/__lshrdi3.c (revision 777) @@ -0,0 +1,23 @@ +/* + * libgcc/__lshrdi3.c + */ + +#include +#include + +uint64_t __lshrdi3(uint64_t v, int cnt) +{ + int c = cnt & 31; + uint32_t vl = (uint32_t) v; + uint32_t vh = (uint32_t) (v >> 32); + + if (cnt & 32) { + vl = (vh >> c); + vh = 0; + } else { + vl = (vl >> c) + (vh << (32 - c)); + vh = (vh >> c); + } + + return ((uint64_t) vh << 32) + vl; +} Index: trunk/i386/modules/klibc/__udivmoddi4.c =================================================================== --- trunk/i386/modules/klibc/__udivmoddi4.c (revision 0) +++ trunk/i386/modules/klibc/__udivmoddi4.c (revision 777) @@ -0,0 +1,33 @@ +#include "libsaio.h" + +extern void __divide_error(); + +uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem_p) +{ + uint64_t quot = 0, qbit = 1; + + if (den == 0) { + __divide_error(); + return 0; /* If trap returns... */ + } + + /* Left-justify denominator and count shift */ + while ((int64_t) den >= 0) { + den <<= 1; + qbit <<= 1; + } + + while (qbit) { + if (den <= num) { + num -= den; + quot += qbit; + } + den >>= 1; + qbit >>= 1; + } + + if (rem_p) + *rem_p = num; + + return quot; +} Index: trunk/i386/modules/klibc/strtok_r.c =================================================================== --- trunk/i386/modules/klibc/strtok_r.c (revision 0) +++ trunk/i386/modules/klibc/strtok_r.c (revision 777) @@ -0,0 +1,13 @@ +#include + +char *strtok_r(char *s, const char *delim, char **holder) +{ + if (s) + *holder = s; + + do { + s = strsep(holder, delim); + } while (s && !*s); + + return s; +} Index: trunk/i386/modules/klibc/qsort.c =================================================================== --- trunk/i386/modules/klibc/qsort.c (revision 0) +++ trunk/i386/modules/klibc/qsort.c (revision 777) @@ -0,0 +1,48 @@ +/* + * qsort.c + * + * This is actually combsort. It's an O(n log n) algorithm with + * simplicity/small code size being its main virtue. + */ + +#include +#include +#include + +extern void memswap(void *m1, void *m2, size_t n); + +static inline size_t newgap(size_t gap) +{ + gap = (gap * 10) / 13; + if (gap == 9 || gap == 10) + gap = 11; + + if (gap < 1) + gap = 1; + return gap; +} + +void qsort(void *base, size_t nmemb, size_t size, + int (*compar) (const void *, const void *)) +{ + size_t gap = nmemb; + size_t i, j; + char *p1, *p2; + int swapped; + + if (!nmemb) + return; + + do { + gap = newgap(gap); + swapped = 0; + + for (i = 0, p1 = base; i < nmemb - gap; i++, p1 += size) { + j = i + gap; + if (compar(p1, p2 = (char *)base + j * size) > 0) { + memswap(p1, p2, size); + swapped = 1; + } + } + } while (gap > 1 || swapped); +} Index: trunk/i386/modules/klibc/__moddi3.c =================================================================== --- trunk/i386/modules/klibc/__moddi3.c (revision 0) +++ trunk/i386/modules/klibc/__moddi3.c (revision 777) @@ -0,0 +1,29 @@ +/* + * arch/i386/libgcc/__moddi3.c + */ + +#include +#include + +extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); + +int64_t __moddi3(int64_t num, int64_t den) +{ + int minus = 0; + int64_t v; + + if (num < 0) { + num = -num; + minus = 1; + } + if (den < 0) { + den = -den; + minus ^= 1; + } + + (void)__udivmoddi4(num, den, (uint64_t *) & v); + if (minus) + v = -v; + + return v; +} Index: trunk/i386/modules/klibc/strxspn.c =================================================================== --- trunk/i386/modules/klibc/strxspn.c (revision 0) +++ trunk/i386/modules/klibc/strxspn.c (revision 777) @@ -0,0 +1,30 @@ +/* + * strpbrk + */ + +#include +#include "libsaio.h" +#include "strxspn.h" + + + + +size_t __strxspn(const char *s, const char *map, int parity) +{ + char matchmap[UCHAR_MAX + 1]; + size_t n = 0; + + /* Create bitmap */ + memset(matchmap, 0, sizeof matchmap); + while (*map) + matchmap[(unsigned char)*map++] = 1; + + /* Make sure the null character never matches */ + matchmap[0] = parity; + + /* Calculate span length */ + while (matchmap[(unsigned char)*s++] ^ parity) + n++; + + return n; +} Index: trunk/i386/modules/klibc/strnlen.c =================================================================== --- trunk/i386/modules/klibc/strnlen.c (revision 0) +++ trunk/i386/modules/klibc/strnlen.c (revision 777) @@ -0,0 +1,18 @@ +/* + * strnlen() + */ + +#include + +size_t strnlen(const char *s, size_t maxlen) +{ + const char *ss = s; + + /* Important: the maxlen test must precede the reference through ss; + since the byte beyond the maximum may segfault */ + while ((maxlen > 0) && *ss) { + ss++; + maxlen--; + } + return ss - s; +} Index: trunk/i386/modules/klibc/__udivmodsi4.c =================================================================== --- trunk/i386/modules/klibc/__udivmodsi4.c (revision 0) +++ trunk/i386/modules/klibc/__udivmodsi4.c (revision 777) @@ -0,0 +1,31 @@ +#include "libsaio.h" +extern void __divide_error(); +uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem_p) +{ + uint32_t quot = 0, qbit = 1; + + if (den == 0) { + __divide_error(); + return 0; /* If trap returns... */ + } + + /* Left-justify denominator and count shift */ + while ((int32_t) den >= 0) { + den <<= 1; + qbit <<= 1; + } + + while (qbit) { + if (den <= num) { + num -= den; + quot += qbit; + } + den >>= 1; + qbit >>= 1; + } + + if (rem_p) + *rem_p = num; + + return quot; +} Index: trunk/i386/modules/klibc/strxspn.h =================================================================== --- trunk/i386/modules/klibc/strxspn.h (revision 0) +++ trunk/i386/modules/klibc/strxspn.h (revision 777) @@ -0,0 +1,12 @@ +/* + * strxspn.h + */ + +#ifndef STRXSPN_H +#define STRXSPN_H + +#include + +extern size_t __strxspn(const char *s, const char *map, int parity); + +#endif Index: trunk/i386/modules/klibc/strtol.c =================================================================== --- trunk/i386/modules/klibc/strtol.c (revision 0) +++ trunk/i386/modules/klibc/strtol.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE signed long +#define NAME strtol +#include "strtox.c" Index: trunk/i386/modules/klibc/__modsi3.c =================================================================== --- trunk/i386/modules/klibc/__modsi3.c (revision 0) +++ trunk/i386/modules/klibc/__modsi3.c (revision 777) @@ -0,0 +1,29 @@ +/* + * libgcc/__modsi3.c + */ + +#include +#include + +extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); + +int32_t __modsi3(int32_t num, int32_t den) +{ + int minus = 0; + int32_t v; + + if (num < 0) { + num = -num; + minus = 1; + } + if (den < 0) { + den = -den; + minus ^= 1; + } + + (void)__udivmodsi4(num, den, (uint32_t *) & v); + if (minus) + v = -v; + + return v; +} Index: trunk/i386/modules/klibc/atoi.c =================================================================== --- trunk/i386/modules/klibc/atoi.c (revision 0) +++ trunk/i386/modules/klibc/atoi.c (revision 777) @@ -0,0 +1,3 @@ +#define TYPE int +#define NAME atoi +#include "atox.c" Index: trunk/i386/modules/klibc/calloc.c =================================================================== --- trunk/i386/modules/klibc/calloc.c (revision 0) +++ trunk/i386/modules/klibc/calloc.c (revision 777) @@ -0,0 +1,18 @@ +/* + * calloc.c + */ + +#include "libsaio.h" +/* FIXME: This should look for multiplication overflow */ + +void *calloc(size_t nmemb, size_t size) +{ + void *ptr; + + size *= nmemb; + ptr = malloc(size); + if (ptr) + memset(ptr, 0, size); + + return ptr; +} Index: trunk/i386/modules/klibc/memccpy.c =================================================================== --- trunk/i386/modules/klibc/memccpy.c (revision 0) +++ trunk/i386/modules/klibc/memccpy.c (revision 777) @@ -0,0 +1,23 @@ +/* + * memccpy.c + * + * memccpy() + */ + +#include +#include + +void *memccpy(void *dst, const void *src, int c, size_t n) +{ + char *q = dst; + const char *p = src; + char ch; + + while (n--) { + *q++ = ch = *p++; + if (ch == (char)c) + return q; + } + + return NULL; /* No instance of "c" found */ +} Index: trunk/i386/modules/uClibc++/exception.cpp =================================================================== --- trunk/i386/modules/uClibc++/exception.cpp (revision 0) +++ trunk/i386/modules/uClibc++/exception.cpp (revision 777) @@ -0,0 +1,87 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#include +#include +#include +#include + +//We can't do this yet because gcc is too stupid to be able to handle +//different implementations of exception class. + +//#undef __UCLIBCXX_EXCEPTION_SUPPORT__ + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +namespace std{ + _UCXXEXPORT static const char * __std_exception_what_value = "exception"; + + //We are providing our own versions to be sneaky + + + _UCXXEXPORT exception::~exception() throw(){ + //Empty function + } + + _UCXXEXPORT const char* exception::what() const throw(){ + return __std_exception_what_value; + } + + _UCXXEXPORT bad_exception::~bad_exception() throw(){ + + } + +} +#else +namespace std{ + _UCXXEXPORT exception::~exception() { + abort(); + } + + _UCXXEXPORT const char* exception::what() const { + abort(); + } + + _UCXXEXPORT bad_exception::~bad_exception() { + abort(); + } + +} +#endif + +void +std::terminate() +{ +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + try + { +#endif // __UCLIBCXX_EXCEPTION_SUPPORT__ + (*std::terminate_handler())(); + // handler should not return + abort (); +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + } + catch (...) + { + // handler should not throw exception + abort (); + } +#endif // __UCLIBCXX_EXCEPTION_SUPPORT__ +} Index: trunk/i386/modules/uClibc++/locale.cpp =================================================================== --- trunk/i386/modules/uClibc++/locale.cpp (revision 0) +++ trunk/i386/modules/uClibc++/locale.cpp (revision 777) @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include +#include + +namespace std{ + +} + Index: trunk/i386/modules/uClibc++/eh_globals.cpp =================================================================== --- trunk/i386/modules/uClibc++/eh_globals.cpp (revision 0) +++ trunk/i386/modules/uClibc++/eh_globals.cpp (revision 777) @@ -0,0 +1,44 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation, version 2.1 + of the License. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include + +//This is a system-specific header which does all of the error-handling management +#include + +//The following functionality is derived from reading of the GNU libstdc++ code and making it...simple + + +namespace __cxxabiv1{ +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +static __UCLIBCXX_TLS __cxa_eh_globals eh_globals; + +extern "C" __cxa_eh_globals* __cxa_get_globals() throw(){ + return &eh_globals; +} + +extern "C" __cxa_eh_globals* __cxa_get_globals_fast() throw(){ + return &eh_globals; +} +#endif + +} Index: trunk/i386/modules/uClibc++/numeric.cpp =================================================================== --- trunk/i386/modules/uClibc++/numeric.cpp (revision 0) +++ trunk/i386/modules/uClibc++/numeric.cpp (revision 777) @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +namespace std{ + + +} + + Index: trunk/i386/modules/uClibc++/vector.cpp =================================================================== --- trunk/i386/modules/uClibc++/vector.cpp (revision 0) +++ trunk/i386/modules/uClibc++/vector.cpp (revision 777) @@ -0,0 +1,83 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_VECTOR__ 1 + + +#include + +namespace std{ + + +#ifdef __UCLIBCXX_EXPAND_VECTOR_BASIC__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT vector >::vector(const allocator& al); + template _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); + + template _UCXXEXPORT vector >::~vector(); + template _UCXXEXPORT vector >::~vector(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::reserve(size_type n); + + template _UCXXEXPORT void vector >::resize(size_type sz, const char & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const unsigned char & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const short & c); + template _UCXXEXPORT void vector > + ::resize(size_type sz, const unsigned short int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const unsigned int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const long int & c); + template _UCXXEXPORT void vector >:: + resize(size_type sz, const unsigned long int & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const float & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const double & c); + template _UCXXEXPORT void vector >::resize(size_type sz, const bool & c); + +#elif defined __UCLIBCXX_EXPAND_STRING_CHAR__ + + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + template _UCXXEXPORT vector >::vector(const allocator& al); + template _UCXXEXPORT vector >::vector(size_type n, const char & value, const allocator & al); + template _UCXXEXPORT vector >::~vector(); +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT void vector >::reserve(size_type n); + template _UCXXEXPORT void vector >::resize(size_type sz, const char & c); + +#endif + + + + +} Index: trunk/i386/modules/uClibc++/stdexcept.cpp =================================================================== --- trunk/i386/modules/uClibc++/stdexcept.cpp (revision 0) +++ trunk/i386/modules/uClibc++/stdexcept.cpp (revision 777) @@ -0,0 +1,63 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +namespace std{ + + _UCXXEXPORT logic_error::logic_error() throw() : mstring(){ + + } + + _UCXXEXPORT logic_error::logic_error(const string& what_arg) : mstring(what_arg){ + + } + + _UCXXEXPORT const char * logic_error::what() const throw(){ + return mstring.c_str(); + } + + + _UCXXEXPORT out_of_range::out_of_range() : logic_error(){ + + } + + _UCXXEXPORT out_of_range::out_of_range(const string & what_arg) : logic_error(what_arg) { + + } + + _UCXXEXPORT runtime_error::runtime_error() : mstring(){ + + } + + _UCXXEXPORT runtime_error::runtime_error(const string& what_arg) : mstring(what_arg){ + + } + + _UCXXEXPORT const char * runtime_error::what() const throw(){ + return mstring.c_str(); + } + +} + +#endif + Index: trunk/i386/modules/uClibc++/utility.cpp =================================================================== --- trunk/i386/modules/uClibc++/utility.cpp (revision 0) +++ trunk/i386/modules/uClibc++/utility.cpp (revision 777) @@ -0,0 +1,30 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + + +#include + + +namespace std{ + + + +} + + Index: trunk/i386/modules/uClibc++/list.cpp =================================================================== --- trunk/i386/modules/uClibc++/list.cpp (revision 0) +++ trunk/i386/modules/uClibc++/list.cpp (revision 777) @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +namespace std{ + + + + +} + + Index: trunk/i386/modules/uClibc++/map.cpp =================================================================== --- trunk/i386/modules/uClibc++/map.cpp (revision 0) +++ trunk/i386/modules/uClibc++/map.cpp (revision 777) @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#include + +namespace std{ + + + + + + + + + + +} Index: trunk/i386/modules/uClibc++/new_opvnt.cpp =================================================================== --- trunk/i386/modules/uClibc++/new_opvnt.cpp (revision 0) +++ trunk/i386/modules/uClibc++/new_opvnt.cpp (revision 777) @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +#include +#include +#include +extern "C" { +#include "libsaio.h" +}; +#ifndef NO_NOTHROW +_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) throw(){ + return malloc(numBytes); +} +#endif Index: trunk/i386/modules/uClibc++/queue.cpp =================================================================== --- trunk/i386/modules/uClibc++/queue.cpp (revision 0) +++ trunk/i386/modules/uClibc++/queue.cpp (revision 777) @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + + +namespace std{ + + + + +} Index: trunk/i386/modules/uClibc++/streambuf.cpp =================================================================== --- trunk/i386/modules/uClibc++/streambuf.cpp (revision 0) +++ trunk/i386/modules/uClibc++/streambuf.cpp (revision 777) @@ -0,0 +1,49 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_STREAMBUF__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT streambuf::basic_streambuf(); + template _UCXXEXPORT streambuf::~basic_streambuf(); + +#endif + + template _UCXXEXPORT locale streambuf::pubimbue(const locale &loc); + template _UCXXEXPORT streamsize streambuf::in_avail(); + template _UCXXEXPORT streambuf::int_type streambuf::sbumpc(); + template _UCXXEXPORT streambuf::int_type streambuf::snextc(); + template _UCXXEXPORT streambuf::int_type streambuf::sgetc(); + template _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c); + template _UCXXEXPORT streambuf::int_type streambuf::sungetc(); + template _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c); + +#endif + + +} + + Index: trunk/i386/modules/uClibc++/iterator.cpp =================================================================== --- trunk/i386/modules/uClibc++/iterator.cpp (revision 0) +++ trunk/i386/modules/uClibc++/iterator.cpp (revision 777) @@ -0,0 +1,28 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +namespace std{ + + + +} + + Index: trunk/i386/modules/uClibc++/new_opnt.cpp =================================================================== --- trunk/i386/modules/uClibc++/new_opnt.cpp (revision 0) +++ trunk/i386/modules/uClibc++/new_opnt.cpp (revision 777) @@ -0,0 +1,31 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +#include +#include +#include +extern "C" { +#include "libsaio.h" +}; +#ifndef NO_NOTHROW +_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) throw(){ + return malloc(numBytes); +} +#endif Index: trunk/i386/modules/uClibc++/ios.cpp =================================================================== --- trunk/i386/modules/uClibc++/ios.cpp (revision 0) +++ trunk/i386/modules/uClibc++/ios.cpp (revision 777) @@ -0,0 +1,189 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_IOS__ 1 + +#include +#include +#include +#include +#include + +namespace std{ + + +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + _UCXXLOCAL int ios_base::Init::init_cnt = 0; //Needed to ensure the static value is created + +//Create buffers first +#if __UCLIBCXX_SUPPORT_COUT__ + _UCXXEXPORT filebuf _cout_filebuf; +#endif +#if __UCLIBCXX_SUPPORT_CIN__ + _UCXXEXPORT filebuf _cin_filebuf; +#endif +#if __UCLIBCXX_SUPPORT_CERR__ + _UCXXEXPORT filebuf _cerr_filebuf; +#endif +#if __UCLIBCXX_SUPPORT_CLOG__ + _UCXXEXPORT filebuf _clog_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + _UCXXEXPORT wfilebuf _wcout_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + _UCXXEXPORT wfilebuf _wcin_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + _UCXXEXPORT wfilebuf _wcerr_filebuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + _UCXXEXPORT wfilebuf _wclog_filebuf; +#endif + +//Then create streams +#if __UCLIBCXX_SUPPORT_COUT__ + _UCXXEXPORT ostream cout(&_cout_filebuf); +#endif +#if __UCLIBCXX_SUPPORT_CIN__ + _UCXXEXPORT istream cin(&_cin_filebuf); +#endif +#if __UCLIBCXX_SUPPORT_CERR__ + _UCXXEXPORT ostream cerr(&_cerr_filebuf); +#endif +#if __UCLIBCXX_SUPPORT_CLOG__ + _UCXXEXPORT ostream clog(&_clog_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + _UCXXEXPORT wostream wcout(&_wcout_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + _UCXXEXPORT wistream wcin(&_wcin_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + _UCXXEXPORT wostream wcerr(&_wcerr_filebuf); +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + _UCXXEXPORT wostream wclog(&_wclog_filebuf); +#endif + + + _UCXXEXPORT ios_base::Init::Init(){ + if(init_cnt == 0){ //Need to construct cout et al +#if __UCLIBCXX_SUPPORT_COUT__ + _cout_filebuf.fp = stdout; + _cout_filebuf.openedFor = ios_base::out; +#endif +#if __UCLIBCXX_SUPPORT_CERR__ + _cerr_filebuf.fp = stderr; + _cerr_filebuf.openedFor = ios_base::out; + cerr.mformat |= ios_base::unitbuf; +#endif +#if __UCLIBCXX_SUPPORT_CLOG__ + _clog_filebuf.fp = stderr; + _clog_filebuf.openedFor = ios_base::out; +#endif +#if __UCLIBCXX_SUPPORT_CIN__ + _cin_filebuf.fp = stdin; + _cin_filebuf.openedFor = ios_base::in; + +#if __UCLIBCXX_SUPPORT_COUT__ + cin.tie(&cout); +#endif + +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + _wcout_filebuf.fp = stdout; + _wcout_filebuf.openedFor = ios_base::out; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + _wcerr_filebuf.fp = stderr; + _wcerr_filebuf.openedFor = ios_base::out; + wcerr.mformat |= ios_base::unitbuf; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + _wclog_filebuf.fp = stderr; + _wclog_filebuf.openedFor = ios_base::out; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + _wcin_filebuf.fp = stdin; + _wcin_filebuf.openedFor = ios_base::in; + +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + wcin.tie(&wcout); +#endif + +#endif + } + init_cnt++; + } + + _UCXXEXPORT ios_base::Init::~Init(){ + --init_cnt; + if(init_cnt==0){ + + } + } +#endif + + +#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ + + template _UCXXEXPORT void basic_ios >::clear(iostate state); + template _UCXXEXPORT void basic_ios >::setstate(iostate state); + +#endif + + + _UCXXEXPORT ios_base::fmtflags ios_base::flags(fmtflags fmtfl){ + fmtflags temp = mformat; + mformat = fmtfl; + return temp; + } + + _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl){ + return flags(flags() | fmtfl); + } + + _UCXXEXPORT ios_base::fmtflags ios_base::setf(fmtflags fmtfl, fmtflags mask ){ + return flags( (flags()& ~mask) | (fmtfl & mask)); + } + + _UCXXEXPORT streamsize ios_base::precision(streamsize prec){ + streamsize temp = mprecision; + mprecision = prec; + return temp; + } + + _UCXXEXPORT streamsize ios_base::width(streamsize wide){ + streamsize temp = mwidth; + mwidth = wide; + return temp; + } + + _UCXXEXPORT locale ios_base::imbue(const locale& loc){ + locale retval = mLocale; + mLocale = loc; + return retval; + } + +} + + + Index: trunk/i386/modules/uClibc++/set.cpp =================================================================== --- trunk/i386/modules/uClibc++/set.cpp (revision 0) +++ trunk/i386/modules/uClibc++/set.cpp (revision 777) @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#include + +namespace std{ + + + + + + + + + + +} Index: trunk/i386/modules/uClibc++/Makefile =================================================================== --- trunk/i386/modules/uClibc++/Makefile (revision 0) +++ trunk/i386/modules/uClibc++/Makefile (revision 777) @@ -0,0 +1,58 @@ + +MODULE_NAME = uClibc++ +MODULE_VERSION = "0.2.2" +MODULE_COMPAT_VERSION = "0.2.2" +MODULE_START = _uClibcxx_start +MODULE_DEPENDENCIES = klibc + +DIR = uClibc++ +# sstream.o fstream.o +MODULE_OBJS = uClibc++.o abi.o algorithm.o associative_base.o bitset.o \ + complex.o del_op.o del_opnt.o del_opv.o del_opvnt.o \ + deque.o eh_alloc.o eh_globals.o exception.o \ + func_exception.o iomanip.o char_traits.o \ + iterator.o limits.o list.o locale.o \ + map.o new_handler.o new_op.o new_opnt.o new_opv.o \ + new_opvnt.o numeric.o queue.o set.o \ + stack.o stdexcept.o streambuf.o string.o typeinfo.o \ + utility.o valarray.o vector.o support.o \ + ios.o iostream.o istream.o ostream.o + +OPTIM = -Os -Oz +DEBUG = -DNOTHING +#DEBUG = -DDEBUG_HELLO_WORLD=1 +CFLAGS = $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \ + -D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \ + -DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \ + -fno-builtin $(OMIT_FRAME_POINTER_CFLAG) \ + -mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \ + -march=pentium4 -msse2 -mfpmath=sse -msoft-float -fno-common + +DEFINES= +CONFIG = hd +INC = -I. -I.. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(BOOT2DIR) -Iinclude +ifneq "" "$(wildcard /bin/mkdirs)" + MKDIRS = /bin/mkdirs +else + MKDIRS = /bin/mkdir -p +endif +AS = as +LD = ld +# LIBS= -lc_static +LIBS= + +VPATH = $(OBJROOT):$(SYMROOT) + +SFILES = +CFILES = +HFILES = +EXPORTED_HFILES = +INSTALLED_HFILES = +OTHERFILES = Makefile +ALLSRC = $(SFILES) $(CFILES) \ + $(HFILES) $(OTHERFILES) +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) + +all embedtheme optionrom: dylib + +include ../MakeInc.dir \ No newline at end of file Index: trunk/i386/modules/uClibc++/fstream.cpp =================================================================== --- trunk/i386/modules/uClibc++/fstream.cpp (revision 0) +++ trunk/i386/modules/uClibc++/fstream.cpp (revision 777) @@ -0,0 +1,174 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_FSTREAM__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT filebuf::basic_filebuf(); + template _UCXXEXPORT filebuf::~basic_filebuf(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT filebuf::int_type filebuf::pbackfail(filebuf::int_type c); + template _UCXXEXPORT filebuf * filebuf::open(const char* s, ios_base::openmode mode); + template _UCXXEXPORT filebuf * filebuf::close(); + template _UCXXEXPORT filebuf::int_type filebuf::overflow(filebuf::int_type); + template _UCXXEXPORT filebuf::int_type filebuf::underflow (); + template _UCXXEXPORT streamsize filebuf::xsputn(const char* s, streamsize n); + + template _UCXXEXPORT basic_streambuf >* + filebuf::setbuf(char * s, streamsize n); + + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT basic_ofstream >::basic_ofstream(); + template _UCXXEXPORT basic_ofstream >::basic_ofstream(const char* s, ios_base::openmode mode); + template _UCXXEXPORT basic_ofstream >::~basic_ofstream(); + + template _UCXXEXPORT basic_ifstream >::basic_ifstream(); + template _UCXXEXPORT basic_ifstream >::basic_ifstream(const char* s, ios_base::openmode mode); + template _UCXXEXPORT basic_ifstream >::~basic_ifstream(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + +#endif + + + +#ifdef __UCLIBCXX_HAS_WCHAR__ + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::overflow(int_type c) +{ + typedef basic_streambuf > wstreambuf; + typedef char_traits wtraits; + + if(is_open() == false){ + //Can't do much + return wtraits::eof(); + } + + mbstate_t ps = { 0 }; + char out_array[8]; + size_t out_size; + + + if( wstreambuf::pbase() != 0 ){ + + //Write all possible character from the existing array first + size_t chars_written = 0; + while(wstreambuf::pbase() && (wstreambuf::pbase() + chars_written !=wstreambuf::pptr()) ){ + out_size = wcrtomb(out_array, wstreambuf::pbase()[chars_written], &ps); + if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){ + break; + } + ++chars_written; + } + + if( wstreambuf::pbase() + chars_written == wstreambuf::pptr() ){ + wstreambuf::pbump(-chars_written); + }else{ + //Shuffle data back into order + size_t chars_left = wstreambuf::pptr() - wstreambuf::pbase() - chars_written; + for(size_t i = 0; i < chars_left; ++i){ + wstreambuf::pbase()[i] = (wstreambuf::pptr() - chars_written)[i]; + } + return wtraits::eof(); + } + } + + if( !wtraits::eq_int_type(c, wtraits::eof()) ){ + out_size = wcrtomb(out_array, c, &ps); + if(out_size == (size_t)(-1) || fwrite(out_array, out_size, 1, fp) == 0){ + return wtraits::eof(); + } + return c; + } + + return wtraits::not_eof(c); +} + + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::underflow() +{ + /*Some variables used internally: + Buffer pointers: + + charT * mgbeg; + charT * mgnext; + charT * mgend; + + eback() returns mgbeg + gptr() returns mgnext + egptr() returns mgend + + gbump(int n) mgnext+=n + */ + + typedef char_traits traits; + typedef basic_streambuf wstreambuf; + + + if(wstreambuf::eback() == wstreambuf::gptr() && 0 != wstreambuf::eback()){ //Buffer is full + return traits::to_int_type(*wstreambuf::gptr()); + } + + size_t in_size; + + wchar_t c = 0; + wint_t wi = 0; + in_size = 0; + + wi = fgetwc(fp); + if(WEOF == wi){ + fprintf(stderr, "WEOF returned by fgetwc\n"); + return traits::eof(); + } + + c = traits::to_char_type(wi); + + if(wstreambuf::eback() == 0){ + return traits::to_int_type(c); + } + + for(wchar_t * i = wstreambuf::gptr(); i < wstreambuf::egptr(); ++i){ + *(i-1) = *i; + } + + *(wstreambuf::egptr()-1) = c; + + wstreambuf::mgnext -= 1; + + return traits::to_int_type(*wstreambuf::gptr()); +} + +#endif // __UCLIBCXX_HAS_WCHAR__ + + +} Index: trunk/i386/modules/uClibc++/limits.cpp =================================================================== --- trunk/i386/modules/uClibc++/limits.cpp (revision 0) +++ trunk/i386/modules/uClibc++/limits.cpp (revision 777) @@ -0,0 +1,25 @@ +/* Copyright (C) 2006 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#include + +namespace std{ + + +} Index: trunk/i386/modules/uClibc++/istream.cpp =================================================================== --- trunk/i386/modules/uClibc++/istream.cpp (revision 0) +++ trunk/i386/modules/uClibc++/istream.cpp (revision 777) @@ -0,0 +1,75 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#define __UCLIBCXX_COMPILE_ISTREAM__ 1 + +#include + + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + + template <> _UCXXEXPORT string _readToken >(istream & stream) + { + string temp; + char_traits::int_type c; + while(true){ + c = stream.rdbuf()->sgetc(); + if(c != char_traits::eof() && isspace(c) == false){ + stream.rdbuf()->sbumpc(); + temp.append(1, char_traits::to_char_type(c)); + }else{ + break; + } + } + if (temp.size() == 0) + stream.setstate(ios_base::eofbit|ios_base::failbit); + + return temp; + } + + template _UCXXEXPORT istream::int_type istream::get(); + template _UCXXEXPORT istream & istream::get(char &c); + + template _UCXXEXPORT istream & istream::operator>>(bool &n); + template _UCXXEXPORT istream & istream::operator>>(short &n); + template _UCXXEXPORT istream & istream::operator>>(unsigned short &n); + template _UCXXEXPORT istream & istream::operator>>(int &n); + template _UCXXEXPORT istream & istream::operator>>(unsigned int &n); + template _UCXXEXPORT istream & istream::operator>>(long unsigned &n); + template _UCXXEXPORT istream & istream::operator>>(long int &n); + template _UCXXEXPORT istream & istream::operator>>(void *& p); + template _UCXXEXPORT istream & operator>>(istream & is, char & c); + + +#ifdef __UCLIBCXX_HAS_FLOATS__ + template _UCXXEXPORT istream & istream::operator>>(float &f); + template _UCXXEXPORT istream & istream::operator>>(double &f); + template _UCXXEXPORT istream & istream::operator>>(long double &f); +#endif + + template _UCXXEXPORT void __skipws(basic_istream >& is); + +#endif + + +} + Index: trunk/i386/modules/uClibc++/stack.cpp =================================================================== --- trunk/i386/modules/uClibc++/stack.cpp (revision 0) +++ trunk/i386/modules/uClibc++/stack.cpp (revision 777) @@ -0,0 +1,27 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + + +namespace std{ + + + + +} Index: trunk/i386/modules/uClibc++/string.cpp =================================================================== --- trunk/i386/modules/uClibc++/string.cpp (revision 0) +++ trunk/i386/modules/uClibc++/string.cpp (revision 777) @@ -0,0 +1,112 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_STRING__ 1 + +#include +#include +#include +#include +#include +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT string::basic_string(const allocator &); + template _UCXXEXPORT string::basic_string(size_type n, char c, const allocator & ); + template _UCXXEXPORT string::basic_string(const char* s, const allocator& al); + template _UCXXEXPORT string::basic_string(const basic_string& str, size_type pos, size_type n, const allocator& al); + template _UCXXEXPORT string::~basic_string(); + +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT string & string::append(const char * s, size_type n); + + template _UCXXEXPORT string::size_type string::find(const string & str, size_type pos) const; + template _UCXXEXPORT string::size_type string::find(const char* s, size_type pos) const; + template _UCXXEXPORT string::size_type string::find (char c, size_type pos) const; + template _UCXXEXPORT string::size_type string::rfind(const string & str, size_type pos) const; + template _UCXXEXPORT string::size_type string::rfind(char c, size_type pos) const; + template _UCXXEXPORT string::size_type string::rfind(const char* s, size_type pos) const; + + template _UCXXEXPORT string::size_type string::find_first_of(const string &, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_of(const char *, size_type pos, size_type n) const; + template _UCXXEXPORT string::size_type string::find_first_of(const char*, size_type pos) const; + template _UCXXEXPORT string::size_type string::find_first_of(char c, size_type pos) const; + + template _UCXXEXPORT string::size_type string::find_last_of (const string & , size_type pos) const; + template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos, size_type n) const; + template _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos) const; + template _UCXXEXPORT string::size_type string::find_last_of (char c, size_type pos) const; + + template _UCXXEXPORT string::size_type string::find_first_not_of(const string &, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type) const; + template _UCXXEXPORT string::size_type string::find_first_not_of(char c, size_type) const; + + template _UCXXEXPORT int string::compare(const string & str) const; +// template _UCXXEXPORT int string::compare(size_type pos1, size_type n1, const string & str) const; + template _UCXXEXPORT int string::compare( + size_type pos1, size_type n1, const string & str, size_type pos2, size_type n2) const; + + template _UCXXEXPORT string string::substr(size_type pos, size_type n) const; + + template _UCXXEXPORT string & string::operator=(const string & str); + template _UCXXEXPORT string & string::operator=(const char * s); + + template _UCXXEXPORT bool operator==(const string & lhs, const string & rhs); + template _UCXXEXPORT bool operator==(const char * lhs, const string & rhs); + template _UCXXEXPORT bool operator==(const string & rhs, const char * rhs); + + template _UCXXEXPORT bool operator!=(const string & lhs, const string & rhs); + template _UCXXEXPORT bool operator!=(const char * lhs, const string & rhs); + template _UCXXEXPORT bool operator!=(const string & rhs, const char * rhs); + + template _UCXXEXPORT string operator+(const string & lhs, const char* rhs); + template _UCXXEXPORT string operator+(const char* lhs, const string & rhs); + template _UCXXEXPORT string operator+(const string & lhs, const string & rhs); + + template _UCXXEXPORT bool operator> (const string & lhs, const string & rhs); + template _UCXXEXPORT bool operator< (const string & lhs, const string & rhs); + + +//Functions dependent upon OSTREAM +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ + +template _UCXXEXPORT ostream & operator<<(ostream & os, const string & str); + +#endif + + +//Functions dependent upon ISTREAM +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + +template _UCXXEXPORT istream & operator>>(istream & is, string & str); + + +#endif + + +#endif + +} Index: trunk/i386/modules/uClibc++/ostream.cpp =================================================================== --- trunk/i386/modules/uClibc++/ostream.cpp (revision 0) +++ trunk/i386/modules/uClibc++/ostream.cpp (revision 777) @@ -0,0 +1,65 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_OSTREAM__ 1 + +#include + +namespace std{ + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + template _UCXXEXPORT ostream::~basic_ostream(); +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT ostream & ostream::flush(); + + template _UCXXEXPORT ostream & ostream::operator<<(bool n); + template _UCXXEXPORT ostream & ostream::operator<<(short int n); + template _UCXXEXPORT ostream & ostream::operator<<(unsigned short int n); + template _UCXXEXPORT ostream & ostream::operator<<(int n); + template _UCXXEXPORT ostream & ostream::operator<<(unsigned int n); + template _UCXXEXPORT ostream & ostream::operator<<(long n); + template _UCXXEXPORT ostream & ostream::operator<<(unsigned long n); + template _UCXXEXPORT ostream & ostream::operator<<(float f); + template _UCXXEXPORT ostream & ostream::operator<<(double f); + template _UCXXEXPORT ostream & ostream::operator<<(long double f); + template _UCXXEXPORT ostream & ostream::operator<<(void* p); + template _UCXXEXPORT ostream & ostream::operator<<(basic_streambuf >* sb); + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT ostream::sentry::sentry(ostream & os); + template _UCXXEXPORT ostream::sentry::~sentry(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT ostream & endl(ostream & os); + template _UCXXEXPORT ostream & flush(ostream & os); + template _UCXXEXPORT ostream & operator<<(ostream & out, char c); + template _UCXXEXPORT ostream & operator<<(ostream & out, const char* c); + template _UCXXEXPORT ostream & operator<<(ostream & out, unsigned char c); + template _UCXXEXPORT ostream & operator<<(ostream & out, const unsigned char* c); + +#endif + + +} Index: trunk/i386/modules/uClibc++/support.cpp =================================================================== --- trunk/i386/modules/uClibc++/support.cpp (revision 0) +++ trunk/i386/modules/uClibc++/support.cpp (revision 777) @@ -0,0 +1,54 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +extern "C" void *__cxa_allocate_exception(size_t thrown_size) +{ + void * retval; + + /*The amount of data needed is the size of the object *PLUS* + the size of the header. The header is of struct __cxa_exception + The address needs to be adjusted because the pointer we return + should not point to the start of the memory, but to the point + where the object being thrown actually starts*/ + + retval = malloc(thrown_size + sizeof(__cxa_exception)); + +// Check to see that we actuall allocated memory + if(retval == 0){ + std::terminate(); + } + + //Need to do a typecast to char* otherwize we are doing math with + //a void* which makes the compiler cranky (Like me) + return ((char *)retval + sizeof(__cxa_exception)); +} + +extern "C" void __cxa_free_exception(void *thrown_exception){ + + + +} + +extern "C" void __cxa_throw (void *thrown_exception, std::type_info *tinfo,void (*dest) (void *) ){ + +} +#endif + Index: trunk/i386/modules/uClibc++/new_opv.cpp =================================================================== --- trunk/i386/modules/uClibc++/new_opv.cpp (revision 0) +++ trunk/i386/modules/uClibc++/new_opv.cpp (revision 777) @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +#include +#include +#include +extern "C" { +#include "libsaio.h" +}; +_UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc){ + //C++ stardard 5.3.4.8 requires that a valid pointer be returned for + //a call to new(0). Thus: + if(numBytes == 0){ + numBytes = 1; + } + void * p = malloc(numBytes); + if(p == 0){ + std::__throw_bad_alloc(); + } + return p; +} Index: trunk/i386/modules/uClibc++/sstream.cpp =================================================================== --- trunk/i386/modules/uClibc++/sstream.cpp (revision 0) +++ trunk/i386/modules/uClibc++/sstream.cpp (revision 777) @@ -0,0 +1,59 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_SSTREAM__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__ + + typedef char_traits tr_ch; + typedef basic_stringbuf > char_stringbuf; + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT char_stringbuf::basic_stringbuf(ios_base::openmode which); + template _UCXXEXPORT char_stringbuf::~basic_stringbuf(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT basic_string, allocator > char_stringbuf::str() const; + template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::pbackfail(char_stringbuf::int_type c); + template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::overflow(char_stringbuf::int_type c); + template _UCXXEXPORT char_stringbuf::pos_type + char_stringbuf::seekoff(char_stringbuf::off_type, ios_base::seekdir, ios_base::openmode); + template _UCXXEXPORT char_stringbuf::int_type char_stringbuf::underflow (); + template _UCXXEXPORT streamsize char_stringbuf::xsputn(const char* s, streamsize n); + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template _UCXXEXPORT basic_stringstream >::basic_stringstream(ios_base::openmode which); + template _UCXXEXPORT basic_istringstream >::~basic_istringstream(); + template _UCXXEXPORT basic_ostringstream >::~basic_ostringstream(); + template _UCXXEXPORT basic_stringstream >::~basic_stringstream(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + +#endif + +} + + Index: trunk/i386/modules/uClibc++/valarray.cpp =================================================================== --- trunk/i386/modules/uClibc++/valarray.cpp (revision 0) +++ trunk/i386/modules/uClibc++/valarray.cpp (revision 777) @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +namespace std{ + + + + +} + + Index: trunk/i386/modules/uClibc++/iostream.cpp =================================================================== --- trunk/i386/modules/uClibc++/iostream.cpp (revision 0) +++ trunk/i386/modules/uClibc++/iostream.cpp (revision 777) @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define __UCLIBCXX_COMPILE_IOSTREAM__ 1 + +#include + +namespace std{ + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + + template _UCXXEXPORT basic_iostream >:: + basic_iostream(basic_streambuf >* sb); + template _UCXXEXPORT basic_iostream >::~basic_iostream(); + +#endif +#endif + +} + + Index: trunk/i386/modules/uClibc++/new_handler.cpp =================================================================== --- trunk/i386/modules/uClibc++/new_handler.cpp (revision 0) +++ trunk/i386/modules/uClibc++/new_handler.cpp (revision 777) @@ -0,0 +1,31 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +const std::nothrow_t std::nothrow = { }; + +//Name selected to be compatable with g++ code +std::new_handler __new_handler; + +_UCXXEXPORT std::new_handler std::set_new_handler(std::new_handler new_p) throw(){ + std::new_handler retval = __new_handler; + __new_handler = new_p; + return retval; +} Index: trunk/i386/modules/uClibc++/new_op.cpp =================================================================== --- trunk/i386/modules/uClibc++/new_op.cpp (revision 0) +++ trunk/i386/modules/uClibc++/new_op.cpp (revision 777) @@ -0,0 +1,38 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include +#include +#include + +extern "C" { +#include "libsaio.h" +}; + +_UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc){ + //C++ stardard 5.3.4.8 requires that a valid pointer be returned for + //a call to new(0). Thus: + if(numBytes == 0){ + numBytes = 1; + } + void * p = malloc(numBytes); + if(p == 0){ + std::__throw_bad_alloc(); + } + return p; +} Index: trunk/i386/modules/uClibc++/uClibc++.c =================================================================== --- trunk/i386/modules/uClibc++/uClibc++.c (revision 0) +++ trunk/i386/modules/uClibc++/uClibc++.c (revision 777) @@ -0,0 +1,12 @@ +#include "libsaio.h" + +void uClibcxx_start() +{ +} + +void abort() +{ + stop("uClibc+: abort()\n"); +} + + Index: trunk/i386/modules/uClibc++/iomanip.cpp =================================================================== --- trunk/i386/modules/uClibc++/iomanip.cpp (revision 0) +++ trunk/i386/modules/uClibc++/iomanip.cpp (revision 777) @@ -0,0 +1,29 @@ +/* Copyright (C) 2005 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +namespace std{ + + + + +} + + Index: trunk/i386/modules/uClibc++/typeinfo.cpp =================================================================== --- trunk/i386/modules/uClibc++/typeinfo.cpp (revision 0) +++ trunk/i386/modules/uClibc++/typeinfo.cpp (revision 777) @@ -0,0 +1,34 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc++ Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +namespace std{ + + _UCXXEXPORT bad_cast::~bad_cast() throw(){ + + } + + _UCXXEXPORT bad_typeid::~bad_typeid() throw(){ + + } + +} + +