Index: branches/slice/i386/boot0/boot0.s =================================================================== --- branches/slice/i386/boot0/boot0.s (revision 726) +++ branches/slice/i386/boot0/boot0.s (revision 727) @@ -354,10 +354,12 @@ call loadBootSector jne .continue - jmp initBootLoader +; jmp initBootLoader + jmp SHORT initBootLoader .continue: - add si, part_size ; advance SI to next partition entry +; add si, part_size ; advance SI to next partition entry + add si, BYTE part_size loop .loop ; loop through all partition entries ; @@ -366,8 +368,11 @@ ; for a possible GPT Header at LBA 1 ; dec bl - jz checkGPT ; found Protective MBR before - +; jz checkGPT ; found Protective MBR before + jnz .switchPass2 + call checkGPT + +.switchPass2 ; ; Switching to Pass 2 ; try to find a boot1h aware HFS+ MBR partition @@ -378,6 +383,22 @@ .exit: ret ; Giving up. + + + ; + ; Jump to partition booter. The drive number is already in register DL. + ; SI is pointing to the modified partition entry. + ; +initBootLoader: + +DebugChar('J') + +%if VERBOSE + LogString(done_str) +%endif + + jmp kBoot0LoadAddr + ; ; Found Protective MBR Partition Type: 0xEE @@ -386,6 +407,7 @@ ; checkGPT: + push bx mov di, kLBA1Buffer ; address of GUID Partition Table Header cmp DWORD [di], kGPTSignatureLow ; looking for 'EFI ' jne .exit ; not found. Giving up. @@ -473,20 +495,21 @@ loop .gpt_loop ; loop through all partition entries .exit: + pop bx ret ; no more GUID partitions. Giving up. - DebugChar('J') +; DebugChar('J') ; ; Jump to partition booter. The drive number is already in register DL. ; SI is pointing to the modified partition entry. ; -initBootLoader: +;initBootLoader: %if VERBOSE LogString(done_str) %endif - jmp kBoot0LoadAddr +; jmp kBoot0LoadAddr ;-------------------------------------------------------------------------- @@ -609,7 +632,8 @@ xor ah, ah ; offset 3, must be 0 push ax ; offset 2, number of sectors - push WORD 16 ; offset 0-1, packet size +; push WORD 16 ; offset 0-1, packet size + push BYTE 16 DebugChar('<') %if DEBUG @@ -746,6 +770,7 @@ popad ret + print_nibble: and al, 0x0f Index: branches/slice/i386/modules/KextPatcher/hex_editor.h =================================================================== --- branches/slice/i386/modules/KextPatcher/hex_editor.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/hex_editor.h (revision 727) @@ -1,17 +0,0 @@ -/* - * hex_editor.h - * - * - * Created by Meklort on 10/19/10. - * Copyright 2010 Evan Lojewski. All rights reserved. - * - */ -#ifndef H_HEX_EDITOR -#define H_HEX_EDITOR -#include "libsaio.h" - -int replace_patern(char* pattern, char* repalcement, char* buffer, long buffer_size); -int replace_word(uint32_t pattern, uint32_t repalcement, char* buffer, long buffer_size); -void replace_string(char* find, char* replace, char* string, int length); -void replace_bytes(char* find, int find_size, char* replace, int replace_size, char* exec, int length); -#endif /* H_HEX_EDITOR */ \ No newline at end of file Index: branches/slice/i386/modules/KextPatcher/inffast.h =================================================================== --- branches/slice/i386/modules/KextPatcher/inffast.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/inffast.h (revision 727) @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); Index: branches/slice/i386/modules/KextPatcher/inffixed.h =================================================================== --- branches/slice/i386/modules/KextPatcher/inffixed.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/inffixed.h (revision 727) @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. It - is part of the implementation of the compression library and - is subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; Index: branches/slice/i386/modules/KextPatcher/zlib.h =================================================================== --- branches/slice/i386/modules/KextPatcher/zlib.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/zlib.h (revision 727) @@ -1,1613 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.5, April 19th, 2010 - - Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.5" -#define ZLIB_VERNUM 0x1250 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 5 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use in the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). Some - output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed code - block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the stream - are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least the - value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect the - compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the - exact value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit() does not process any header information -- that is deferred - until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing will - resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all the uncompressed data. (The size - of the uncompressed data may have been saved by the compressor for this - purpose.) The next operation on this stream must be inflateEnd to deallocate - the decompression state. The use of Z_FINISH is never required, but can be - used to inform inflate that a faster approach may be used for the single - inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK or Z_TREES is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained, so applications that need that information should - instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any call - of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. The - stream will keep the same compression level and any other attributes that - may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression level is changed, the input available so far is - compressed with the old level (and may be flushed); the new level will take - effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to be - compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if - strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been - found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the - success case, the application may save the current current value of total_in - which indicates where valid compressed data was found. In the error case, - the application may repeatedly call inflateSync, providing more input each - time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above or -1 << 16 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the normal - behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef voidp gzFile; /* opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) Also "a" - can be used instead of "w" to request that the gzip stream that will be - written be appended to the file. "+" will result in an error, since reading - and writing to the same gzip file is not supported. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Two buffers are allocated, either both of the specified size when - writing, or one of the specified size and the other twice that size when - reading. A larger buffer size of, for example, 64K or 128K bytes will - noticeably increase the speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. If - the input file was not in gzip format, gzread copies the given number of - bytes into the buffer. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream, or failing that, reading the rest - of the input file directly without decompression. The entire input file - will be read if gzread is called until it returns less than the requested - len. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or 0 in case of error. The number of - uncompressed bytes written is limited to 8191, or one less than the buffer - size given to gzbuffer(). The caller should assure that this limit is not - exceeded. If it is exceeded, then gzprintf() will return an error (0) with - nothing written. In this case, there may also be a buffer overflow with - unpredictable consequences, which is possible only if zlib was compiled with - the insecure functions sprintf() or vsprintf() because the secure snprintf() - or vsnprintf() functions were not available. This can be determined using - zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatented gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. This state can change from - false to true while reading the input file if the end of a gzip stream is - reached, but is followed by data that is not another gzip stream. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the for the crc. Pre- and post-conditioning (one's - complement) is performed within this function so it shouldn't be done by the - application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# ifdef _LARGEFILE64_SOURCE - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); -#endif - -/* hack for buggy compilers */ -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; -#endif - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ Index: branches/slice/i386/modules/KextPatcher/deflate.h =================================================================== --- branches/slice/i386/modules/KextPatcher/deflate.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/deflate.h (revision 727) @@ -1,342 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2010 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* STORED (for zip only) or DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - - ulg high_water; - /* High water mark offset in window for initialized bytes -- bytes above - * this are set to zero in order to avoid memory check warnings when - * longest match routines access bytes past the input. This is then - * updated to the new high water mark. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - -#define WIN_INIT MAX_MATCH -/* Number of bytes after end of data in window to initialize in order to avoid - memory checker errors from longest match routines */ - - /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch ZLIB_INTERNAL _length_code[]; - extern uch ZLIB_INTERNAL _dist_code[]; -#else - extern const uch ZLIB_INTERNAL _length_code[]; - extern const uch ZLIB_INTERNAL _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ Index: branches/slice/i386/modules/KextPatcher/zutil.h =================================================================== --- branches/slice/i386/modules/KextPatcher/zutil.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/zutil.h (revision 727) @@ -1,275 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2010 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include "libsaio.h" -#include "zlib.h" - -#ifdef STDC -# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) -# include -# endif -//# include -//# include -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# ifdef M_I86 -//# include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - -#if defined(__BORLANDC__) - #pragma warn -8004 - #pragma warn -8008 - #pragma warn -8066 -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf -# endif -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); -void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ Index: branches/slice/i386/modules/KextPatcher/zconf.h =================================================================== --- branches/slice/i386/modules/KextPatcher/zconf.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/zconf.h (revision 727) @@ -1,428 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2010 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ - -/* all linked symbols */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzgetc z_gzgetc -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzwrite z_gzwrite -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetHeader z_inflateGetHeader -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# define uncompress z_uncompress -# define zError z_zError -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# define gzFile z_gzFile -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef STDC -//# include /* for off_t */ -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -//# include /* for SEEK_* and off_t */ -# ifdef VMS -//# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -#endif - -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 -# define z_off64_t off64_t -#else -# define z_off64_t z_off_t -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ Index: branches/slice/i386/modules/KextPatcher/inftrees.h =================================================================== --- branches/slice/i386/modules/KextPatcher/inftrees.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/inftrees.h (revision 727) @@ -1,62 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of the dynamic table. The maximum number of code structures is - 1444, which is the sum of 852 for literal/length codes and 592 for distance - codes. These values were found by exhaustive searches using the program - examples/enough.c found in the zlib distribtution. The arguments to that - program are the number of symbols, the initial root table size, and the - maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the - inflate_table() calls in inflate.c and infback.c. If the root table size is - changed, then these maximum sizes would be need to be recalculated and - updated. */ -#define ENOUGH_LENS 852 -#define ENOUGH_DISTS 592 -#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) - -/* Type of code to build for inflate_table() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); Index: branches/slice/i386/modules/KextPatcher/inflate.h =================================================================== --- branches/slice/i386/modules/KextPatcher/inflate.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/inflate.h (revision 727) @@ -1,122 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2009 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY_, /* i/o: same as COPY below, but only first time in */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN_, /* i: same as LEN below, but only first time in */ - LEN, /* i: waiting for length/lit/eob code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to BAD or MEM on error -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) or (raw) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> - HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - (raw) -> TYPEDO - Read deflate blocks: - TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK - STORED -> COPY_ -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN_ - LEN_ -> LEN - Read deflate codes in fixed or dynamic block: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* state maintained between inflate() calls. Approximately 10K bytes. */ -struct inflate_state { - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ - int sane; /* if false, allow invalid distance too far */ - int back; /* bits back of last unprocessed length/lit */ - unsigned was; /* initial length of match */ -}; Index: branches/slice/i386/modules/KextPatcher/trees.h =================================================================== --- branches/slice/i386/modules/KextPatcher/trees.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/trees.h (revision 727) @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - Index: branches/slice/i386/modules/KextPatcher/mkext.h =================================================================== --- branches/slice/i386/modules/KextPatcher/mkext.h (revision 726) +++ branches/slice/i386/modules/KextPatcher/mkext.h (revision 727) @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2008 Apple Inc. All rights reserved. - * - * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ - * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. The rights granted to you under the License - * may not be used to create, or enable the creation or redistribution of, - * unlawful or unlicensed copies of an Apple operating system, or to - * circumvent, violate, or enable the circumvention or violation of, any - * terms of an Apple operating system software license agreement. - * - * Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. - * - * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ - */ - -#ifndef _MKEXT_H_ -#define _MKEXT_H_ 1 - -#include -#include - -#include - -/********************************************************************* -* Mkext File Format -* -* ALL BINARY VALUES ARE BIG-ENDIAN. -*********************************************************************/ -#if PRAGMA_MARK -#pragma mark Constants -#endif - -#define MKEXT_MAGIC 0x4D4B5854 /* 'MKXT' */ -#define MKEXT_SIGN 0x4D4F5358 /* 'MOSX' */ - -#define MKEXT_EXTN ".mkext" - -#define MKEXT_VERS_1 (0x01008000) - -// Used during development/bringup: v 2.0d1 -#define MKEXT_VERS_2 (0x02002001) -// xxx - Will use this when format is final -// #define MKEXT_VERS_2 (0x02008000) - -#if PRAGMA_MARK -#pragma mark Core Header -#endif -/********************************************************************* -* Core Header -* -* All versions of mkext files have this basic header: -* -* - magic & signature - always 'MKXT' and 'MOSX' as defined above. -* - length - the length of the whole file -* - adler32 - checksum from &version to end of file -* - version - a 'vers' style value -* - numkexts - how many kexts are in the archive (only needed in v.1) -* - cputype & cpusubtype - in version 1 could be CPU_TYPE_ANY -* and CPU_SUBTYPE_MULTIPLE if the archive contained fat kexts; -* version 2 does not allow this and all kexts must be of a single -* arch. For either version, mkexts of specific arches can be -* embedded in a fat Mach-O file to combine them. -*********************************************************************/ - -#define MKEXT_HEADER_CORE \ - uint32_t magic; \ - uint32_t signature; \ - uint32_t length; \ - uint32_t adler32; \ - uint32_t version; \ - uint32_t numkexts; \ - cpu_type_t cputype; \ - cpu_subtype_t cpusubtype; - -typedef struct mkext_basic_header { - MKEXT_HEADER_CORE -} mkext_basic_header; - -#define MKEXT_HDR_CAST(hdr) ((mkext_basic_header *)(hdr)) - -#define MKEXT_SWAP(num) OSSwapBigToHostInt32((uint32_t)(num)) - -#define MKEXT_GET_MAGIC(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->magic)) -#define MKEXT_GET_SIGNATURE(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->signature)) -#define MKEXT_GET_LENGTH(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->length)) -#define MKEXT_GET_CHECKSUM(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->adler32)) -#define MKEXT_GET_VERSION(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->version)) -#define MKEXT_GET_COUNT(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->numkexts)) -#define MKEXT_GET_CPUTYPE(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->cputype)) -#define MKEXT_GET_CPUSUBTYPE(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->cpusubtype)) - -#if PRAGMA_MARK -#pragma mark Mkext Version 2 Format Definitions -#endif -/********************************************************************* -* Mkext Version 2 Format Definitions -* -* The version field here will be some variant of 0x0200....; that is -* the major version byte will be 0x02. -* -* Version 2 uses zlib for compression, not the lzss compressor used -* by version 1. -* -* In version 2, all executable & resource files are stored in sequence -* followed by the combined info dictionaries of all kexts at the end. -* This XML plist should be nul-terminated and stored at a page-aligned -* offset in the file so that kernel code can unmap it as soon as it's -* parsed. -* -* The info dict for each kext will have inserted into it these -* additional properties: -* -* - _MKEXTBundlePath (string) - full path to the original bundle, -* relative to volume. -* - _MKEXTExecutable (integer) - offset to the executable entry. -* - _MKEXTResources (dict) - keyed by filename, values integer offsets -* to file entries. -* -* Mkext2 buffers are used to send load requests to the kernel. When -* this is done, the plist will contain an _MKEXTLoadRequest dictionary -* whose keys are the bundle IDs to load, and whose values are -* dictionaries of flags: -* -* - "Load Kext" - boolean, whether to load the kext or not (default true). -* May be used to send just personalities for already-loaded kexts, -* but we do have a mechanism to do that from userland already. -* - "Start Kext" - boolean, whether to start the kext or not -* (used when debugging). Defaults to true. -* - "Add Personalities" - boolean, whether to send personalities to -* the IOCatalogue (used when debugging). Defaults to true. -* - "Disable Autounload" - boolean, whether to prevent the reaper -* thread from unloading the kext, so the dev. has time to set up -* the debug session. (Predefined window, or maybe this will be a -* number of seconds to wait.) Defaults to false. -*********************************************************************/ -#define kMKEXTInfoDictionariesKey "_MKEXTInfoDictionaries" - -#define kMKEXTBundlePathKey "_MKEXTBundlePath" -#define kMKEXTExecutableKey "_MKEXTExecutable" - -#define kMKEXTLoadRequestKey "_MKEXTLoadRequest" -#define kMKEXTLoadRequestLoadKey "Load Kext" -#define kMKEXTLoadRequestStartKey "Start Kext" -#define kMKEXTLoadRequestAddPersonalitiesKey "Add Personalities" -#define kMKEXTLoadRequestDisableAutounloadKey "Disable Autounload" - -typedef struct mkext2_file_entry { - uint32_t compressed_size; // if zero, file is not compressed - uint32_t full_size; // full size of data w/o this struct - uint8_t data[0]; // data is inline to this struct -} mkext2_file_entry; - -typedef struct mkext2_header { - MKEXT_HEADER_CORE - uint32_t plist_offset; - uint32_t plist_compressed_size; - uint32_t plist_full_size; -} mkext2_header; - -#define MKEXT2_GET_ENTRY_COMPSIZE(ptr) MKEXT_SWAP((ptr)->compressed_size) -#define MKEXT2_GET_ENTRY_FULLSIZE(ptr) MKEXT_SWAP((ptr)->full_size) -#define MKEXT2_GET_ENTRY_DATA(ptr) ((ptr)->data) - -#define MKEXT2_HDR_CAST(hdr) ((mkext2_header *)(hdr)) -#define MKEXT2_GET_PLIST(hdr) MKEXT_SWAP(MKEXT2_HDR_CAST(hdr)->plist_offset) -#define MKEXT2_GET_PLIST_COMPSIZE(hdr) MKEXT_SWAP(MKEXT2_HDR_CAST(hdr)->plist_compressed_size) -#define MKEXT2_GET_PLIST_FULLSIZE(hdr) MKEXT_SWAP(MKEXT2_HDR_CAST(hdr)->plist_full_size) - -#if PRAGMA_MARK -#pragma mark Mkext Version 1 Format Definitions -#endif -/********************************************************************* -* Mkext Version 1 Format Definitions -* -* The original mkext format has version 0x01008000 ("1.0"). -* -* In version 1, plists were not nul-terminated, so it's up to the -* reader to add that '\0' on the end if it's needed. -* -* Original bad names preserved for source compatibility. -*********************************************************************/ - -// If all fields are 0 then this file slot is empty -// If compsize is zero then the file isn't compressed. -typedef struct mkext_file { - uint32_t offset; // 4 bytes - uint32_t compsize; // 4 bytes - uint32_t realsize; // 4 bytes - uint32_t modifiedsecs; // 4 bytes; cast to time_t to use -} mkext_file; - -// The plist file entry is mandatory, but module may be empty -typedef struct mkext_kext { - mkext_file plist; // 16 bytes - mkext_file module; // 16 bytes -} mkext_kext; - -typedef struct mkext_header { - MKEXT_HEADER_CORE - mkext_kext kext[1]; // 32 bytes/entry -} mkext_header; - -typedef mkext_header mkext1_header; - -#define MKEXT1_ENTRY_CAST(ptr) ((mkext_file *)(ptr)) -#define MKEXT1_GET_ENTRY_OFFSET(ptr) (MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->offset)) -#define MKEXT1_GET_ENTRY_COMPSIZE(ptr) (MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->compsize)) -#define MKEXT1_GET_ENTRY_FULLSIZE(ptr) (MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->realsize)) -#define MKEXT1_GET_ENTRY_MODTIME(ptr) ((time_t)MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->modifiedsecs)) -#define MKEXT1_ENTRY_EXISTS(ptr) (MKEXT1_GET_ENTRY_OFFSET(ptr) || \ - MKEXT1_GET_ENTRY_FULLSIZE(ptr) || \ - MKEXT_GET_ENTRY_COMPSIZE(ptr) || \ - MKEXT_GET_ENTRY_COMPSIZE(ptr)) - -#define MKEXT1_GET_KEXT(hdr, i) ((mkext_kext *)&(MKEXT1_HDR_CAST(hdr)->kext[(i)])) -#define MKEXT1_GET_KEXT_PLIST(hdr, i) (MKEXT1_ENTRY_CAST(&(MKEXT1_GET_KEXT((hdr), (i))->plist))) -#define MKEXT1_GET_KEXT_EXEC(hdr, i) (MKEXT1_ENTRY_CAST(&(MKEXT1_GET_KEXT((hdr), (i))->module) - -#define MKEXT1_HDR_CAST(hdr) ((mkext1_header *)(hdr)) - -#endif /* _MKEXT_H_ */ Index: branches/slice/i386/modules/KextPatcher/include/hex_editor.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/hex_editor.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/hex_editor.h (revision 727) @@ -0,0 +1,17 @@ +/* + * hex_editor.h + * + * + * Created by Meklort on 10/19/10. + * Copyright 2010 Evan Lojewski. All rights reserved. + * + */ +#ifndef H_HEX_EDITOR +#define H_HEX_EDITOR +#include "libsaio.h" + +int replace_patern(char* pattern, char* repalcement, char* buffer, long buffer_size); +int replace_word(uint32_t pattern, uint32_t repalcement, char* buffer, long buffer_size); +void replace_string(char* find, char* replace, char* string, int length); +void replace_bytes(char* find, int find_size, char* replace, int replace_size, char* exec, int length); +#endif /* H_HEX_EDITOR */ \ No newline at end of file Index: branches/slice/i386/modules/KextPatcher/include/inffast.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/inffast.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/inffast.h (revision 727) @@ -0,0 +1,11 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2003, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); Index: branches/slice/i386/modules/KextPatcher/include/inffixed.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/inffixed.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/inffixed.h (revision 727) @@ -0,0 +1,94 @@ + /* inffixed.h -- table for decoding fixed codes + * Generated automatically by makefixed(). + */ + + /* WARNING: this file should *not* be used by applications. It + is part of the implementation of the compression library and + is subject to change. Applications should only use zlib.h. + */ + + static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} + }; + + static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} + }; Index: branches/slice/i386/modules/KextPatcher/include/inftrees.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/inftrees.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/inftrees.h (revision 727) @@ -0,0 +1,62 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2005, 2010 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Structure for decoding tables. Each entry provides either the + information needed to do the operation requested by the code that + indexed that table entry, or it provides a pointer to another + table that indexes more bits of the code. op indicates whether + the entry is a pointer to another table, a literal, a length or + distance, an end-of-block, or an invalid code. For a table + pointer, the low four bits of op is the number of index bits of + that table. For a length or distance, the low four bits of op + is the number of extra bits to get after the code. bits is + the number of bits in this code or part of the code to drop off + of the bit buffer. val is the actual byte to output in the case + of a literal, the base length or distance, or the offset from + the current table to the next table. Each entry is four bytes. */ +typedef struct { + unsigned char op; /* operation, extra bits, table bits */ + unsigned char bits; /* bits in this part of the code */ + unsigned short val; /* offset in table or code value */ +} code; + +/* op values as set by inflate_table(): + 00000000 - literal + 0000tttt - table link, tttt != 0 is the number of table index bits + 0001eeee - length or distance, eeee is the number of extra bits + 01100000 - end of block + 01000000 - invalid code + */ + +/* Maximum size of the dynamic table. The maximum number of code structures is + 1444, which is the sum of 852 for literal/length codes and 592 for distance + codes. These values were found by exhaustive searches using the program + examples/enough.c found in the zlib distribtution. The arguments to that + program are the number of symbols, the initial root table size, and the + maximum bit length of a code. "enough 286 9 15" for literal/length codes + returns returns 852, and "enough 30 6 15" for distance codes returns 592. + The initial root table size (9 or 6) is found in the fifth argument of the + inflate_table() calls in inflate.c and infback.c. If the root table size is + changed, then these maximum sizes would be need to be recalculated and + updated. */ +#define ENOUGH_LENS 852 +#define ENOUGH_DISTS 592 +#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) + +/* Type of code to build for inflate_table() */ +typedef enum { + CODES, + LENS, + DISTS +} codetype; + +int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work)); Index: branches/slice/i386/modules/KextPatcher/include/zconf.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/zconf.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/zconf.h (revision 727) @@ -0,0 +1,428 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ + +/* all linked symbols */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetHeader z_inflateGetHeader +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# define uncompress z_uncompress +# define zError z_zError +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# define gzFile z_gzFile +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef STDC +//# include /* for off_t */ +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +//# include /* for SEEK_* and off_t */ +# ifdef VMS +//# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +#endif + +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +# define z_off64_t off64_t +#else +# define z_off64_t z_off_t +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ Index: branches/slice/i386/modules/KextPatcher/include/zlib.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/zlib.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/zlib.h (revision 727) @@ -0,0 +1,1613 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.5, April 19th, 2010 + + Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.5" +#define ZLIB_VERNUM 0x1250 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 5 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use in the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). Some + output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed code + block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the stream + are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least the + value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect the + compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the + exact value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit() does not process any header information -- that is deferred + until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing will + resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all the uncompressed data. (The size + of the uncompressed data may have been saved by the compressor for this + purpose.) The next operation on this stream must be inflateEnd to deallocate + the decompression state. The use of Z_FINISH is never required, but can be + used to inform inflate that a faster approach may be used for the single + inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK or Z_TREES is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained, so applications that need that information should + instead use raw inflate, see inflateInit2() below, or inflateBack() and + perform their own processing of the gzip header and trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any call + of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. The + stream will keep the same compression level and any other attributes that + may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression level is changed, the input available so far is + compressed with the old level (and may be flushed); the new level will take + effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to be + compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if + strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been + found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the + success case, the application may save the current current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above or -1 << 16 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the normal + behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef voidp gzFile; /* opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) Also "a" + can be used instead of "w" to request that the gzip stream that will be + written be appended to the file. "+" will result in an error, since reading + and writing to the same gzip file is not supported. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Two buffers are allocated, either both of the specified size when + writing, or one of the specified size and the other twice that size when + reading. A larger buffer size of, for example, 64K or 128K bytes will + noticeably increase the speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. If + the input file was not in gzip format, gzread copies the given number of + bytes into the buffer. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream, or failing that, reading the rest + of the input file directly without decompression. The entire input file + will be read if gzread is called until it returns less than the requested + len. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or 0 in case of error. The number of + uncompressed bytes written is limited to 8191, or one less than the buffer + size given to gzbuffer(). The caller should assure that this limit is not + exceeded. If it is exceeded, then gzprintf() will return an error (0) with + nothing written. In this case, there may also be a buffer overflow with + unpredictable consequences, which is possible only if zlib was compiled with + the insecure functions sprintf() or vsprintf() because the secure snprintf() + or vsnprintf() functions were not available. This can be determined using + zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatented gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. This state can change from + false to true while reading the input file if the end of a gzip stream is + reached, but is followed by data that is not another gzip stream. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the for the crc. Pre- and post-conditioning (one's + complement) is performed within this function so it shouldn't be done by the + application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# ifdef _LARGEFILE64_SOURCE + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif + +/* hack for buggy compilers */ +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; +#endif + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ Index: branches/slice/i386/modules/KextPatcher/include/inflate.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/inflate.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/inflate.h (revision 727) @@ -0,0 +1,122 @@ +/* inflate.h -- internal inflate state definition + * Copyright (C) 1995-2009 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer decoding by inflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip decoding + should be left enabled. */ +#ifndef NO_GZIP +# define GUNZIP +#endif + +/* Possible inflate modes between inflate() calls */ +typedef enum { + HEAD, /* i: waiting for magic header */ + FLAGS, /* i: waiting for method and flags (gzip) */ + TIME, /* i: waiting for modification time (gzip) */ + OS, /* i: waiting for extra flags and operating system (gzip) */ + EXLEN, /* i: waiting for extra length (gzip) */ + EXTRA, /* i: waiting for extra bytes (gzip) */ + NAME, /* i: waiting for end of file name (gzip) */ + COMMENT, /* i: waiting for end of comment (gzip) */ + HCRC, /* i: waiting for header crc (gzip) */ + DICTID, /* i: waiting for dictionary check value */ + DICT, /* waiting for inflateSetDictionary() call */ + TYPE, /* i: waiting for type bits, including last-flag bit */ + TYPEDO, /* i: same, but skip check to exit inflate on new block */ + STORED, /* i: waiting for stored size (length and complement) */ + COPY_, /* i/o: same as COPY below, but only first time in */ + COPY, /* i/o: waiting for input or output to copy stored block */ + TABLE, /* i: waiting for dynamic block table lengths */ + LENLENS, /* i: waiting for code length code lengths */ + CODELENS, /* i: waiting for length/lit and distance code lengths */ + LEN_, /* i: same as LEN below, but only first time in */ + LEN, /* i: waiting for length/lit/eob code */ + LENEXT, /* i: waiting for length extra bits */ + DIST, /* i: waiting for distance code */ + DISTEXT, /* i: waiting for distance extra bits */ + MATCH, /* o: waiting for output space to copy string */ + LIT, /* o: waiting for output space to write literal */ + CHECK, /* i: waiting for 32-bit check value */ + LENGTH, /* i: waiting for 32-bit length (gzip) */ + DONE, /* finished check, done -- remain here until reset */ + BAD, /* got a data error -- remain here until reset */ + MEM, /* got an inflate() memory error -- remain here until reset */ + SYNC /* looking for synchronization bytes to restart inflate() */ +} inflate_mode; + +/* + State transitions between above modes - + + (most modes can go to BAD or MEM on error -- not shown for clarity) + + Process header: + HEAD -> (gzip) or (zlib) or (raw) + (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> + HCRC -> TYPE + (zlib) -> DICTID or TYPE + DICTID -> DICT -> TYPE + (raw) -> TYPEDO + Read deflate blocks: + TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK + STORED -> COPY_ -> COPY -> TYPE + TABLE -> LENLENS -> CODELENS -> LEN_ + LEN_ -> LEN + Read deflate codes in fixed or dynamic block: + LEN -> LENEXT or LIT or TYPE + LENEXT -> DIST -> DISTEXT -> MATCH -> LEN + LIT -> LEN + Process trailer: + CHECK -> LENGTH -> DONE + */ + +/* state maintained between inflate() calls. Approximately 10K bytes. */ +struct inflate_state { + inflate_mode mode; /* current inflate mode */ + int last; /* true if processing last block */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + int havedict; /* true if dictionary provided */ + int flags; /* gzip header method and flags (0 if zlib) */ + unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ + unsigned long check; /* protected copy of check value */ + unsigned long total; /* protected copy of output count */ + gz_headerp head; /* where to save gzip header information */ + /* sliding window */ + unsigned wbits; /* log base 2 of requested window size */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned wnext; /* window write index */ + unsigned char FAR *window; /* allocated sliding window, if needed */ + /* bit accumulator */ + unsigned long hold; /* input bit accumulator */ + unsigned bits; /* number of bits in "in" */ + /* for string and stored block copying */ + unsigned length; /* literal or length of data to copy */ + unsigned offset; /* distance back to copy string from */ + /* for table and code decoding */ + unsigned extra; /* extra bits needed */ + /* fixed and dynamic code tables */ + code const FAR *lencode; /* starting table for length/literal codes */ + code const FAR *distcode; /* starting table for distance codes */ + unsigned lenbits; /* index bits for lencode */ + unsigned distbits; /* index bits for distcode */ + /* dynamic table building */ + unsigned ncode; /* number of code length code lengths */ + unsigned nlen; /* number of length code lengths */ + unsigned ndist; /* number of distance code lengths */ + unsigned have; /* number of code lengths in lens[] */ + code FAR *next; /* next available space in codes[] */ + unsigned short lens[320]; /* temporary storage for code lengths */ + unsigned short work[288]; /* work area for code table building */ + code codes[ENOUGH]; /* space for code tables */ + int sane; /* if false, allow invalid distance too far */ + int back; /* bits back of last unprocessed length/lit */ + unsigned was; /* initial length of match */ +}; Index: branches/slice/i386/modules/KextPatcher/include/trees.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/trees.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/trees.h (revision 727) @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + Index: branches/slice/i386/modules/KextPatcher/include/deflate.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/deflate.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/deflate.h (revision 727) @@ -0,0 +1,342 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2010 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef DEFLATE_H +#define DEFLATE_H + +#include "zutil.h" + +/* define NO_GZIP when compiling if you want to disable gzip header and + trailer creation by deflate(). NO_GZIP would be used to avoid linking in + the crc code when it is not needed. For shared libraries, gzip encoding + should be left enabled. */ +#ifndef NO_GZIP +# define GZIP +#endif + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define INIT_STATE 42 +#define EXTRA_STATE 69 +#define NAME_STATE 73 +#define COMMENT_STATE 91 +#define HCRC_STATE 103 +#define BUSY_STATE 113 +#define FINISH_STATE 666 +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + uInt pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + gz_headerp gzhead; /* gzip header information to write */ + uInt gzindex; /* where in extra, name, or comment */ + Byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to supress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + int last_eob_len; /* bit length of EOB code for last block */ + +#ifdef DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + + ulg high_water; + /* High water mark offset in window for initialized bytes -- bytes above + * this are set to zero in order to avoid memory check warnings when + * longest match routines access bytes past the input. This is then + * updated to the new high water mark. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + +#define WIN_INIT MAX_MATCH +/* Number of bytes after end of data in window to initialize in order to avoid + memory checker errors from longest match routines */ + + /* in trees.c */ +void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); +int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, + ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); +void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, + ulg stored_len, int last)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch ZLIB_INTERNAL _length_code[]; + extern uch ZLIB_INTERNAL _dist_code[]; +#else + extern const uch ZLIB_INTERNAL _length_code[]; + extern const uch ZLIB_INTERNAL _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (length); \ + ush dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif /* DEFLATE_H */ Index: branches/slice/i386/modules/KextPatcher/include/zutil.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/zutil.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/zutil.h (revision 727) @@ -0,0 +1,275 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) +# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) +#else +# define ZLIB_INTERNAL +#endif + +#include "libsaio.h" +#include "zlib.h" + +#ifdef STDC +# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) +# include +# endif +//# include +//# include +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +# ifdef M_I86 +//# include +# endif +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifdef WIN32 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0f +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + +#if defined(__BORLANDC__) + #pragma warn -8004 + #pragma warn -8008 + #pragma warn -8066 +#endif + +/* provide prototypes for these when building zlib without LFS */ +#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS + /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 + /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) +# define vsnprintf _vsnprintf +# endif +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +#endif +#ifdef VMS +# define NO_vsnprintf +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int ZLIB_INTERNAL z_verbose; + extern void ZLIB_INTERNAL z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, + unsigned size)); +void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* ZUTIL_H */ Index: branches/slice/i386/modules/KextPatcher/include/mkext.h =================================================================== --- branches/slice/i386/modules/KextPatcher/include/mkext.h (revision 0) +++ branches/slice/i386/modules/KextPatcher/include/mkext.h (revision 727) @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2008 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MKEXT_H_ +#define _MKEXT_H_ 1 + +#include +#include + +#include + +/********************************************************************* +* Mkext File Format +* +* ALL BINARY VALUES ARE BIG-ENDIAN. +*********************************************************************/ +#if PRAGMA_MARK +#pragma mark Constants +#endif + +#define MKEXT_MAGIC 0x4D4B5854 /* 'MKXT' */ +#define MKEXT_SIGN 0x4D4F5358 /* 'MOSX' */ + +#define MKEXT_EXTN ".mkext" + +#define MKEXT_VERS_1 (0x01008000) + +// Used during development/bringup: v 2.0d1 +#define MKEXT_VERS_2 (0x02002001) +// xxx - Will use this when format is final +// #define MKEXT_VERS_2 (0x02008000) + +#if PRAGMA_MARK +#pragma mark Core Header +#endif +/********************************************************************* +* Core Header +* +* All versions of mkext files have this basic header: +* +* - magic & signature - always 'MKXT' and 'MOSX' as defined above. +* - length - the length of the whole file +* - adler32 - checksum from &version to end of file +* - version - a 'vers' style value +* - numkexts - how many kexts are in the archive (only needed in v.1) +* - cputype & cpusubtype - in version 1 could be CPU_TYPE_ANY +* and CPU_SUBTYPE_MULTIPLE if the archive contained fat kexts; +* version 2 does not allow this and all kexts must be of a single +* arch. For either version, mkexts of specific arches can be +* embedded in a fat Mach-O file to combine them. +*********************************************************************/ + +#define MKEXT_HEADER_CORE \ + uint32_t magic; \ + uint32_t signature; \ + uint32_t length; \ + uint32_t adler32; \ + uint32_t version; \ + uint32_t numkexts; \ + cpu_type_t cputype; \ + cpu_subtype_t cpusubtype; + +typedef struct mkext_basic_header { + MKEXT_HEADER_CORE +} mkext_basic_header; + +#define MKEXT_HDR_CAST(hdr) ((mkext_basic_header *)(hdr)) + +#define MKEXT_SWAP(num) OSSwapBigToHostInt32((uint32_t)(num)) + +#define MKEXT_GET_MAGIC(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->magic)) +#define MKEXT_GET_SIGNATURE(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->signature)) +#define MKEXT_GET_LENGTH(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->length)) +#define MKEXT_GET_CHECKSUM(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->adler32)) +#define MKEXT_GET_VERSION(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->version)) +#define MKEXT_GET_COUNT(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->numkexts)) +#define MKEXT_GET_CPUTYPE(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->cputype)) +#define MKEXT_GET_CPUSUBTYPE(hdr) (MKEXT_SWAP(MKEXT_HDR_CAST(hdr)->cpusubtype)) + +#if PRAGMA_MARK +#pragma mark Mkext Version 2 Format Definitions +#endif +/********************************************************************* +* Mkext Version 2 Format Definitions +* +* The version field here will be some variant of 0x0200....; that is +* the major version byte will be 0x02. +* +* Version 2 uses zlib for compression, not the lzss compressor used +* by version 1. +* +* In version 2, all executable & resource files are stored in sequence +* followed by the combined info dictionaries of all kexts at the end. +* This XML plist should be nul-terminated and stored at a page-aligned +* offset in the file so that kernel code can unmap it as soon as it's +* parsed. +* +* The info dict for each kext will have inserted into it these +* additional properties: +* +* - _MKEXTBundlePath (string) - full path to the original bundle, +* relative to volume. +* - _MKEXTExecutable (integer) - offset to the executable entry. +* - _MKEXTResources (dict) - keyed by filename, values integer offsets +* to file entries. +* +* Mkext2 buffers are used to send load requests to the kernel. When +* this is done, the plist will contain an _MKEXTLoadRequest dictionary +* whose keys are the bundle IDs to load, and whose values are +* dictionaries of flags: +* +* - "Load Kext" - boolean, whether to load the kext or not (default true). +* May be used to send just personalities for already-loaded kexts, +* but we do have a mechanism to do that from userland already. +* - "Start Kext" - boolean, whether to start the kext or not +* (used when debugging). Defaults to true. +* - "Add Personalities" - boolean, whether to send personalities to +* the IOCatalogue (used when debugging). Defaults to true. +* - "Disable Autounload" - boolean, whether to prevent the reaper +* thread from unloading the kext, so the dev. has time to set up +* the debug session. (Predefined window, or maybe this will be a +* number of seconds to wait.) Defaults to false. +*********************************************************************/ +#define kMKEXTInfoDictionariesKey "_MKEXTInfoDictionaries" + +#define kMKEXTBundlePathKey "_MKEXTBundlePath" +#define kMKEXTExecutableKey "_MKEXTExecutable" + +#define kMKEXTLoadRequestKey "_MKEXTLoadRequest" +#define kMKEXTLoadRequestLoadKey "Load Kext" +#define kMKEXTLoadRequestStartKey "Start Kext" +#define kMKEXTLoadRequestAddPersonalitiesKey "Add Personalities" +#define kMKEXTLoadRequestDisableAutounloadKey "Disable Autounload" + +typedef struct mkext2_file_entry { + uint32_t compressed_size; // if zero, file is not compressed + uint32_t full_size; // full size of data w/o this struct + uint8_t data[0]; // data is inline to this struct +} mkext2_file_entry; + +typedef struct mkext2_header { + MKEXT_HEADER_CORE + uint32_t plist_offset; + uint32_t plist_compressed_size; + uint32_t plist_full_size; +} mkext2_header; + +#define MKEXT2_GET_ENTRY_COMPSIZE(ptr) MKEXT_SWAP((ptr)->compressed_size) +#define MKEXT2_GET_ENTRY_FULLSIZE(ptr) MKEXT_SWAP((ptr)->full_size) +#define MKEXT2_GET_ENTRY_DATA(ptr) ((ptr)->data) + +#define MKEXT2_HDR_CAST(hdr) ((mkext2_header *)(hdr)) +#define MKEXT2_GET_PLIST(hdr) MKEXT_SWAP(MKEXT2_HDR_CAST(hdr)->plist_offset) +#define MKEXT2_GET_PLIST_COMPSIZE(hdr) MKEXT_SWAP(MKEXT2_HDR_CAST(hdr)->plist_compressed_size) +#define MKEXT2_GET_PLIST_FULLSIZE(hdr) MKEXT_SWAP(MKEXT2_HDR_CAST(hdr)->plist_full_size) + +#if PRAGMA_MARK +#pragma mark Mkext Version 1 Format Definitions +#endif +/********************************************************************* +* Mkext Version 1 Format Definitions +* +* The original mkext format has version 0x01008000 ("1.0"). +* +* In version 1, plists were not nul-terminated, so it's up to the +* reader to add that '\0' on the end if it's needed. +* +* Original bad names preserved for source compatibility. +*********************************************************************/ + +// If all fields are 0 then this file slot is empty +// If compsize is zero then the file isn't compressed. +typedef struct mkext_file { + uint32_t offset; // 4 bytes + uint32_t compsize; // 4 bytes + uint32_t realsize; // 4 bytes + uint32_t modifiedsecs; // 4 bytes; cast to time_t to use +} mkext_file; + +// The plist file entry is mandatory, but module may be empty +typedef struct mkext_kext { + mkext_file plist; // 16 bytes + mkext_file module; // 16 bytes +} mkext_kext; + +typedef struct mkext_header { + MKEXT_HEADER_CORE + mkext_kext kext[1]; // 32 bytes/entry +} mkext_header; + +typedef mkext_header mkext1_header; + +#define MKEXT1_ENTRY_CAST(ptr) ((mkext_file *)(ptr)) +#define MKEXT1_GET_ENTRY_OFFSET(ptr) (MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->offset)) +#define MKEXT1_GET_ENTRY_COMPSIZE(ptr) (MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->compsize)) +#define MKEXT1_GET_ENTRY_FULLSIZE(ptr) (MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->realsize)) +#define MKEXT1_GET_ENTRY_MODTIME(ptr) ((time_t)MKEXT_SWAP(MKEXT1_ENTRY_CAST(ptr)->modifiedsecs)) +#define MKEXT1_ENTRY_EXISTS(ptr) (MKEXT1_GET_ENTRY_OFFSET(ptr) || \ + MKEXT1_GET_ENTRY_FULLSIZE(ptr) || \ + MKEXT_GET_ENTRY_COMPSIZE(ptr) || \ + MKEXT_GET_ENTRY_COMPSIZE(ptr)) + +#define MKEXT1_GET_KEXT(hdr, i) ((mkext_kext *)&(MKEXT1_HDR_CAST(hdr)->kext[(i)])) +#define MKEXT1_GET_KEXT_PLIST(hdr, i) (MKEXT1_ENTRY_CAST(&(MKEXT1_GET_KEXT((hdr), (i))->plist))) +#define MKEXT1_GET_KEXT_EXEC(hdr, i) (MKEXT1_ENTRY_CAST(&(MKEXT1_GET_KEXT((hdr), (i))->module) + +#define MKEXT1_HDR_CAST(hdr) ((mkext1_header *)(hdr)) + +#endif /* _MKEXT_H_ */ Index: branches/slice/i386/modules/include/iostream =================================================================== --- branches/slice/i386/modules/include/iostream (revision 726) +++ branches/slice/i386/modules/include/iostream (revision 727) @@ -1,101 +0,0 @@ -/* 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 - -#ifndef __HEADER_STD_IOSTREAM -#define __HEADER_STD_IOSTREAM 1 - -#include -#include -#include -#include -#include -#include - -#pragma GCC visibility push(default) - -namespace std{ -#ifdef __UCLIBCXX_SUPPORT_CIN__ - extern istream cin; -#endif -#ifdef __UCLIBCXX_SUPPORT_COUT__ - extern ostream cout; -#endif -#ifdef __UCLIBCXX_SUPPORT_CERR__ - extern ostream cerr; -#endif -#ifdef __UCLIBCXX_SUPPORT_CLOG__ - extern ostream clog; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCIN__ - extern wistream wcin; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCOUT__ - extern wostream wcout; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCERR__ - extern wostream wcerr; -#endif -#ifdef __UCLIBCXX_SUPPORT_WCLOG__ - extern wostream wclog; -#endif - - - template class _UCXXEXPORT basic_iostream : - public basic_istream, public basic_ostream - { - public: - // constructor/destructor - explicit _UCXXEXPORT basic_iostream(basic_streambuf* sb); - virtual _UCXXEXPORT ~basic_iostream(); //Below - }; - - template _UCXXEXPORT - basic_iostream:: basic_iostream(basic_streambuf* sb) - : basic_ios(sb), basic_istream(sb), basic_ostream(sb) - { - return; - } - - - template _UCXXEXPORT basic_iostream::~basic_iostream(){ - return; - } - - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_IOSTREAM__ - - template <> _UCXXEXPORT basic_iostream >:: - basic_iostream(basic_streambuf >* sb); - template <> _UCXXEXPORT basic_iostream >::~basic_iostream(); - -#endif -#endif -#endif - - - -} - -#pragma GCC visibility pop - -#endif Index: branches/slice/i386/modules/include/cstdio =================================================================== --- branches/slice/i386/modules/include/cstdio (revision 726) +++ branches/slice/i386/modules/include/cstdio (revision 727) @@ -1,75 +0,0 @@ -/* 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 - - 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 - -#ifndef __HEADER_CSTDIO -#define __HEADER_CSTDIO 1 - - -namespace std{ - using ::FILE; - using ::fpos_t; - - using ::clearerr; - using ::fclose; - using ::feof; - using ::ferror; - using ::fflush; - using ::fgetc; - using ::fgetpos; - using ::fgets; - using ::fopen; - using ::fprintf; - using ::fputc; - using ::fputs; - using ::fread; - using ::freopen; - using ::fscanf; - using ::fseek; - using ::fsetpos; - using ::ftell; - using ::fwrite; - using ::getc; - using ::getchar; - using ::gets; - using ::perror; - using ::printf; - using ::putc; - using ::putchar; - using ::puts; - using ::remove; - using ::rename; - using ::rewind; - using ::scanf; - using ::setbuf; - using ::setvbuf; - using ::sprintf; - using ::sscanf; - using ::tmpfile; - using ::tmpnam; - using ::ungetc; - using ::vfprintf; - using ::vprintf; - using ::vsprintf; -} - - - -#endif - Index: branches/slice/i386/modules/include/cstdarg =================================================================== --- branches/slice/i386/modules/include/cstdarg (revision 726) +++ branches/slice/i386/modules/include/cstdarg (revision 727) @@ -1,60 +0,0 @@ -// -*- C++ -*- forwarding header. - -// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, 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 General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 20.4.6 C library -// - -/** @file cstdarg - * This is a Standard C++ Library file. You should @c #include this file - * in your programs, rather than any of the "*.h" implementation files. - * - * This is the C++ version of the Standard C Library header @c stdarg.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. - */ - -#ifndef _CPP_CSTDARG -#define _CPP_CSTDARG 1 - -#pragma GCC system_header - -#include - -// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 -#ifndef va_end -#define va_end(ap) va_end (ap) -#endif - -namespace std -{ - using ::va_list; -} - -#endif Index: branches/slice/i386/modules/include/map.old =================================================================== --- branches/slice/i386/modules/include/map.old (revision 726) +++ branches/slice/i386/modules/include/map.old (revision 727) @@ -1,1163 +0,0 @@ -/* 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 - - -#ifndef __STD_HEADER_MAP -#define __STD_HEADER_MAP - -#pragma GCC visibility push(default) - -namespace std{ - - -template, class Allocator = allocator > class __base_map; -template, class Allocator = allocator > class map; -template, class Allocator = allocator > class multimap; - -template class __map_iter; -template class __map_citer; - -/* The code for the map containers is split up into two classes. - * The first class, __base_map holds all of the data and does much of the iterator-based - * work. Then the classes map and multimap inherit from there. This was done to reduce - * the redundancy of code (And thus errors which might crop up), as well as possibly - * reducing the size of binaries if both map and multimap are used, along with the same - * template parameters. - */ - - - -//All base classes first (__base_map, iterators, value_compare) and it's associated code - - -template class _UCXXEXPORT __base_map{ - -protected: - friend class __map_iter; - friend class __map_citer; - -public: - typedef __base_map map_type; - typedef Key key_type; - typedef T mapped_type; - typedef pair value_type; - typedef Compare key_compare; - typedef Allocator allocator_type; - typedef typename Allocator::reference reference; - typedef typename Allocator::const_reference const_reference; - typedef __map_iter iterator; - typedef __map_citer const_iterator; - typedef typename Allocator::size_type size_type; - typedef typename Allocator::difference_type difference_type; - typedef typename Allocator::pointer pointer; - typedef typename Allocator::const_pointer const_pointer; - typedef typename std::reverse_iterator reverse_iterator; - typedef typename std::reverse_iterator const_reverse_iterator; - - class value_compare; - - explicit __base_map(const Compare& comp = Compare(), const Allocator& al = Allocator()); - __base_map(const map_type& x); - ~__base_map(); - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - - bool empty() const; - size_type size() const; - size_type max_size() const; - - iterator lower_bound(const key_type& x); - const_iterator lower_bound(const key_type& x) const; - - void swap(map_type & x); - void clear(); - - key_compare key_comp() const; -// value_compare value_comp() const; - -protected: - - deque, allocator > > data; - Compare c; - -}; - - - //Implementations - - template class _UCXXEXPORT __map_citer - : public std::iterator< - bidirectional_iterator_tag, - std::pair, - typename Allocator::difference_type, - std::pair*, - std::pair& - > - { - protected: - typedef __base_map Map; - - friend class __base_map; - friend class __base_map::iterator; - - friend class map; - friend class multimap; - - typename Map::size_type element; - const Map * container; - public: - __map_citer() : element(0), container(0) { } - __map_citer(const typename Map::const_iterator & m) - : element(m.element), container(m.container) { } - __map_citer(typename Map::size_type e, const Map * const c) - : element(e), container(c) { } - ~__map_citer() { } - - typename Map::value_type operator*() const{ - return container->data[element]; - } - const typename Map::value_type * operator->() const{ - return &(container->data[element]); - } - __map_citer & operator=(const typename Map::const_iterator & m){ - element = m.element; - container = m.container; - return *this; - } - bool operator==(const typename Map::const_iterator & m) const { - return (m.element == element && m.container == container); - } - bool operator!=(const typename Map::const_iterator & m) const { - return (m.element != element || m.container != container); - } - __map_citer & operator++(){ - ++element; - return *this; - } - __map_citer operator++(int){ - __map_citer temp(*this); - ++element; - return temp; - } - __map_citer & operator--(){ - --element; - return *this; - } - __map_citer operator--(int){ - __map_citer temp(*this); - --element; - return temp; - } - - }; - - - template class _UCXXEXPORT __map_iter - : public std::iterator< - bidirectional_iterator_tag, - std::pair, - typename Allocator::difference_type, - std::pair*, - std::pair& - > - { - protected: - typedef class __base_map Map; - - //FIXME - Find a way to use template parameters or something. This will do for now - friend class __base_map; - friend class __base_map::const_iterator; - - friend class map; - friend class multimap; - - typename Map::size_type element; - Map * container; - public: - __map_iter() : element(0), container(0) { } - __map_iter(const typename Map::iterator & m) - : element(m.element), container(m.container) { } - __map_iter(typename Map::size_type e, Map * c) - : element(e), container(c) { } - ~__map_iter() { } - - typename Map::value_type & operator*(){ - return container->data[element]; - } - const typename Map::value_type & operator*() const{ - return container->data[element]; - } - typename Map::value_type * operator->(){ - return &(container->data[element]); - } - __map_iter & operator=(const typename Map::iterator & m){ - element = m.element; - container = m.container; - return *this; - } - bool operator==(const typename Map::iterator & m) const { - return (m.element == element && m.container == container); - } - bool operator!=(const typename Map::iterator & m) const { - return (m.element != element || m.container != container); - } - bool operator==(const typename Map::const_iterator & m) const { - return (m.element == element && m.container == container); - } - bool operator!=(const typename Map::const_iterator & m) const { - return (m.element != element || m.container != container); - } - __map_iter & operator++(){ - ++element; - return *this; - } - __map_iter operator++(int){ - __map_iter temp(*this); - ++element; - return temp; - } - __map_iter & operator--(){ - --element; - return *this; - } - __map_iter operator--(int){ - __map_iter temp(*this); - --element; - return temp; - } - - operator typename Map::const_iterator() const{ - return typename Map::const_iterator(element, container); - } - - }; - - - //Compare the keys of the two items - template class _UCXXEXPORT - __base_map::value_compare : public binary_function< - typename map::value_type, - typename map::value_type, - bool> - { - friend class __base_map; - protected: - Compare comp; - value_compare(Compare c) : comp(c) { } - ~value_compare() { } - public: - bool operator()(const value_type& x, const value_type& y) const { - return comp(x.first, y.first); - } - }; - - template - __base_map::__base_map(const Compare& comp, const Allocator&) - : data(), c(comp) - { - - } - - template - __base_map::__base_map(const __base_map& x) - : data(x.data), c(x.c) - { - - } - - template - __base_map::~__base_map() - { - - } - - - template - typename __base_map::iterator - __base_map::begin() - { - return iterator(0, this); - } - - template - typename __base_map::const_iterator - __base_map::begin() const - { - return const_iterator(0, this); - - } - - template - typename __base_map::iterator - __base_map::end() - { - return iterator(data.size(), this); - } - - template - typename __base_map::const_iterator - __base_map::end() const - { - return const_iterator(data.size(), this); - } - - template - typename __base_map::reverse_iterator - __base_map::rbegin() - { - return reverse_iterator(end()); - } - - template - typename __base_map::const_reverse_iterator - __base_map::rbegin() const - { - return const_reverse_iterator(end()); - } - - template - typename __base_map::reverse_iterator - __base_map::rend() - { - return reverse_iterator(begin()); - } - - template - typename __base_map::const_reverse_iterator - __base_map::rend() const - { - return const_reverse_iterator(begin()); - } - - template - bool __base_map::empty() const - { - return (data.size() == 0); - } - - template - typename __base_map::size_type - __base_map::size() const - { - return data.size(); - } - - template - typename __base_map::size_type - __base_map::max_size() const - { - return data.max_size(); - } - - template - typename __base_map::iterator - __base_map::lower_bound(const key_type &x) - { - size_type low = 0; - size_type high = data.size(); - - while (low < high) { - size_type i = (low + high) / 2; - if( c(data[i].first, x) ){ - low = i + 1; - }else{ - high = i; - } - } - - return iterator(low, this); - } - - template - typename __base_map::const_iterator - __base_map::lower_bound(const key_type &x) const - { - size_type low = 0; - size_type high = data.size(); - - while (low < high) { - size_type i = (low + high) / 2; - if( c(data[i].first, x) ){ - low = i + 1; - }else{ - high = i; - } - } - - return const_iterator(low, this); - } - - template - void __base_map::swap(__base_map& m) - { - Compare n = c; - c = m.c; - m.c = n; - - data.swap(m.data); - } - - - template - void __base_map::clear() - { - data.clear(); - } - - - template - typename __base_map::key_compare - __base_map::key_comp() const - { - return c; - } - -// value_compare value_comp() const; - - - - - -/* This is the implementation for the map container. As noted above, it deviates - * from ISO spec by deriving from a base class in order to reduce code redundancy. - * More code could be reduced by convirting to virtual functions (thus allowing - * much of the erase and insert code to be duplicated), but that would deviate from - * the specifications too much to be worth the risk. - */ - - - - - -//Implementation of map - - -template class _UCXXEXPORT map - : public __base_map -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it -public: - - typedef __base_map base; - typedef typename base::key_type key_type; - typedef typename base::mapped_type mapped_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - using base::value_compare; - - explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al) { } - - template map(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& = Allocator()); - - map(const map& x) : base(x) { } - ~map() { } - - map& operator=(const map& x); - - reference operator[](const key_type& k); - - pair insert(const value_type& x); - iterator insert(iterator position, const value_type& x); - - template void insert(InputIterator first, InputIterator last); - void erase(iterator position); - size_type erase(const key_type& x); - void erase(iterator first, iterator last); - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - iterator find(const key_type& x); - const_iterator find(const key_type& x) const; - size_type count(const key_type& x) const; - iterator upper_bound(const key_type& x); - const_iterator upper_bound(const key_type& x) const; - pair equal_range(const key_type& x); - pair equal_range(const key_type& x) const; - -protected: - friend class base::iterator; - friend class base::const_iterator; - - friend bool operator==(const map& x, const map& y); - - using base::data; - using base::c; - -}; - - - template template - map:: - map(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) - : base(comp, al) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - template - map::map& - map::operator=(const map& x) - { - if( &x == this){ - return *this; - } - c = x.c; - data = x.data; - return *this; - } - - - template - typename map::reference - map::operator[](const key_type & k) - { -/* iterator i = lower_bound(k); - if( !c( i->first, k) && !c(k, i->first) ){ - return i->second; - } - pair t; - t.first = k; - t.second = T(); - return insert(t).first->second; -*/ - //This is from the spec and is quite ugly. - return (*((insert(make_pair(k, T()))).first)).second; - } - - template - pair::iterator, bool> - map::insert(const value_type& x) - { - pair::iterator, bool> retval; - - //Either set is empty or element to insert goes at the begining - if(data.size() == 0 || c(x.first, data[0].first) ){ - data.push_front(x); - retval.first = begin(); - retval.second = true; - return retval; - } - - //Element to insert goes at the end - if( c(data[data.size() - 1].first, x.first) ){ - data.push_back(x); - retval.first = end(); - --retval.first; - retval.second = true; - return retval; - } - - retval.first = __base_map::lower_bound(x.first); - - //No match - this should never happen - if(retval.first == end()){ - retval.second = false; - return retval; - } - - //If we have an exact match - if( !c( retval.first->first, x.first) && !c(x.first, retval.first->first ) ){ - retval.second = false; - return retval; - } - - typename deque, allocator > >::iterator q(&data, retval.first.element); - data.insert(q, x); - - retval.first = __base_map::lower_bound(x.first); //Need to refind because insert can move data around - retval.second = true; - - return retval; - } - - - template - typename map::iterator - map::insert(iterator, const value_type& x) - { - //Just reusing code. It's hard to make improvements over existing algo. - //We aren't using the iterator parameter, but it's only a hint and not required to be used. - insert(x); - return find(x.first); - } - - template - template void - map::insert(InputIterator first, InputIterator last) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - template void - map::erase(iterator position) - { - //Create a deque iterator from position information and then - //Use built in erase feature because it is handy. - typename deque, allocator > >::iterator pos(&data, position.element); - data.erase(pos); - } - - template - typename map::size_type - map::erase(const key_type& x) - { - typename map::iterator i = find(x); - if(i!=end()){ - erase(i); - return 1; - } - return 0; - } - - template - void map::erase(iterator first, iterator last) - { - typename deque, allocator > >::iterator f(&data, first.element); - typename deque, allocator > >::iterator l(&data, last.element); - data.erase(f, l); - } - - template - typename map::iterator - map:: - find(const typename map::key_type& x) - { - if(data.size() == 0){ - return end(); - } - - iterator retval = __base_map::lower_bound(x); - - if(retval == end()){ - return retval; - } - - //Make sure we have an exact match.... - if(!c( retval->first, x) && !c(x, retval->first )){ - return retval; - } - return end(); - - } - - template - typename map::const_iterator - map::find(const key_type& x) const - { - if(data.size() == 0){ - return end(); - } - - const_iterator retval = __base_map::lower_bound(x); - - if(retval == end()){ - return retval; - } - - //Make sure we have an exact match.... - if(!c( retval->first, x) && !c(x, retval->first )){ - return retval; - } - return end(); - - } - - template - typename map::size_type - map::count(const typename map::key_type& x) const - { - if( find(x) == end()){ - return 0; - } - return 1; - } - - template - typename map::iterator - map::upper_bound(const key_type& x) - { - typename map::iterator i = __base_map::lower_bound(x); - if( i != end() && !c(x, i->first) ){ - ++i; - } - return i; - } - - template - typename map::const_iterator - map::upper_bound(const key_type& x) const - { - typename map::const_iterator i = __base_map::lower_bound(x); - if(i != end() && !c(x, i->first)){ - ++i; - } - return i; - } - - - template - pair< typename map::iterator, - typename map::iterator - > map::equal_range(const key_type& x) - { - pair< typename map::iterator, - typename map::iterator - > retval; - retval.first = __base_map::lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - template - pair< typename map::const_iterator, - typename map::const_iterator - > map::equal_range(const key_type& x) const - { - pair< typename map::const_iterator, - typename map::const_iterator - > retval; - retval.first = __base_map::lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - template bool operator== - (const map& x, const map& y) - { - if(x.c == y.c && x.data == y.data){ - return true; - } - return false; - } - - - -//Implementation of multimap - - -template class _UCXXEXPORT multimap - : public __base_map -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it -public: - - typedef __base_map base; - typedef typename base::key_type key_type; - typedef typename base::mapped_type mapped_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al) { } - - template multimap(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& = Allocator()); - - multimap(const multimap& x) : base(x) { } - ~multimap() { } - - multimap& operator=(const multimap& x); - - iterator insert(const value_type& x); - iterator insert(iterator position, const value_type& x); - template void insert(InputIterator first, InputIterator last); - - void erase(iterator position); - size_type erase(const key_type& x); - void erase(iterator first, iterator last); - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - iterator find(const key_type& x); - const_iterator find(const key_type& x) const; - size_type count(const key_type& x) const; - iterator upper_bound(const key_type& x); - const_iterator upper_bound(const key_type& x) const; - pair equal_range(const key_type& x); - pair equal_range(const key_type& x) const; - -protected: - friend class base::iterator; - friend class base::const_iterator; - - using base::data; - using base::c; - -}; - - - - template template - multimap:: - multimap(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) - : base(comp, al) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - template - multimap::multimap& - multimap::operator=(const multimap& x) - { - if( &x == this){ - return *this; - } - c = x.c; - data = x.data; - return *this; - } - - - template - typename multimap::iterator - multimap::insert(const value_type &x) - { - iterator retval; - - //Either set is empty or element to insert goes at the begining - if(data.size() == 0 || c(x.first, data[0].first) ){ - data.push_front(x); - return begin(); - } - - //Element to insert goes at the end - if( c(data[data.size() - 1].first, x.first) ){ - data.push_back(x); - return end(); - } - - retval = __base_map::lower_bound(x.first); - - //No match - this should never happen - if(retval == end()){ - return retval; - } - - if( !c(x.first, retval->first) ){ - ++retval; - } - - typename deque, allocator > >::iterator q(&data, retval.element); - data.insert(q, x); - - return retval; - } - - - template - typename multimap::iterator - multimap::insert(iterator position, const value_type& x) - { - - //Inserting at begining - if(position == begin() && !c(position->first, x.first) ){ - data.push_front(x); - return position; - } - //Inserting at end - if(position == end() && !c(x.first, data[data.size() - 1].first) ){ - data.push_back(x); - return position; - } - - //Inserting in middle - iterator temp = position; - --temp; - if( !c(position->first, x.first) && !c(x.first, temp->first) ){ - typename deque, allocator > >::iterator q(&data, position.element); - data.insert(q, x); - return position; - } - - return insert(x); - } - - template - template void - multimap::insert(InputIterator first, InputIterator last) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - - - template void - multimap::erase(iterator position) - { - //Create a deque iterator from position information and then - //Use built in erase feature because it is handy. - typename deque, allocator > >::iterator pos(&data, position.element); - data.erase(pos); - } - - template - typename multimap::size_type - multimap::erase(const key_type& x) - { - typename multimap::iterator f = __base_map::lower_bound(x); - typename multimap::iterator l = upper_bound(x); - size_type t = l.element - f.element; - erase(f, l); - return t; - } - - - - template - void multimap::erase(iterator first, iterator last) - { - typename deque, allocator > >::iterator f(&data, first.element); - typename deque, allocator > >::iterator l(&data, last.element); - data.erase(f, l); - } - - - template - typename multimap::iterator - multimap::find(const key_type& x) - { - if(data.size() == 0){ - return end(); - } - - iterator retval = __base_map::lower_bound(x); - - if(retval == end()){ - return retval; - } - - if( c(x, retval->first) || c(retval->first, x) ){ - return end(); - } - - while( retval.element > 0 && !c(retval->first, x) && !c(x, retval->first) ){ - --retval; - } - if( c(retval->first, x)){ - ++retval; - } - - return retval; - } - - - template - typename multimap::const_iterator - multimap::find(const key_type& x) const - { - if(data.size() == 0){ - return end(); - } - const_iterator retval = __base_map::lower_bound(x); - - if(retval == end()){ - return retval; - } - - if( c(x, retval->first) || c(retval->first, x) ){ - return end(); - } - - while( retval.element > 0 && !c(retval->first, x) && !c(x, retval->first) ){ - --retval; - } - if( c(retval->first, x)){ - ++retval; - } - - - return retval; - } - - - template - typename multimap::size_type - multimap:: - count(const typename multimap::key_type& x) const - { - pair< typename multimap::const_iterator, - typename multimap::const_iterator - > temp = equal_range(x); - - return temp.second.element - temp.first.element; - } - - template - typename multimap::iterator - multimap::upper_bound(const key_type& x) - { - typename multimap::iterator i = __base_map::lower_bound(x); - - while(i != end() && !c(x, i->first)){ - ++i; - } - return i; - } - - template - typename multimap::const_iterator - multimap::upper_bound(const key_type& x) const - { - typename multimap::const_iterator i = __base_map::lower_bound(x); - - while(i != end() && !c(x, i->first)){ - ++i; - } - return i; - } - - - template - pair< typename multimap::iterator, - typename multimap::iterator - > multimap::equal_range(const key_type& x) - { - pair< typename multimap::iterator, - typename multimap::iterator - > retval; - retval.first = __base_map::lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - template - pair< typename multimap::const_iterator, - typename multimap::const_iterator - > multimap::equal_range(const key_type& x) const - { - pair< typename multimap::const_iterator, - typename multimap::const_iterator - > retval; - retval.first = __base_map::lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - - - - -/* Non-member functions. These are at the end because they are not associated with any - particular class. These will be implemented as I figure out exactly what all of - them are supposed to do, and I have time. - */ - - template _UCXXEXPORT bool operator< - (const map& x, const map& y); - template _UCXXEXPORT bool operator!= - (const map& x, const map& y); - template _UCXXEXPORT bool operator> - (const map& x, const map& y); - template _UCXXEXPORT bool operator>= - (const map& x, const map& y); - template _UCXXEXPORT bool operator<= - (const map& x, const map& y); - template _UCXXEXPORT void swap - (map& x, map& y); - - - template _UCXXEXPORT bool operator== - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator< - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator!= - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator> - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator>= - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator<= - (const multimap& x, const multimap& y); - template _UCXXEXPORT void swap - (multimap& x, multimap& y); - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/unwind-cxx.h =================================================================== --- branches/slice/i386/modules/include/unwind-cxx.h (revision 726) +++ branches/slice/i386/modules/include/unwind-cxx.h (revision 727) @@ -1,182 +0,0 @@ -// -*- C++ -*- Exception handling and frame unwind runtime interface routines. -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This file is part of GCC. -// -// GCC is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// GCC 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GCC; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// This is derived from the C++ ABI for IA-64. Where we diverge -// for cross-architecture compatibility are noted with "@@@". - -#ifndef _UNWIND_CXX_H -#define _UNWIND_CXX_H 1 - -// Level 2: C++ ABI - -#include -#include -#include -#include "unwind.h" - -#pragma GCC visibility push(default) - -namespace __cxxabiv1 -{ - -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ - -// A C++ exception object consists of a header, which is a wrapper around -// an unwind object header with additional C++ specific information, -// followed by the exception object itself. - -struct __cxa_exception -{ - // Manage the exception object itself. - std::type_info *exceptionType; - void (*exceptionDestructor)(void *); - - // The C++ standard has entertaining rules wrt calling set_terminate - // and set_unexpected in the middle of the exception cleanup process. - std::unexpected_handler unexpectedHandler; - std::terminate_handler terminateHandler; - - // The caught exception stack threads through here. - __cxa_exception *nextException; - - // How many nested handlers have caught this exception. A negated - // value is a signal that this object has been rethrown. - int handlerCount; - - // Cache parsed handler data from the personality routine Phase 1 - // for Phase 2 and __cxa_call_unexpected. - int handlerSwitchValue; - const unsigned char *actionRecord; - const unsigned char *languageSpecificData; - _Unwind_Ptr catchTemp; - void *adjustedPtr; - - // The generic exception header. Must be last. - _Unwind_Exception unwindHeader; -}; - - // Each thread in a C++ program has access to a __cxa_eh_globals object. -struct __cxa_eh_globals -{ - __cxa_exception *caughtExceptions; - unsigned int uncaughtExceptions; -}; - - -// The __cxa_eh_globals for the current thread can be obtained by using -// either of the following functions. The "fast" version assumes at least -// one prior call of __cxa_get_globals has been made from the current -// thread, so no initialization is necessary. -extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); -extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw(); -#endif - -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ -// Allocate memory for the exception plus the thown object. -extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw(); - -// Free the space allocated for the exception. -extern "C" void __cxa_free_exception(void *thrown_exception) throw(); - -// Throw the exception. -extern "C" void __cxa_throw (void *thrown_exception, - std::type_info *tinfo, - void (*dest) (void *)) - __attribute__((noreturn)); - -// Used to implement exception handlers. -extern "C" void *__cxa_begin_catch (void *) throw(); -extern "C" void __cxa_end_catch (); -extern "C" void __cxa_rethrow () __attribute__((noreturn)); -#endif - -// These facilitate code generation for recurring situations. -extern "C" void __cxa_bad_cast (); -extern "C" void __cxa_bad_typeid (); - -// @@@ These are not directly specified by the IA-64 C++ ABI. - -// Handles re-checking the exception specification if unexpectedHandler -// throws, and if bad_exception needs to be thrown. Called from the -// compiler. -extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn)); - -// Invokes given handler, dying appropriately if the user handler was -// so inconsiderate as to return. -extern void __terminate(std::terminate_handler) __attribute__((noreturn)); -extern void __unexpected(std::unexpected_handler) __attribute__((noreturn)); - -// The current installed user handlers. -extern std::terminate_handler __terminate_handler; -extern std::unexpected_handler __unexpected_handler; - -// These are explicitly GNU C++ specific. - -// This is the exception class we report -- "GNUCC++\0". -const _Unwind_Exception_Class __gxx_exception_class -= ((((((((_Unwind_Exception_Class) 'G' - << 8 | (_Unwind_Exception_Class) 'N') - << 8 | (_Unwind_Exception_Class) 'U') - << 8 | (_Unwind_Exception_Class) 'C') - << 8 | (_Unwind_Exception_Class) 'C') - << 8 | (_Unwind_Exception_Class) '+') - << 8 | (_Unwind_Exception_Class) '+') - << 8 | (_Unwind_Exception_Class) '\0'); - -// GNU C++ personality routine, Version 0. -extern "C" _Unwind_Reason_Code __gxx_personality_v0 - (int, _Unwind_Action, _Unwind_Exception_Class, - struct _Unwind_Exception *, struct _Unwind_Context *); - -// GNU C++ sjlj personality routine, Version 0. -extern "C" _Unwind_Reason_Code __gxx_personality_sj0 - (int, _Unwind_Action, _Unwind_Exception_Class, - struct _Unwind_Exception *, struct _Unwind_Context *); - - -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ -// Acquire the C++ exception header from the C++ object. -static inline __cxa_exception * -__get_exception_header_from_obj (void *ptr) -{ - return reinterpret_cast<__cxa_exception *>(ptr) - 1; -} - -// Acquire the C++ exception header from the generic exception header. -static inline __cxa_exception * -__get_exception_header_from_ue (_Unwind_Exception *exc) -{ - return reinterpret_cast<__cxa_exception *>(exc + 1) - 1; -} -#endif -} /* namespace __cxxabiv1 */ - -#pragma GCC visibility pop - -#endif // _UNWIND_CXX_H Index: branches/slice/i386/modules/include/iomanip =================================================================== --- branches/slice/i386/modules/include/iomanip (revision 726) +++ branches/slice/i386/modules/include/iomanip (revision 727) @@ -1,170 +0,0 @@ -/* 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 -#include - -#ifndef __STD_IOMANIP -#define __STD_IOMANIP 1 - -#pragma GCC visibility push(default) - -namespace std{ - -// These are the helper classes which we are going to be using to -// hold the required data - -class _UCXXEXPORT __resetiosflags{ -public: - ios_base::fmtflags m; - _UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ } -}; - -class _UCXXEXPORT __setiosflags{ -public: - ios_base::fmtflags m; - _UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ } -}; - -class _UCXXEXPORT __setbase{ -public: - int base; - _UCXXEXPORT __setbase(int b) : base(b){ } -}; - -class _UCXXEXPORT __setfill{ -public: - int character; - _UCXXEXPORT __setfill(int c): character(c){ } -}; - -class _UCXXEXPORT __setprecision{ -public: - int digits; - _UCXXEXPORT __setprecision(int n): digits(n) { } -}; - -class _UCXXEXPORT __setw{ -public: - int width; - _UCXXEXPORT __setw(int n): width(n) { } -}; - - -//Actual manipulator functions - -inline __resetiosflags resetiosflags(ios_base::fmtflags mask){ - return __resetiosflags(mask); -} - -inline __setiosflags setiosflags(ios_base::fmtflags mask){ - return __setiosflags(mask); -} - -inline __setbase setbase(int b){ - return __setbase(b); -} - -inline __setfill setfill(int c){ - return __setfill(c); -} - -inline __setprecision setprecision(int n){ - return __setprecision(n); -} - -inline __setw setw(int n){ - return __setw(n); -} - - -//How to handle interaction with [i|o]stream classes - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __resetiosflags s) -{ - os.setf(ios_base::fmtflags(0),s.m); - return os; -} - -template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, const __resetiosflags s) -{ - is.setf(ios_base::fmtflags(0),s.m); - return is; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setiosflags s) -{ - os.setf(s.m); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setbase s) -{ - ios_base::fmtflags f(0); - switch(s.base){ - case 8: - f = ios_base::oct; - break; - case 10: - f = ios_base::dec; - break; - case 16: - f = ios_base::hex; - break; - default: - break; - - } - os.setf(f, ios_base::basefield); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setfill s) -{ - os.fill(s.character); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setprecision s) -{ - os.precision(s.digits); - return os; -} - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const __setw s) -{ - os.width(s.width); - return os; -} - - - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/numeric =================================================================== --- branches/slice/i386/modules/include/numeric (revision 726) +++ branches/slice/i386/modules/include/numeric (revision 727) @@ -1,161 +0,0 @@ -/* 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 - -#ifndef __STD_NUMERIC_HEADER -#define __STD_NUMERIC_HEADER 1 - -#pragma GCC visibility push(default) - -namespace std{ - template _UCXXEXPORT - T accumulate(InputIterator first, InputIterator last, T init) - { - while(first != last){ - init = init + *first; - ++first; - } - return init; - } - - template _UCXXEXPORT - T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) - { - while(first != last){ - init = binary_op(init, *first); - ++first; - } - return init; - } - - - template _UCXXEXPORT - T inner_product(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, T init) - { - while(first1 != last1){ - init = init + *first1 * *first2; - ++first1; - ++first2; - } - return init; - } - - template _UCXXEXPORT - T inner_product(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, T init, - BinaryOperation1 binary_op1, - BinaryOperation2 binary_op2) - { - while(first1 != last1){ - init = binary_op1(init, binary_op2(*first1, *first2)); - ++first1; - ++first2; - } - return init; - } - - template _UCXXEXPORT - OutputIterator partial_sum(InputIterator first, InputIterator last, - OutputIterator result) - { - OutputIterator temp(result); - *result = *first; - ++first; - ++result; - - while(first != last){ - *result = *first + *temp; - temp = result; - ++first; - ++result; - } - return result; - } - - - template _UCXXEXPORT - OutputIterator partial_sum(InputIterator first, InputIterator last, - OutputIterator result, BinaryOperation binary_op) - { - OutputIterator temp(result); - *result = *first; - ++first; - ++result; - - while(first != last){ - *result = binary_op(*first, *temp); - temp = result; - ++first; - ++result; - } - return result; - } - - - template _UCXXEXPORT - OutputIterator - adjacent_difference(InputIterator first, InputIterator last, - OutputIterator result) - { - OutputIterator temp(first); - *result = *first; - ++first; - ++result; - - while(first != last){ - *result = *first - *temp; - temp = first; - ++first; - ++result; - } - - return result; - } - - - template _UCXXEXPORT - OutputIterator - adjacent_difference(InputIterator first, InputIterator last, - OutputIterator result, BinaryOperation binary_op) - { - OutputIterator temp(first); - *result = *first; - ++first; - ++result; - - while(first != last){ - *result = binary_op(*first, *temp); - temp = first; - ++first; - ++result; - } - - return result; - } - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/utility =================================================================== --- branches/slice/i386/modules/include/utility (revision 726) +++ branches/slice/i386/modules/include/utility (revision 727) @@ -1,88 +0,0 @@ -/* 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 - - -#ifndef __STD_HEADER_UTILITY -#define __STD_HEADER_UTILITY 1 - -#pragma GCC visibility push(default) - -namespace std{ - - namespace rel_ops { - template inline bool operator!=(const T& x, const T& y){ - return !(x == y); - } - - template inline bool operator> (const T& x, const T& y){ - return ( y < x); - } - - template inline bool operator<=(const T& x, const T& y){ - return !( y < x ); - } - - template inline bool operator>=(const T& x, const T& y){ - return !(x < y); - } - } - - template struct _UCXXEXPORT pair { - typedef T1 first_type; - typedef T2 second_type; - - T1 first; - T2 second; - pair() : first(), second() { } - pair(const T1& x, const T2& y) : first(x), second(y) { } - template pair(const pair &p) : first(p.first), second(p.second) { } - }; - - template bool operator==(const pair& x, const pair& y){ - using namespace rel_ops; - return (x.first == y.first && x.second==y.second); - } - template bool operator< (const pair& x, const pair& y){ - return x.first < y.first || (!(y.first < x.first) && x.second < y.second); - } - template bool operator!=(const pair& x, const pair& y){ - return !(x == y); - } - template bool operator> (const pair& x, const pair& y){ - return y < x; - } - template bool operator>=(const pair& x, const pair& y){ - return !(x < y); - } - template bool operator<=(const pair& x, const pair& y){ - return !(y < x); - } - template pair make_pair(const T1& x, const T2& y){ - return pair(x, y); - } - - -} - -#pragma GCC visibility pop - -#endif //__STD_HEADER_UTILITY Index: branches/slice/i386/modules/include/cwchar =================================================================== --- branches/slice/i386/modules/include/cwchar (revision 726) +++ branches/slice/i386/modules/include/cwchar (revision 727) @@ -1,86 +0,0 @@ -/* 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 - - 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 - -#ifndef __HEADER_CWCHAR -#define __HEADER_CWCHAR 1 - - -namespace std{ - using ::mbstate_t; - using ::wint_t; - - using ::btowc; - using ::fgetwc; - using ::fgetws; - using ::fputwc; - using ::fputws; - using ::fwide; - using ::fwprintf; - using ::fwscanf; - using ::getwc; - using ::getwchar; - using ::mbrlen; - using ::mbrtowc; - using ::mbsinit; - using ::mbsrtowcs; - using ::putwc; - using ::putwchar; - using ::swprintf; - using ::swscanf; - using ::ungetwc; - using ::vfwprintf; - using ::vswprintf; - using ::vwprintf; - using ::wcrtomb; - using ::wcscat; - using ::wcschr; - using ::wcscmp; - using ::wcscoll; - using ::wcscpy; - using ::wcscspn; - using ::wcsftime; - using ::wcslen; - using ::wcsncat; - using ::wcsncmp; - using ::wcsncpy; - using ::wcspbrk; - using ::wcsrchr; - using ::wcsrtombs; - using ::wcsspn; - using ::wcsstr; - using ::wcstod; - using ::wcstok; - using ::wcstol; - using ::wcstoul; - using ::wcsxfrm; - using ::wctob; - using ::wmemchr; - using ::wmemcmp; - using ::wmemcpy; - using ::wmemmove; - using ::wmemset; - using ::wprintf; - using ::wscanf; -} - - - -#endif - Index: branches/slice/i386/modules/include/type_traits =================================================================== --- branches/slice/i386/modules/include/type_traits (revision 726) +++ branches/slice/i386/modules/include/type_traits (revision 727) @@ -1,92 +0,0 @@ -/* 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 -#include -#include -#include -#include - -#ifndef __HEADER_TYPE_TRAITS -#define __HEADER_TYPE_TRAITS 1 - -#pragma GCC visibility push(default) - -namespace std{ - - struct _UCXXEXPORT __true_type{}; - struct _UCXXEXPORT __false_type{}; - - template class _UCXXEXPORT __is_integer{ - public: - typedef __false_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - template <> class _UCXXEXPORT __is_integer { - public: - typedef __true_type value; - }; - - - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/memory =================================================================== --- branches/slice/i386/modules/include/memory (revision 726) +++ branches/slice/i386/modules/include/memory (revision 727) @@ -1,196 +0,0 @@ -/* 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 -#include - -#ifndef HEADER_STD_MEMORY -#define HEADER_STD_MEMORY 1 - -#pragma GCC visibility push(default) - -namespace std{ - -template class allocator; - // Specialize for void: - -template <> class _UCXXEXPORT allocator { -public: - typedef void* pointer; - typedef const void* const_pointer; - typedef void value_type; - template struct rebind { typedef allocator other; }; -}; - -template class _UCXXEXPORT allocator{ -public: - typedef T value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - - typedef T* pointer; - typedef const T* const_pointer; - - typedef T& reference; - typedef const T& const_reference; - - pointer address(reference r) const { return &r; } - const_pointer address(const_reference r) const { return &r; } - - allocator() throw(){} - template allocator(const allocator& ) throw(); - ~allocator() throw(){} - - //Space for n Ts - pointer allocate(size_type n, typename allocator::const_pointer = 0){ - return (T*)(::operator new( n * sizeof(T) )); - } - void deallocate(pointer p, size_type){ - ::operator delete(p); - } - - //Use placement new to engage the constructor - void construct(pointer p, const T& val) { new((void*)p) T(val); } - void destroy(pointer p){ ((T*)p)->~T(); } //Call destructor - - size_type max_size() const throw(); - template struct rebind { typedef allocator other; }; - -}; - -template class _UCXXEXPORT raw_storage_iterator - : public iterator -{ - Out p; - -public: - explicit raw_storage_iterator(Out pp) : p (pp) { } - raw_storage_iterator & operator*() { return *this; } - raw_storage_iterator & operator=(const T& val) { - T* pp = &*p; - new(pp) T(val); - return *this; - } - - raw_storage_iterator & operator++() { ++p; return *this; } - raw_storage_iterator operator++(int) { - raw_storage_iterator t = *this; - ++p; - return t; - } -}; - -template _UCXXEXPORT pair get_temporary_buffer(ptrdiff_t n){ - pair retval; - retval.first = static_cast(malloc(n * sizeof(T))); - if(retval.first == 0){ - retval.second = 0; - }else{ - retval.second = n; - } - return retval; -} - -template _UCXXEXPORT void return_temporary_buffer(T* p){ - free(p); -} - - -template class _UCXXEXPORT auto_ptr{ - -private: - T * object; - template struct auto_ptr_ref{ - Y * p; - }; - -public: - - typedef T element_type; - - explicit auto_ptr(T* p =0) throw() : object(p){ } - auto_ptr(auto_ptr& p) throw() : object(p.release()){ } - auto_ptr(auto_ptr_ref r) throw() : object(r.p){ - r.p = 0; - } - template auto_ptr(auto_ptr& p) throw() : object(p.release()){ } - auto_ptr& operator=(auto_ptr& p) throw(){ - if(&p == this){ - return *this; - } - delete object; - object = p.release(); - return *this; - } - template auto_ptr& operator=(auto_ptr& p) throw(){ - if(&p == this){ - return *this; - } - delete object; - object = p.release(); - return *this; - } - ~auto_ptr(){ - delete object; - } - - T& operator*() const throw(){ - return *object; - } - T* operator->() const throw(){ - return object; - } - T* get() const throw(){ - return object; - } - T* release() throw(){ - T * temp(object); - object = 0; - return temp; - } - void reset(T * p=0) throw(){ - if(p != object){ - delete object; - object = p; - } - } - template operator auto_ptr_ref() throw(){ - auto_ptr_ref retval; - retval.p = object; - object = 0; - return retval; - } - template operator auto_ptr() throw(){ - auto_ptr retval(object); - object = 0; - return retval; - } - -}; - -} //namespace std - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/set.old =================================================================== --- branches/slice/i386/modules/include/set.old (revision 726) +++ branches/slice/i386/modules/include/set.old (revision 727) @@ -1,1535 +0,0 @@ -/* 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 - - -#ifndef __STD_HEADER_SET -#define __STD_HEADER_SET - -#pragma GCC visibility push(default) - -namespace std{ - - -template, class Allocator = allocator > class __base_set; -template, class Allocator = allocator > class set; -template, class Allocator = allocator > class multiset; - -template class __set_iter; -template class __set_citer; - -template bool operator== - (const set& x, const set& y); - -template bool operator== - (const multiset& x, const multiset& y); - - - -/* The code for the set containers is split up into two classes. - * The first class, __base_set holds all of the data and does much of the iterator-based - * work. Then the classes set and multiset inherit from there. This was done to reduce - * the redundancy of code (And thus errors which might crop up), as well as possibly - * reducing the size of binaries if both set and multiset are used, along with the same - * template parameters. - */ - - - -//All base classes first (__base_set, iterators, value_compare) and it's associated code - - -template class _UCXXEXPORT __base_set{ - -protected: - friend class __set_iter; - friend class __set_citer; - friend bool operator==<>(const set& x, const set& y); - friend bool operator==<>(const multiset& x, const multiset& y); - -public: - typedef __base_set set_type; - typedef Key key_type; - typedef Key value_type; - typedef Compare key_compare; - typedef Allocator allocator_type; - typedef typename Allocator::reference reference; - typedef typename Allocator::const_reference const_reference; - typedef __set_iter iterator; - typedef __set_citer const_iterator; - typedef typename Allocator::size_type size_type; - typedef typename Allocator::difference_type difference_type; - typedef typename Allocator::pointer pointer; - typedef typename Allocator::const_pointer const_pointer; - typedef typename std::reverse_iterator reverse_iterator; - typedef typename std::reverse_iterator const_reverse_iterator; - - class value_compare; - - explicit __base_set(const Compare& comp = Compare(), const Allocator& al = Allocator()); - __base_set(const set_type& x); - ~__base_set(); - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - - bool empty() const; - size_type size() const; - size_type max_size() const; - - void swap(set_type & x); - void clear(); - - key_compare key_comp() const; - -protected: - - deque > data; - Compare c; - -}; - - - //Implementations - - template class _UCXXEXPORT __set_citer - : public std::iterator< - bidirectional_iterator_tag, - Key, - typename Allocator::difference_type, - typename Allocator::pointer, - typename Allocator::reference - > - { - protected: - typedef class __base_set Set; - - friend class __base_set; - friend class __base_set::iterator; - - friend class set; - friend class multiset; - - typename Set::size_type element; - const Set * container; - public: - __set_citer() : element(0), container(0) { } - __set_citer(const typename Set::const_iterator & m) - : element(m.element), container(m.container) { } - __set_citer(typename Set::size_type e, const Set * const c) - : element(e), container(c) { } - ~__set_citer() { } - - typename Set::value_type operator*(){ - return container->data[element]; - } - const typename Set::value_type * operator->() const{ - return &(container->data[element]); - } - __set_citer & operator=(const typename Set::const_iterator & m){ - element = m.element; - container = m.container; - return *this; - } - bool operator==(const typename Set::const_iterator & m) const { - return (m.element == element && m.container == container); - } - bool operator!=(const typename Set::const_iterator & m) const { - return (m.element != element || m.container != container); - } - __set_citer & operator++(){ - ++element; - return *this; - } - __set_citer operator++(int){ - __set_citer temp(*this); - ++element; - return temp; - } - __set_citer & operator--(){ - --element; - return *this; - } - __set_citer operator--(int){ - __set_citer temp(*this); - --element; - return temp; - } - - }; - - template class _UCXXEXPORT __set_iter - : public std::iterator< - bidirectional_iterator_tag, - Key, - typename Allocator::difference_type, - typename Allocator::pointer, - typename Allocator::reference - > - { - protected: - typedef __base_set Set; - - //FIXME - Find a way to use template parameters or something. This will do for now - friend class __base_set; - friend class __base_set::const_iterator; - - friend class set; - friend class multiset; - - typename Set::size_type element; - Set * container; - public: - __set_iter() : element(0), container(0) { } - __set_iter(const typename Set::iterator & m) - : element(m.element), container(m.container) { } - __set_iter(typename Set::size_type e, Set * c) - : element(e), container(c) { } - ~__set_iter() { } - - typename Set::value_type & operator*(){ - return container->data[element]; - } - const typename Set::value_type & operator*() const{ - return container->data[element]; - } - typename Set::value_type * operator->(){ - return &(container->data[element]); - } - __set_iter & operator=(const typename Set::iterator & m){ - element = m.element; - container = m.container; - return *this; - } - bool operator==(const typename Set::iterator & m) const { - return (m.element == element && m.container == container); - } - bool operator!=(const typename Set::iterator & m) const { - return (m.element != element || m.container != container); - } - bool operator==(const typename Set::const_iterator & m) const { - return (m.element == element && m.container == container); - } - bool operator!=(const typename Set::const_iterator & m) const { - return (m.element != element || m.container != container); - } - __set_iter & operator++(){ - ++element; - return *this; - } - __set_iter operator++(int){ - __set_iter temp(*this); - ++element; - return temp; - } - __set_iter & operator--(){ - --element; - return *this; - } - __set_iter operator--(int){ - __set_iter temp(*this); - --element; - return temp; - } - - //Conversion operator - operator typename Set::const_iterator () const - { - typename Set::const_iterator retval(element, container); -// return typename Set::const_iterator(element, container); - return retval; - } - }; - - - - //Compare the keys of the two items - template class _UCXXEXPORT - __base_set::value_compare : public binary_function< - typename set::value_type, - typename set::value_type, - bool> - { - friend class __base_set; - protected: - Compare comp; - value_compare(Compare c) : comp(c) { } - ~value_compare() { } - public: - bool operator()(const value_type& x, const value_type& y) const { - return comp(x, y); - } - }; - - template - __base_set::__base_set(const Compare& comp, const Allocator&) - : data(), c(comp) - { - - } - - template - __base_set::__base_set(const __base_set& x) - : data(x.data), c(x.c) - { - - } - - template - __base_set::~__base_set() - { - - } - - template - typename __base_set::iterator - __base_set::begin() - { - return iterator(0, this); - } - - template - typename __base_set::const_iterator - __base_set::begin() const - { - return const_iterator(0, this); - - } - - template - typename __base_set::iterator - __base_set::end() - { - return iterator(data.size(), this); - } - - template - typename __base_set::const_iterator - __base_set::end() const - { - return const_iterator(data.size(), this); - } - - template - typename __base_set::reverse_iterator - __base_set::rbegin() - { - return reverse_iterator(end()); - } - - template - typename __base_set::const_reverse_iterator - __base_set::rbegin() const - { - return const_reverse_iterator(end()); - } - - template - typename __base_set::reverse_iterator - __base_set::rend() - { - return reverse_iterator(begin()); - } - - template - typename __base_set::const_reverse_iterator - __base_set::rend() const - { - return const_reverse_iterator(begin()); - } - - template - bool __base_set::empty() const - { - return (data.size() == 0); - } - - template - typename __base_set::size_type - __base_set::size() const - { - return data.size(); - } - - template - typename __base_set::size_type - __base_set::max_size() const - { - return data.max_size(); - } - - - template - void __base_set::swap(__base_set& m) - { - Compare n = c; - c = m.c; - m.c = n; - - data.swap(m.data); - } - - - template - void __base_set::clear() - { - data.clear(); - } - - - template - typename __base_set::key_compare - __base_set::key_comp() const - { - return c; - } - -// value_compare value_comp() const; - - - -/* This is the implementation for the set container. As noted above, it deviates - * from ISO spec by deriving from a base class in order to reduce code redundancy. - * More code could be reduced by convirting to virtual functions (thus allowing - * much of the erase and insert code to be duplicated), but that would deviate from - * the specifications too much to be worth the risk. - */ - - - - - -//Implementation of set - - -template class _UCXXEXPORT set - : public __base_set -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it -public: - - typedef __base_set base; - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - using base::value_compare; - - explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al) { } - - template set(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& = Allocator()); - - set(const set& x) : base(x) { } - ~set() { } - - set& operator=(const set& x); - - pair insert(const value_type& x); - iterator insert(iterator position, const value_type& x); - - template void insert(InputIterator first, InputIterator last); - void erase(iterator position); - size_type erase(const key_type& x); - void erase(iterator first, iterator last); - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - iterator find(const key_type& x); - const_iterator find(const key_type& x) const; - size_type count(const key_type& x) const; - iterator lower_bound(const key_type& x); - const_iterator lower_bound(const key_type& x) const; - iterator upper_bound(const key_type& x); - const_iterator upper_bound(const key_type& x) const; - pair equal_range(const key_type& x); - pair equal_range(const key_type& x) const; - -protected: - friend class base::iterator; - friend class base::const_iterator; - - iterator ifind(const key_type& x); //Core find functionality - const_iterator ifind(const key_type& x) const; //Core find functionality - - using base::data; - using base::c; - -}; - - - template template - set:: - set(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) - : base(comp, al) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - template - typename set::iterator - set::ifind(const key_type &x) - { - /* This function is not from the standard. It is an internal - * utility function which returns an iterator to either the - * first matching element, or to the element before which - * an insert should be performed. Will not indicate if the - *insert should be performed before the first element - */ - - if(data.size() == 0){ - return end(); - } - - if(data.size() == 1){ - if( c(data[0], x) ){ - return end(); - } - return begin(); - } - - size_type low; - size_type high; - size_type i; - - low = 0; - high = data.size() - 1; - - //This algorithm assumes no duplicates in stored information - while(( high - low) > 1){ - i = low + ((high - low) /2); - if( c(x, data[i]) ){ - high = i; - }else{ - low = i; - } - } - - if( c(data[low], x) ){ // k >=high - i = high; - }else{ - i = low; - } - - return iterator(i, this); - } - - template - typename set::const_iterator - set::ifind(const key_type &x) const - { - /* This function is not from the standard. It is an internal - * utility function which returns an iterator to either the - * first matching element, or to the element before which - * an insert should be performed. Will not indicate if the - *insert should be performed before the first element - */ - - if(data.size() == 0){ - return end(); - } - - if(data.size() == 1){ - if( c(data[0], x) ){ - return end(); - } - return begin(); - } - - size_type low; - size_type high; - size_type i; - - low = 0; - high = data.size() - 1; - - //This algorithm assumes no duplicates in stored information - while(( high - low) > 1){ - i = low + ((high - low) /2); - if( c(x, data[i]) ){ - high = i; - }else{ - low = i; - } - } - - if( c(data[low], x) ){ // k >=high - i = high; - }else{ - i = low; - } - - return const_iterator(i, this); - } - - - template - set::set& - set::operator=(const set& x) - { - if( &x == this){ - return *this; - } - c = x.c; - data = x.data; - return *this; - } - - - template - pair::iterator, bool> - set::insert(const value_type& x) - { - pair::iterator, bool> retval; - - //Either set is empty or element to insert goes at the begining - if(data.size() == 0 || c(x, data[0]) ){ - data.push_front(x); - retval.first = begin(); - retval.second = true; - return retval; - } - - //Element to insert goes at the end - if( c(data[data.size() - 1], x) ){ - data.push_back(x); - retval.first = end(); - --retval.first; - retval.second = true; - return retval; - } - - retval.first = ifind(x); - - //No match - this should never happen - if(retval.first == end()){ - retval.second = false; - return retval; - } - - //If we have an exact match - if( !c( *(retval.first), x) && !c(x, *(retval.first) ) ){ - retval.second = false; - return retval; - } - - typename deque >::iterator q(&data, retval.first.element); - data.insert(q, x); - - retval.first = ifind(x); //Need to refind because insert can move data around - retval.second = true; - - return retval; - } - - - template - typename set::iterator - set::insert(iterator position, const value_type& x) - { - //Just reusing code. It's hard to make improvements over existing algo. - insert(x); - return find(x); - } - - template - template void - set::insert(InputIterator first, InputIterator last) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - template void - set::erase(iterator position) - { - //Create a deque iterator from position information and then - //Use built in erase feature because it is handy. - typename deque >::iterator pos(&data, position.element); - data.erase(pos); - } - - template - typename set::size_type - set::erase(const key_type& x) - { - typename set::iterator i = find(x); - if(i!=end()){ - erase(i); - return 1; - } - return 0; - } - - template - void set::erase(iterator first, iterator last) - { - typename deque >::iterator f(&data, first.element); - typename deque >::iterator l(&data, last.element); - data.erase(f, l); - } - - template - typename set::iterator - set:: - find(const typename set::key_type& x) - { - if(data.size() == 0){ - return end(); - } - - iterator retval = ifind(x); - - if(retval == end()){ - return retval; - } - - //Make sure we have an exact match.... - if(!c( *retval, x) && !c(x, *retval )){ - return retval; - } - return end(); - - } - - template - typename set::const_iterator - set::find(const key_type& x) const - { - if(data.size() == 0){ - return end(); - } - - const_iterator retval = ifind(x); - - if(retval == end()){ - return retval; - } - - //Make sure we have an exact match.... - if(!c( *retval, x) && !c(x, *retval )){ - return retval; - } - return end(); - - } - - template - typename set::size_type - set::count(const typename set::key_type& x) const - { - if( find(x) == end()){ - return 0; - } - return 1; - } - - template - typename set::iterator - set::lower_bound(const key_type& x) - { - return find(x); - } - - template - typename set::const_iterator - set::lower_bound(const key_type& x) const - { - return find(x); - } - - template - typename set::iterator - set::upper_bound(const key_type& x) - { - typename set::iterator i = find(x); - if(i != end()){ - ++i; - } - return i; - } - - template - typename set::const_iterator - set::upper_bound(const key_type& x) const - { - typename set::const_iterator i = find(x); - if(i != end()){ - ++i; - } - return i; - } - - - template - pair< typename set::iterator, - typename set::iterator - > set::equal_range(const key_type& x) - { - pair< typename set::iterator, - typename set::iterator - > retval; - retval.first = lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - template - pair< typename set::const_iterator, - typename set::const_iterator - > set::equal_range(const key_type& x) const - { - pair< typename set::const_iterator, - typename set::const_iterator - > retval; - retval.first = lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - template bool operator== - (const set& x, const set& y) - { - if(x.data == y.data){ - return true; - } - return false; - } - - - -//Implementation of multiset - - -template class _UCXXEXPORT multiset - : public __base_set -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it -public: - - typedef __base_set base; - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al) { } - - template multiset(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& = Allocator()); - - multiset(const multiset& x) : base(x) { } - ~multiset() { } - - multiset& operator=(const multiset& x); - - iterator insert(const value_type& x); - iterator insert(iterator position, const value_type& x); - template void insert(InputIterator first, InputIterator last); - - void erase(iterator position); - size_type erase(const key_type& x); - void erase(iterator first, iterator last); - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - iterator find(const key_type& x); - const_iterator find(const key_type& x) const; - size_type count(const key_type& x) const; - iterator lower_bound(const key_type& x); - const_iterator lower_bound(const key_type& x) const; - iterator upper_bound(const key_type& x); - const_iterator upper_bound(const key_type& x) const; - pair equal_range(const key_type& x); - pair equal_range(const key_type& x) const; - -protected: - friend class base::iterator; - friend class base::const_iterator; - - iterator ifind(const key_type& x); //Core find functionality - const_iterator ifind(const key_type& x) const; //Core find functionality - - using base::data; - using base::c; - -}; - - - - template template - multiset:: - multiset(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) - : base(comp, al) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - - template - typename multiset::iterator - multiset::ifind(const key_type &x) - { - /* This function is not from the standard. It is an internal - * utility function which returns an iterator to either the - * first matching element, or to the element before which - * an insert should be performed. end() for error. - */ - - if(data.size() == 0){ - return end(); - } - - //Before the first element - if( c(x, data[0]) ){ - return begin(); - } - - - //Element is larger than all known elemenst - if( c( data[data.size()-1], x) ){ - return end(); - } - - //Or if it is the last element - if( !c(x, data[size()-1]) ){ - return iterator(data.size()-1, this); - } - - size_type low; - size_type high; - size_type i=0; - - low = 0; - high = data.size() - 1; - - //This algorithm will accept duplicates in keys - - while( c(data[i+1], x) || c(x, data[i]) || !c(x, data[i+1]) ){ - i = low + ((high - low) /2); - if( c( x, data[i]) ){ - high = i; - }else{ - low = i; - } - } - - if( c(data[i], x) ){ // k >=high - ++i; - } - - return iterator(i, this); - } - - template - typename multiset::const_iterator - multiset::ifind(const key_type &x) const - { - /* This function is not from the standard. It is an internal - * utility function which returns an iterator to either the - * first matching element, or to the element before which - * an insert should be performed. end() for error. - */ - - if(data.size() == 0){ - return end(); - } - - //Before the first element - if( c(x, data[0]) ){ - return begin(); - } - - - //Element is larger than all known elemenst - if( c( data[data.size()-1], x) ){ - return end(); - } - - //Or if it is the last element - if( !c(x, data[size()-1]) ){ - return const_iterator(data.size()-1, this); - } - - size_type low; - size_type high; - size_type i=0; - - low = 0; - high = data.size() - 1; - - //This algorithm will accept duplicates in keys - - while( c(data[i+1], x) || c(x, data[i]) || !c(x, data[i+1]) ){ - i = low + ((high - low) /2); - if( c( x, data[i]) ){ - high = i; - }else{ - low = i; - } - } - - if( c(data[i], x) ){ // k >=high - ++i; - } - - return const_iterator(i, this); - } - - - template - typename multiset::iterator - multiset::insert(const value_type &x) - { - iterator retval; - - //Either set is empty or element to insert goes at the begining - if(data.size() == 0 || c(x, data[0]) ){ - data.push_front(x); - return begin(); - } - - //Element to insert goes at the end - if( c(data[data.size() - 1], x) ){ - data.push_back(x); - return end(); - } - - retval = ifind(x); - - //No match - this should never happen - if(retval == end()){ - return retval; - } - - if( !c(x, *retval) ){ - ++retval; - } - - typename deque >::iterator q(&data, retval.element); - data.insert(q, x); - - return retval; - } - - - template - typename multiset::iterator - multiset::insert(iterator position, const value_type& x) - { - - //Inserting at begining - if(position == begin() && !c(*position, x) ){ - data.push_front(x); - return position; - } - //Inserting at end - if(position == end() && !c(x, data[data.size() - 1]) ){ - data.push_back(x); - return position; - } - - //Inserting in middle - iterator temp = position; - --temp; - if( !c( *position, x) && !c(x, *temp) ){ - typename deque >::iterator q(&data, position.element); - data.insert(q, x); - return position; - } - - return insert(x); - } - - template - template void - multiset::insert(InputIterator first, InputIterator last) - { - while(first !=last){ - insert(*first); - ++first; - } - } - - - template void - multiset::erase(iterator position) - { - //Create a deque iterator from position information and then - //Use built in erase feature because it is handy. - typename deque >::iterator pos(&data, position.element); - data.erase(pos); - } - - - template - typename multiset::size_type - multiset::erase(const key_type& x) - { - typename multiset::iterator f = lower_bound(x); - typename multiset::iterator l = upper_bound(x); - size_type t = l.element - f.element; - erase(f, l); - return t; - } - - - template - void multiset::erase(iterator first, iterator last) - { - typename deque >::iterator f(&data, first.element); - typename deque >::iterator l(&data, last.element); - data.erase(f, l); - } - - - template - typename multiset::iterator - multiset::find(const key_type& x) - { - if(data.size() == 0){ - return end(); - } - - iterator retval = ifind(x); - - if( c(x, *retval) || c(*retval, x) ){ - return end(); - } - - return retval; - } - - - template - typename multiset::const_iterator - multiset::find(const key_type& x) const - { - if(data.size() == 0){ - return end(); - } - const_iterator retval = ifind(x); - - if( c(x, *retval) || c(*retval, x) ){ - return end(); - } - - return retval; - } - - - template - typename multiset::size_type - multiset:: - count(const typename multiset::key_type& x) const - { - pair< typename multiset::const_iterator, - typename multiset::const_iterator - > temp = equal_range(x); - - return temp.second.element - temp.first.element; - } - - - template - typename multiset::iterator - multiset::lower_bound(const key_type& x) - { - //FIXME - linear search - can we do any better? - typename multiset::iterator i = find(x); - if(i == end()){ - return i; - } - while( i.element > 0 && !c( *i, x) && !c(x, *i) ){ - --i; - } - if( c(*i, x)){ - ++i; - } - return i; - } - - template - typename multiset::const_iterator - multiset::lower_bound(const key_type& x) const - { - //FIXME - linear search - can we do any better? - typename multiset::const_iterator i = find(x); - if(i == end()){ - return i; - } - while( i.element >0 && !c( *i, x) && !c(x, *i) ){ - --i; - } - if( c( *i, x)){ - ++i; - } - return i; - } - - template - typename multiset::iterator - multiset::upper_bound(const key_type& x) - { - typename multiset::iterator i = find(x); - if(i != end()){ - ++i; - } - return i; - } - - template - typename multiset::const_iterator - multiset::upper_bound(const key_type& x) const - { - typename multiset::const_iterator i = find(x); - if(i != end()){ - ++i; - } - return i; - } - - - template - pair< typename multiset::iterator, - typename multiset::iterator - > multiset::equal_range(const key_type& x) - { - pair< typename multiset::iterator, - typename multiset::iterator - > retval; - retval.first = lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - template - pair< typename multiset::const_iterator, - typename multiset::const_iterator - > multiset::equal_range(const key_type& x) const - { - pair< typename multiset::const_iterator, - typename multiset::const_iterator - > retval; - retval.first = lower_bound(x); - retval.second = upper_bound(x); - return retval; - } - - - - -/* Non-member functions. These are at the end because they are not associated with any - particular class. These will be implemented as I figure out exactly what all of - them are supposed to do, and I have time. - */ - - template _UCXXEXPORT bool operator< - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1==last1 && first2 != last2; - } - - template _UCXXEXPORT bool operator!= - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 != *first2 ){ - return true; - } - ++first1; - ++first2; - } - return first1!=last1 || first2 != last2; - } - - template _UCXXEXPORT bool operator> - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1 && first2 == last2; - } - - template _UCXXEXPORT bool operator>= - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1; - } - - template _UCXXEXPORT bool operator<= - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first2!=last2; - } - template _UCXXEXPORT void swap - (set& x, set& y) - { - x.swap(y); - } - - - template _UCXXEXPORT bool operator== - (const multiset& x, const multiset& y) - { - if(x.data == y.data){ - return true; - } - return false; - } - - template _UCXXEXPORT bool operator< - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1==last1 && first2 != last2; - } - - template _UCXXEXPORT bool operator!= - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 != *first2 ){ - return true; - } - ++first1; - ++first2; - } - return first1!=last1 || first2 != last2; - } - - template _UCXXEXPORT bool operator> - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1 && first2 == last2; - } - - template _UCXXEXPORT bool operator>= - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1; - } - - template _UCXXEXPORT bool operator<= - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first2!=last2; - } - - template _UCXXEXPORT void swap - (multiset& x, multiset& y) - { - x.swap(y); - } - - - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/cstddef =================================================================== --- branches/slice/i386/modules/include/cstddef (revision 726) +++ branches/slice/i386/modules/include/cstddef (revision 727) @@ -1,58 +0,0 @@ -// -*- C++ -*- forwarding header. - -// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, 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 General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 18.1 Types -// - -/** @file cstddef - * This is a Standard C++ Library file. You should @c #include this file - * in your programs, rather than any of the "*.h" implementation files. - * - * This is the C++ version of the Standard C Library header @c stddef.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. - */ - -#ifndef _CPP_CSTDDEF -#define _CPP_CSTDDEF 1 - -#ifdef __GCC__ -#pragma GCC system_header -#endif - -#include - -namespace std -{ - using ::ptrdiff_t; - using ::size_t; -} - -#endif Index: branches/slice/i386/modules/include/map =================================================================== --- branches/slice/i386/modules/include/map (revision 726) +++ branches/slice/i386/modules/include/map (revision 727) @@ -1,261 +0,0 @@ -/* Copyright (C) 2004-2007 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 -#include - - -#ifndef __STD_HEADER_MAP -#define __STD_HEADER_MAP - -#pragma GCC visibility push(default) - -namespace std{ - - -template, class Allocator = allocator > class map; -template, class Allocator = allocator > class multimap; - - - //Compare the keys of the two items -/* template class _UCXXEXPORT - __base_map::value_compare : public binary_function< - typename map::value_type, - typename map::value_type, - bool> - { - friend class __base_map; - protected: - Compare comp; - value_compare(Compare c) : comp(c) { } - ~value_compare() { } - public: - bool operator()(const value_type& x, const value_type& y) const { - return comp(x.first, y.first); - } - }; -*/ - -// value_compare value_comp() const; - - - -/* This is the implementation for the map container. As noted above, it deviates - * from ISO spec by deriving from a base class in order to reduce code redundancy. - * More code could be reduced by convirting to virtual functions (thus allowing - * much of the erase and insert code to be duplicated), but that would deviate from - * the specifications too much to be worth the risk. - */ - - - -//Implementation of map - - -template class _UCXXEXPORT map - : public __single_associative, Compare, Allocator> -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it - -public: - - typedef __single_associative, Compare, Allocator> base; - typedef T mapped_type; - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - static const key_type v_t_k(const value_type v){ - return v.first; - } - -// using base::value_compare; - - explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al, v_t_k) { } - - template map(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(first, last, comp, al, v_t_k) { } - - map(const map& x) : base(x) { } - ~map() { } - - using base::operator=; - using base::operator==; - using base::operator!=; - - using base::insert; - using base::erase; - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - using base::find; - using base::count; - using base::lower_bound; - using base::upper_bound; - using base::equal_range; - - reference operator[](const key_type& k){ - //This is from the spec and is quite ugly. - return (*((insert(make_pair(k, T()))).first)).second; - } - -protected: - using base::backing; -}; - - -//Implementation of multimap - - -template class _UCXXEXPORT multimap - : public __multi_associative, Compare, Allocator> - -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it -public: - - typedef __multi_associative, Compare, Allocator> base; - typedef T mapped_type; - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - static const key_type v_t_k(const value_type v){ - return v.first; - } - - explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al, v_t_k) { } - - template multimap(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(first, last, comp, al, v_t_k) { } - - - multimap(const multimap& x) : base(x) { } - ~multimap() { } - - using base::operator=; - using base::operator==; - using base::operator!=; - - using base::insert; - using base::erase; - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - using base::find; - using base::count; - using base::lower_bound; - using base::upper_bound; - using base::equal_range; - -protected: - - using base::c; - -}; - - -/* Non-member functions. These are at the end because they are not associated with any - particular class. These will be implemented as I figure out exactly what all of - them are supposed to do, and I have time. - */ - - template _UCXXEXPORT bool operator< - (const map& x, const map& y); - template _UCXXEXPORT bool operator!= - (const map& x, const map& y); - template _UCXXEXPORT bool operator> - (const map& x, const map& y); - template _UCXXEXPORT bool operator>= - (const map& x, const map& y); - template _UCXXEXPORT bool operator<= - (const map& x, const map& y); - template _UCXXEXPORT void swap - (map& x, map& y); - - - template _UCXXEXPORT bool operator== - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator< - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator!= - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator> - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator>= - (const multimap& x, const multimap& y); - template _UCXXEXPORT bool operator<= - (const multimap& x, const multimap& y); - template _UCXXEXPORT void swap - (multimap& x, multimap& y); - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/Makefile =================================================================== --- branches/slice/i386/modules/include/Makefile (revision 726) +++ branches/slice/i386/modules/include/Makefile (revision 727) @@ -1,13 +0,0 @@ -TOPDIR=../ -include $(TOPDIR)Rules.mak - -all: - -clean: - -distclean: - -HEADERS = $(filter-out .svn CVS Makefile,$(wildcard *)) -install: - $(INSTALL) -d $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR) - $(INSTALL) -m 644 $(HEADERS) $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR) Index: branches/slice/i386/modules/include/cstdlib =================================================================== --- branches/slice/i386/modules/include/cstdlib (revision 726) +++ branches/slice/i386/modules/include/cstdlib (revision 727) @@ -1,71 +0,0 @@ -/* 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 -#include - -#ifndef __HEADER_CSTDLIB -#define __HEADER_CSTDLIB 1 - - -namespace std{ - using ::abort; - using ::abs; - using ::atexit; - using ::atol; - using ::atof; - using ::atoi; - using ::bsearch; - using ::calloc; - using ::div; - using ::exit; - using ::free; - using ::getenv; - using ::labs; - using ::ldiv; - using ::malloc; - using ::qsort; - using ::rand; - using ::realloc; - using ::srand; - using ::strtod; - using ::strtol; - using ::strtoul; - using ::system; -#ifdef __UCLIBCXX_HAS_WCHAR__ - using ::mblen; - using ::mbstowcs; - using ::mbtowc; - using ::wctomb; - using ::wcstombs; -#endif - - inline long abs(long i){ - return labs(i); - } - - inline ldiv_t div(long i, long j){ - return ldiv(i, j); - } - -} - - - -#endif - Index: branches/slice/i386/modules/include/cctype =================================================================== --- branches/slice/i386/modules/include/cctype (revision 726) +++ branches/slice/i386/modules/include/cctype (revision 727) @@ -1,37 +0,0 @@ -/* 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{ - - using ::isalnum; - using ::isalpha; - using ::iscntrl; - using ::isdigit; - using ::isgraph; - using ::islower; - using ::isprint; - using ::ispunct; - using ::isspace; - using ::isupper; - using ::isxdigit; - using ::tolower; - using ::toupper; - -} Index: branches/slice/i386/modules/include/iterator =================================================================== --- branches/slice/i386/modules/include/iterator (revision 726) +++ branches/slice/i386/modules/include/iterator (revision 727) @@ -1,229 +0,0 @@ -/* 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 - - - -#ifndef __STD_HEADER_ITERATOR -#define __STD_HEADER_ITERATOR 1 - -#pragma GCC visibility push(default) - -namespace std{ - - // subclause _lib.stream.iterators_, stream iterators: - template , class Distance = ptrdiff_t> class istream_iterator; - template bool - operator==(const istream_iterator& x, const istream_iterator& y); - template bool - operator!=(const istream_iterator& x, const istream_iterator& y); - template > class ostream_iterator; - template > class istreambuf_iterator; - template bool - operator==(const istreambuf_iterator& a, const istreambuf_iterator& b); - template bool - operator!=(const istreambuf_iterator& a, const istreambuf_iterator& b); - template > class ostreambuf_iterator; - - - template < class T, class charT, class traits, class Distance > class _UCXXEXPORT istream_iterator - : public iterator - { - public: - typedef charT char_type; - typedef traits traits_type; - typedef basic_istream istream_type; - istream_iterator() : in_stream(0), value(0) {} - istream_iterator(istream_type& s) : in_stream(&s), value() { - *in_stream >> value; - } - istream_iterator(const istream_iterator& x) - : in_stream(x.in_stream), value(x.value) - { } - ~istream_iterator() { } - const T& operator*() const{ - return value; - } - const T* operator->() const{ - return &value; - } - istream_iterator& operator++() { - *in_stream >> value; - return *this; - } - istream_iterator operator++(int){ - istream_iterator tmp = *this; - *in_stream >> value; - return (tmp); - } - bool m_equal(const istream_iterator& x) const{ - return (in_stream == x.in_stream); - } - private: - basic_istream* in_stream; - T value; - }; - - template _UCXXEXPORT - bool operator==(const istream_iterator& x, - const istream_iterator& y) - { - return x.m_equal(y); - } - - template _UCXXEXPORT - bool operator!=(const istream_iterator& x, - const istream_iterator& y) - { - return !(x == y); - } - - template class _UCXXEXPORT ostream_iterator - : public iterator - { - public: - typedef charT char_type; - typedef traits traits_type; - typedef basic_ostream ostream_type; - - ostream_iterator(ostream_type& s) : out_stream(&s), delim(0) { } - ostream_iterator(ostream_type& s, const charT* delimiter) : out_stream(&s), delim(delimiter) { } - ostream_iterator(const ostream_iterator& x) : out_stream(x.out_stream), delim(x.delim) { } - ~ostream_iterator() { } - ostream_iterator& operator=(const T& value){ - *out_stream << value; - if(delim != 0){ - *out_stream << delim; - } - return (*this); - } - ostream_iterator& operator*(){ return *this; } - ostream_iterator& operator++() { return *this; } - ostream_iterator operator++(int) { return *this; } - private: - basic_ostream* out_stream; - const char* delim; - }; - - template class _UCXXEXPORT istreambuf_iterator : - public iterator - { - public: - typedef charT char_type; - typedef traits traits_type; - typedef typename traits::int_type int_type; - typedef basic_streambuf streambuf_type; - typedef basic_istream istream_type; - - class _UCXXEXPORT proxy{ - charT val; - basic_streambuf * buf; - - proxy(charT v, basic_streambuf * b) : val(v), buf(b) { } - public: - charT operator*() { return val; } - }; - - istreambuf_iterator() throw() : sbuf(0) { } - istreambuf_iterator(istream_type& s) throw() : sbuf(s.rdbuf()) { } - istreambuf_iterator(streambuf_type* s) throw() : sbuf(s) { } - istreambuf_iterator(const proxy& p) throw() : sbuf(&p.buf) { } - - charT operator*() const{ - return sbuf->sgetc(); - } - istreambuf_iterator& operator++(){ - sbuf->sbumpc(); - return *this; - } - proxy operator++(int){ - istreambuf_iterator tmp = *this; - sbuf->sbumpc(); - return(tmp); - } - - bool equal(const istreambuf_iterator& b) const{ - return sbuf == b.sbuf || is_eof() && b.is_eof(); - } - private: - streambuf_type* sbuf; - inline bool is_eof() const{ - return sbuf == 0 || sbuf->sgetc() == traits_type::eof(); - } - }; - - template _UCXXEXPORT bool - operator==(const istreambuf_iterator& a, - const istreambuf_iterator& b) - { - return a.equal(b); - } - - template bool _UCXXEXPORT - operator!=(const istreambuf_iterator& a, - const istreambuf_iterator& b) - { - return !a.equal(b); - } - - template class _UCXXEXPORT ostreambuf_iterator - : iterator - { - public: - typedef charT char_type; - typedef traits traits_type; - typedef basic_streambuf streambuf_type; - typedef basic_ostream ostream_type; - public: - ostreambuf_iterator(ostream_type& s) throw() : sbuf(s.rdbuf()), f(false) { } - ostreambuf_iterator(streambuf_type* s) throw() : sbuf(s), f(false) { } - ostreambuf_iterator& operator=(charT c){ - if(failed() == false){ - if(sbuf->sputc(c) == traits::eof()){ - f = true; - } - } - return *this; - } - ostreambuf_iterator& operator*(){ - return *this; - } - ostreambuf_iterator& operator++() { return *this; } - ostreambuf_iterator operator++(int) { return *this; } - bool failed() const throw(){ - return f; - } - - private: - streambuf_type* sbuf; - bool f; - }; - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/bitset =================================================================== --- branches/slice/i386/modules/include/bitset (revision 726) +++ branches/slice/i386/modules/include/bitset (revision 727) @@ -1,423 +0,0 @@ -/* 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 -#include - -#ifndef __STD_BITSET_HEADER -#define __STD_BITSET_HEADER 1 - -#pragma GCC visibility push(default) - -namespace std{ - template class bitset; - - - template bitset operator&(const bitset&, const bitset&); - template bitset operator|(const bitset&, const bitset&); - template bitset operator^(const bitset&, const bitset&); - template basic_istream& - operator>>(basic_istream& is, bitset& x); - - template basic_ostream& - operator<<(basic_ostream& os, const bitset& x); - - //Actual Code - - - template class _UCXXEXPORT bitset { - private: - //Number of characters allocated to hold the bits - static const size_t WORD_SIZE = CHAR_BIT; //Use int maybe? - static const size_t num_bytes = (N + WORD_SIZE - 1) / WORD_SIZE; - - //From the bit number, figure out which byte we are working with - size_t byte_num(size_t bit_num) const{ - if(WORD_SIZE == 8){ - return (bit_num >> 3); - } - if(WORD_SIZE == 16){ - return (bit_num >> 4); - } - if(WORD_SIZE == 32){ - return (bit_num >> 5); - } - if(WORD_SIZE == 64){ - return (bit_num >> 6); - } - return bit_num / WORD_SIZE; - } - //From the bit number, figure out which bit inside the byte we need - size_t bit_num(const size_t bit_num) const{ - return bit_num % WORD_SIZE; - } - - - //Point to the actual data - char data[num_bytes]; - public: - - class _UCXXEXPORT reference { - friend class bitset; - reference() : bit_num(0), parent(0) { } - size_t bit_num; - bitset * parent; - public: - ~reference() { } - reference& operator=(bool x){ // for b[i] = x; - parent->set(bit_num, x); - return *this; - } - reference& operator=(const reference& x){ // for b[i] = b[j]; - parent->set(bit_num, x); - return *this; - } - bool operator~() const{ // flips the bit - return !parent->test(bit_num); - } - operator bool() const{ // for x = b[i]; - return parent->test(bit_num); - } - reference& flip(){ // for b[i].flip(); - parent->flip(bit_num); - return *this; - } - }; - - bitset(){ - reset(); - } - bitset(unsigned long val){ - reset(); - size_t count = sizeof(val) * CHAR_BIT; - if(count > N){ - count = N; - } - for(size_t i = 0; i < count; ++i){ - set(i, ((val >> i) & 1)); - } - } - - bitset(const bitset & val){ - for(size_t i = 0; i < num_bytes; ++i){ - data[i] = val.data[i]; - } - } - - template _UCXXEXPORT - explicit bitset( - const basic_string& str, - typename basic_string::size_type pos = 0, - typename basic_string::size_type n = - basic_string::npos - - ){ - reset(); - if(n > str.length()){ - n = str.length(); - } - size_t width = n; - if (width + pos > str.length()){ - width = str.length() - pos; - } - - for(size_t i = 0; i < width; ++i){ - switch(str[pos + width - i - 1]){ - case '0': - break; - case '1': - set(i); - break; - default: - __throw_invalid_argument(); - } - } - } - - bitset& operator&=(const bitset& rhs){ - for(size_t i =0; i < num_bytes; ++i){ - data[i] &= rhs.data[i]; - } - return *this; - } - - bitset& operator|=(const bitset& rhs){ - for(size_t i =0; i < num_bytes; ++i){ - data[i] |= rhs.data[i]; - } - return *this; - } - bitset& operator^=(const bitset& rhs){ - for(size_t i=0; i < num_bytes; ++i){ - data[i] ^= rhs.data[i]; - } - return *this; - } - - bitset& operator<<=(size_t pos){ - for(size_t i = N-1; i >=pos; --i){ - set(i, test(i - pos)); - } - for(size_t i = 0; i < pos; ++i){ - reset(i); - } - return *this; - } - - bitset& operator>>=(size_t pos){ - for(size_t i = 0; i < (N - pos); ++i){ - set(i, test(i + pos)); - } - for(size_t i = pos; i > 0; --i){ - reset(N - i); - } - return *this; - } - - bitset& set(){ - size_t i; - for(i = 0; i < N ; ++i){ - data[byte_num(i)] |= (1<& set(size_t pos, int val = true){ - if(val == true){ - data[byte_num(pos)] |= (1<& reset(){ - for(size_t i = 0; i <= num_bytes; ++i){ - data[i] = 0; - } - return *this; - } - bitset& reset(size_t pos){ - data[byte_num(pos)] &= ~(1< operator~() const{ - bitset retval(*this); - retval.flip(); - return retval; - } - - bitset& flip(){ - for(size_t i = 0; i <= num_bytes; ++i){ - data[i] = ~data[i]; - } - return *this; - } - bitset& flip(size_t pos){ - char temp = data[byte_num(pos)] & (1 << bit_num(pos)); - if(temp == 0){ //Bit was 0 - data[byte_num(pos)] |= (1 << bit_num(pos)); - }else{ //Bit was 1 - data[byte_num(pos)] &= ~(1< sizeof(unsigned long) * CHAR_BIT){ - __throw_overflow_error(); - } - unsigned long retval = 0; - size_t count = N; - for(size_t i = count; i > 0; --i){ - if(test(i)){ - retval +=1; - } - retval<<=1; - } - if(test(0)){ - retval +=1; - } - return retval; - } - - template - basic_string to_string() const - { - basic_string retval; - retval.reserve(N); - for(size_t i = N ; i > 0; --i){ - if(test(i-1) == true){ - retval.append("1"); - }else{ - retval.append("0"); - } - } - return retval; - } - - - size_t count() const{ - size_t retval = 0; - for(size_t i =0; i < N; ++i){ - if(test(i)){ - ++retval; - } - } - return retval; - } - size_t size() const{ - return N; - } - - bitset& operator=(const bitset & rhs){ - if(&rhs == this){ - return *this; - } - for(size_t i = 0; i <= byte_num(N); ++i){ - data[i] = rhs.data[i]; - } - return *this; - } - - - bool operator==(const bitset& rhs) const{ - for(size_t i =0; i< N; ++i){ - if(test(i) != rhs.test(i)){ - return false; - } - } - return true; - } - - bool operator!=(const bitset& rhs) const{ - for(size_t i =0; i< N; ++i){ - if(test(i) != rhs.test(i)){ - return true; - } - } - return false; - } - - bool test(size_t pos) const{ - return (data[byte_num(pos)] & (1< operator<<(size_t pos) const{ - bitset retval(*this); - retval<<=pos; - return retval; - } - bitset operator>>(size_t pos) const{ - bitset retval(*this); - retval>>=pos; - return retval; - } - }; - - //Non-member functions - - - template _UCXXEXPORT bitset operator&(const bitset& lhs, const bitset& rhs){ - bitset retval(lhs); - retval &= rhs; - return retval; - } - - template _UCXXEXPORT bitset operator|(const bitset& lhs, const bitset& rhs){ - bitset retval(lhs); - retval |= rhs; - return retval; - } - - template _UCXXEXPORT bitset operator^(const bitset& lhs, const bitset& rhs){ - bitset retval(lhs); - retval ^= rhs; - return retval; - } - - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, bitset& x) - { - string s; - charT c; - for(size_t i = 0; i < N; ++i){ - is.get(c); - if(!is.good()){ - break; - } - if(c != '1' && c !='0'){ - is.putback(c); - break; - } - s+=c; - } - bitset temp(s); - x = temp; - - return is; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const bitset& x) - { - for(size_t i = N ; i > 0; --i){ - if(x.test(i-1) == true){ - os << "1"; - }else{ - os << "0"; - } - } - return os; - } - - - - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/set =================================================================== --- branches/slice/i386/modules/include/set (revision 726) +++ branches/slice/i386/modules/include/set (revision 727) @@ -1,407 +0,0 @@ -/* 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 -#include - -#ifndef __STD_HEADER_SET -#define __STD_HEADER_SET - -#pragma GCC visibility push(default) - -namespace std{ - - -template, class Allocator = allocator > class set; -template, class Allocator = allocator > class multiset; - - -/* This is the implementation for the set container. As noted above, it deviates - * from ISO spec by deriving from a base class in order to reduce code redundancy. - * More code could be reduced by convirting to virtual functions (thus allowing - * much of the erase and insert code to be duplicated), but that would deviate from - * the specifications too much to be worth the risk. - */ - - -//Implementation of set - - -template class _UCXXEXPORT set - : public __single_associative -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it -public: - - typedef __single_associative base; - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - -// using base::value_compare; - - static const key_type v_t_k(const value_type v){ - return v; - } - - explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al, v_t_k) { } - - template set(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(first, last, comp, al, v_t_k) { } - - set(const set& x) : base(x) { } - ~set() { } - - using base::operator=; - using base::operator==; - using base::operator!=; - - using base::insert; - using base::erase; - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - - using base::find; - using base::count; - using base::lower_bound; - using base::upper_bound; - using base::equal_range; - -protected: - -}; - - -//Implementation of multiset - - -template class _UCXXEXPORT multiset - : public __multi_associative -{ - //Default value of allocator does not meet C++ standard specs, but it works for this library - //Deal with it -public: - - typedef __multi_associative base; - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - static const key_type v_t_k(const value_type v){ - return v; - } - - explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(comp, al, v_t_k) { } - - template multiset(InputIterator first, InputIterator last, - const Compare& comp = Compare(), const Allocator& al = Allocator()) - : base(first, last, comp, al, v_t_k) { } - - - multiset(const multiset& x) : base(x) { } - ~multiset() { } - - using base::operator=; - using base::operator==; - using base::operator!=; - - using base::insert; - using base::erase; - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - using base::find; - using base::count; - using base::lower_bound; - using base::upper_bound; - using base::equal_range; - - -protected: - -}; - - -/* Non-member functions. These are at the end because they are not associated with any - particular class. These will be implemented as I figure out exactly what all of - them are supposed to do, and I have time. - */ - - template _UCXXEXPORT bool operator< - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1==last1 && first2 != last2; - } - - template _UCXXEXPORT bool operator> - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1 && first2 == last2; - } - - template _UCXXEXPORT bool operator>= - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1; - } - - template _UCXXEXPORT bool operator<= - (const set& x, const set& y) - { - typename set::const_iterator first1 = x.begin(); - typename set::const_iterator first2 = y.begin(); - typename set::const_iterator last1 = x.end(); - typename set::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first2!=last2; - } - template _UCXXEXPORT void swap - (set& x, set& y) - { - x.swap(y); - } - - - template _UCXXEXPORT bool operator== - (const multiset& x, const multiset& y) - { - if(x.data == y.data){ - return true; - } - return false; - } - - template _UCXXEXPORT bool operator< - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1==last1 && first2 != last2; - } - - template _UCXXEXPORT bool operator!= - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 != *first2 ){ - return true; - } - ++first1; - ++first2; - } - return first1!=last1 || first2 != last2; - } - - template _UCXXEXPORT bool operator> - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1 && first2 == last2; - } - - template _UCXXEXPORT bool operator>= - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 > *first2 ){ - return true; - } - if( *first2 > *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first1!=last1; - } - - template _UCXXEXPORT bool operator<= - (const multiset& x, const multiset& y) - { - typename multiset::const_iterator first1 = x.begin(); - typename multiset::const_iterator first2 = y.begin(); - typename multiset::const_iterator last1 = x.end(); - typename multiset::const_iterator last2 = y.end(); - - while(first1 != last1 && first2 != last2){ - if( *first1 < *first2 ){ - return true; - } - if( *first2 < *first1 ){ - return false; - } - ++first1; - ++first2; - } - return first2!=last2; - } - - template _UCXXEXPORT void swap - (multiset& x, multiset& y) - { - x.swap(y); - } - - - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/iosfwd =================================================================== --- branches/slice/i386/modules/include/iosfwd (revision 726) +++ branches/slice/i386/modules/include/iosfwd (revision 727) @@ -1,114 +0,0 @@ -/* 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 - - -#ifndef __HEADER_STD_IOSFWD -#define __HEADER_STD_IOSFWD 1 - -#pragma GCC visibility push(default) - -namespace std { - class ios_base; - template<> class char_traits; - -#ifdef __UCLIBCXX_HAS_WCHAR__ - template<> class char_traits; -#endif - - template > class basic_ios; - - template > class basic_streambuf; - template > class basic_istream; - template > class basic_ostream; - template > class basic_iostream; - - template , - class Allocator = allocator > class basic_stringbuf; - - template , - class Allocator = allocator > class basic_istringstream; - - template , - class Allocator = allocator > class basic_ostringstream; - - template , - class Allocator = allocator > class basic_stringstream; - - template > class basic_filebuf; - - template > class basic_ifstream; - - template > class basic_ofstream; - - template > class basic_fstream; - - template > class basic_istreambuf_iterator; - - template > class basic_ostreambuf_iterator; - - typedef basic_ios ios; -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_ios wios; -#endif - - typedef basic_streambuf streambuf; - typedef basic_istream istream; - typedef basic_ostream ostream; - typedef basic_iostream iostream; - - typedef basic_stringbuf stringbuf; - typedef basic_istringstream istringstream; - typedef basic_ostringstream ostringstream; - typedef basic_stringstream stringstream; - - typedef basic_filebuf filebuf; - typedef basic_ifstream ifstream; - typedef basic_ofstream ofstream; - typedef basic_fstream fstream; -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_streambuf wstreambuf; - typedef basic_istream wistream; - typedef basic_ostream wostream; - typedef basic_iostream wiostream; - - typedef basic_stringbuf wstringbuf; - typedef basic_istringstream wistringstream; - typedef basic_ostringstream wostringstream; - typedef basic_stringstream wstringstream; - - typedef basic_filebuf wfilebuf; - typedef basic_ifstream wifstream; - typedef basic_ofstream wofstream; - typedef basic_fstream wfstream; -#endif - - template class fpos; - typedef fpos::state_type> streampos; -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef fpos::state_type> wstreampos; -#endif -} - -#pragma GCC visibility pop - -#endif Index: branches/slice/i386/modules/include/cmath =================================================================== --- branches/slice/i386/modules/include/cmath (revision 726) +++ branches/slice/i386/modules/include/cmath (revision 727) @@ -1,205 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_CMATH -#define __STD_HEADER_CMATH 1 - -namespace std{ - using ::acos; - using ::asin; - using ::atan; - using ::atan2; - using ::ceil; - using ::cos; - using ::cosh; - using ::exp; - using ::fabs; - using ::floor; - using ::fmod; - using ::frexp; - using ::ldexp; - using ::log; - using ::log10; - using ::modf; - using ::pow; - using ::sin; - using ::sinh; - using ::sqrt; - using ::tan; - using ::tanh; - - inline float abs (float x){ - return fabsf(x); - } - inline float acos (float x){ - return acosf(x); - } - inline float asin (float x){ - return asinf(x); - } - inline float atan (float x){ - return atanf(x); - } - inline float atan2(float y, float x){ - return atan2f(y, x); - } - inline float ceil (float x){ - return ceilf(x); - } - inline float cos (float x){ - return cosf(x); - } - inline float cosh (float x){ - return coshf(x); - } - inline float exp (float x){ - return expf(x); - } - inline float fabs (float x){ - return fabsf(x); - } - inline float floor(float x){ - return floorf(x); - } - inline float fmod (float x, float y){ - return fmodf(x, y); - } - inline float frexp(float x, int* exp){ - return frexpf(x, exp); - } - inline float ldexp(float x, int exp){ - return ldexpf(x, exp); - } - inline float log (float x){ - return logf(x); - } - inline float log10(float x){ - return log10f(x); - } - inline float modf (float x, float* inptr){ - return modff(x, inptr); - } - inline float pow (float x, float y){ - return powf(x, y); - } - inline float pow (float x, int y){ - return pow((double)x, (double)y); - } - inline float sin (float x){ - return sinf(x); - } - inline float sinh (float x){ - return sinhf(x); - } - inline float sqrt (float x){ - return sqrtf(x); - } - inline float tan (float x){ - return tanf(x); - } - inline float tanh (float x){ - return tanhf(x); - } - inline double abs(double x){ - return fabs(x); - } - inline double pow(double x, int y){ - return pow((double)x, (double)y); - } - -#ifdef __UCLIBCXX_HAS_LONG_DOUBLE__ - inline long double abs (long double x){ - return fabsl(x); - } - inline long double acos (long double x){ - return acosl(x); - } - inline long double asin (long double x){ - return asinl(x); - } - inline long double atan (long double x){ - return atanl(x); - } - inline long double atan2(long double y, long double x){ - return atan2l(y, x); - } - inline long double ceil (long double x){ - return ceill(x); - } - inline long double cos (long double x){ - return cosl(x); - } - inline long double cosh (long double x){ - return coshl(x); - } - inline long double exp (long double x){ - return expl(x); - } - inline long double fabs (long double x){ - return fabsl(x); - } - inline long double floor(long double x){ - return floorl(x); - } - inline long double frexp(long double x, int* exp){ - return frexpl(x, exp); - } - inline long double fmod (long double x, long double y){ - return fmodl(x, y); - } - inline long double ldexp(long double x, int y){ - return ldexpl(x, y); - } - inline long double log (long double x){ - return logl(x); - } - inline long double log10(long double x){ - return log10l(x); - } - inline long double modf (long double x, long double* iptr){ - return modfl(x, iptr); - } - inline long double pow (long double x, long double y){ - return powl(x, y); - } - inline long double pow (long double x, int y){ - return powl(x, (long double)y ); - } - inline long double sin (long double x){ - return sinl(x); - } - inline long double sinh (long double x){ - return sinhl(x); - } - inline long double sqrt (long double x){ - return sqrtl(x); - } - inline long double tan (long double x){ - return tanl(x); - } - inline long double tanh (long double x){ - return tanhl(x); - } -#endif // __UCLIBCXX_HAS_LONG_DOUBLE__ -} - -#endif //__STD_HEADER_CMATH - Index: branches/slice/i386/modules/include/system_configuration.h =================================================================== --- branches/slice/i386/modules/include/system_configuration.h (revision 726) +++ branches/slice/i386/modules/include/system_configuration.h (revision 727) @@ -1,59 +0,0 @@ -/* - * Automatically generated C config: don't edit - */ -/* - * Version Number - */ -#define __UCLIBCXX_MAJOR__ 0 -#define __UCLIBCXX_MINOR__ 2 -#define __UCLIBCXX_SUBLEVEL__ 2 - -/* - * Target Features and Options - */ -#define __UCLIBCXX_HAS_FLOATS__ 1 -#undef __UCLIBCXX_HAS_LONG_DOUBLE__ -#undef __UCLIBCXX_HAS_TLS__ -#define __WARNINGS__ "-Wall" -#define __BUILD_EXTRA_LIBRARIES__ "" -#define __HAVE_DOT_CONFIG__ 1 - -/* - * String and I/O Stream Support - */ -#undef __UCLIBCXX_HAS_WCHAR__ -#define __UCLIBCXX_IOSTREAM_BUFSIZE__ 32 -#define __UCLIBCXX_HAS_LFS__ 1 -#define __UCLIBCXX_SUPPORT_CDIR__ 0 -#define __UCLIBCXX_SUPPORT_CIN__ 0 -#define __UCLIBCXX_SUPPORT_COUT__ 0 -#define __UCLIBCXX_SUPPORT_CERR__ 0 -#undef __UCLIBCXX_SUPPORT_CLOG__ - -/* - * STL and Code Expansion - */ -#define __UCLIBCXX_STL_BUFFER_SIZE__ 32 -#define __UCLIBCXX_CODE_EXPANSION__ 1 -#undef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ -#define __UCLIBCXX_EXPAND_STRING_CHAR__ 1 -#define __UCLIBCXX_EXPAND_VECTOR_BASIC__ 1 -#define __UCLIBCXX_EXPAND_IOS_CHAR__ 1 -#define __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ 1 -#define __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 1 -#define __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 1 -#define __UCLIBCXX_EXPAND_FSTREAM_CHAR__ 1 -#define __UCLIBCXX_EXPAND_SSTREAM_CHAR__ 1 - -/* - * Library Installation Options - */ -#define __UCLIBCXX_RUNTIME_PREFIX__ "." -#define __UCLIBCXX_RUNTIME_INCLUDE_SUBDIR__ "/include" -#define __UCLIBCXX_RUNTIME_LIB_SUBDIR__ "/lib" -#define __UCLIBCXX_RUNTIME_BIN_SUBDIR__ "/bin" -#undef __UCLIBCXX_EXCEPTION_SUPPORT__ -#define __BUILD_STATIC_LIB__ 1 -#define __BUILD_ONLY_STATIC_LIB__ 1 -#undef __DODEBUG__ - Index: branches/slice/i386/modules/include/limits =================================================================== --- branches/slice/i386/modules/include/limits (revision 726) +++ branches/slice/i386/modules/include/limits (revision 727) @@ -1,615 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_LIMITS -#define __STD_HEADER_LIMITS 1 - -//#warning limits header is nowhere complete or accurate - -#pragma GCC visibility push(default) - -namespace std{ - -enum float_round_style{ - round_indeterminate =-1, - round_toward_zero = 0, - round_to_nearest = 1, - round_toward_infinity = 2, - round_toward_neg_infinity = 3 -}; - -template struct __bits_to_base_10{ - static const int size = -1; -}; -template <> struct __bits_to_base_10<7>{ - static const int size = 2; -}; -template <> struct __bits_to_base_10<8>{ - static const int size = 2; -}; -template <> struct __bits_to_base_10<9>{ - static const int size = 2; -}; -template <> struct __bits_to_base_10<10>{ - static const int size = 3; -}; -template <> struct __bits_to_base_10<15>{ - static const int size = 4; -}; -template <> struct __bits_to_base_10<16>{ - static const int size = 4; -}; -template <> struct __bits_to_base_10<17>{ - static const int size = 5; -}; -template <> struct __bits_to_base_10<18>{ - static const int size = 5; -}; -template <> struct __bits_to_base_10<31>{ - static const int size = 9; -}; -template <> struct __bits_to_base_10<32>{ - static const int size = 9; -}; -template <> struct __bits_to_base_10<35>{ - static const int size = 10; -}; -template <> struct __bits_to_base_10<36>{ - static const int size = 10; -}; -template <> struct __bits_to_base_10<63>{ - static const int size = 18; -}; -template <> struct __bits_to_base_10<64>{ - static const int size = 19; -}; -template <> struct __bits_to_base_10<71>{ - static const int size = 21; -}; -template <> struct __bits_to_base_10<72>{ - static const int size = 21; -}; -template <> struct __bits_to_base_10<79>{ - static const int size = 23; -}; -template <> struct __bits_to_base_10<80>{ - static const int size = 24; -}; -template <> struct __bits_to_base_10<127>{ - static const int size = 38; -}; -template <> struct __bits_to_base_10<128>{ - static const int size = 38; -}; - - - - - - -template class numeric_limits { -public: - // General -- meaningful for all specializations. - - static const bool is_specialized = false; - static T min(); - static T max(); - static const int radix; - static const int digits; - static const int digits10; - static const bool is_signed; - static const bool is_integer; - static const bool is_exact; - static const bool traps; - static const bool is_modulo; - static const bool is_bounded; - - // Floating point specific. - - static T epsilon(); - static T round_error(); - static const int min_exponent10; - static const int max_exponent10; - static const int min_exponent; - - static const int max_exponent; - static const bool has_infinity; - static const bool has_quiet_NaN; - static const bool has_signaling_NaN; - static const bool is_iec559; - static const bool has_denorm; - static const bool tinyness_before; - static const float_round_style round_style; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef unsigned char T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return 0; - } - static T max(){ - return UCHAR_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT; - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = false; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef signed char T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return SCHAR_MIN; - } - static T max(){ - return SCHAR_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT - 1; - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = true; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef char T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return CHAR_MIN; - } - static T max(){ - return CHAR_MAX; - } - static const int radix = 2; - static const int digits = (CHAR_MIN != 0) ? CHAR_BIT - 1 : CHAR_BIT; - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = (CHAR_MIN != 0); - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef unsigned short T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return 0; - } - static T max(){ - return USHRT_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT * sizeof(T); - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = false; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef signed short T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return SHRT_MIN; - } - static T max(){ - return SHRT_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT * sizeof(T); - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = true; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef unsigned int T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return 0; - } - static T max(){ - return UINT_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT * sizeof(T); - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = false; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef signed int T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return INT_MIN; - } - static T max(){ - return INT_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT * sizeof(T); - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = true; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef unsigned long int T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return 0; - } - static T max(){ - return ULONG_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT * sizeof(T); - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = false; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { -public: - typedef signed long int T; - // General -- meaningful for all specializations. - static const bool is_specialized = true; - static T min(){ - return LONG_MIN; - } - static T max(){ - return LONG_MAX; - } - static const int radix = 2; - static const int digits = CHAR_BIT * sizeof(T); - static const int digits10 = __bits_to_base_10::size; - static const bool is_signed = true; - static const bool is_integer = true; - static const bool is_exact = true; - static const bool traps = false; - static const bool is_modulo = true; - static const bool is_bounded = true; - - // Floating point specific. - - static T epsilon(){ - return 0; - } - static T round_error(){ - return 0; - } - static const int min_exponent10 = 0; - static const int max_exponent10 = 0; - static const int min_exponent = 0; - - static const int max_exponent = 0; - static const bool has_infinity = false; - static const bool has_quiet_NaN = false; - static const bool has_signaling_NaN = false; - static const bool is_iec559 = false; - static const bool has_denorm = false; - static const bool tinyness_before = false; - static const float_round_style round_style = round_indeterminate; - static T denorm_min(); - static T infinity(); - static T quiet_NaN(); - static T signaling_NaN(); -}; - -template <> class numeric_limits { - typedef double numeric_type; - - static const bool is_specialized = true; - static numeric_type min () { return __DBL_MIN__; } - static numeric_type max () { return __DBL_MAX__; } - static const int radix = __FLT_RADIX__; - static const int digits = __DBL_MANT_DIG__; - static const int digits10 = __DBL_DIG__; - static const bool is_signed = true; - static const bool is_integer = false; - static const bool is_exact = false; - static const bool traps = false; // this is a guess - static const bool is_modulo = false; - static const bool is_bounded = true; - - // Floating point specific. - - static numeric_type epsilon () { return __DBL_EPSILON__; } - static numeric_type round_error () { return 0.5; } - static const int min_exponent10 = -1; //How do I properly get this? - static const int max_exponent10 = -1; //How do I properly get this? - static const int min_exponent = -1; //How do I properly get this? - static const int max_exponent = -1; //How do I properly get this? - static const bool has_infinity = false; //I don't know, so until I can find out, I'm saying no - static const bool has_quiet_NaN = false; //I don't know, so until I can find out, I'm saying no - static const bool has_signaling_NaN = false; //I don't know, so until I can find out, I'm saying no - static const bool has_denorm = false; //I don't know, so until I can find out, I'm saying no - - static const bool is_iec559 = false; //I don't know, so until I can find out, I'm saying no - static const bool tinyness_before = false; // more questions - static const float_round_style round_style = round_to_nearest; // more questions - static numeric_type denorm_min () { return -1; } //How do I properly get this? - static numeric_type infinity () { return -1; } //How do I properly get this? - static numeric_type quiet_NaN () { return -1; } //How do I properly get this? - static numeric_type signaling_NaN () { return -1; } //How do I properly get this? -}; - - - - - -} - -#pragma GCC visibility pop - -#endif Index: branches/slice/i386/modules/include/functional =================================================================== --- branches/slice/i386/modules/include/functional (revision 726) +++ branches/slice/i386/modules/include/functional (revision 727) @@ -1,439 +0,0 @@ -/* 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 -*/ - - -#ifndef __STD_HEADER_FUNCTIONAL -#define __STD_HEADER_FUNCTIONAL 1 - -#include - -#pragma GCC visibility push(default) - -namespace std{ - - template struct unary_function; - template struct binary_function; - - template struct plus; - template struct minus; - template struct multiplies; - template struct divides; - template struct modulus; - template struct negate; - - template struct equal_to; - template struct not_equal_to; - template struct greater; - template struct less; - template struct greater_equal; - template struct less_equal; - - template struct logical_and; - template struct logical_or; - template struct logical_not; - - template struct unary_negate; - template unary_negate not1(const Predicate&); - template struct binary_negate; - template binary_negate not2(const Predicate&); - - - template class binder1st; - template binder1st bind1st(const Operation&, const T&); - template class binder2nd; - template binder2nd bind2nd(const Operation&, const T&); - - template class pointer_to_unary_function; - template pointer_to_unary_function ptr_fun(Result (*)(Arg)); - template class pointer_to_binary_function; - template - pointer_to_binary_function ptr_fun(Result (*)(Arg1,Arg2)); - - template class mem_fun_t; - template class mem_fun1_t; - template class const_mem_fun_t; - template class const_mem_fun1_t; - template mem_fun_t mem_fun(S (T::*f)()); - template mem_fun1_t mem_fun(S (T::*f)(A)); - template class mem_fun_ref_t; - template class mem_fun1_ref_t; - template mem_fun_ref_t mem_fun_ref(S (T::*f)()); - template mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A)); - - //Implementation - - template struct _UCXXEXPORT unary_function{ - typedef Arg argument_type; - typedef Result result_type; - }; - - - template struct _UCXXEXPORT binary_function{ - typedef Arg1 first_argument_type; - typedef Arg2 second_argument_type; - typedef Result result_type; - }; - - template struct _UCXXEXPORT plus : binary_function{ - T operator()(const T& x, const T& y) const{ - return x + y; - } - }; - - template struct _UCXXEXPORT minus : binary_function{ - T operator()(const T& x, const T& y) const{ - return x - y; - } - }; - - template struct _UCXXEXPORT multiplies : binary_function{ - T operator()(const T& x, const T& y) const{ - return x * y; - } - }; - - template struct _UCXXEXPORT divides : binary_function{ - T operator()(const T& x, const T& y) const{ - return x / y; - } - }; - - template struct _UCXXEXPORT modulus : binary_function{ - T operator()(const T& x, const T& y) const{ - return x % y; - } - }; - - template struct _UCXXEXPORT negate : unary_function{ - T operator()(const T& x) const{ - return -x; - } - }; - - template struct _UCXXEXPORT equal_to : binary_function{ - bool operator()(const T& x, const T& y) const{ - return (x == y); - } - }; - - template struct _UCXXEXPORT not_equal_to : binary_function{ - bool operator()(const T& x, const T& y) const{ - return (x != y); - } - }; - - template struct _UCXXEXPORT greater : binary_function{ - bool operator()(const T& x, const T& y) const{ - return (x > y); - } - }; - - template struct _UCXXEXPORT less : binary_function{ - bool operator()(const T& x, const T& y) const{ - return (x < y); - } - }; - - template struct _UCXXEXPORT greater_equal : binary_function{ - bool operator()(const T& x, const T& y) const{ - return (x >= y); - } - }; - - template struct _UCXXEXPORT less_equal : binary_function{ - bool operator()(const T& x, const T& y) const{ - return (x <= y); - } - }; - - template struct _UCXXEXPORT logical_and : binary_function { - bool operator()(const T& x, const T& y) const{ - return (x && y); - } - }; - - template struct _UCXXEXPORT logical_or : binary_function { - bool operator()(const T& x, const T& y) const{ - return (x || y); - } - }; - - template struct _UCXXEXPORT logical_not : unary_function { - bool operator()(const T& x) const{ - return !x; - } - }; - - template class _UCXXEXPORT unary_negate - : public unary_function - { - public: - explicit unary_negate(const Predicate& pred) : p(pred) { } - bool operator()(const typename Predicate::argument_type& x) const{ - return !p(x); - } - private: - Predicate p; - }; - - - template _UCXXEXPORT unary_negate not1(const Predicate& pred){ - return unary_negate(pred); - } - - - template class _UCXXEXPORT binary_negate : public - binary_function - { - public: - explicit binary_negate(const Predicate& pred) : p(pred) { } - bool operator()(const typename Predicate::first_argument_type& x, - const typename Predicate::second_argument_type& y) const - { - return !p(x, y); - } - private: - Predicate p; - }; - - - template _UCXXEXPORT binary_negate not2(const Predicate& pred){ - return binary_negate(pred); - } - - - template class _UCXXEXPORT binder1st - : public unary_function - { - protected: - Operation op; - typename Operation::first_argument_type value; - public: - binder1st(const Operation& x, const typename Operation::first_argument_type& y) : op(x), value(y){ } - typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const{ - return op(value,x); - } - }; - - - template _UCXXEXPORT binder1st bind1st(const Operation& op, const T& x){ - return binder1st(op, typename Operation::first_argument_type(x)); - } - - - template class _UCXXEXPORT binder2nd - : public unary_function - { - protected: - Operation op; - typename Operation::second_argument_type value; - public: - binder2nd(const Operation& x, const typename Operation::second_argument_type& y) : op(x), value(y) { } - typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const{ - return op(x,value); - } - }; - - - template _UCXXEXPORT - binder2nd bind2nd(const Operation& op, const T& x) - { - return binder2nd(op, typename Operation::second_argument_type(x)); - } - - - template class _UCXXEXPORT - pointer_to_unary_function : public unary_function - { - protected: - Result (*func)(Arg); - public: - explicit pointer_to_unary_function(Result (*f)(Arg)) : func(f) { } - Result operator()(Arg x) const{ - return func(x); - } - }; - - - template _UCXXEXPORT pointer_to_unary_function ptr_fun(Result (*f)(Arg)){ - return pointer_to_unary_function(f); - } - - - template class _UCXXEXPORT - pointer_to_binary_function : public binary_function - { - protected: - Result (*func)(Arg1, Arg2); - public: - explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) : func(f) { } - Result operator()(Arg1 x, Arg2 y) const{ - return func(x, y); - } - }; - - template _UCXXEXPORT - pointer_to_binary_function ptr_fun(Result (*f)(Arg1, Arg2)) - { - return pointer_to_binary_function(f); - } - - - template class _UCXXEXPORT mem_fun_t - : public unary_function - { - public: - explicit mem_fun_t(S (T::*p)()) : m(p) { } - S operator()(T* p) const { return (p->*m)(); } - private: - S (T::*m)(); - }; - - - template class _UCXXEXPORT mem_fun1_t - : public binary_function - { - public: - explicit mem_fun1_t(S (T::*p)(A)) : m(p) { } - S operator()(T* p, A x) const { return (p->*m)(x); } - private: - S (T::*m)(A); - }; - - - template class _UCXXEXPORT const_mem_fun_t - : public unary_function - { - public: - explicit const_mem_fun_t(S (T::*p)() const) : m(p) { } - S operator()(const T* p) const { return (p->*m)(); } - private: - S (T::*m)() const; - }; - - - template class _UCXXEXPORT const_mem_fun1_t - : public binary_function - { - public: - explicit const_mem_fun1_t(S (T::*p)(A) const) : m(p) { } - S operator()(const T* p, A x) const { return (p->*m)(x); } - private: - S (T::*m)(A) const; - }; - - - template _UCXXEXPORT mem_fun_t mem_fun(S (T::*f)()){ - return mem_fun_t(f); - } - - template _UCXXEXPORT const_mem_fun_t mem_fun(S (T::*f)() const){ - return const_mem_fun_t(f); - } - - template _UCXXEXPORT mem_fun1_t mem_fun(S (T::*f)(A)){ - return mem_fun1_t(f); - } - - template _UCXXEXPORT const_mem_fun1_t mem_fun(S (T::*f)(A) const){ - return const_mem_fun1_t(f); - } - - template class _UCXXEXPORT mem_fun_ref_t - : public unary_function - { - public: - explicit mem_fun_ref_t(S (T::*p)()) : mf(p) { } - S operator()(T& p) { return (p.*mf)(); } - private: - S (T::*mf)(); - }; - - template class _UCXXEXPORT mem_fun1_ref_t - : public binary_function - { - public: - explicit mem_fun1_ref_t(S (T::*p)(A)) : mf(p) { } - S operator()(T& p, A x) { return (p.*mf)(x); } - private: - S (T::*mf)(A); - }; - - template _UCXXEXPORT mem_fun_ref_t mem_fun_ref(S (T::*f)()){ - return mem_fun_ref_t(f); - } - - template _UCXXEXPORT mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A)){ - return mem_fun1_ref_t(f); - } - - -} - - -//These are SGI extensions which are checked for by some conformance checks. They -// are *NOT* part of the C++ standard, however - -template class _UCXXEXPORT unary_compose : - public std::unary_function -{ -protected: - Op1 mf1; - Op2 mf2; -public: - unary_compose(const Op1& x, const Op2& y) : mf1(x), mf2(y) { } - typename Op1::result_type operator()(const typename Op2::argument_type& x) const { - return mf1(mf2(x)); - } -}; - -template _UCXXEXPORT -inline unary_compose -compose1(const Op1& fn1, const Op2& fn2){ - return unary_compose(fn1, fn2); -} - -template class _UCXXEXPORT binary_compose : - public std::unary_function -{ -protected: - Op1 mf1; - Op2 mf2; - Op3 mf3; -public: - binary_compose(const Op1 & x, const Op2 & y, const Op3 & z) - : mf1(x), mf2(y), mf3(z){ } - typename Op1::result_type operator()(const typename Op2::argument_type & x) const { - return mf1(mf2(x), mf3(x)); - } -}; - -template inline _UCXXEXPORT binary_compose -compose2(const Op1 & fn1, const Op2 & fn2, const Op3 & fn3){ - return binary_compose(fn1, fn2, fn3); -} - -#pragma GCC visibility pop - -#endif - - - Index: branches/slice/i386/modules/include/istream =================================================================== --- branches/slice/i386/modules/include/istream (revision 726) +++ branches/slice/i386/modules/include/istream (revision 727) @@ -1,601 +0,0 @@ -/* Copyright (C) 2004 Garrett A. Kajmowicz - - This file is part of the uClibc C++ Library. This library is free - software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this library; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. -*/ - -#include -#include -#include -#include -#include - -#ifndef __STD_HEADER_ISTREAM -#define __STD_HEADER_ISTREAM 1 - -#pragma GCC visibility push(default) - -namespace std{ - - typedef basic_istream istream; - -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_istream wistream; -#endif - - template basic_istream& ws(basic_istream& is); - - template class _UCXXEXPORT basic_istream : - virtual public basic_ios - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef basic_streambuf streambuf_type; - typedef traits traits_type; - - explicit basic_istream(basic_streambuf* sb) - : basic_ios(sb), count_last_ufmt_input(0) - { - basic_ios::init(sb); - } - virtual ~basic_istream() { } - - class sentry; - - basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); - basic_istream& operator>>(basic_ios& (*pf)(basic_ios&)); - basic_istream& operator>>(ios_base& (*pf)(ios_base&)); - basic_istream& operator>>(bool& n); - basic_istream& operator>>(short& n); - basic_istream& operator>>(unsigned short& n); - basic_istream& operator>>(int& n); - basic_istream& operator>>(unsigned int& n); - basic_istream& operator>>(long& n); - basic_istream& operator>>(unsigned long& n); - basic_istream& operator>>(void*& p); - basic_istream& operator>>(basic_streambuf* sb); - -#ifdef __UCLIBCXX_HAS_FLOATS__ - basic_istream& operator>>(float& f); - basic_istream& operator>>(double& f); - basic_istream& operator>>(long double& f); -#endif - - _UCXXEXPORT streamsize gcount() const{ - return count_last_ufmt_input; - } - - _UCXXEXPORT int_type get(); //below - _UCXXEXPORT basic_istream& get(char_type& c); //Below - - _UCXXEXPORT basic_istream& get(char_type* s, streamsize n){ - return get(s, n, basic_ios::widen('\n')); - } - - _UCXXEXPORT basic_istream& get(char_type* s, streamsize n, char_type delim){ - sentry(*this, true); - streamsize i = 0; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - basic_ios::mstreambuf->sbumpc(); - if(c == traits::eof() ){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - }else{ - basic_ios::setstate(ios_base::eofbit); - } - break; - } - if(c == delim){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - } - basic_ios::mstreambuf->sputbackc(c); - break; - } - s[i] = c; - } - s[i] = traits::eos(); - count_last_ufmt_input = i; - return *this; - } - - _UCXXEXPORT basic_istream& get(basic_streambuf& sb){ - return get(sb, basic_ios::widen('\n')); - } - - _UCXXEXPORT basic_istream& get(basic_streambuf& sb, char_type delim){ - sentry(*this, true); - streamsize i = 0; - int_type c; - while(1){ //We will exit internally based upon error conditions - c = basic_ios::mstreambuf->sgetc(); - if(c == traits::eof()){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - }else{ - basic_ios::setstate(ios_base::eofbit); - } - count_last_ufmt_input = i; - return *this; - } - if(c == delim){ - if(i==0){ - basic_ios::setstate(ios_base::failbit); - } - count_last_ufmt_input = i; - return *this; - } - if(sb.sputc(c) != c){ //Error doing output - count_last_ufmt_input = i; - return *this; - } - ++i; - basic_ios::mstreambuf->sbumpc(); - } - } - - _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n){ - return getline(s, n, basic_ios::widen('\n')); - } - - _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n, char_type delim){ - sentry(*this, true); - streamsize i = 0; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - if(c == traits::eof() ){ - if( basic_ios::eof() ){ - basic_ios::setstate(ios_base::failbit); - }else{ - basic_ios::setstate(ios_base::eofbit); - } - count_last_ufmt_input = i; - s[i] = traits::eos(); - return *this; - } - if(basic_ios::mstreambuf->sbumpc()==traits::eof() ){ - basic_ios::setstate(ios_base::eofbit); - } - if(c == delim){ - count_last_ufmt_input = i+1; - s[i] = traits::eos(); - return *this; - } - s[i] = c; - } - s[n-1] = traits::eos(); - return *this; - } - - _UCXXEXPORT basic_istream& ignore (streamsize n = 1, int_type delim = traits::eof()){ - sentry(*this, true); - streamsize i; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - if(c == traits::eof()){ - basic_ios::setstate(ios_base::eofbit); - return *this; - } - basic_ios::mstreambuf->sbumpc(); - if(c == delim){ - return *this; - } - } - return *this; - } - - _UCXXEXPORT int_type peek(){ - if(basic_ios::good() == false){ - return traits::eof(); - }else{ - int_type c = basic_ios::mstreambuf->sgetc(); - if(c == traits::eof()){ - basic_ios::setstate(ios_base::eofbit); - } - return basic_ios::mstreambuf->sgetc(); - } - } - - _UCXXEXPORT basic_istream& read (char_type* s, streamsize n){ - sentry(*this, true); - streamsize i; - int_type c; - for(i=0;i::mstreambuf->sgetc(); - - if(c == traits::eof()){ - basic_ios::setstate(ios_base::failbit); - basic_ios::setstate(ios_base::eofbit); - count_last_ufmt_input = i; - return *this; - } - basic_ios::mstreambuf->sbumpc(); - s[i] = c; - } - count_last_ufmt_input = n; - return *this; - } - - _UCXXEXPORT streamsize readsome(char_type* s, streamsize n){ - sentry(*this, true); - if(!basic_ios::good()){ - count_last_ufmt_input = 0; - basic_ios::setstate(ios_base::failbit); - return 0; - } - - if( basic_ios::mstreambuf->in_avail() == -1){ - count_last_ufmt_input=0; - basic_ios::setstate(ios_base::eofbit); - return 0; - } - - if(n > basic_ios::mstreambuf->in_avail() ){ - n = basic_ios::mstreambuf->in_avail(); - } - - streamsize i; - int_type c; - - for(i=0;i::mstreambuf->sgetc(); - basic_ios::mstreambuf->sbumpc(); - s[i] = c; - } - count_last_ufmt_input = n; - return n; - } - - _UCXXEXPORT basic_istream& putback(char_type c){ - sentry(*this, true); - if(!basic_ios::good()){ - basic_ios::setstate(ios_base::failbit); - return *this; - } - if(basic_ios::mstreambuf == 0){ - basic_ios::setstate(ios_base::badbit); - return *this; - } - if(basic_ios::mstreambuf->sputbackc(c) == traits::eof()){ - basic_ios::setstate(ios_base::badbit); - return *this; - } - return *this; - } - - _UCXXEXPORT basic_istream& unget(){ - sentry(*this, true); - if(!basic_ios::good()){ - basic_ios::setstate(ios_base::failbit); - return *this; - } - if(basic_ios::mstreambuf == 0){ - basic_ios::setstate(ios_base::failbit); - return *this; - } - if(basic_ios::mstreambuf->sungetc() == traits::eof()){ - basic_ios::setstate(ios_base::failbit); - } - return *this; - } - - _UCXXEXPORT int sync(){ - sentry(*this, true); - if(basic_ios::mstreambuf == 0){ - return -1; - } - if(basic_ios::mstreambuf->pubsync() == -1){ - basic_ios::setstate(ios_base::badbit); - return traits::eof(); - } - return 0; - } - - _UCXXEXPORT pos_type tellg(){ - if(basic_ios::fail() !=false){ - return pos_type(-1); - } - return basic_ios::mstreambuf->pubseekoff(0, ios_base::cur, ios_base::in); - } - - _UCXXEXPORT basic_istream& seekg(pos_type pos){ - if(basic_ios::fail() !=true){ - basic_ios::mstreambuf->pubseekpos(pos); - } - return *this; - } - - _UCXXEXPORT basic_istream& seekg(off_type off, ios_base::seekdir dir){ - if(basic_ios::fail() !=true){ - basic_ios::mstreambuf->pubseekoff(off, dir); - } - return *this; - } - - protected: - _UCXXEXPORT basic_istream(const basic_istream &): basic_ios() { } - _UCXXEXPORT basic_istream & operator=(const basic_istream &){ return *this; } - streamsize count_last_ufmt_input; - - }; - - template > class _UCXXEXPORT basic_istream::sentry { - bool ok; - public: - explicit _UCXXEXPORT sentry(basic_istream& os, bool noskipws = false){ - if(os.good() !=0){ //Prepare for output - } - - //Flush any tied buffer - if(os.tie() != 0){ - os.tie()->flush(); - } - if(!noskipws){ - __skipws(os); - } - - ok = true; - } - _UCXXEXPORT ~sentry() { } - _UCXXEXPORT operator bool() { - return ok; - } - }; - - //Template implementations of basic_istream functions which may be partially specialized - //For code reduction - - template - _UCXXEXPORT typename basic_istream::int_type basic_istream::get(){ - sentry(*this, true); - int_type retval = basic_ios::mstreambuf->sgetc(); - if(retval == traits::eof()){ - count_last_ufmt_input = 0; - basic_ios::setstate(ios_base::eofbit); - }else{ - count_last_ufmt_input = 1; - basic_ios::mstreambuf->sbumpc(); - } - return retval; - } - - template - _UCXXEXPORT basic_istream& basic_istream::get(char_type& c){ - sentry(*this, true); - int_type retval = basic_ios::mstreambuf->sgetc(); - if(retval == traits::eof()){ - count_last_ufmt_input = 0; - basic_ios::setstate(ios_base::eofbit); - basic_ios::setstate(ios_base::failbit); - }else{ - count_last_ufmt_input = 1; - c = traits::to_char_type(retval); - basic_ios::mstreambuf->sbumpc(); - } - return *this; - } - - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(bool& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(short& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(unsigned short& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& basic_istream::operator>>(int& n){ - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& basic_istream::operator>>(unsigned int& n){ - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& basic_istream::operator>>(long int& n){ - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(unsigned long int& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - -#ifdef __UCLIBCXX_HAS_FLOATS__ - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(float& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(double& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(long double& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } -#endif - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(void *& n) - { - sentry(*this); - __istream_readin::readin(*this, n); - return *this; - } - - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, charT& c) - { - typename basic_istream::sentry s(is); - is.get(c); - return is; - } - - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, unsigned char& c) - { - typename basic_istream::sentry s(is); - char b; - is.get(b); - c = b; - return is; - } - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, signed char& c) - { - typename basic_istream::sentry s(is); - is.get(c); - return is; - } - - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, charT* c) - { - typename basic_istream::sentry s(is); - int n = is.width(); - if(n == 0){ - n = __STRING_MAX_UNITS; - } - is.get(c, n); - return is; - - } - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, unsigned char* c) - { - typename basic_istream::sentry s(is); - int n = is.width(); - if(n == 0){ - n = __STRING_MAX_UNITS; - } - is.get(c, n); - return is; - } - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, signed char* c) - { - typename basic_istream::sentry s(is); - int n = is.width(); - if(n == 0){ - n = __STRING_MAX_UNITS; - } - is.get(c, n); - return is; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(basic_istream& (*pf)(basic_istream&)) - { - sentry(*this); - pf(*this); - return *this; - } - - template _UCXXEXPORT basic_istream& - basic_istream::operator>>(basic_ios& (*pf)(basic_ios&)) - { - sentry(*this); - pf(*this); - return *this; - } - - template _UCXXEXPORT basic_istream& - ws(basic_istream& is) - { - __skipws(is); - return is; - } - - -#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_ISTREAM__ - - - template <> _UCXXEXPORT istream & basic_istream >::get(char & c); - template <> _UCXXEXPORT istream::int_type basic_istream >::get(); - - 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); - -#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 istream & operator>>(istream & is, char & c); - - template <> _UCXXEXPORT void __skipws(basic_istream >& is); - -#endif -#endif - - - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/stack =================================================================== --- branches/slice/i386/modules/include/stack (revision 726) +++ branches/slice/i386/modules/include/stack (revision 727) @@ -1,84 +0,0 @@ -/* 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 - -#ifndef __HEADER_STD_STACK -#define __HEADER_STD_STACK 1 - -#pragma GCC visibility push(default) - -namespace std{ - - template > class _UCXXEXPORT stack{ - protected: - Container c; - - public: - typedef typename Container::value_type value_type; - typedef typename Container::size_type size_type; - typedef Container container_type; - - explicit stack(const Container& a = Container()) : c(a) { }; - bool empty() const { return c.empty(); } - size_type size() const { return c.size(); } - value_type& top() { return c.back(); } - const value_type& top() const { return c.back(); } - void push(const value_type& x) { c.push_back(x); } - void pop() { c.pop_back(); } - - bool operator==(const stack &x) const{ - return x.c == c; - } - - }; - - - template _UCXXEXPORT bool - operator< (const stack& x, const stack& y) - { - return (x.c < y.c); - } - template _UCXXEXPORT bool - operator!=(const stack& x, const stack& y) - { - return (x.c != y.c); - } - template _UCXXEXPORT bool - operator> (const stack& x, const stack& y) - { - return (x.c > y.c); - } - template _UCXXEXPORT bool - operator>=(const stack& x, const stack& y) - { - return (x.c >= y.c); - } - template _UCXXEXPORT bool - operator<=(const stack& x, const stack& y) - { - return (x.c <= y.c); - } - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/csetjmp =================================================================== --- branches/slice/i386/modules/include/csetjmp (revision 726) +++ branches/slice/i386/modules/include/csetjmp (revision 727) @@ -1,44 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_CSETJMP -#define __STD_HEADER_CSETJMP 1 - - -//From GCC Header files -#undef longjmp - -// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 -#ifndef setjmp -#define setjmp(env) setjmp (env) -#endif - -//Mine again - - -namespace std{ - using ::longjmp; - using ::jmp_buf; -} - - -#endif - Index: branches/slice/i386/modules/include/string =================================================================== --- branches/slice/i386/modules/include/string (revision 726) +++ branches/slice/i386/modules/include/string (revision 727) @@ -1,1042 +0,0 @@ -/* 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 -#include - - -#ifdef __UCLIBCXX_HAS_WCHAR__ -#include -#include -#endif - -#ifndef __HEADER_STD_STRING -#define __HEADER_STD_STRING 1 - -#pragma GCC visibility push(default) - -namespace std{ - - //Basic basic_string - - template, class A = allocator > class basic_string; - - typedef basic_string string; - #ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_string wstring; - #endif - - - -//template, class A = allocator > class _UCXXEXPORT basic_string -template class basic_string - : public std::vector -{ -public: - typedef Tr traits_type; - typedef typename Tr::char_type value_type; - typedef A allocator_type; - typedef typename A::size_type size_type; - typedef typename A::difference_type difference_type; - - typedef typename A::reference reference; - typedef typename A::const_reference const_reference; - typedef typename A::pointer pointer; - typedef typename A::const_pointer const_pointer; - - typedef typename vector::iterator iterator; - typedef typename vector::const_iterator const_iterator; - - typedef typename vector::reverse_iterator reverse_iterator; - typedef typename vector::const_reverse_iterator const_reverse_iterator; - - static const size_type npos = (size_type)-1; - - explicit _UCXXEXPORT basic_string(const A& al = A()) : vector(al){ return; } - - _UCXXEXPORT basic_string(const basic_string& str, size_type pos = 0, size_type n = npos, const A& al = A()); //Below - - _UCXXEXPORT basic_string(const Ch* s, size_type n, const A& al = A()) - : vector(al) - { - if(n == npos){ - __throw_out_of_range(); - } - if(s > 0){ - resize(n); - Tr::copy(vector::data, s, vector::elements); - } - } - - _UCXXEXPORT basic_string(const Ch* s, const A& al = A()); //Below - - _UCXXEXPORT basic_string(size_type n, Ch c, const A& al = A()) - : vector(n, c, al) - { - } - - template _UCXXEXPORT basic_string(InputIterator begin, InputIterator end, const A& a = A()) - :vector(begin, end) - { - - } - - _UCXXEXPORT ~basic_string() { - return; - } - - _UCXXEXPORT basic_string& operator=(const basic_string& str); //Below - - _UCXXEXPORT basic_string& operator=(const Ch* s){ - vector::clear(); - if(s!=0){ - size_type len = Tr::length(s); - resize(len); - Tr::copy( vector::data, s, len); - } - return *this; - } - - _UCXXEXPORT basic_string& operator=(Ch c){ - vector::clear(); - vector::push_back(c); - return *this; - } - - inline _UCXXEXPORT size_type length() const { return vector::size(); } - - void _UCXXEXPORT resize(size_type n, Ch c = Ch()){ - vector::resize(n, c); - } - - _UCXXEXPORT basic_string& operator+=(const basic_string& str){ - return append(str); - } - - _UCXXEXPORT basic_string& operator+=(const Ch * s){ - return append(s); - } - - _UCXXEXPORT basic_string& operator+=(Ch c){ - vector::push_back(c); - return *this; - } - - _UCXXEXPORT basic_string& append(const basic_string& str){ - size_t temp = vector::elements; - resize(vector::elements + str.elements); - Tr::copy( vector::data + temp, str.vector::data, str.elements); - - return *this; - } - - _UCXXEXPORT basic_string& append(const basic_string& str, size_type pos, size_type n){ - if(pos > str.size()){ - __throw_out_of_range(); - } - - size_type rlen = str.elements - pos; - if(rlen > n){ - rlen = n; - } - if(vector::elements > npos - rlen){ - __throw_length_error(); - } - size_t temp = vector::elements; - resize(vector::elements + rlen); - Tr::copy( vector::data + temp, str.vector::data + pos, rlen); - return *this; - } - - _UCXXEXPORT basic_string& append(const Ch* s, size_type n){ - size_t temp = vector::elements; - resize(vector::elements + n); - Tr::copy( vector::data + temp, s, n); - return *this; - } - - _UCXXEXPORT basic_string& append(const Ch* s){ - size_type strLen = Tr::length(s); - size_t temp = vector::elements; - resize(vector::elements + strLen); - Tr::copy( vector::data + temp, s, strLen); - return *this; - } - - _UCXXEXPORT basic_string& append(size_type n, Ch c){ - vector::resize(vector::elements + n, c); - return *this; - } - - _UCXXEXPORT basic_string& assign(const basic_string& str){ - operator=(str); - return *this; - } - - _UCXXEXPORT basic_string& assign(const basic_string& str, size_type pos, size_type n){ - if(pos > str.elements){ - __throw_out_of_range(); - } - size_type r = str.elements - pos; - if(r > n){ - r = n; - } - resize(r); - Tr::copy(vector::data, str.vector::data + pos, r); - return *this; - } - - _UCXXEXPORT basic_string& assign(const Ch* s, size_type n){ - resize(n); - Tr::copy(vector::data, s, n); - return *this; - } - - _UCXXEXPORT basic_string& assign(const Ch* s){ - size_type len = Tr::length(s); - return assign(s, len); - } - - _UCXXEXPORT basic_string& assign(size_type n, Ch c){ - vector::clear(); - vector::resize(n, Ch() ); - return *this; - } - - template _UCXXEXPORT basic_string& assign(InputIterator first, InputIterator last){ - vector::resize(0, Ch()); - while (first != last){ - append(*first); - ++first; - } - return *this; - } - - _UCXXEXPORT basic_string& insert(size_type pos1, const basic_string& str, size_type pos2=0, size_type n=npos){ - if(pos1 > vector::elements || pos2 > str.elements){ - __throw_out_of_range(); - } - size_type r = str.elements - pos2; - if( r > n){ - r = n; - } - if(vector::elements > npos - r){ - __throw_length_error(); - } - size_type temp = vector::elements; - resize(vector::elements + r); - Tr::move(vector::data + pos1 + r, vector::data + pos1, temp - pos1); - Tr::copy(vector::data + pos1, str.vector::data + pos2, r); - return *this; - } - - _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s, size_type n){ - if(pos > vector::elements){ - __throw_out_of_range(); - } - if(vector::elements > npos - n){ - __throw_length_error(); - } - size_type temp = vector::elements; - resize(vector::elements + n); - Tr::move(vector::data + pos + n, vector::data + pos, temp - pos); - Tr::copy(vector::data + pos, s, n); - return *this; - } - - inline _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s){ - size_type len = Tr::length(s); - return insert(pos, s, len); - } - - _UCXXEXPORT basic_string& insert(size_type pos, size_type n, Ch c){ - if(pos > vector::elements){ - __throw_out_of_range(); - } - if(vector::elements > npos - n){ - __throw_length_error(); - } - size_type temp = vector::elements; - resize(vector::elements + n); - Tr::move(vector::data + pos + n, vector::data + pos, temp - pos); - Tr::assign(vector::data + pos, n, c); - return *this; - } - -// iterator insert(iterator p, charT c = charT()); -// void insert(iterator p, size_type n, charT c); -// template void insert(iterator p, InputIterator first, InputIterator last); - - _UCXXEXPORT basic_string& erase(size_type pos = 0, size_type n = npos){ - size_type xlen = vector::elements - pos; - - if(xlen > n){ - xlen = n; - } - size_type temp = vector::elements; - - Tr::move(vector::data + pos, vector::data + pos + xlen, temp - pos - xlen); - resize(temp - xlen); - return *this; - } - - _UCXXEXPORT iterator erase(iterator position){ - if(position == vector::end()){ - return position; - } - - ++position; - - iterator temp = position; - - while(position != vector::end()){ - *(position-1) = *position; - ++position; - } - vector::pop_back(); - return temp; - } - - _UCXXEXPORT iterator erase(iterator first, iterator last){ - size_t count = last - first; - - iterator temp = last; - - while(last != vector::end()){ - *(last - count) = *last; - ++last; - } - - resize( vector::elements-count); - - return temp; - } - - _UCXXEXPORT basic_string& - replace(size_type pos1, size_type n1, const basic_string& str, size_type pos2=0, size_type n2=npos) - { - if(pos1 > vector::elements){ - __throw_out_of_range(); - } - size_type xlen = vector::elements - pos1; - if(xlen > n1){ - xlen = n1; - } - size_type rlen = str.elements - pos2; - if(rlen > n2){ - rlen = n2; - } - if((vector::elements - xlen) >= (npos - rlen)){ - __throw_length_error(); - } - - size_t temp = vector::elements; - - if(rlen > xlen){ //Only if making larger - resize(temp - xlen + rlen); - } - - //Final length = vector::elements - xlen + rlen - //Initial block is of size pos1 - //Block 2 is of size len - - Tr::move(vector::data + pos1 + rlen, vector::data + pos1 + xlen, temp - pos1 - xlen); - Tr::copy(vector::data + pos1, str.vector::data + pos2, rlen); - resize(temp - xlen + rlen); - return *this; - } - - _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s, size_type n2){ - return replace(pos,n1,basic_string(s,n2)); - - } - - inline _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s){ - return replace(pos,n1,basic_string(s)); - } - - _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, size_type n2, Ch c){ - return replace(pos,n1,basic_string(n2,c)); - } -// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const basic_string& str); -// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s, size_type n); -// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s); -// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, size_type n, Ch c); -/* template _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, - InputIterator j1, InputIterator j2);*/ - - size_type _UCXXEXPORT copy(Ch* s, size_type n, size_type pos = 0) const{ - if(pos > vector::elements){ - __throw_out_of_range(); - } - size_type r = vector::elements - pos; - if(r > n){ - r = n; - } - Tr::copy(s, vector::data + pos, r); - return r; - } - - _UCXXEXPORT void swap(basic_string& s){ - //Data pointers - - vector::swap(s); - } - - _UCXXEXPORT const Ch* c_str() const{ - const_cast *>(this)->reserve(vector::elements+1); - vector::data[vector::elements] = 0; //Add 0 at the end - return vector::data; - } - - _UCXXEXPORT const Ch* data() const{ - return vector::data; - } - _UCXXEXPORT allocator_type get_allocator() const{ - return vector::a; - } - - _UCXXEXPORT size_type find (const basic_string& str, size_type pos = 0) const; //Below - - _UCXXEXPORT size_type find (const Ch* s, size_type pos, size_type n) const{ - return find(basic_string(s,n), pos); - } - _UCXXEXPORT size_type find (const Ch* s, size_type pos = 0) const{ - return find(basic_string(s), pos); - } - _UCXXEXPORT size_type find (Ch c, size_type pos = 0) const{ - for(size_type i = pos; i < length(); ++i){ - if(operator[](i) == c){ - return i; - } - } - return npos; - } - _UCXXEXPORT size_type rfind(const basic_string& str, size_type pos = npos) const{ - if(pos >= length()){ - pos = length(); - } - for(size_type i = pos; i > 0; --i){ - if(str == substr(i-1, str.length())){ - return i-1; - } - } - return npos; - } - _UCXXEXPORT size_type rfind(const Ch* s, size_type pos, size_type n) const{ - return rfind(basic_string(s,n),pos); - } - _UCXXEXPORT size_type rfind(const Ch* s, size_type pos = npos) const{ - return rfind(basic_string(s),pos); - } - _UCXXEXPORT size_type rfind(Ch c, size_type pos = npos) const{ - return rfind(basic_string(1,c),pos); - } - - _UCXXEXPORT size_type find_first_of(const basic_string& str, size_type pos = 0) const{ - for(size_type i = pos; i < length(); ++i){ - for(size_type j = 0; j < str.length() ; ++j){ - if( Tr::eq(str[j], operator[](i)) ){ - return i; - } - } - } - return npos; - } - - _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos, size_type n) const{ - return find_first_of(basic_string(s,n),pos); - } - _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos = 0) const{ - return find_first_of(basic_string(s),pos); - } - _UCXXEXPORT size_type find_first_of(Ch c, size_type pos = 0) const{ - for(size_type i = pos; i< length(); ++i){ - if( Tr::eq(operator[](i), c) ){ - return i; - } - } - return npos; - } - - _UCXXEXPORT size_type find_last_of (const basic_string& str, size_type pos = npos) const{ - if(pos > length()){ - pos = length(); - } - for(size_type i = pos; i >0 ; --i){ - for(size_type j = 0 ; j < str.length(); ++j){ - if( Tr::eq(operator[](i-1), str[j]) ){ - return i-1; - } - } - } - return npos; - } - _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos, size_type n) const{ - return find_last_of(basic_string(s,n),pos); - } - _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos = npos) const{ - return find_last_of(basic_string(s),pos); - } - _UCXXEXPORT size_type find_last_of (Ch c, size_type pos = npos) const{ - if(pos > length()){ - pos = length(); - } - for(size_type i = pos; i >0 ; --i){ - if( Tr::eq(operator[](i-1), c) ){ - return i-1; - } - } - return npos; - } - - _UCXXEXPORT size_type find_first_not_of(const basic_string& str, size_type pos = 0) const{ - bool foundCharacter; - for(size_type i = pos; i < length(); ++i){ - foundCharacter = false; - for(size_type j = 0; j < str.length() ; ++j){ - if( Tr::eq(str[j], operator[](i)) ){ - foundCharacter = true; - } - } - if(foundCharacter == false){ - return i; - } - } - return npos; - } - - _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos, size_type n) const{ - return find_first_not_of(basic_string(s,n),pos); - } - _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos = 0) const{ - return find_first_not_of(basic_string(s),pos); - } - _UCXXEXPORT size_type find_first_not_of(Ch c, size_type pos = 0) const{ - for(size_type i = pos; i < length() ; ++i){ - if(operator[](i) != c){ - return i; - } - } - return npos; - } - _UCXXEXPORT size_type find_last_not_of (const basic_string& str, size_type pos = npos) const{ - size_type xpos(length() - 1); - if(xpos > pos){ - xpos = pos; - } - - while(xpos != npos && npos != str.find_first_of(at(xpos))){ - --xpos; - } - - return xpos; - } - - _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos, size_type n) const{ - return find_last_not_of(basic_string(s,n),pos); - } - _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos = npos) const{ - return find_last_not_of(basic_string(s),pos); - } - _UCXXEXPORT size_type find_last_not_of (Ch c, size_type pos = npos) const{ - size_type xpos(length() - 1); - if(xpos > pos){ - xpos = pos; - } - while(xpos != npos && Tr::eq(at(xpos), c)){ - --xpos; - } - return xpos; - - } - - _UCXXEXPORT basic_string substr(size_type pos = 0, size_type n = npos) const; - - _UCXXEXPORT int compare(const basic_string& str) const{ - size_type rlen = vector::elements; - if(rlen > str.elements){ - rlen = str.elements; - } - int retval = Tr::compare(vector::data, str.vector::data, rlen); - if(retval == 0){ - if(vector::elements < str.elements){ - retval = -1; - } - if(vector::elements > str.elements){ - retval = 1; - } - } - return retval; - } - - _UCXXEXPORT int compare(size_type pos1, size_type n1, const basic_string& str, - size_type pos2=0, size_type n2=npos) const{ - size_type len1 = vector::elements - pos1; - if(len1 > n1){ - len1 = n1; - } - size_type len2 = str.vector::elements - pos2; - if(len2 > n2){ - len2 = n2; - } - size_type rlen = len1; - if(rlen > len2){ - rlen = len2; - } - int retval = Tr::compare(vector::data + pos1, str.vector::data + pos2, rlen); - if(retval == 0){ - if(len1 < len2){ - retval = -1; - } - if(len1 > len2){ - retval = 1; - } - } - return retval; - } - - _UCXXEXPORT int compare(const Ch* s) const{ - size_type slen = Tr::length(s); - size_type rlen = slen; - if(rlen > vector::elements){ - rlen=vector::elements; - } - int retval = Tr::compare(vector::data, s, rlen); - if(retval==0){ - if(vector::elements < slen){ - retval = -1; - } - if(vector::elements > slen){ - retval = 1; - } - } - return retval; - } - - _UCXXEXPORT int compare(size_type pos1, size_type n1, const Ch* s, size_type n2 = npos) const{ - size_type len1 = vector::elements - pos1; - if(len1 > n1){ - len1 = n1; - } - size_type slen = Tr::length(s); - size_type len2 = slen; - if(len2 > n2){ - len2 = n2; - } - size_type rlen = len1; - if(rlen > len2){ - rlen = len2; - } - int retval = Tr::compare(vector::data + pos1, s, rlen); - if(retval == 0){ - if(len1 < len2){ - retval = -1; - } - if(len1 > len2){ - retval = 1; - } - } - return retval; - } - -}; - - -//Functions - -template _UCXXEXPORT basic_string::basic_string(const Ch* s, const A& al) - : vector(al) -{ - if(s!=0){ - size_type temp = Tr::length(s); - append(s, temp); - } -} - -template _UCXXEXPORT basic_string:: - basic_string(const basic_string& str, size_type pos, size_type n, const A& al) - : vector(al) -{ - if(pos>str.size()){ - __throw_out_of_range(); - } - size_type rlen = str.size() - pos; - if( rlen > n){ - rlen = n; - } - resize(rlen); - Tr::copy(vector::data, str.vector::data + pos, vector::elements); -} - -template _UCXXEXPORT basic_string& - basic_string::operator=(const basic_string & str) -{ - if(&str == this){ //Check if we are doing a=a - return *this; - } - vector::clear(); - resize(str.elements); - Tr::copy( vector::data, str.vector::data, str.elements); - return *this; -} - - -template _UCXXEXPORT typename basic_string::size_type - basic_string::find (const basic_string& str, size_type pos) const -{ - if(str.length() > length()){ - return npos; - } - size_type max_string_start = 1 + length() - str.length(); - for(size_type i = pos; i < max_string_start; ++i){ - if(str == substr(i, str.length())){ - return i; - } - } - return npos; -} - - -template - _UCXXEXPORT basic_string basic_string::substr(size_type pos, size_type n) const -{ - if(pos > vector::elements){ - __throw_out_of_range(); - } - size_type rlen = vector::elements - pos; - if(rlen > n){ - rlen = n; - } - return basic_string(vector::data + pos,rlen); -} - - - - -#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ -#ifndef __UCLIBCXX_COMPILE_STRING__ - -#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 - - 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, 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); - -#endif -#endif - - - - -//typedef basic_string string; - -template _UCXXEXPORT basic_string - operator+(const basic_string& lhs, const basic_string& rhs) -{ - basic_string temp(lhs); - temp.append(rhs); - return temp; -} - -template _UCXXEXPORT basic_string - operator+(const charT* lhs, const basic_string& rhs) -{ - basic_string temp(lhs); - temp.append(rhs); - return temp; -} - - -template _UCXXEXPORT basic_string - operator+(charT lhs, const basic_string& rhs) -{ - basic_string temp(1, lhs); - temp.append(rhs); - return temp; -} - -template _UCXXEXPORT basic_string - operator+(const basic_string& lhs, const charT* rhs) -{ - basic_string temp(lhs); - temp.append(rhs); - return temp; -} - -template _UCXXEXPORT basic_string - operator+(const basic_string& lhs, charT rhs) -{ - basic_string temp(lhs); - temp+=rhs; - return temp; -} - -template _UCXXEXPORT bool - operator==(const basic_string& lhs, const basic_string& rhs) -{ - if(lhs.compare(rhs) == 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator==(const charT* lhs, const basic_string& rhs) -{ - if(rhs.compare(lhs) == 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator==(const basic_string& lhs, const charT* rhs) -{ - if(lhs.compare(rhs)==0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator!=(const basic_string& lhs, const basic_string& rhs) -{ - if(lhs.compare(rhs) !=0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator!=(const charT* lhs, const basic_string& rhs) -{ - basic_string temp(lhs); - return (temp != rhs); -} - -template _UCXXEXPORT bool - operator!=(const basic_string& lhs, const charT* rhs) -{ - basic_string temp(rhs); - return (lhs != temp); -} - -template _UCXXEXPORT bool - operator< (const basic_string& lhs, const basic_string& rhs) -{ - if(lhs.compare(rhs) < 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator< (const basic_string& lhs, const charT* rhs) -{ - basic_string temp(rhs); - if(lhs.compare(rhs) < 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator< (const charT* lhs, const basic_string& rhs) -{ - basic_string temp(lhs); - if(temp.compare(rhs) < 0){ - return true; - } - return false; -} - - -template _UCXXEXPORT bool - operator> (const basic_string& lhs, const basic_string& rhs) -{ - if(lhs.compare(rhs) > 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator> (const basic_string& lhs, const charT* rhs) -{ - basic_string temp(rhs); - if(lhs.compare(rhs) > 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator> (const charT* lhs, const basic_string& rhs) -{ - basic_string temp(lhs); - if(temp.compare(rhs) > 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator<=(const basic_string& lhs, const basic_string& rhs) -{ - if(lhs.compare(rhs) <=0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator<=(const basic_string& lhs, const charT* rhs) -{ - basic_string temp(rhs); - if(lhs.compare(temp) <=0 ){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator<=(const charT* lhs, const basic_string& rhs) -{ - basic_string temp(lhs); - if(temp.compare(rhs) <= 0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator>=(const basic_string& lhs, const basic_string& rhs) -{ - if(lhs.compare(rhs) >=0){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator>=(const basic_string& lhs, const charT* rhs) -{ - basic_string temp(rhs); - if(lhs.compare(temp) >=0 ){ - return true; - } - return false; -} - -template _UCXXEXPORT bool - operator>=(const charT* lhs, const basic_string& rhs) -{ - basic_string temp(lhs); - if(temp.compare(rhs) >=0 ){ - return true; - } - return false; -} - -template _UCXXEXPORT void - swap(basic_string& lhs, basic_string& rhs) -{ - lhs.swap(rhs); -} - -/*template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const basic_string& str) -{ - return os.write(str.data(), str.length()); -}*/ - -#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ -#ifndef __UCLIBCXX_COMPILE_STRING__ - -//Operators we can avoid duplication of - -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); - - -#endif -#endif - - -} - -#pragma GCC visibility pop - -#endif Index: branches/slice/i386/modules/include/complex =================================================================== --- branches/slice/i386/modules/include/complex (revision 726) +++ branches/slice/i386/modules/include/complex (revision 727) @@ -1,327 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_COMPLEX -#define __STD_HEADER_COMPLEX 1 - - -namespace std { -// class complex; -// class complex; -// class complex; - - template class _UCXXEXPORT complex{ - public: - typedef T value_type; - - complex(const T& re = T(), const T& im = T()) : r(re), i(im) { } - complex(const complex& c): r(c.r), i(c.i){ } - template complex(const complex& c): r(c.r), i(c.i){ } - - inline T real() const{ - return r; - } - inline T imag() const{ - return i; - } - - complex& operator= (const T& v){ - r = v; - i = 0; - return *this; - } - complex& operator+=(const T& v){ - r +=v; - return *this; - } - complex& operator-=(const T& v){ - r -=v; - return *this; - } - complex& operator*=(const T& v){ - r*=v; - i*=v; - return *this; - } - complex& operator/=(const T& v){ - r/=v; - i/=v; - return *this; - } - complex& operator=(const complex& v){ - if(&v != this){ - r = v.r; - i = v.i; - } - return *this; - } - template complex& operator= (const complex& v){ - r = v.r; - i = v.i; - return *this; - } - template complex& operator+=(const complex& v){ - r+=v.r; - i+=v.i; - return *this; - } - template complex& operator-=(const complex& v){ - r-=v.r; - i-=v.i; - return *this; - } - template complex& operator*=(const complex& v){ - T tempr = r*v.r - i*v.i; - T tempi = r*v.i + i*v.r; - r = tempr; - i = tempi; - return *this; - } - template complex& operator/=(const complex& v){ - T tempr = (r*v.r + i*v.i) / (v.r*v.r + v.i*v.i); - T tempi = (i*v.r - r*v.i) / (v.r*v.r + v.i*v.i); - r = tempr; - i = tempi; - return *this; - } - private: - T r; - T i; - }; - - template _UCXXEXPORT complex operator+(const complex& ls, const complex& rs){ - complex retval(ls); - retval += rs; - return retval; - } - template _UCXXEXPORT complex operator+(const complex& ls, const T& rs){ - complex retval(ls); - ls += rs; - return retval; - } - template _UCXXEXPORT inline complex operator+(const T& ls, const complex& rs){ - return rs + ls; - } - template _UCXXEXPORT complex operator-(const complex& ls, const complex& rs){ - complex retval(ls); - retval -= rs; - return retval; - } - template _UCXXEXPORT complex operator-(const complex& ls, const T& rs){ - complex retval(ls); - retval -= rs; - return retval; - } - template _UCXXEXPORT complex operator-(const T& ls, const complex& rs){ - complex retval(ls); - retval -= rs; - return retval; - } - template _UCXXEXPORT complex operator*(const complex& ls, const complex& rs){ - complex retval(ls); - retval *= rs; - return retval; - } - template _UCXXEXPORT complex operator*(const complex& ls, const T& rs){ - complex retval(ls); - retval *= rs; - return retval; - } - template _UCXXEXPORT complex operator*(const T& ls, const complex& rs){ - complex retval(ls); - retval *=rs; - return retval; - } - template _UCXXEXPORT complex operator/(const complex& ls, const complex& rs){ - complex retval(ls); - retval/=rs; - return retval; - } - template _UCXXEXPORT complex operator/(const complex& ls, const T& rs){ - complex retval(ls); - retval/=rs; - return retval; - } - template _UCXXEXPORT complex operator/(const T& ls, const complex& rs){ - complex retval(ls); - retval/=rs; - return retval; - } - template _UCXXEXPORT complex operator+(const complex& v){ - return v; - } - template _UCXXEXPORT complex operator-(const complex& v){ - return complex (-v.real(), -v.imag()); - } - template _UCXXEXPORT bool operator==(const complex& ls, const complex& rs){ - if( ls.real() == rs.real() && ls.imag() == rs.image()){ - return true; - } - return false; - } - template _UCXXEXPORT bool operator==(const complex& ls, const T& rs){ - if(ls.real() == rs && ls.imag() == T()){ - return true; - } - return false; - } - template _UCXXEXPORT bool operator==(const T& ls, const complex& rs){ - if(ls == rs.real() && rs.imag() == T()){ - return true; - } - return false; - } - template _UCXXEXPORT bool operator!=(const complex& ls, const complex& rs){ - if(ls == rs){ - return false; - } - return true; - } - template _UCXXEXPORT bool operator!=(const complex& ls, const T& rs){ - if(ls == rs){ - return false; - } - return true; - } - template _UCXXEXPORT bool operator!=(const T& ls, const complex& rs){ - if(ls == rs){ - return false; - } - return true; - } - template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, complex& v) - { - T tempr; - T tempi; - is >> tempr; - is.get(); - is >> tempi; - v = complex(tempr, tempi); - return is; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const complex&v) - { - os << v.real() << ", " << v.imag(); - return os; - } - - template _UCXXEXPORT T real(const complex& v){ - return v.real(); - } - - template _UCXXEXPORT T imag(const complex& v){ - return v.imag(); - } - - template _UCXXEXPORT T norm(const complex& v){ - return (v.real() * v.real() + v.imag() * v.imag()); - } - - template _UCXXEXPORT complex conj(const complex& v){ - return complex(v.real(), -v.imag()); - } - -#ifdef __UCLIBCXX_SUPPORT_MATH__ //Can we link with libm? - - template _UCXXEXPORT T abs(const complex& v){ - return sqrt(v.real() * v.real() + v.imag() * v.imag()); - } - - template _UCXXEXPORT T arg(const complex& v){ - return atan2(v.imag(), v.real()); - } - - template _UCXXEXPORT complex polar(const T& rho, const T& theta){ - return complex(rho * cos(theta), rho * sin(theta)); - } - - template _UCXXEXPORT complex cos (const complex& v){ - return complex(cos(v.real()) * cosh(v.imag()), -sin(v.real()) * sinh(v.imag())); - } - - template _UCXXEXPORT complex cosh (const complex& v){ - return complex(cosh(v.real()) * cos(v.imag()), sinh(v.real()) * sin(v.imag())); - } - - template _UCXXEXPORT complex exp (const complex& v){ - return polar(exp(v.real()), v.imag()); - } - - template _UCXXEXPORT complex log (const complex& v){ - return complex(log(abs(v)), arg(v)); - } - - template _UCXXEXPORT complex log10(const complex& v){ - return (log(v) / log(T(10.0))); - } - - template _UCXXEXPORT complex pow(const complex& v, int p){ - T rho = pow(abs(v), p); - T theta = arg(v); - return complex(rho * cos(p * theta), rho * sin(p * theta) ); - } - - template _UCXXEXPORT complex pow(const complex& v, const T& p){ - return polar( pow(abs(v),p), arg(v)*p ); - } - - template _UCXXEXPORT complex pow(const complex& v, const complex& p){ - if(v == T()){ - //We are using "0" as the value - return T(); - } - return exp(p * log(v)); - } - - template _UCXXEXPORT complex pow(const T& v, const complex& p){ - if(v == T()){ - return T(); - } - return polar(pow(v,p.real()), y.imag() * log(x) ); - } - - template _UCXXEXPORT complex sin (const complex& v){ - return complex(sin(v.real()) * cosh(v.imag()), cosh(v.real()) * sin(v.imag())); - } - - template _UCXXEXPORT complex sinh (const complex& v){ - return complext(sinh(v.real()) * cos(v.imag()), cosh(v.real()) * sin(v.imag()) ); - } - - template _UCXXEXPORT complex sqrt (const complex&); - template _UCXXEXPORT complex tan (const complex& v){ - return sin(v) / cos(v); - } - - template _UCXXEXPORT complex tanh (const complex& v){ - return sinh(v) / cosh(v); - } - -#endif - -} - -#endif - Index: branches/slice/i386/modules/include/cfloat =================================================================== --- branches/slice/i386/modules/include/cfloat (revision 726) +++ branches/slice/i386/modules/include/cfloat (revision 727) @@ -1,30 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_CFLOAT -#define __STD_HEADER_CFLOAT 1 - - -#include - - -#endif - Index: branches/slice/i386/modules/include/ostream =================================================================== --- branches/slice/i386/modules/include/ostream (revision 726) +++ branches/slice/i386/modules/include/ostream (revision 727) @@ -1,483 +0,0 @@ -/* 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 - -#ifndef STD_HEADER_OSTREAM -#define STD_HEADER_OSTREAM 1 - -#include -#include -#include -#include - -#pragma GCC visibility push(default) - -namespace std { - template class basic_ostream; - typedef basic_ostream ostream; - -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_ostream wostream; -#endif - - template basic_ostream& endl(basic_ostream& os); - template basic_ostream& ends(basic_ostream& os); - template basic_ostream& flush(basic_ostream& os); - - template class _UCXXEXPORT basic_ostream - : virtual public basic_ios - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef traits traits_type; - - - _UCXXEXPORT basic_ostream(basic_streambuf* sb) - : basic_ios(sb) - { - basic_ios::init(sb); - } - virtual _UCXXEXPORT ~basic_ostream(); - - class sentry; - - _UCXXEXPORT basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&)){ - return pf(*this); - } - _UCXXEXPORT basic_ostream& operator<<(basic_ios& (*pf)(basic_ios&)){ - pf(*this); - return *this; - } - _UCXXEXPORT basic_ostream& operator<<(ios_base& (*pf)(ios_base&)){ - pf(*this); - return *this; - } - basic_ostream& operator<<(bool n); - basic_ostream& operator<<(short n); - basic_ostream& operator<<(unsigned short n); - basic_ostream& operator<<(int n); - basic_ostream& operator<<(unsigned int n); - basic_ostream& operator<<(long n); - basic_ostream& operator<<(unsigned long n); - basic_ostream& operator<<(float f); - basic_ostream& operator<<(double f); - basic_ostream& operator<<(long double f); - basic_ostream& operator<<(void* p); - basic_ostream& operator<<(basic_streambuf* sb); - - _UCXXEXPORT basic_ostream& put(char_type c){ - if(basic_ostream::traits_type::eq_int_type( - basic_ios::mstreambuf->sputc(c), - basic_ostream::traits_type::eof())) - { - basic_ios::setstate(ios_base::eofbit); - } - return *this; - } - _UCXXEXPORT basic_ostream& write(const char_type* s, streamsize n){ - if(basic_ostream::traits_type::eq_int_type( - basic_ios::mstreambuf->sputn(s, n), - basic_ostream::traits_type::eof()) - ){ - basic_ios::setstate(ios_base::eofbit); - } - return *this; - } - _UCXXEXPORT basic_ostream& flush(){ - if(basic_ios::mstreambuf->pubsync() == -1){ - basic_ios::setstate(ios_base::badbit); - } - return *this; - } - _UCXXEXPORT pos_type tellp(){ - if(basic_ios::fail() != false){ - return pos_type(-1); - } - return basic_ios::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); - } - _UCXXEXPORT basic_ostream& seekp(pos_type pos){ - if( basic_ios::fail() != true ){ - basic_ios::rdbuf()->pubseekpos(pos); - } - return *this; - } - _UCXXEXPORT basic_ostream& seekp(off_type off, ios_base::seekdir dir){ - if( basic_ios::fail() != true){ - basic_ios::rdbuf()->pubseekoff(off, dir); - } - return *this; - } - - protected: - basic_ostream(const basic_ostream &){ } - basic_ostream & operator=(const basic_ostream &){ return *this; } - }; - - //Implementations of template functions. To allow for partial specialization - - template _UCXXEXPORT basic_ostream::~basic_ostream(){ } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(bool n){ - sentry s(*this); - if( basic_ios::flags() & ios_base::boolalpha){ - if(n){ - write("true", 4); - }else{ - write("false", 5); - } - }else{ - if(n){ - write("1", 1); - }else{ - write("0", 1); - } - } - if(basic_ios::flags() & ios_base::unitbuf){ - flush(); - } - return *this; - } - - template _UCXXEXPORT basic_ostream& - basic_ostream::operator<<(unsigned short n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(short n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(int n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(unsigned int n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long n){ - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& - basic_ostream::operator<<(unsigned long n) - { - sentry s(*this); - __ostream_printout::printout(*this, n); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(float f){ - sentry s(*this); - __ostream_printout::printout(*this, f); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(double f){ - sentry s(*this); - __ostream_printout::printout(*this, f); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long double f){ - sentry s(*this); - __ostream_printout::printout(*this, f); - return *this; - } - - template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(void* p){ - sentry s(*this); - char buffer[20]; - write(buffer, snprintf(buffer, 20, "%p", p) ); - if(basic_ios::flags() & ios_base::unitbuf){ - flush(); - } - return *this; - } - - template _UCXXEXPORT basic_ostream& - basic_ostream::operator<<(basic_streambuf* sb) - { - sentry s(*this); - if(sb == 0){ - basic_ios::setstate(ios_base::badbit); - return *this; - } - - typename traits::int_type c; - - while(basic_ios::good() && (c = sb->sbumpc()) != traits::eof() ){ - put(c); - } - - if(basic_ios::flags() & ios_base::unitbuf){ - flush(); - } - return *this; - } - - /*Template Specializations*/ - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_OSTREAM__ - -#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); -#endif -#endif - - template > - class _UCXXEXPORT basic_ostream::sentry - { - bool ok; - public: - explicit _UCXXEXPORT sentry(basic_ostream& os): ok(true){ - if(os.good() !=0){ //Prepare for output - } - - //Flush any tied buffer - if(os.tie() !=0 ){ - os.tie()->flush(); - } - } - _UCXXEXPORT ~sentry() { } - _UCXXEXPORT operator bool() { - return ok; - } - }; - - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_OSTREAM__ -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT ostream::sentry::sentry(ostream & os); - template <> _UCXXEXPORT ostream::sentry::~sentry(); - -#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ -#endif -#endif - - - //Non - class functions - - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, charT c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - // signed and unsigned - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, signed char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, unsigned char c) - { - typename basic_ostream::sentry s(out); - out.put(c); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const charT* c) - { - typename basic_ostream::sentry s(out); - out.write(c, traits::length(c) ); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const char* c) - { - typename basic_ostream::sentry s(out); - out.write(c, char_traits::length(c) ); - return out; - } - - // partial specializations - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const char* c) - { - typename basic_ostream::sentry s(out); - out.write(c, traits::length(c)); - return out; - } - -#ifdef __UCLIBCXX_HAS_WCHAR__ - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const char* c) - { - typename basic_ostream::sentry s(out); - size_t numChars = char_traits::length(c); - wchar_t * temp = new wchar_t[numChars]; - - for(size_t i=0; i < numChars; ++i){ - temp[i] = out.widen(c[i]); - } - - out.write(temp, numChars); - return out; - } -#endif - - // signed and unsigned - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const signed char* c) - { - typename basic_ostream::sentry s(out); - out.write(reinterpret_cast(c), traits::length( reinterpret_cast(c))); - return out; - } - - template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& out, const unsigned char* c) - { - typename basic_ostream::sentry s(out); - out.write(reinterpret_cast(c), traits::length( reinterpret_cast(c))); - return out; - } - - template _UCXXEXPORT basic_ostream& - endl(basic_ostream& os) - { - typename basic_ostream::sentry s(os); - os.put('\n'); - os.flush(); - return os; - } - - template _UCXXEXPORT basic_ostream& - ends(basic_ostream& os) - { - typename basic_ostream::sentry s(os); - os.put(traits::eos()); - return os; - } - - template _UCXXEXPORT basic_ostream& flush(basic_ostream& os){ - typename basic_ostream::sentry s(os); - os.flush(); - return os; - } - - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_OSTREAM__ - 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, unsigned const char* c); - -#endif -#endif - - -#ifndef __STRICT_ANSI__ - -//Support for output of long long data types - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, signed long long int i) -{ - typename basic_ostream::sentry s(os); - __ostream_printout::printout(os, i); - return os; -} - - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, unsigned long long int i) -{ - typename basic_ostream::sentry s(os); - __ostream_printout::printout(os, i); - return os; -} - - -#endif //__STRICT_ANSI__ - - - - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/sstream =================================================================== --- branches/slice/i386/modules/include/sstream (revision 726) +++ branches/slice/i386/modules/include/sstream (revision 727) @@ -1,384 +0,0 @@ -/* 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 - -#ifndef HEADER_STD_SSTREAM -#define HEADER_STD_SSTREAM 1 - -#include -#include -#include -#include -#include -#include - -#pragma GCC visibility push(default) - -namespace std{ - - template - class _UCXXEXPORT basic_stringbuf : public basic_streambuf - { - public: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef typename Allocator::size_type size_type; - - explicit _UCXXEXPORT basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out) - : data(), ielement(0), oelement(0) - { - basic_streambuf::openedFor = which; - } - - explicit _UCXXEXPORT basic_stringbuf(const basic_string& str, - ios_base::openmode which = ios_base::in | ios_base::out) - : data(str), ielement(0), oelement(0) - { - if(which & ios_base::ate){ - oelement = data.length(); - } - basic_streambuf::openedFor = which; - } - - virtual _UCXXEXPORT ~basic_stringbuf() { } - - _UCXXEXPORT basic_string str() const{ - return data; - } - - _UCXXEXPORT void str(const basic_string& s){ - data = s; - ielement = 0; - if(basic_streambuf::openedFor & ios_base::ate){ - oelement = data.length(); - }else{ - oelement = 0; - } - } - - protected: - virtual _UCXXEXPORT int sync(){ - return 0; - } - virtual _UCXXEXPORT int_type underflow(){ - if(ielement >= data.length()){ - return traits::eof(); - } - return traits::to_int_type(data[ielement]); - } - - virtual _UCXXEXPORT int_type uflow(){ - int_type retval = underflow(); - if(retval != traits::eof()){ - ++ielement; - } - return retval; - } - - virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){ - //Error possibilities - if(ielement == 0){ - return traits::eof(); - } - if(ielement > data.length()){ - ielement = data.length(); - return traits::eof(); - } - //eof passed in - if(traits::eq_int_type(c,traits::eof())==true){ - --ielement; - return traits::not_eof(c); - } - if(traits::eq(traits::to_char_type(c),data[ielement-1]) == true){ - --ielement; - return c; - } - if(basic_streambuf::openedFor & ios_base::out){ - --ielement; - data[ielement] = c; - return c; - } - return traits::eof(); - } - - virtual _UCXXEXPORT int showmanyc(){ - return data.length() - ielement; - } - virtual _UCXXEXPORT streamsize xsgetn(char_type* c, streamsize n){ - streamsize i = 0; - while(ielement < data.length() && i < n ){ - c[i] = data[ielement]; - ++i; - ++ielement; - } - return i; - } - - virtual _UCXXEXPORT int_type overflow (int_type c = traits::eof()){ - //Nothing to do - if(traits::eq_int_type(c,traits::eof())){ - return traits::not_eof(c); - } - - //Actually add character, if possible - if(basic_streambuf::openedFor & ios_base::out){ - if(oelement >= data.length()){ - data.push_back(c); - }else{ - data[oelement] = c; - } - ++oelement; - return c; - } - //Not possible - return traits::eof(); - } - - virtual _UCXXEXPORT basic_streambuf* setbuf(charT*, streamsize){ - //This function does nothing - return this; - } - - virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){ - data.replace(oelement, n, s, n); - oelement += n; - return n; - } - - virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way, - ios_base::openmode which = ios_base::in | ios_base::out) - { - //Test for invalid option - if( (which & ios_base::in) && (which & ios_base::out) && (way == ios_base::cur)){ - return -1; - } - - //Calculate new location - size_type newpos = 0; - - if(way == ios_base::beg){ - newpos = off; - }else if(way == ios_base::cur){ - if(which & ios_base::out){ - newpos = data.length() + off; - } - if(which & ios_base::in){ - newpos = ielement + off; - } - - }else{ - newpos = data.length() + off; - } - - //Test for error conditions - if(newpos > data.length()){ - return -1; - } - - //Shuffle pointers - - if(which & ios_base::in){ - ielement = newpos; - } - if(which & ios_base::out){ - data.resize(newpos); - if(ielement > data.length()){ - ielement = data.length(); - } - } - - return newpos; - } - - virtual _UCXXEXPORT pos_type seekpos(pos_type sp, - ios_base::openmode which = ios_base::in | ios_base::out) - { - return seekoff(sp, ios_base::beg, which); - } - - basic_string data; - size_type ielement; - size_type oelement; - }; - - - template class _UCXXEXPORT basic_istringstream - : public basic_istream - { - public: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - - explicit _UCXXEXPORT basic_istringstream(ios_base::openmode m = ios_base::in) - : basic_ios(&sb), basic_istream(&sb), sb(m) - { - } - explicit _UCXXEXPORT basic_istringstream( const basic_string& str, - ios_base::openmode which = ios_base::in) - : basic_ios(&sb), basic_istream(&sb), sb(str, which) - { - } - virtual _UCXXEXPORT ~basic_istringstream() { } - _UCXXEXPORT basic_stringbuf* rdbuf() const{ - return &sb; - } - _UCXXEXPORT basic_string str() const{ - return sb.str(); - } - _UCXXEXPORT void str(const basic_string& s){ - sb.str(s); - basic_istream::clear(); - } - private: - basic_stringbuf sb; - }; - - - template class _UCXXEXPORT basic_ostringstream - : public basic_ostream - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - explicit _UCXXEXPORT basic_ostringstream(ios_base::openmode m = ios_base::out) - : basic_ios(&sb), basic_ostream(&sb), sb(m) - { - } - explicit _UCXXEXPORT basic_ostringstream(const basic_string& str, - ios_base::openmode which = ios_base::out) - : basic_ios(&sb), basic_ostream(&sb), sb(str, which) - { - } - virtual _UCXXEXPORT ~basic_ostringstream() { } - - _UCXXEXPORT basic_stringbuf* rdbuf() const{ - return &sb; - } - _UCXXEXPORT basic_string str() const{ - return sb.str(); - } - _UCXXEXPORT void str(const basic_string& s){ - sb.str(s); - basic_ostream::clear(); - } - private: - basic_stringbuf sb; - }; - - - template class _UCXXEXPORT basic_stringstream - : public basic_iostream - { - public: - - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - explicit _UCXXEXPORT basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in) - : basic_ios(&sb), basic_iostream(&sb), sb(which) - { - } - - explicit _UCXXEXPORT basic_stringstream(const basic_string& str, - ios_base::openmode which = ios_base::out|ios_base::in) - : basic_ios(&sb), basic_iostream(&sb), sb(str, which) - { - } - virtual _UCXXEXPORT ~basic_stringstream(){ } - - _UCXXEXPORT basic_stringbuf* rdbuf(){ - return &sb; - } - _UCXXEXPORT basic_string str() const{ - return sb.str(); - } - _UCXXEXPORT void str(const basic_string& s){ - sb.str(s); - basic_iostream::clear(); - } - private: - basic_stringbuf sb; - }; - -#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_SSTREAM__ - -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT basic_stringbuf, allocator >:: - basic_stringbuf(ios_base::openmode which); - template <> _UCXXEXPORT basic_stringbuf, allocator >::~basic_stringbuf(); - -#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT basic_string, allocator > - basic_stringbuf, allocator >::str() const; - - template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type - basic_stringbuf, allocator >:: - pbackfail(basic_stringbuf, allocator >::int_type c); - - template <> _UCXXEXPORT basic_stringbuf, allocator >::pos_type - basic_stringbuf, allocator >:: - seekoff (basic_stringbuf, allocator >::off_type off, - ios_base::seekdir way, - ios_base::openmode which - ); - - template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type - basic_stringbuf, allocator >:: - overflow (basic_stringbuf, allocator >::int_type c); - - template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type - basic_stringbuf, allocator >::underflow (); - - template <> _UCXXEXPORT streamsize basic_stringbuf, allocator >:: - xsputn(const char* s, streamsize n); - -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT basic_stringstream, allocator >:: - basic_stringstream(ios_base::openmode which); - template <> _UCXXEXPORT basic_stringstream, allocator >::~basic_stringstream(); - template <> _UCXXEXPORT basic_istringstream, allocator >::~basic_istringstream(); - template <> _UCXXEXPORT basic_ostringstream, allocator >::~basic_ostringstream(); - -#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - -#endif -#endif - -#pragma GCC visibility pop - -} - - -#endif Index: branches/slice/i386/modules/include/csignal =================================================================== --- branches/slice/i386/modules/include/csignal (revision 726) +++ branches/slice/i386/modules/include/csignal (revision 727) @@ -1,61 +0,0 @@ -// -*- C++ -*- forwarding header. - -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 -// Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, 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 General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 20.4.6 C library -// - -/** @file csignal - * This is a Standard C++ Library file. You should @c #include this file - * in your programs, rather than any of the "*.h" implementation files. - * - * This is the C++ version of the Standard C Library header @c signal.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. - */ - -#ifndef _CPP_CSIGNAL -#define _CPP_CSIGNAL 1 - -#pragma GCC system_header - -#include - -// Get rid of those macros defined in in lieu of real functions. -#undef raise - -namespace std -{ - using ::sig_atomic_t; - using ::signal; - using ::raise; -} - -#endif Index: branches/slice/i386/modules/include/valarray =================================================================== --- branches/slice/i386/modules/include/valarray (revision 726) +++ branches/slice/i386/modules/include/valarray (revision 727) @@ -1,996 +0,0 @@ -/* 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 - -#ifndef __HEADER_STD_VALARRAY -#define __HEADER_STD_VALARRAY 1 - -#include -#include - -#pragma GCC visibility push(default) - -namespace std{ - - template class valarray; - class slice; - template class slice_array; - class gslice; - template class gslice_array; - template class mask_array; - template class indirect_array; - - //Actual class definitions - - - class _UCXXEXPORT slice { - protected: - size_t sta; - size_t siz; - size_t str; - - public: - slice() : sta(0), siz(0), str(0){ } - slice(size_t a, size_t b, size_t c) : sta(a), siz(b), str(c) { } - slice(const slice& s) : sta(s.sta), siz(s.siz), str(s.str) { } - ~slice() { } - size_t start() const{ - return sta; - } - size_t size() const{ - return siz; - } - size_t stride() const{ - return str; - } - }; - - - - template class _UCXXEXPORT valarray { - friend class slice_array; - protected: - T * data; - size_t length; - - public: - typedef T value_type; - - valarray() : data(0), length(0) { } - - explicit valarray(size_t t) : data(0), length(t){ - data = new T[length]; - } - - valarray(const T& v, size_t t) : data(0), length(t){ - data = new T[length]; - for(size_t i = 0; i < length; ++i){ - data[i] = v; - } - } - valarray(const T* p, size_t t) : data(0), length(t) { - data = new T[length]; - for(size_t i = 0; i < length; ++i){ - data[i] = p[i]; - } - } - valarray(const valarray& v) : data(0), length(v.length){ - data = new T[length]; - for(size_t i = 0; i < length; ++i){ - data[i] = v.data[i]; - } - } - valarray(const slice_array & sa) : data(0), length(sa.s.size()){ - data = new T[length]; - for(unsigned int i = 0; i < length; ++i){ - data[i] = sa.array->data[sa.s.start() + i * sa.s.stride()]; - } - } - valarray(const gslice_array&); - valarray(const mask_array&); - valarray(const indirect_array&); - ~valarray(){ - delete [] data; - data = 0; - length = 0; - } - - valarray& operator=(const valarray& v){ - for(size_t i =0; i< length; ++i){ - data[i] = v.data[i]; - } - return *this; - } - valarray& operator=(const T& t){ - for(size_t i = 0; i < length; ++i){ - data[i] = t; - } - return *this; - } - valarray& operator=(const slice_array& sa){ - for(size_t i =0; i < length; ++i){ - data[i] = sa.data[sa.s.start() + i * sa.s.stride()]; - } - return *this; - } - valarray& operator=(const gslice_array&); - valarray& operator=(const mask_array&); - valarray& operator=(const indirect_array&); - - T operator[](size_t t) const{ - return data[t]; - } - T& operator[](size_t t){ - return data[t]; - } - - valarray operator[](slice s) const{ - valarray retval(s.size()); - for(unsigned int i = 0; i< s.size(); ++i){ - retval.data[i] = data[s.start() + i * s.stride()]; - } - return retval; - } - - slice_array operator[](slice sl){ - slice_array retval; - retval.s = sl; - retval.array = this; - return retval; - } - - valarray operator[](const gslice&) const; - gslice_array operator[](const gslice&); - valarray operator[](const valarray&) const; - mask_array operator[](const valarray&); - valarray operator[](const valarray&) const; - indirect_array operator[](const valarray&); - - valarray operator+() const{ - valarray retval(length); - for(size_t i = 0; i< length ; ++i){ - retval.data[i] = +data[i]; - } - return retval; - } - valarray operator-() const{ - valarray retval(length); - for(size_t i = 0; i< length; ++i){ - retval.data[i] = -data[i]; - } - return retval; - } - valarray operator~() const{ - valarray retval(length); - for(size_t i = 0; i< length ; ++i){ - retval.data[i] = ~data[i]; - } - return retval; - } - valarray operator!() const{ - valarray retval(length); - for(size_t i = 0; i< length ; ++i){ - retval.data[i] = !data[i]; - } - return retval; - } - valarray& operator*= (const T& t){ - for(size_t i=0;i& operator/= (const T& t){ - for(size_t i=0;i& operator%= (const T& t){ - for(size_t i=0;i& operator+= (const T& t){ - for(size_t i=0;i& operator-= (const T& t){ - for(size_t i=0;i& operator^= (const T& t){ - for(size_t i=0;i& operator&= (const T& t){ - for(size_t i=0;i& operator|= (const T& t){ - for(size_t i=0;i& operator<<=(const T& t){ - for(size_t i=0;i& operator>>=(const T& t){ - for(size_t i=0;i>= t; - } - return *this; - } - valarray& operator*= (const valarray& a){ - for(size_t i=0;i& operator/= (const valarray& a){ - for(size_t i=0;i& operator%= (const valarray& a){ - for(size_t i=0;i& operator+= (const valarray& a){ - for(size_t i=0;i& operator-= (const valarray& a){ - for(size_t i=0;i& operator^= (const valarray& a){ - for(size_t i=0;i& operator|= (const valarray& a){ - for(size_t i=0;i& operator&= (const valarray& a){ - for(size_t i=0;i& operator<<=(const valarray& a){ - for(size_t i=0;i& operator>>=(const valarray& a){ - for(size_t i=0;i>= a.data[i]; - } - return *this; - } - - size_t size() const{ - return length; - } - - T sum() const{ - T retval(data[0]); - for(size_t i = 1; i< length; ++i){ - retval += data[i]; - } - return retval; - } - - T min() const{ - T retval(data[0]); - for(size_t i = 1; i< length; ++i){ - if(data[i] < retval){ - retval = data[i]; - } - } - return retval; - } - - T max() const{ - T retval(data[0]); - for(size_t i = 1; i< length; ++i){ - if(retval < data[i]){ - retval = data[i]; - } - } - return retval; - } - - valarray shift (int n) const{ - valarray retval(length); - for(size_t i = 0; i < length ; ++i){ - if(i + n > 0 && i + n < length){ - retval.data[i] = data[i + n]; - } - } - return retval; - } - valarray cshift(int n) const{ - valarray retval(length); - for(size_t i = 0; i < length ; ++i){ - retval.data[i] = data[ (i + n) % length ]; - } - return retval; - } - valarray apply(T func(T) ) const{ - valarray retval(length); - for(size_t i = 0; i< length; ++i){ - retval.data[i] = func(data[i]); - } - return retval; - } - valarray apply(T func(const T&)) const{ - valarray retval(length); - for(size_t i = 0; i< length; ++i){ - retval.data[i] = func(data[i]); - } - return retval; - } - void resize(size_t sz, T c = T()){ - delete [] data; - data = 0; - if(sz > 0){ - data = new T[sz]; - for(size_t i = 0; i < sz; ++i){ - data[i] = c; - } - } - length = sz; - } - }; - - - - template class _UCXXEXPORT slice_array { - friend class valarray; - public: - typedef T value_type; - - void operator= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] = v[i]; - } - } - void operator= (const T & v){ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] = v; - } - } - void fill(const T & v){ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] = v; - } - } - void operator*= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] *= v[i]; - } - } - void operator/= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] /= v[i]; - } - } - void operator%= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] %= v[i]; - } - } - void operator+= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] += v[i]; - } - } - void operator-= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] -= v[i]; - } - } - void operator^= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] ^= v[i]; - } - } - void operator&= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] &= v[i]; - } - } - void operator|= (const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] |= v[i]; - } - } - void operator<<=(const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] <<= v[i]; - } - } - void operator>>=(const valarray& v) const{ - for(unsigned int i = 0; i < s.size(); ++i){ - array->data[s.start() + i * s.stride()] >>= v[i]; - } - } - ~slice_array(){ - array = 0; - } - - private: - slice_array() : array(0){ } - - public: - slice_array(const slice_array& sa) : array(sa.array), s(sa.s){ } - slice_array& operator=(const slice_array& sa){ - array = sa.array; - s = sa.s; - } - - private: - valarray * array; - slice s; - }; - - - class _UCXXEXPORT gslice { - private: - size_t sta; - valarray siz; - valarray str; - - public: - gslice() : sta(0) { } - gslice(size_t s, const valarray& l, const valarray& d) - : sta(s), siz(l), str(d) { } - - size_t start() const{ - return sta; - } - valarray size() const{ - return siz; - } - valarray stride() const{ - return str; - } - }; - - template class gslice_array { - private: - friend class valarray; - - public: - ~gslice_array(); - - void operator=(const valarray& array) const; - void operator*=(const valarray& array) const; - void operator/=(const valarray& array) const; - void operator%=(const valarray& array) const; - void operator+=(const valarray& array) const; - void operator-=(const valarray& array) const; - void operator^=(const valarray& array) const; - void operator&=(const valarray& array) const; - void operator|=(const valarray& array) const; - void operator<<=(const valarray& array) const; - void operator>>=(const valarray& array) const; - - void operator=(const T&); - - private: - gslice_array(); - gslice_array(const gslice_array&); - gslice_array& operator= (const gslice_array& array); - }; - - - - template valarray operator* (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval *= rhs; - return retval; - } - - template valarray operator* (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval *= rhs; - return retval; - } - template valarray operator* (const T& lhs, const valarray& rhs){ - valarray retval(rhs); - retval *= lhs; - return retval; - } - template valarray operator/ (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval /= rhs; - return retval; - } - template valarray operator/ (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval /= rhs; - return retval; - } - template valarray operator/ (const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval /= rhs; - return retval; - } - template valarray operator% (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval %= rhs; - return retval; - } - template valarray operator% (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval %= rhs; - return retval; - } - template valarray operator% (const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval %= rhs; - return retval; - } - template valarray operator+ (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval += rhs; - return retval; - } - template valarray operator+ (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval += rhs; - return retval; - } - template valarray operator+ (const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval += rhs; - return retval; - } - template valarray operator- (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval -= rhs; - return retval; - } - template valarray operator- (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval-= rhs; - return retval; - } - template valarray operator- (const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval -= rhs; - return retval; - } - template valarray operator^ (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval ^= rhs; - return retval; - } - template valarray operator^ (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval ^= rhs; - return retval; - } - template valarray operator^ (const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval ^= rhs; - return retval; - } - template valarray operator& (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval &= rhs; - return retval; - } - template valarray operator& (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval &= rhs; - return retval; - } - template valarray operator& (const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval &= rhs; - return retval; - } - template valarray operator| (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval |= rhs; - return retval; - } - template valarray operator| (const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval |= rhs; - return retval; - } - template valarray operator| (const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval |= rhs; - return retval; - } - template valarray operator<<(const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval <<= rhs; - return retval; - } - template valarray operator<<(const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval <<= rhs; - return retval; - } - template valarray operator<<(const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval <<= rhs; - return retval; - } - template valarray operator>>(const valarray& lhs, const valarray& rhs){ - valarray retval(lhs); - retval >>= rhs; - return retval; - } - template valarray operator>>(const valarray& lhs, const T& rhs){ - valarray retval(lhs); - retval >>= rhs; - return retval; - } - template valarray operator>>(const T& lhs, const valarray& rhs){ - valarray retval(lhs, rhs.size()); - retval >>= rhs; - return retval; - } - - template valarray operator&&(const valarray& lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = lhs[i] && rhs[i]; - } - return retval; - } - template valarray operator&&(const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator&&(const T& lhs, const valarray& rhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i valarray operator||(const valarray&lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator||(const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator||(const T& lhs, const valarray& rhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = lhs || rhs[i]; - } - return retval; - } - - template valarray operator==(const valarray& lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator==(const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = lhs[i] == rhs; - } - return retval; - } - template valarray operator==(const T& lhs, const valarray& rhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = lhs == rhs[i]; - } - return retval; - } - template valarray operator!=(const valarray& lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator!=(const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator!=(const T& lhs, const valarray& rhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i valarray operator< (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator< (const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator< (const T& lhs, const valarray& rhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i valarray operator> (const valarray& lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i rhs[i]; - } - return retval; - } - template valarray operator> (const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i rhs; - } - return retval; - } - template valarray operator> (const T& rhs, const valarray& lhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i rhs[i]; - } - return retval; - } - template valarray operator<=(const valarray& lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator<=(const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i valarray operator<=(const T& lhs, const valarray& rhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i valarray operator>=(const valarray& lhs, const valarray& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i = rhs[i]; - } - return retval; - } - template valarray operator>=(const valarray& lhs, const T& rhs){ - valarray retval(lhs.size()); - for(size_t i = 0; i = rhs; - } - return retval; - } - template valarray operator>=(const T& lhs, const valarray& rhs){ - valarray retval(rhs.size()); - for(size_t i = 0; i = rhs[i]; - } - return retval; - } - template T min(const valarray& x){ - T retval(x[0]); - for(size_t i = 1; i < x.size(); ++i){ - if(x[i] < retval){ - retval = x[i]; - } - } - } - template T max(const valarray& x){ - T retval(x[0]); - for(size_t i = 1; i < x.size(); ++i){ - if(x[i] > retval){ - retval = x[i]; - } - } - } - - template valarray abs (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = abs(x[i]); - } - } - template valarray acos (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = acos(x[i]); - } - } - template valarray asin (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = asin(x[i]); - } - } - template valarray atan (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = atan(x[i]); - } - } - template valarray atan2(const valarray& y, const valarray& x){ - valarray retval(y.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = atan2(y[i], x[i]); - } - } - template valarray atan2(const valarray& y, const T& x){ - valarray retval(y.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = atan2(y[i], x); - } - } - template valarray atan2(const T& y, const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = abs(y, x[i]); - } - } - template valarray cos (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = cos(x[i]); - } - } - template valarray cosh (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = cosh(x[i]); - } - } - template valarray exp (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = exp(x[i]); - } - } - template valarray log (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = log(x[i]); - } - } - template valarray log10(const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = log10(x[i]); - } - } - template valarray pow (const valarray& x, const valarray& y){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = pow(x[i], y[i]); - } - } - template valarray pow (const valarray& x, const T& y){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = pow(x[i], y); - } - } - template valarray pow (const T& x, const valarray& y){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = pow(x, y[i]); - } - } - template valarray sin (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = sin(x[i]); - } - } - template valarray sinh (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = sinh(x[i]); - } - } - template valarray sqrt (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = sqrt(x[i]); - } - } - template valarray tan (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = tan(x[i]); - } - } - template valarray tanh (const valarray& x){ - valarray retval(x.size()); - for(size_t i = 0; i < retval.size(); ++i){ - retval[i] = tanh(x[i]); - } - } - -} - -#pragma GCC visibility pop - -#endif Index: branches/slice/i386/modules/include/iterator_base =================================================================== --- branches/slice/i386/modules/include/iterator_base (revision 726) +++ branches/slice/i386/modules/include/iterator_base (revision 727) @@ -1,305 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_ITERATOR_BASE -#define __STD_HEADER_ITERATOR_BASE 1 - -#pragma GCC visibility push(default) - -namespace std{ - template struct iterator_traits; - template struct iterator_traits; - - template struct iterator; - - struct _UCXXEXPORT input_iterator_tag {}; - struct _UCXXEXPORT output_iterator_tag {}; - struct _UCXXEXPORT forward_iterator_tag: public input_iterator_tag {}; - struct _UCXXEXPORT bidirectional_iterator_tag: public forward_iterator_tag {}; - struct _UCXXEXPORT random_access_iterator_tag: public bidirectional_iterator_tag {}; - - template _UCXXEXPORT void advance(InputIterator& i, Distance n){ - while(n > 0){ - --n; - ++i; - } - } - - template _UCXXEXPORT typename iterator_traits::difference_type - distance(InputIterator first, InputIterator last) - { - typename iterator_traits::difference_type d = 0; - while(first++ !=last){ - d++; - } - return d; - } - - // subclause _lib.predef.iterators_, predefined iterators: - template class reverse_iterator; - template bool operator==(const reverse_iterator& x, const reverse_iterator& y); - template bool operator<(const reverse_iterator& x, const reverse_iterator& y); - template bool operator!=(const reverse_iterator& x, const reverse_iterator& y); - template bool operator>(const reverse_iterator& x, const reverse_iterator& y); - template bool operator>=(const reverse_iterator& x, const reverse_iterator& y); - template bool operator<=(const reverse_iterator& x, const reverse_iterator& y); - template typename reverse_iterator::difference_type - operator-( const reverse_iterator& x, const reverse_iterator& y); - template reverse_iterator - operator+( typename reverse_iterator::difference_type n, const reverse_iterator& x); - template class back_insert_iterator; - template back_insert_iterator back_inserter(Container& x); - template class front_insert_iterator; - template front_insert_iterator front_inserter(Container& x); - template class insert_iterator; - template - insert_iterator inserter(Container& x, Iterator i); - - //Actual Template definitions - - template struct _UCXXEXPORT iterator_traits { - typedef typename Iterator::difference_type difference_type; - typedef typename Iterator::value_type value_type; - typedef typename Iterator::pointer pointer; - typedef typename Iterator::reference reference; - typedef typename Iterator::iterator_category iterator_category; - }; - - //Pointer specialization - required by standard - template struct _UCXXEXPORT iterator_traits { - typedef ptrdiff_t difference_type; - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef random_access_iterator_tag iterator_category; - }; - - //Specialization recomended by standard -/* template struct _UCXXEXPORT iterator_traits { - typedef long difference_type; - typedef T value_type; - typedef T __far* pointer; - typedef T __far& reference; - typedef random_access_iterator_tag iterator_category; - };*/ - -/* template _UCXXEXPORT void - reverse(BidirectionalIterator first, BidirectionalIterator last) - { - typename iterator_traits::difference_type n = distance(first, last); - --n; - while(n > 0){ - typename iterator_traits::value_type tmp = *first; - *first++ = * --last; - *last = tmp; - n -= 2; - } - };*/ - - - template - struct _UCXXEXPORT iterator - { - typedef T value_type; - typedef Distance difference_type; - typedef Pointer pointer; - typedef Reference reference; - typedef Category iterator_category; - }; - - - template class _UCXXEXPORT reverse_iterator - : public iterator::iterator_category, - typename iterator_traits::value_type, typename iterator_traits::difference_type, - typename iterator_traits::pointer, typename iterator_traits::reference> - { - protected: - Iterator current; - friend bool operator== (const reverse_iterator& x, const reverse_iterator& y); - friend bool operator< (const reverse_iterator& x, const reverse_iterator& y); - - public: - typedef Iterator iterator_type; - - reverse_iterator() : current(){}; - explicit reverse_iterator(Iterator x) : current(x) { } - template reverse_iterator(const reverse_iterator &x) : current(x.base()){} - - Iterator base() const { return current; } // explicit - - typename iterator_traits::reference operator*() const { Iterator tmp = current; return *--tmp; } - typename iterator_traits::pointer operator->() const { return &(operator*()); } - typename iterator_traits::reference operator[](typename iterator_traits::difference_type n) const{ - return current[-n-1]; - } - - reverse_iterator& operator++(){ --current; return *this; } - reverse_iterator operator++(int) {reverse_iterator tmp = *this; --current; return tmp; } - reverse_iterator& operator--() { ++ current; return *this; } - reverse_iterator operator--(int) {reverse_iterator tmp = *this; ++current; return tmp; } - - reverse_iterator operator+ (typename iterator_traits::difference_type n) const{ - reverse_iterator retval( *this ); - retval+=n; - return retval; - } - reverse_iterator& operator+=(typename iterator_traits::difference_type n){ - current -= n; - return *this; - } - reverse_iterator operator- (typename iterator_traits::difference_type n) const{ - reverse_iterator retval( *this ); - retval-=n; - return retval; - } - reverse_iterator& operator-=(typename iterator_traits::difference_type n){ - current += n; - return *this; - } - }; - - - template _UCXXEXPORT bool - operator==(const reverse_iterator& x, const reverse_iterator& y) - { - return x.base() == y.base(); - } - template _UCXXEXPORT bool - operator<(const reverse_iterator& x, const reverse_iterator& y) - { - return x.base() < y.base(); - } - template _UCXXEXPORT bool - operator!=(const reverse_iterator& x, const reverse_iterator& y) - { - return x.base() != y.base(); - } - template _UCXXEXPORT bool - operator>(const reverse_iterator& x, const reverse_iterator& y) - { - return x.base() > y.base(); - } - template _UCXXEXPORT bool - operator>=(const reverse_iterator& x, const reverse_iterator& y) - { - return x.base() >= y.base(); - } - template _UCXXEXPORT bool - operator<=(const reverse_iterator& x, const reverse_iterator& y) - { - return x.base() <= y.base(); - } - template _UCXXEXPORT typename reverse_iterator::difference_type - operator-( const reverse_iterator& x, const reverse_iterator& y) - { - return y.base() - x.base(); - } - template _UCXXEXPORT reverse_iterator - operator+(typename reverse_iterator::difference_type n, const reverse_iterator& x) - { - return reverse_iterator (x.base() - n); - } - - template class _UCXXEXPORT back_insert_iterator : - public iterator - { - protected: - Container& container; - public: - typedef Container container_type; - explicit back_insert_iterator(Container& x):container(x) {}; - back_insert_iterator& operator=(const typename Container::value_type& value){ - container.push_back(value); - return *this; - } - back_insert_iterator& operator*(){ - return *this; - } - back_insert_iterator& operator++(){ - return *this; - } - back_insert_iterator operator++(int){ - return *this; - } - }; - - template _UCXXEXPORT back_insert_iterator - back_inserter(Container& x) - { - return back_insert_iterator(x); - } - - template class _UCXXEXPORT front_insert_iterator - : public iterator - { - protected: - Container& container; - public: - typedef Container container_type; - explicit front_insert_iterator(Container& x): container(x) {} - front_insert_iterator& operator=(const typename Container::value_type& value){ - container.push_front(value); - return *this; - } - - front_insert_iterator& operator*() { return *this; } - front_insert_iterator& operator++() { return *this; } - front_insert_iterator operator++(int) { return *this; } - }; - - template _UCXXEXPORT front_insert_iterator - front_inserter(Container& x) - { - return front_insert_iterator(x); - } - - template class _UCXXEXPORT insert_iterator - : public iterator - { - protected: - Container& container; - typename Container::iterator iter; - public: - typedef Container container_type; - insert_iterator(Container& x, typename Container::iterator i) : container(x), iter(i) {} - insert_iterator& operator=(const typename Container::value_type& value){ - iter = container.insert(iter, value); - ++iter; - return *this; - } - insert_iterator& operator*() { return *this; } - insert_iterator& operator++() { return *this; } - insert_iterator operator++(int) { return *this; } - }; - - template _UCXXEXPORT insert_iterator - inserter(Container& x, Iterator i) - { - return insert_iterator(x,typename Container::iterator(i)); - } - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/algorithm =================================================================== --- branches/slice/i386/modules/include/algorithm (revision 726) +++ branches/slice/i386/modules/include/algorithm (revision 727) @@ -1,1695 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_ALGORITHM -#define __STD_HEADER_ALGORITHM 1 - -//Elliminate any previously defined macro -#undef min -#undef max - -#pragma GCC visibility push(default) - -namespace std{ - - // subclause _lib.alg.nonmodifying_, non-modifying sequence operations: - template _UCXXEXPORT - Function for_each(InputIterator first, InputIterator last, Function f) - { - while(first !=last){ - f(*first); - ++first; - } - return f; - } - - - template _UCXXEXPORT - InputIterator find(InputIterator first, InputIterator last, const T& value) - { - while(first !=last && *first != value){ - ++first; - } - return first; - } - - template _UCXXEXPORT - InputIterator find_if(InputIterator first, InputIterator last, Predicate pred) - { - while(first !=last && !pred(*first)){ - ++first; - } - return first; - } - - template _UCXXEXPORT ForwardIterator1 - find_end(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - ForwardIterator1 retval = last1; - while(first1 !=last1){ - ForwardIterator1 temp1(first1); - ForwardIterator2 temp2(first2); - while(temp2!=last2 && temp1!= last1){ - if(*temp1 != *temp2){ - break; //Exit while loop - } - ++temp1; - ++temp2; - if(temp2 == last2){ //Have successfully checked the whole sequence - retval = first1; - } - } - } - return retval; - } - - template _UCXXEXPORT - ForwardIterator1 - find_end(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate pred) - { - ForwardIterator1 retval = last1; - while(first1 !=last1){ - ForwardIterator1 temp1(first1); - ForwardIterator2 temp2(first2); - while(temp2!=last2 && temp1!= last1){ - if( ! pred(*temp1, *temp2)){ - break; //Exit while loop - } - ++temp1; - ++temp2; - if(temp2 == last2){ //Have successfully checked the whole sequence - retval = first1; - } - } - } - return retval; - } - - template _UCXXEXPORT - ForwardIterator1 - find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - while(first1 != last1){ - ForwardIterator2 temp2(first2); - while(temp2 != last2 ){ - if(*temp2 == first1){ - return first1; - } - ++temp2; - } - - } - return last1; - } - - template _UCXXEXPORT - ForwardIterator1 - find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate pred) - { - while(first1 != last1){ - ForwardIterator2 temp2(first2); - while(temp2 != last2 ){ - if(*temp2 == first1){ - return first1; - } - ++temp2; - } - - } - return last1; - } - - template _UCXXEXPORT ForwardIterator - adjacent_find(ForwardIterator first, ForwardIterator last) - { - ForwardIterator temp; - while(first != last){ - temp = first; - ++temp; - if(*temp == *first){ - return first; - } - ++first; - } - return first; - } - - template _UCXXEXPORT - ForwardIterator - adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) - { - ForwardIterator temp; - while(first != last){ - temp = first; - ++temp; - if( pred(*temp, *first)){ - return first; - } - ++first; - } - return first; - } - - template _UCXXEXPORT - typename iterator_traits::difference_type - count(InputIterator first, InputIterator last, const T& value) - { - typename iterator_traits::difference_type i = 0; - while(first!=last){ - if(*first == value){ - ++i; - } - ++first; - } - return i; - } - - template _UCXXEXPORT - typename iterator_traits::difference_type - count_if(InputIterator first, InputIterator last, Predicate pred) - { - typename iterator_traits::difference_type i = 0; - while(first!=last){ - if( pred(*first) ){ - ++i; - } - ++first; - } - return i; - } - - template _UCXXEXPORT - pair - mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) - { - while(first1 != last1){ - if(*first1 != *first2){ - break; - } - ++first1; - ++first2; - } - - pair retval; - retval.first = first1; - retval.second = first2; - return retval; - } - - template _UCXXEXPORT - pair - mismatch(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, BinaryPredicate pred) - { - while(first1 != last1){ - if( !pred(*first1, *first2) ){ - break; - } - ++first1; - ++first2; - } - - pair retval; - retval.first = first1; - retval.second = first2; - return retval; - } - - template _UCXXEXPORT - bool - equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) - { - while(first1 !=last1){ - if(*first1 != *first2){ - return false; - } - ++first1; - ++first2; - } - return true; - } - - template _UCXXEXPORT - bool - equal(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, BinaryPredicate pred) - { - while(first1 !=last1){ - if( !pred(*first1, *first2) ){ - return false; - } - ++first1; - ++first2; - } - return true; - } - - template _UCXXEXPORT - ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2) - { - equal_to::value_type> c; - return search(first1, last1, first2, last2, c); - } - - - template _UCXXEXPORT - ForwardIterator1 - search(ForwardIterator1 first1, ForwardIterator1 last1, - ForwardIterator2 first2, ForwardIterator2 last2, - BinaryPredicate pred) - { - while(first1 != last1){ - ForwardIterator1 temp1(first1); - ForwardIterator2 temp2(first2); - while(temp2 != last2 && temp1 != last1){ - if( !pred(*temp2, *temp1) ){ - break; - } - ++temp1; - ++temp2; - if(temp2 == last2){ - return first1; - } - } - ++first1; - } - return last1; - } - - - template _UCXXEXPORT - ForwardIterator - search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value) - { - while( first != last ){ - if(*first == value){ - ForwardIterator temp(first); - Size i = 1; - ++first; //Avoid doing the same comparison over again - while(i < count && *temp == value){ - ++first; - ++i; - } - if(i == count){ - return first; - } - } - ++first; - } - return first; - } - - - template _UCXXEXPORT - ForwardIterator - search_n(ForwardIterator first, ForwardIterator last, - Size count, const T& value, BinaryPredicate pred) - { - while( first != last ){ - if( pred(*first, value) ){ - ForwardIterator temp(first); - Size i = 1; - ++first; //Avoid doing the same comparison over again - while(i < count && pred(*temp, value) ){ - ++first; - ++i; - } - if(i == count){ - return first; - } - } - ++first; - } - return first; - - } - - // subclause _lib.alg.modifying.operations_, modifying sequence operations: - - template _UCXXEXPORT - OutputIterator - copy(InputIterator first, InputIterator last, OutputIterator result) - { - while(first != last){ - *result = *first; - ++first; - ++result; - } - return result; - } - - template _UCXXEXPORT - BidirectionalIterator2 - copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, - BidirectionalIterator2 result) - { - while(first !=last ){ - --result; - --last; - *result = *last; - } - return result; - } - - template _UCXXEXPORT void swap(T& a, T& b){ - T temp(a); - a = b; - b = temp; - } - - template _UCXXEXPORT - ForwardIterator2 - swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) - { - while(first1 != last1){ - iter_swap(first1, first2); - ++first1; - ++first2; - } - return first2; - } - - - template _UCXXEXPORT - void - iter_swap(ForwardIterator1 a, ForwardIterator2 b) - { - typename iterator_traits::value_type temp(*a); - *a = *b; - *b = temp; - } - - - template _UCXXEXPORT - OutputIterator - transform(InputIterator first, InputIterator last, - OutputIterator result, UnaryOperation op) - { - while(first != last){ - *result = op(*first); - ++first; - ++result; - } - return result; - } - - - template _UCXXEXPORT - OutputIterator transform(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, OutputIterator result, - BinaryOperation binary_op) - { - while(first1 != last1){ - *result = binary_op(*first1, *first2); - ++first1; - ++first2; - ++result; - } - return result; - } - - - template _UCXXEXPORT - void - replace(ForwardIterator first, ForwardIterator last, - const T& old_value, const T& new_value) - { - while(first != last){ - if(*first == old_value){ - *first = new_value; - } - ++first; - } - } - - template _UCXXEXPORT - void - replace_if(ForwardIterator first, ForwardIterator last, - Predicate pred, const T& new_value) - { - while(first != last){ - if( pred(*first) ){ - *first = new_value; - } - ++first; - } - } - - - template _UCXXEXPORT - OutputIterator - replace_copy(InputIterator first, InputIterator last, - OutputIterator result, const T& old_value, const T& new_value) - { - while(first != last){ - if(*first == old_value){ - *result = new_value; - }else{ - *result = *first; - } - ++first; - ++result; - } - return result; - } - - template _UCXXEXPORT - OutputIterator - replace_copy_if(Iterator first, Iterator last, - OutputIterator result, Predicate pred, const T& new_value) - { - while(first != last){ - if( pred(*first) ){ - *result = new_value; - }else{ - *result = *first; - } - ++first; - ++result; - } - return result; - } - - template _UCXXEXPORT - void - fill(ForwardIterator first, ForwardIterator last, const T& value) - { - while(first != last){ - *first = value; - ++first; - } - } - - template _UCXXEXPORT - void - fill_n(OutputIterator first, Size n, const T& value) - { - while(n != 0){ - *first = value; - --n; - ++first; - } - } - - template _UCXXEXPORT - void - generate(ForwardIterator first, ForwardIterator last, Generator gen) - { - while(first != last){ - *first = gen(); - ++first; - } - } - - template _UCXXEXPORT - void - generate_n(OutputIterator first, Size n, Generator gen) - { - while(n !=0){ - *first = gen(); - --n; - ++first; - } - } - - template _UCXXEXPORT - ForwardIterator - remove(ForwardIterator first, ForwardIterator last, const T& value) - { - ForwardIterator temp(first); - while(temp !=last){ - if(*temp == value){ - - }else{ - *first = *temp; - ++first; - } - ++temp; - } - return first; - } - - template _UCXXEXPORT - ForwardIterator - remove_if(ForwardIterator first, ForwardIterator last, Predicate pred) - { - ForwardIterator temp(first); - while(temp !=last){ - if( pred(*temp) ){ - - }else{ - *first = *temp; - ++first; - } - ++temp; - } - return first; - } - - - template _UCXXEXPORT - OutputIterator - remove_copy(InputIterator first, InputIterator last, - OutputIterator result, const T& value) - { - while(first !=last){ - if(*first != value){ - *result = *first; - ++result; - } - ++first; - } - return result; - } - - template _UCXXEXPORT - OutputIterator - remove_copy_if(InputIterator first, InputIterator last, - OutputIterator result, Predicate pred) - { - while(first !=last){ - if( !pred(*first) ){ - *result = *first; - ++result; - } - ++first; - } - return result; - } - - template _UCXXEXPORT - ForwardIterator - unique(ForwardIterator first, ForwardIterator last) - { - ForwardIterator new_val(first); - ForwardIterator old_val(first); - - while(new_val !=last){ - if(*new_val == *old_val && new_val != old_val){ - - }else{ - *first = *new_val; - old_val = new_val; - ++first; - } - ++new_val; - } - return first; - } - - template _UCXXEXPORT - ForwardIterator - unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) - { - ForwardIterator new_val(first); - ForwardIterator old_val(first); - - while(new_val !=last){ - if( pred(*new_val, *old_val) && new_val != old_val){ - - }else{ - *first = *new_val; - old_val = new_val; - ++first; - } - ++new_val; - } - return first; - } - - template _UCXXEXPORT - OutputIterator - unique_copy(InputIterator first, InputIterator last, OutputIterator result) - { - InputIterator temp(first); - while(first !=last ){ - if(*first == *temp && first != temp){ - - }else{ - *result = *first; - temp = first; - ++result; - } - ++first; - } - return result; - } - - template _UCXXEXPORT - OutputIterator - unique_copy(InputIterator first, InputIterator last, - OutputIterator result, BinaryPredicate pred) - { - InputIterator temp(first); - while(first !=last ){ - if( pred(*first, *temp) && first != temp){ - - }else{ - *result = *first; - temp = first; - ++result; - } - ++first; - } - return result; - } - - template _UCXXEXPORT - void - reverse(BidirectionalIterator first, BidirectionalIterator last) - { - --last; //Don't work with one past the end element - while(first < last){ - iter_swap(first, last); - ++first; - --last; - } - } - - template _UCXXEXPORT - OutputIterator - reverse_copy(BidirectionalIterator first, BidirectionalIterator last, - OutputIterator result) - { - while(last > first){ - --last; - *result = *last; - ++result; - } - return result; - } - - template _UCXXEXPORT - void - rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last) - { - if ((first == middle) || (last == middle)){ - return; - } - - ForwardIterator first2 = middle; - - do { - swap(*first, *first2); - first++; - first2++; - if(first == middle){ - middle = first2; - } - } while(first2 != last); - - first2 = middle; - - while (first2 != last) { - swap(*first, *first2); - first++; - first2++; - if (first == middle){ - middle = first2; - }else if (first2 == last){ - first2 = middle; - } - } - } - - template _UCXXEXPORT - OutputIterator - rotate_copy(ForwardIterator first, ForwardIterator middle, - ForwardIterator last, OutputIterator result) - { - ForwardIterator temp(middle); - while(temp !=last){ - *result = *temp; - ++temp; - ++result; - } - while(first != middle){ - *result = *first; - ++first; - ++result; - } - return result; - } - - - template _UCXXEXPORT - void - random_shuffle(RandomAccessIterator first, RandomAccessIterator last) - { - --last; - while(first != last){ - iter_swap(first, (first + (rand() % (last - first) ) ) ); - ++first; - } - } - - template _UCXXEXPORT - void - random_shuffle(RandomAccessIterator first, RandomAccessIterator last, - RandomNumberGenerator& rand) - { - --last; - while(first != last){ - iter_swap(first, (first + (rand(last - first) ) ) ); - ++first; - } - } - - // _lib.alg.partitions_, partitions: - template _UCXXEXPORT BidirectionalIterator - partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred) - { - return stable_partition(first, last, pred); - } - - template _UCXXEXPORT BidirectionalIterator - stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred) - { - //first now points to the first non-desired element - while( first != last && pred(*first) ){ - ++first; - } - - BidirectionalIterator tempb; - BidirectionalIterator tempe = first; - - while( tempe != last ){ - //Find the next desired element - while( !pred(*tempe) ){ - ++tempe; - - //See if we should exit - if(tempe == last){ - return first; - } - } - - //Rotate the element back to the begining - tempb = tempe; - while(tempb != first){ - iter_swap(tempb, tempb-1 ); - --tempb; - } - //First now has a desired element - ++first; - } - - return first; - } - - template _UCXXEXPORT - void sort(RandomAccessIterator first, RandomAccessIterator last) - { - less::value_type> c; - sort(first, last, c ); - } - - template _UCXXEXPORT - void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp) - { - stable_sort(first, last, comp); - } - - template _UCXXEXPORT - void stable_sort(RandomAccessIterator first, RandomAccessIterator last) - { - less::value_type> c; - stable_sort(first, last, c); - } - - template _UCXXEXPORT - void stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp) - { - //FIXME - bubble sort - RandomAccessIterator temp; - --last; - while(last - first > 0){ - temp = last; - while(temp != first){ - if( comp( *temp, *(temp-1) ) ){ - iter_swap( temp-1, temp); - } - --temp; - } - ++first; - } - } - - template _UCXXEXPORT - void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last) - { - less::value_type> c; - partial_sort(first, middle, last, c); - } - template _UCXXEXPORT - void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, - RandomAccessIterator last, Compare comp) - { - //Fixme - partial bubble sort - RandomAccessIterator temp; - --last; - while(first < middle){ - temp = last; - while(temp != first){ - if( comp(*temp, *(temp -1 ) ) ) { - iter_swap( temp-1, temp); - } - --temp; - } - ++first; - } - } - template _UCXXEXPORT - RandomAccessIterator - partial_sort_copy(InputIterator first, InputIterator last, - RandomAccessIterator result_first, RandomAccessIterator result_last) - { - less::value_type> c; - return partial_sort_copy(first, last, result_first, result_last, c); - } - template _UCXXEXPORT - RandomAccessIterator - partial_sort_copy(InputIterator first, InputIterator last, - RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp) - { - size_t output_size = last-first; - size_t temp_size = result_last - result_first; - if(temp_size < output_size){ - output_size = temp_size; - } - - RandomAccessIterator middle = result_first + output_size; - RandomAccessIterator temp = result_first; - - while(temp != middle){ - *temp = *first; - ++temp; - ++first; - } - sort(result_first, middle, comp); - - while( first != last){ - if( comp( *first, *(middle-1) ) ){ - *(middle-1) = *first; - sort(result_first, middle, comp); - } - ++first; - } - - return middle; - } - template _UCXXEXPORT - void nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last) - { - less::value_type> c; - nth_element(first, nth, last, c); - } - template _UCXXEXPORT - void nth_element(RandomAccessIterator first, RandomAccessIterator nth, - RandomAccessIterator last, Compare comp) - { - partial_sort(first, nth, last, comp); - } - - template _UCXXEXPORT - ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, - const T& value) - { - less::value_type> c; - return lower_bound(first, last, value, c); - } - - template _UCXXEXPORT - ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, - const T& value, Compare comp) - { - if(first == last){ - return last; - } - //If below or equal to the first element - if( comp(*first, value) == false){ - return first; - } - ForwardIterator middle; - - //If greater than the top element - middle = first; - advance(middle, distance(first, last) - 1); - if( comp(*middle, value) ){ - return last; - } - - //Now begin the actual search for the begining - while( distance(first, last) > 1 ){ - //Find middle - middle = first; - advance(middle, (distance(first, last)/2) ); - if( !comp(*middle, value) ){ - last = middle; - }else{ - first = middle; - } - } - - if( !comp(*first, value) ){ - return first; - } - return last; - } - - template _UCXXEXPORT - ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, - const T& value) - { - less::value_type> c; - return upper_bound(first, last, value, c); - } - - - template _UCXXEXPORT - ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, - const T& value, Compare comp) - { - if(first == last){ - return last; - } - //If below the first element - if( comp(value, *first) == true){ - return first; - } - - ForwardIterator middle; - - //If greater than the top element - middle = first; - advance(middle, distance(first, last) - 1); - if( comp(*middle, value) ){ - return last; - } - - //Now begin the actual search for the end - while( distance(first, last) > 1 ){ - //Find middle - middle = first; - advance(middle, (distance(first, last)/2) ); - if( comp(value, *middle) ){ - last = middle; - }else{ - first = middle; - } - } - - if( comp(value, *first) ){ - return first; - } - return last; - } - - - template _UCXXEXPORT - pair - equal_range(ForwardIterator first, ForwardIterator last, const T& value) - { - less::value_type> c; - return equal_range(first, last, value, c); - } - - template _UCXXEXPORT - pair - equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp) - { - pair retval; - retval.first = lower_bound(first, last, value, comp); - //Reuse retval.first in order to (possibly) save a few comparisons - retval.second = upper_bound(retval.first, last, value, comp); - return retval; - - } - - template _UCXXEXPORT - bool binary_search(ForwardIterator first, ForwardIterator last, - const T& value) - { - less::value_type> c; - return binary_search(first, last, value, c); - } - - template _UCXXEXPORT - bool binary_search(ForwardIterator first, ForwardIterator last, - const T& value, Compare comp) - { - if( distance(first, last) == 0){ - return false; - } - - ForwardIterator middle; - - while( distance(first, last) > 1 ){ - //Set middle between first and last - middle = first; - advance(middle, distance(first, last)/2 ); - - if( comp(*middle, value ) == true){ - first = middle; - }else{ - last = middle; - } - } - - if( !comp(*first, value) && !comp(value, *first) ){ - return true; - } - if( !comp(*last, value) && !comp(value, *last) ){ - return true; - } - - return false; - } - - // _lib.alg.merge_, merge: - template _UCXXEXPORT - OutputIterator - merge(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result) - { - less::value_type> c; - return merge(first1, last1, first2, last2, result, c); - } - template _UCXXEXPORT - OutputIterator - merge(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) - { - while( first1 != last1 && first2 != last2){ - //If in this order so first1 elements which are equal come first - if( comp(*first2, *first1) ){ - *result = *first2; - ++first2; - }else{ - *result = *first1; - ++first1; - } - ++result; - } - //Clean up remaining elements - while(first1 != last1){ - *result = *first1; - ++first1; - ++result; - } - while(first2 != last2){ - *result = *first2; - ++first2; - ++result; - } - return result; - } - template _UCXXEXPORT - void inplace_merge(BidirectionalIterator first, - BidirectionalIterator middle, BidirectionalIterator last) - { - less::value_type> c; - inplace_merge(first, middle, last, c); - } - template _UCXXEXPORT - void inplace_merge(BidirectionalIterator first, - BidirectionalIterator middle, BidirectionalIterator last, Compare comp) - { - //FIXME - using a bubble exchange method - while(first != middle && middle !=last){ - if( comp(*middle, *first) ){ - BidirectionalIterator temp(middle); - while( temp != first){ - iter_swap(temp, temp-1); - --temp; - } - ++middle; - } - ++first; - } - } - - // _lib.alg.set.operations_, set operations: - template _UCXXEXPORT - bool includes(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2) - { - less::value_type> c; - return includes(first1, last1, first2, last2, c ); - } - - template _UCXXEXPORT - bool includes(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, Compare comp) - { - while(first2 != last2){ - //Advance the large set until no longer smaller than the element we are looking for - while( comp(*first1, *first2) ){ - ++first1; - //If we are at the end of the list, we don't have the desired element - if(first1 == last1){ - return false; - } - } - //If we are past the element we want, it isn't here - if( comp(*first2, *first1) ){ - return false; - } - ++first2; //Move to next element - } - return true; - } - - template _UCXXEXPORT - OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result) - { - less::value_type> c; - return set_union(first1, last1, first2, last2, result, c); - } - - template _UCXXEXPORT - OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) - { - while( first1 != last1 && first2 != last2){ - if( comp(*first2, *first1) ){ - *result = *first2; - - //Elliminate duplicates - InputIterator2 temp = first2; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - }else{ - *result = *first1; - //Elliminate duplicates - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - } - ++result; - } - - //Clean up remaining elements - while(first1 != last1){ - *result = *first1; - ++result; - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - } - - while(first2 != last2){ - *result = *first2; - ++result; - InputIterator2 temp = first2; - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - } - return result; - } - - template _UCXXEXPORT - OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result) - { - less::value_type> c; - return set_intersection(first1, last1, first2, last2, result, c); - } - template _UCXXEXPORT - OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) - { - while( first1 != last1 && first2 != last2){ - if( comp(*first2, *first1) ){ - ++first2; - }else if( comp(*first1, *first2) ) { - ++first1; - }else{ - *result = *first1; - ++result; - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - ++first2; - } - } - return result; - } - template _UCXXEXPORT - OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result) - { - less::value_type> c; - return set_difference(first1, last1, first2, last2, result, c); - } - template _UCXXEXPORT - OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) - { - while( first1 != last1 && first2 != last2){ - if( comp(*first1, *first2) ){ - *result = *first1; - ++result; - - //Elliminate duplicates - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - }else if( comp(*first2, *first1) ){ - - //Elliminate duplicates - InputIterator2 temp = first2; - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - - }else{ //They are identical - skip - //Elliminate duplicates - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - } - } - - //Clean up remaining elements - while(first1 != last1){ - *result = *first1; - ++result; - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - } - - return result; - } - template _UCXXEXPORT - OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result) - { - less::value_type> c; - return set_symmetric_difference(first1, last1, first2, last2, result, c); - } - template _UCXXEXPORT - OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) - { - while( first1 != last1 && first2 != last2){ - if( comp(*first1, *first2) ){ - *result = *first1; - ++result; - - //Elliminate duplicates - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - }else if( comp(*first2, *first1) ){ - *result = *first2; - ++result; - - //Elliminate duplicates - InputIterator2 temp = first2; - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - - }else{ //They are identical - skip - //Elliminate duplicates - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - } - } - - //Clean up remaining elements - while(first1 != last1){ - *result = *first1; - ++result; - InputIterator1 temp = first1; - while( first1 != last1 && !comp( *temp, *first1) ){ - ++first1; - } - } - - while(first2 != last2){ - *result = *first2; - ++result; - InputIterator2 temp = first2; - while( first2 != last2 && !comp( *temp, *first2) ){ - ++first2; - } - } - - return result; - } - - // _lib.alg.heap.operations_, heap operations: - - template _UCXXEXPORT - void push_heap(RandomAccessIterator first, RandomAccessIterator last) - { - less::value_type> c; - push_heap(first, last, c); - } - - template _UCXXEXPORT - void push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) - { - // *(last - 1) is the last element - RandomAccessIterator begin, middle, end; - begin = first; - end = last - 2; - if(last - first < 2){ //Empty heap - return; - } - if ( comp(*(last-1), *end) ){ //Belongs past the end - already in place - return; - } - while(end - begin > 1){ - middle = begin + ((end - begin)/2); - if( comp(*middle, *(last-1) ) ){ - end = middle; - }else{ - begin = middle; - } - } - - if( comp(*begin, *(last-1)) ){ - middle = begin; - }else{ - middle = end; - } - - //Now all we do is swap the elements up to the begining - --last; - - while(last > middle){ - iter_swap(last, last-1); - --last; - } - } - - template _UCXXEXPORT - void pop_heap(RandomAccessIterator first, RandomAccessIterator last) - { - less::value_type> c; - pop_heap(first, last, c); - } - template _UCXXEXPORT - void pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare) - { - --last; - while(first < last){ - iter_swap( first, first+1); - ++first; - } - } - - template _UCXXEXPORT - void make_heap(RandomAccessIterator first, RandomAccessIterator last) - { - less::value_type> c; - make_heap(first, last, c); - } - template _UCXXEXPORT - void make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) - { - sort( reverse_iterator(last), reverse_iterator(first), comp); - } - template _UCXXEXPORT - void sort_heap(RandomAccessIterator first, RandomAccessIterator last) - { - less::value_type> c; - sort_heap(first, last, c); - } - template _UCXXEXPORT - void sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) - { - sort( first, last, comp); - } - - - // _lib.alg.min.max_, minimum and maximum: - template _UCXXEXPORT - const T& min(const T& a, const T& b) - { - if(b < a){ - return b; - } - return a; - } - - template _UCXXEXPORT - const T& min(const T& a, const T& b, Compare comp) - { - if( comp(b, a) == true){ - return b; - } - return a; - } - - template _UCXXEXPORT - const T& max(const T& a, const T& b) - { - if( a < b){ - return b; - } - return a; - } - - template _UCXXEXPORT - const T& max(const T& a, const T& b, Compare comp) - { - if( comp(a, b) ){ - return b; - } - return a; - } - - template _UCXXEXPORT - ForwardIterator min_element(ForwardIterator first, ForwardIterator last) - { - less::value_type> c; - return min_element(first, last, c); - } - - template _UCXXEXPORT - ForwardIterator min_element(ForwardIterator first, ForwardIterator last, Compare comp) - { - ForwardIterator retval = first; - ++first; - while(first != last){ - if( comp( *first, *retval) ){ - retval = first; - } - ++first; - } - return retval; - } - - template _UCXXEXPORT - ForwardIterator max_element(ForwardIterator first, ForwardIterator last) - { - less::value_type> c; - return max_element(first, last, c); - } - - template _UCXXEXPORT - ForwardIterator max_element(ForwardIterator first, ForwardIterator last, Compare comp) - { - ForwardIterator retval = first; - ++first; - while(first != last){ - if( comp( *retval, *first ) ){ - retval = first; - } - ++first; - } - return retval; - } - - template _UCXXEXPORT - bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2) - { - less::value_type> c; - return lexicographical_compare(first1, last1, first2, last2, c); - } - - template _UCXXEXPORT - bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, Compare comp) - { - while(first1 != last1 && first2 != last2){ - if( comp(*first1, *first2) ){ - return true; - } - if( comp(*first2, *first1) ){ - return false; - } - ++first1; - ++first2; - } - return first1==last1 && first2 != last2; - } - - // _lib.alg.permutation.generators_, permutations - template _UCXXEXPORT - bool next_permutation(BidirectionalIterator first, BidirectionalIterator last) - { - less::value_type> c; - return next_permutation(first, last, c); - } - - template _UCXXEXPORT - bool next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp) - { - if(first == last){ - return false; // No data - } - BidirectionalIterator i = last; - --i; - if(i == first){ - return false; //Only one element - } - BidirectionalIterator ii = i; - --ii; - //If the last two items are in order, swap them and call it done - if( comp(*ii, *i) ){ - iter_swap(ii, i); - return true; - } - - - //This part of the algorithm copied from G++ header files ver. 3.4.2 - i = last; - --i; - for(;;){ - ii = i; - --i; - if ( comp(*i, *ii) ){ - BidirectionalIterator j = last; - --j; - while ( !comp(*i, *j)){ - --j; - } - iter_swap(i, j); - reverse(ii, last); - return true; - } - if (i == first){ - reverse(first, last); - return false; - } - } - - - } - - template _UCXXEXPORT - bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last) - { - less::value_type> c; - return prev_permutation(first, last, c); - } - - template _UCXXEXPORT - bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp) - { - if(first == last){ - return false; // No data - } - BidirectionalIterator i = last; - --i; - if(i == first){ - return false; //Only one element - } - BidirectionalIterator ii = i; - --ii; - //If the last two items are in reverse order, swap them and call it done - if( comp(*i, *ii) ){ - iter_swap(ii, i); - return true; - } - - //Copied from GNU GCC header files version 3.4.2 - i = last; - --i; - - for(;;){ - ii = i; - --i; - if ( comp(*ii, *i)){ - BidirectionalIterator j = last; - --j; - while ( !comp(*j, *i)){ - --j; - } - iter_swap(i, j); - reverse(ii, last); - return true; - } - if (i == first){ - reverse(first, last); - return false; - } - } - - } - -} - -#pragma GCC visibility pop - -#endif - - - Index: branches/slice/i386/modules/include/istream_helpers =================================================================== --- branches/slice/i386/modules/include/istream_helpers (revision 726) +++ branches/slice/i386/modules/include/istream_helpers (revision 727) @@ -1,344 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_ISTREAM_HELPERS -#define __STD_HEADER_ISTREAM_HELPERS 1 - -#pragma GCC visibility push(default) - -namespace std{ - - - /* We are making the following template class for serveral reasons. Firstly, - * we want to keep the main istream code neat and tidy. Secondly, we want it - * to be easy to do partial specialization of the istream code so that it can - * be expanded and put into the library. This will allow us to make application - * code smaller at the expense of increased library size. This is a fair - * trade-off when there are multiple applications being compiled. Also, this - * feature will be used optionally via configuration options. It will also - * allow us to keep the code bases in sync, dramatically simplifying the - * maintenance required. We specialized for char because wchar and others - * require different scanf functions - */ - - template _UCXXEXPORT - basic_string _readToken(basic_istream& stream) - { - basic_string temp; - typename traits::int_type c; - while(true){ - c = stream.rdbuf()->sgetc(); - if(c != traits::eof() && isspace(c) == false){ - stream.rdbuf()->sbumpc(); - temp.append(1, traits::to_char_type(c)); - }else{ - break; - } - } - if (temp.size() == 0) - stream.setstate(ios_base::eofbit|ios_base::failbit); - - return temp; - } - - template _UCXXEXPORT - basic_string _readTokenDecimal(basic_istream& stream) - { - basic_string temp; - typename traits::int_type c; - while(true){ - c = stream.rdbuf()->sgetc(); - if(c != traits::eof() && isspace(c) == false && (isdigit(c) || c == '.' || c == ',' )){ - stream.rdbuf()->sbumpc(); - temp.append(1, traits::to_char_type(c)); - }else{ - break; - } - } - if (temp.size() == 0) - stream.setstate(ios_base::eofbit|ios_base::failbit); - - return temp; - } - -#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ - - template <> _UCXXEXPORT string _readToken >(istream & stream); - -#endif - - - template class _UCXXEXPORT __istream_readin{ - public: - static void readin(basic_istream& stream, dataType & var); - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, bool & var) - { - basic_string temp; - temp = _readToken( stream); - if(temp == "true" || temp == "True" || temp == "TRUE" || temp == "1"){ - var = true; - }else{ - var = false; - } - } - }; - - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, short & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%hd", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%hi", &var); - - } - } - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, unsigned short & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%hu", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%ho", &var); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%hX", &var ); - }else{ - sscanf(temp.c_str(), "%hx", &var); - } - }else{ - sscanf(temp.c_str(), "%hi", (signed short int*)(&var) ); - } - } - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%d", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%i", &var); - } - } - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, unsigned int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%u", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%i", (int *)(&var) ); - } - } - - } - }; - - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, long int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%ld", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var) ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var) ); - }else{ - sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var) ); - } - }else{ - sscanf(temp.c_str(), "%li", (long int *)(&var) ); - } - } - - } - }; - - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, unsigned long int & var) - { - basic_string temp; - - if(stream.flags() & ios_base::dec){ - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%lu", &var ); - }else{ - temp = _readToken( stream); - if( stream.flags() & ios_base::oct){ - sscanf(temp.c_str(), "%lo", &var ); - }else if(stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::uppercase){ - sscanf(temp.c_str(), "%lX", &var ); - }else{ - sscanf(temp.c_str(), "%lx", &var); - } - }else{ - sscanf(temp.c_str(), "%li", (long int *)(&var) ); - } - } - } - }; - - -#ifdef __UCLIBCXX_HAS_FLOATS__ - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, float & var) - { - basic_string temp; - temp = _readTokenDecimal( stream); - - sscanf(temp.c_str(), "%g", &var); - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, double & var) - { - basic_string temp; - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%lg", &var); - } - }; - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, long double & var) - { - basic_string temp; - temp = _readTokenDecimal( stream); - sscanf(temp.c_str(), "%Lg", &var); - } - }; - -#endif // ifdef __UCLIBCXX_HAS_FLOATS__ - - template class _UCXXEXPORT __istream_readin{ - public: - inline static void readin(basic_istream& stream, void* & var) - { - basic_string temp; - temp = _readToken( stream); - sscanf(temp.c_str(), "%p", &var); - } - }; - - - template void __skipws(basic_istream& is){ - const typename basic_istream::int_type eof = traits::eof(); - typename basic_istream::int_type c; - //While the next character normally read doesn't equal eof - //and that character is a space, advance to the next read position - //Thus itterating through all whitespace until we get to the meaty stuff - while ( - !traits::eq_int_type((c = is.rdbuf()->sgetc()), eof) - && isspace(c) - ) - { - is.rdbuf()->sbumpc(); - } - if(traits::eq_int_type(c, eof)){ - is.setstate(ios_base::eofbit); - } - } -} - -#pragma GCC visibility pop - -#endif - - - Index: branches/slice/i386/modules/include/ostream_helpers =================================================================== --- branches/slice/i386/modules/include/ostream_helpers (revision 726) +++ branches/slice/i386/modules/include/ostream_helpers (revision 727) @@ -1,490 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_OSTREAM_HELPERS -#define __STD_HEADER_OSTREAM_HELPERS 1 - -#pragma GCC visibility push(default) - -namespace std{ - - /* We are making the following template class for serveral reasons. Firstly, - * we want to keep the main ostream code neat and tidy. Secondly, we want it - * to be easy to do partial specialization of the ostream code so that it can - * be expanded and put into the library. This will allow us to make application - * code smaller at the expense of increased library size. This is a fair - * trade-off when there are multiple applications being compiled. Also, this - * feature will be used optionally via configuration options. It will also - * allow us to keep the code bases in sync, dramatically simplifying the - * maintenance required. We specialized for char because wchar and others - * require different scanf functions - */ - - - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const dataType n); - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long int n) - { - char buffer[20]; - const char * c_ld = "%ld"; - const char * c_lo = "%lo"; - const char * c_lX = "%lX"; - const char * c_lx = "%lx"; - const char * c_hashlo = "%#lo"; - const char * c_hashlX = "%#lX"; - const char * c_hashlx = "%#lx"; - - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = c_ld; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = c_hashlo; - }else{ - formatString = c_lo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = c_hashlX; - }else{ - formatString = c_hashlx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = c_lX; - }else{ - formatString = c_lx; - } - } - } - - stream.write(buffer, snprintf(buffer, 20, formatString, n) ); - - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long int n) - { - char buffer[20]; - const char * c_lo = "%lo"; - const char * c_lu = "%lu"; - const char * c_lX = "%lX"; - const char * c_lx = "%lx"; - const char * c_hashlo = "%#lo"; - const char * c_hashlX = "%#lX"; - const char * c_hashlx = "%#lx"; - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = c_lu; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = c_hashlo; - }else{ - formatString = c_lo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = c_hashlX; - }else{ - formatString = c_hashlx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = c_lX; - }else{ - formatString = c_lx; - } - } - } - - stream.write(buffer, snprintf(buffer, 20, formatString, n)); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - -#ifndef __STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long long int n) - { - char buffer[28]; - const char * lld = "%lld"; - const char * llo = "%llo"; - const char * llX = "%llX"; - const char * llx = "%llx"; - const char * hashllo = "%#llo"; - const char * hashllX = "%#llX"; - const char * hashllx = "%#llx"; - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = lld; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = hashllo; - }else{ - formatString = llo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = hashllX; - }else{ - formatString = hashllx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = llX; - }else{ - formatString = llx; - } - } - } - - stream.write(buffer, snprintf(buffer, 27, formatString, n) ); - - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long long int n) - { - char buffer[28]; - const char * llo = "%llo"; - const char * llu = "%llu"; - const char * llX = "%llX"; - const char * llx = "%llx"; - const char * hashllo = "%#llo"; - const char * hashllX = "%#llX"; - const char * hashllx = "%#llx"; - const char * formatString=0; - - if( stream.flags() & ios_base::dec){ - formatString = llu; - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - formatString = hashllo; - }else{ - formatString = llo; - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - formatString = hashllX; - }else{ - formatString = hashllx; - } - }else{ - if(stream.flags() & ios_base::uppercase){ - formatString = llX; - }else{ - formatString = llx; - } - } - } - - stream.write(buffer, snprintf(buffer, 27, formatString, n) ); - - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - -#endif //__STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const double f) - { - char buffer[32]; - int length; - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - length = snprintf(buffer, 32, "%*.*E", static_cast(stream.width()),static_cast(stream.precision()), f); - }else{ - length = snprintf(buffer, 32, "%*.*e", static_cast(stream.width()),static_cast(stream.precision()), f); - } - } else if(stream.flags() & ios_base::fixed){ - length = snprintf(buffer, 32, "%*.*f",static_cast(stream.width()),static_cast(stream.precision()), f); - } else { - length = snprintf(buffer, 32, "%*.*g",static_cast(stream.width()),static_cast(stream.precision()), f); - } - stream.write(buffer, length); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const long double f) - { - char buffer[32]; - int length; - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - length = snprintf(buffer, 32, "%*.*LE", static_cast(stream.width()), static_cast(stream.precision()), f); - }else{ - length = snprintf(buffer, 32, "%*.*Le", static_cast(stream.width()), static_cast(stream.precision()), f); - } - } else if(stream.flags() & ios_base::fixed){ - length = snprintf(buffer, 32, "%*.*Lf", static_cast(stream.width()), static_cast(stream.precision()), f); - } else { - length = snprintf(buffer, 32, "%*.*Lg", static_cast(stream.width()), static_cast(stream.precision()), f); - } - stream.write(buffer, length); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - - } - }; - -#ifdef __UCLIBCXX_HAS_WCHAR__ - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long int n) - { - wchar_t buffer[20]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 20, L"%ld", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long int n) - { - wchar_t buffer[20]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 20, L"%lu", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 20, L"%lX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 20, L"%lx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - -#ifndef __STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const signed long long int n) - { - wchar_t buffer[28]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 27, L"%lld", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const unsigned long long int n) - { - wchar_t buffer[28]; - if( stream.flags() & ios_base::dec){ - stream.write(buffer, swprintf(buffer, 27, L"%llu", n)); - }else if( stream.flags() & ios_base::oct){ - if( stream.flags() & ios_base::showbase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llo", n)); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llo", n) ); - } - }else if (stream.flags() & ios_base::hex){ - if(stream.flags() & ios_base::showbase){ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) ); - } - }else{ - if(stream.flags() & ios_base::uppercase){ - stream.write(buffer, swprintf(buffer, 27, L"%llX", n) ); - }else{ - stream.write(buffer, swprintf(buffer, 27, L"%llx", n) ); - } - } - } - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - -#endif //__STRICT_ANSI__ - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const double f) - { - wchar_t buffer[32]; - wchar_t format_string[32]; - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - swprintf(format_string, 32, L"%%%u.%uE", static_cast(stream.width()), static_cast(stream.precision())); - }else{ - swprintf(format_string, 32, L"%%%u.%ue", static_cast(stream.width()), static_cast(stream.precision())); - } - } else if(stream.flags() & ios_base::fixed){ - swprintf(format_string, 32, L"%%%u.%uf", static_cast(stream.width()), static_cast(stream.precision())); - } else { - swprintf(format_string, 32, L"%%%u.%ug", static_cast(stream.width()), static_cast(stream.precision())); - } - stream.write(buffer, swprintf(buffer, 32, format_string, f) ); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - - template class _UCXXEXPORT __ostream_printout{ - public: - static void printout(basic_ostream& stream, const long double f) - { - wchar_t buffer[32]; - wchar_t format_string[32]; - if(stream.flags() & ios_base::scientific){ - if(stream.flags() & ios_base::uppercase){ - swprintf(format_string, 32, L"%%%u.%uLE", static_cast(stream.width()), static_cast(stream.precision())); - }else{ - swprintf(format_string, 32, L"%%%u.%uLe", static_cast(stream.width()), static_cast(stream.precision())); - } - } else if(stream.flags() & ios_base::fixed){ - swprintf(format_string, 32, L"%%%u.%uLf", static_cast(stream.width()), static_cast(stream.precision())); - } else { - swprintf(format_string, 32, L"%%%u.%uLg", static_cast(stream.width()), static_cast(stream.precision())); - } - stream.write(buffer, swprintf(buffer, 32, format_string, f) ); - if(stream.flags() & ios_base::unitbuf){ - stream.flush(); - } - } - }; - -#endif //__UCLIBCXX_HAS_WCHAR__ - -} - -#pragma GCC visibility pop - -#endif - - - Index: branches/slice/i386/modules/include/typeinfo =================================================================== --- branches/slice/i386/modules/include/typeinfo (revision 726) +++ branches/slice/i386/modules/include/typeinfo (revision 727) @@ -1,156 +0,0 @@ -// RTTI support for -*- C++ -*- -// Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 -// Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// GNU CC 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GNU CC; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -/** @file typeinfo - * This header provides RTTI support. - */ - -#ifndef __TYPEINFO__ -#define __TYPEINFO__ - -#include - -extern "C++" { - -namespace __cxxabiv1 -{ - class __class_type_info; -} // namespace __cxxabiv1 - -#if !__GXX_WEAK__ - // If weak symbols are not supported, typeinfo names are not merged. - #define __GXX_MERGED_TYPEINFO_NAMES 0 -#else - // On platforms that support weak symbols, typeinfo names are merged. - #define __GXX_MERGED_TYPEINFO_NAMES 1 -#endif - -namespace std -{ - /** - * @brief Part of RTTI. - * - * The @c type_info class describes type information generated by - * an implementation. - */ - class type_info - { - public: - /** Destructor. Being the first non-inline virtual function, this - * controls in which translation unit the vtable is emitted. The - * compiler makes use of that information to know where to emit - * the runtime-mandated type_info structures in the new-abi. */ - virtual ~type_info(); - - private: - /// Assigning type_info is not supported. Made private. - type_info& operator=(const type_info&); - type_info(const type_info&); - - protected: - const char *__name; - - protected: - explicit type_info(const char *__n): __name(__n) { } - - public: - // the public interface - /** Returns an @e implementation-defined byte string; this is not - * portable between compilers! */ - const char* name() const - { return __name; } - -#if !__GXX_MERGED_TYPEINFO_NAMES - bool before(const type_info& __arg) const; - // In old abi, or when weak symbols are not supported, there can - // be multiple instances of a type_info object for one - // type. Uniqueness must use the _name value, not object address. - bool operator==(const type_info& __arg) const; -#else - /** Returns true if @c *this precedes @c __arg in the implementation's - * collation order. */ - // In new abi we can rely on type_info's NTBS being unique, - // and therefore address comparisons are sufficient. - bool before(const type_info& __arg) const - { return __name < __arg.__name; } - bool operator==(const type_info& __arg) const - { return __name == __arg.__name; } -#endif - bool operator!=(const type_info& __arg) const - { return !operator==(__arg); } - - // the internal interface - public: - // return true if this is a pointer type of some kind - virtual bool __is_pointer_p() const; - // return true if this is a function type - virtual bool __is_function_p() const; - - // Try and catch a thrown type. Store an adjusted pointer to the - // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then - // THR_OBJ points to the thrown object. If THR_TYPE is a pointer - // type, then THR_OBJ is the pointer itself. OUTER indicates the - // number of outer pointers, and whether they were const - // qualified. - virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, - unsigned __outer) const; - - // internally used during catch matching - virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, - void **__obj_ptr) const; - }; - - /** - * @brief Thrown during incorrect typecasting. - * - * If you attempt an invalid @c dynamic_cast expression, an instance of - * this class (or something derived from this class) is thrown. */ - class bad_cast : public exception - { - public: - bad_cast() throw() { } - // This declaration is not useless: - // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 - virtual ~bad_cast() throw(); - }; - - /** If you use a NULL pointer in a @c typeid expression, this is thrown. */ - class bad_typeid : public exception - { - public: - bad_typeid () throw() { } - // This declaration is not useless: - // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 - virtual ~bad_typeid() throw(); - }; -} // namespace std - -} // extern "C++" -#endif Index: branches/slice/i386/modules/include/exception =================================================================== --- branches/slice/i386/modules/include/exception (revision 726) +++ branches/slice/i386/modules/include/exception (revision 727) @@ -1,120 +0,0 @@ -// Exception Handling support header for -*- C++ -*- - -// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002 -// Free Software Foundation -// -// This file is part of GNU CC. -// -// GNU CC is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// GNU CC 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with GNU CC; see the file COPYING. If not, write to -// the Free Software Foundation, 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -/** @file exception - * This header defines several types and functions relating to the - * handling of exceptions in a C++ program. - */ - -#ifndef __EXCEPTION__ -#define __EXCEPTION__ - -#include - -extern "C++" { - -namespace std -{ - /** - * @brief Base class for all library exceptions. - * - * This is the base class for all exceptions thrown by the standard - * library, and by certain language expressions. You are free to derive - * your own %exception classes, or use a different hierarchy, or to - * throw non-class data (e.g., fundamental types). - */ - class exception - { - public: - exception() throw() { } - virtual ~exception() throw(); - /** Returns a C-style character string describing the general cause - * of the current error. */ - virtual const char* what() const throw(); - }; - - /** If an %exception is thrown which is not listed in a function's - * %exception specification, one of these may be thrown. */ - class bad_exception : public exception - { - public: - bad_exception() throw() { } - // This declaration is not useless: - // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 - virtual ~bad_exception() throw(); - }; - - /// If you write a replacement %terminate handler, it must be of this type. - typedef void (*terminate_handler) (); - /// If you write a replacement %unexpected handler, it must be of this type. - typedef void (*unexpected_handler) (); - - /// Takes a new handler function as an argument, returns the old function. - terminate_handler set_terminate(terminate_handler) throw(); - /** The runtime will call this function if %exception handling must be - * abandoned for any reason. */ - void terminate() __UCLIBCXX_NORETURN; - - /// Takes a new handler function as an argument, returns the old function. - unexpected_handler set_unexpected(unexpected_handler) throw(); - /** The runtime will call this function if an %exception is thrown which - * violates the function's %exception specification. */ - void unexpected() __UCLIBCXX_NORETURN; - - /** [18.6.4]/1: "Returns true after completing evaluation of a - * throw-expression until either completing initialization of the - * exception-declaration in the matching handler or entering @c unexpected() - * due to the throw; or after entering @c terminate() for any reason - * other than an explicit call to @c terminate(). [Note: This includes - * stack unwinding [15.2]. end note]" - * - * 2: "When @c uncaught_exception() is true, throwing an %exception can - * result in a call of @c terminate() (15.5.1)." - */ - bool uncaught_exception() throw(); -} // namespace std - -namespace __gnu_cxx -{ - /** A replacement for the standard terminate_handler which prints more - information about the terminating exception (if any) on stderr. Call - @code - std::set_terminate (__gnu_cxx::__verbose_terminate_handler) - @endcode - to use. For more info, see - http://gcc.gnu.org/onlinedocs/libstdc++/19_diagnostics/howto.html#4 - */ - void __verbose_terminate_handler (); -} // namespace __gnu_cxx - -} // extern "C++" - -#endif Index: branches/slice/i386/modules/include/locale =================================================================== --- branches/slice/i386/modules/include/locale (revision 726) +++ branches/slice/i386/modules/include/locale (revision 727) @@ -1,83 +0,0 @@ -/* 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 - -#ifndef __HEADER_STD_LOCALE -#define __HEADER_STD_LOCALE 1 - -#pragma GCC visibility push(default) - -namespace std{ - class _UCXXEXPORT locale { - public: - // types: - class facet; - class id; - typedef unsigned char category; - - static const category - none = 0, - collate = 0x01, ctype = 0x02, - monetary = 0x04, numeric = 0x08, - time = 0x10, messages = 0x20, - all = collate | ctype | monetary | numeric | time | messages; - - // construct/copy/destroy: - locale() throw(){ - return; - } - locale(const locale& other) throw(){ - (void)other; - return; - } - locale(const char *) throw(){ - return; - } - ~locale() throw(){ - return; - } - - const locale& operator=(const locale&) throw(){ - return *this; - } - std::string name() const { return "C"; } - }; - - class _UCXXEXPORT locale::facet { - friend class locale; - explicit facet(size_t = 0){ - return; - } - virtual ~facet(){ - return; - } - }; - - class _UCXXEXPORT locale::id { - id(){ } - }; - -} - -#pragma GCC visibility pop - -#endif Index: branches/slice/i386/modules/include/vector =================================================================== --- branches/slice/i386/modules/include/vector (revision 726) +++ branches/slice/i386/modules/include/vector (revision 727) @@ -1,517 +0,0 @@ -/* 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 -#include - - -#ifndef __STD_HEADER_VECTOR -#define __STD_HEADER_VECTOR - -#pragma GCC visibility push(default) - -namespace std{ - - template > class vector; - template bool operator==(const vector& x, const vector& y); - template bool operator< (const vector& x, const vector& y); - template bool operator!=(const vector& x, const vector& y); - template bool operator> (const vector& x, const vector& y); - template bool operator>=(const vector& x, const vector& y); - template bool operator<=(const vector& x, const vector& y); - template void swap(vector& x, vector& y); - - template class _UCXXEXPORT vector { - public: - - typedef typename Allocator::reference reference; - typedef typename Allocator::const_reference const_reference; - typedef typename Allocator::size_type size_type; - typedef typename Allocator::difference_type difference_type; - typedef typename Allocator::pointer pointer; - typedef typename Allocator::const_pointer const_pointer; - - typedef T* iterator; - typedef const T* const_iterator; - typedef T value_type; - typedef Allocator allocator_type; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - explicit _UCXXEXPORT vector(const Allocator& al= Allocator()): data(0), //defaultValue(T()), - data_size(__UCLIBCXX_STL_BUFFER_SIZE__), elements(0), a(al) - { - data = a.allocate(data_size); - } - - explicit _UCXXEXPORT vector(size_type n, const T& value = T(), const Allocator& al= Allocator()) : - data(0), data_size(0), elements(0), a(al) - { - data_size = n + __UCLIBCXX_STL_BUFFER_SIZE__; - data = a.allocate(data_size); - - resize(n, value); - } - - template _UCXXEXPORT - vector(InputIterator first, InputIterator last, const Allocator& al = Allocator()): - data(0), data_size(__UCLIBCXX_STL_BUFFER_SIZE__), elements(0), a(al) - { - data = a.allocate(data_size); - assign(first, last); - } - - _UCXXEXPORT vector(const vector& x){ - a = x.a; - - elements = x.elements; - data_size = elements + __UCLIBCXX_STL_BUFFER_SIZE__; - data = a.allocate(data_size); - - for(size_type i = 0; i < elements; i++){ - a.construct(data+i, x.data[i]); - } - } - - _UCXXEXPORT ~vector(); //Below - - _UCXXEXPORT vector& operator=(const vector& x){ - if(&x == this){ - return *this; - } - - reserve(x.elements); //Make sure that we have enough actual memory - - - //Copy as many elements as possible - - size_t minElements = elements; - if(minElements > x.elements){ - minElements = x.elements; - } - for(size_t i = 0; i < minElements; ++i){ - data[i] = x.data[i]; - } - - //If we need to add new elements - if(elements < x.elements){ - for(size_t i = elements; i< x.elements; ++i){ - a.construct(data+i, x.data[i]); - ++elements; - } - } - - if(elements > x.elements){ - downsize(x.elements); - } - - return *this; - } - - template _UCXXEXPORT void assign(InputIterator first, InputIterator last){ - clear(); - insert(begin(), first, last); - } - - template _UCXXEXPORT void assign(Size n, const U& u = U()){ - clear(); - resize(n, u); - } - - inline allocator_type get_allocator() const{ - return a; - } - - inline iterator begin(){ - return data; - } - - inline const_iterator begin() const{ - return data; - } - - inline iterator end(){ - return (data + elements); - } - - inline const_iterator end() const{ - return (data + elements); - } - - inline reverse_iterator rbegin(){ - return reverse_iterator(end()); - } - - inline const_reverse_iterator rbegin() const{ - return const_reverse_iterator(end()); - } - - inline reverse_iterator rend(){ - return reverse_iterator(begin()); - } - - inline const_reverse_iterator rend() const{ - return const_reverse_iterator(begin()); - } - - inline size_type size() const{ - return elements; - } - - _UCXXEXPORT size_type max_size() const{ - return ((size_type)(-1)) / sizeof(T); - } - - void downsize(size_type sz); - void resize(size_type sz, const T & c = T()); - - inline size_type capacity() const{ - return data_size; - } - - inline bool empty() const{ - return (size() == 0); - } - - void reserve(size_type n); - - inline reference operator[](size_type n){ - return data[n]; - } - - inline const_reference operator[](size_type n) const{ - return data[n]; - } - - _UCXXEXPORT const_reference at(size_type n) const{ - if(n >= elements){ - __throw_out_of_range("Invalid subscript"); - } - return data[n]; - } - - _UCXXEXPORT reference at(size_type n){ - if(n >= elements){ - __throw_out_of_range("Invalid subscript"); - } - return data[n]; - } - - inline reference front(){ - return data[0]; - } - - inline const_reference front() const{ - return data[0]; - } - - inline reference back(){ - return data[ size() - 1]; - } - - inline const_reference back() const{ - return data[ size() - 1 ]; - } - - inline void push_back(const T& x){ - resize( size() + 1, x); - } - - inline void pop_back(){ - downsize(size() - 1); - } - - _UCXXEXPORT iterator insert(iterator position, const T& x = T()){ - size_type index = position - data; - resize(size() + 1, x); - for(size_type i = elements - 1; i > index; --i){ - data[i] = data[i-1]; - } - data[index] = x; - return (data + index); - } - - _UCXXEXPORT void _insert_fill(iterator position, size_type n, const T & x){ - size_type index = position - data; - resize(size() + n, x); - - for(size_type i = elements -1; (i > (index+n-1)); --i){ - data[i] = data[i-n]; - } - for(size_type i = 0; i < n; i++){ - data[i + index] = x; - } - } - - template _UCXXEXPORT - void _insert_from_iterator(iterator position, InputIterator first, InputIterator last) - { - T temp; - while(first !=last){ - temp = *first; - position = insert(position, temp); - ++position; - ++first; - } - } - - template - inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __true_type) - { - _insert_fill(position, first, last); - } - - template - inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __false_type) - { - _insert_from_iterator(position, first, last); - } - - inline void insert(iterator position, size_type n, const T& x ){ - _insert_fill(position, n, x); - } - - template inline void insert(iterator position, InputIterator first, InputIterator last){ - typedef typename __is_integer::value __some_type; - _dispatch_insert(position, first, last, __some_type()); - } - - _UCXXEXPORT iterator erase(iterator position){ - size_type index = position - data; - for(size_type i = index; i < (elements - 1); ++i){ - data[i] = data[i+1]; - } - downsize(size() - 1); - return (data + index); - } - - _UCXXEXPORT iterator erase(iterator first, iterator last){ - size_type index = first - data; - size_type width = last - first; - for(size_type i = index; i < (elements - width) ;++i){ - data[i] = data[i+width]; - } - downsize(size() - width); - return (data + index); - } - - _UCXXEXPORT void swap(vector& v){ - if(this == &v){ //Avoid dv.swap(v) - return; - } - T* ptr; - size_type temp; - - //Swap pointers first - ptr = data; - data = v.data; - v.data = ptr; - - //Swap element counts - temp = elements; - elements = v.elements; - v.elements = temp; - - //Swap data size - temp = data_size; - data_size = v.data_size; - v.data_size = temp; - } - - _UCXXEXPORT void clear(){ - downsize(0); - } - - protected: - T* data; - size_type data_size; - size_type elements; - Allocator a; - }; - - - - //Here go template instantiations - - template _UCXXEXPORT vector::~vector(){ - for(size_t i = 0; i < elements; ++i){ - a.destroy(data + i); - } - a.deallocate(data, data_size); - } - - - template _UCXXEXPORT void vector::reserve(size_type n){ - if(n > data_size){ //We never shrink... - T * temp_ptr = data; - size_type temp_size = data_size; - - data_size = n; - data = a.allocate(data_size); - - for(size_type i = 0; i _UCXXEXPORT void vector::resize(size_type sz, const T & c){ - if(sz > elements){ //Need to actually call constructor - if(sz > data_size){ - reserve(sz + __UCLIBCXX_STL_BUFFER_SIZE__); - } - - for(size_type i = elements; i _UCXXEXPORT void vector::downsize(size_type sz){ - if(sz < elements){ //Actually are downsizing - for(size_t i = sz; i< elements; ++i){ - a.destroy(data+i); - } - elements = sz; - } - } - - -#ifndef __UCLIBCXX_COMPILE_VECTOR__ -#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 - - template<> _UCXXEXPORT void vector >::reserve(size_type n); - template<> _UCXXEXPORT void vector >::resize(size_type sz, const char & c); - -#endif -#endif - - - - template _UCXXEXPORT bool - operator==(const vector& x, const vector& y) - { - if(x.size() !=y.size() ){ - return false; - } - for(size_t i = 0; i < x.size(); ++i){ - if(x[i] != y[i]){ - return false; - } - } - return true; - } - - template _UCXXEXPORT bool - operator< (const vector& x, const vector& y) - { - less::iterator >::value_type> c; - return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); - } - template _UCXXEXPORT bool - operator!=(const vector& x, const vector& y) - { - return !(x == y); - } - template _UCXXEXPORT bool - operator> (const vector& x, const vector& y) - { - greater::iterator >::value_type> c; - return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); - } - template _UCXXEXPORT bool - operator>=(const vector& x, const vector& y) - { - greater_equal::iterator >::value_type> c; - return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); - } - template _UCXXEXPORT bool - operator<=(const vector& x, const vector& y) - { - less_equal::iterator >::value_type> c; - return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); - } - - template _UCXXEXPORT void swap(vector& x, vector& y){ - x.swap(y); - } - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/deque =================================================================== --- branches/slice/i386/modules/include/deque (revision 726) +++ branches/slice/i386/modules/include/deque (revision 727) @@ -1,811 +0,0 @@ -/* 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 - -#pragma GCC visibility push(default) - -#ifndef __STD_HEADER_DEQUE -#define __STD_HEADER_DEQUE - - -namespace std{ - template > class deque; - template bool operator==(const deque& x, const deque& y); - template bool operator< (const deque& x, const deque& y); - template bool operator!=(const deque& x, const deque& y); - template bool operator> (const deque& x, const deque& y); - template bool operator>=(const deque& x, const deque& y); - template bool operator<=(const deque& x, const deque& y); - template void swap(deque& x, deque& y); - - template class _UCXXEXPORT deque { - public: - friend bool operator==<>(const deque& x, const deque& y); - friend class deque_iter; - friend class deque_citer; - class deque_iter; - class deque_citer; - - typedef typename Allocator::reference reference; - typedef typename Allocator::const_reference const_reference; - typedef deque_iter iterator; - typedef deque_citer const_iterator; - typedef typename Allocator::size_type size_type; - typedef typename Allocator::difference_type difference_type; - typedef T value_type; - typedef Allocator allocator_type; - typedef typename Allocator::pointer pointer; - typedef typename Allocator::const_pointer const_pointer; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - explicit deque(const Allocator& al = Allocator()); - explicit deque(size_type n, const T& value = T(), const Allocator& al = Allocator()); - template deque(InputIterator first, InputIterator last, const Allocator& = Allocator()); - deque(const deque& x); - ~deque(); - - deque& operator=(const deque& x); - template void assign(InputIterator first, InputIterator last); - template void assign(Size n, const U& u = U()); - allocator_type get_allocator() const; - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - - size_type size() const; - size_type max_size() const; - void resize(size_type sz, T c = T()); - bool empty() const; - - reference operator[](size_type n); - const_reference operator[](size_type n) const; - reference at(size_type n); - const_reference at(size_type n) const; - reference front(); - const_reference front() const; - reference back(); - const_reference back() const; - - void push_front(const T& x); - void push_back(const T& x); - iterator insert(iterator position, const T& x = T()); - void insert(iterator position, size_type n, const T& x); - template void insert (iterator position, InputIterator first, InputIterator last); - void pop_front(); - void pop_back(); - - iterator erase(iterator position); - iterator erase(iterator first, iterator last); - void swap(deque&); - void clear(); - - protected: - void reserve(size_type n); - inline size_type array_element(size_type deque_element) const{ - if(deque_element < (data_size - first_element)){ - return first_element + deque_element; - } - return deque_element - (data_size - first_element); - } - inline size_type first_subtract(size_type sub_size) const{ - if(sub_size > first_element){ - return (data_size - first_element) - sub_size; - } - return first_element - sub_size; - } - - T * data; - size_type data_size; //Physical size of array - size_type elements; //Elements in array - size_type first_element; //Element number of array 0..n - size_type last_element; //Element number of array 0..n - Allocator a; - - }; - - - template class _UCXXEXPORT deque::deque_iter - : public std::iterator< - random_access_iterator_tag, - T, - typename Allocator::difference_type, - typename Allocator::pointer, - typename Allocator::reference - > - { - friend class deque; - protected: - deque * container; - typename Allocator::size_type element; - - public: - deque_iter() : container(0), element(0) { } - deque_iter(const deque_iter & d) : container (d.container), element(d.element) { } - deque_iter(deque * c, typename Allocator::size_type e) - : container(c), element(e) - { - return; - } - ~deque_iter() { } - deque_iter & operator=(const deque_iter & d){ - container = d.container; - element = d.element; - return *this; - } - T & operator*(){ - return container->data[container->array_element(element)]; - } - T * operator->(){ - return container->data + container->array_element(element); - } - const T & operator*() const{ - return container->data[container->array_element(element)]; - } - const T * operator->() const{ - return container->data + container->array_element(element); - } - bool operator==(const deque_iter & d) const{ - if(container == d.container && element == d.element){ - return true; - } - return false; - } - bool operator!=(const deque_iter & d) const{ - if(container != d.container || element != d.element){ - return true; - } - return false; - } - bool operator<(const deque_iter & d) const{ - if(element < d.element){ - return true; - } - return false; - } - bool operator<=(const deque_iter & d) const{ - if(element <= d.element){ - return true; - } - return false; - } - bool operator>(const deque_iter & d) const{ - if(element > d.element){ - return true; - } - return false; - } - bool operator>=(const deque_iter & d) const{ - if(element >= d.element){ - return true; - } - return false; - } - deque_iter & operator++(){ - ++element; - return *this; - } - deque_iter operator++(int){ - deque_iter temp(container, element); - ++element; - return temp; - } - deque_iter operator+(typename Allocator::size_type n){ - deque_iter temp(container, element + n); - return temp; - } - deque_iter & operator+=(typename Allocator::size_type n){ - element += n; - return *this; - } - deque_iter & operator--(){ - --element; - return *this; - } - deque_iter operator--(int){ - deque_iter temp(container, element); - --element; - return temp; - } - deque_iter operator-(typename Allocator::size_type n){ - deque_iter temp(container, element - n); - return temp; - } - deque_iter & operator-=(typename Allocator::size_type n){ - element -= n; - return *this; - } - typename Allocator::size_type operator-(const deque_iter & d){ - return element - d.element; - } - - }; - - template class _UCXXEXPORT deque::deque_citer - : public std::iterator< - random_access_iterator_tag, - T, - typename Allocator::difference_type, - typename Allocator::const_pointer, - typename Allocator::const_reference - > - { - friend class deque; - protected: - const deque * container; - typename Allocator::size_type element; - - public: - deque_citer() : container(0), element(0) { } - deque_citer(const deque_citer & d) : container (d.container), element(d.element) { } - deque_citer(const deque * c, typename Allocator::size_type e) - : container(c), element(e) - { - return; - } - ~deque_citer() { } - deque_citer & operator=(const deque_iter & d){ - container = d.container; - element = d.element; - return *this; - } - const T & operator*() const{ - return container->data[container->array_element(element)]; - } - const T * operator->() const{ - return container->data + container->array_element(element); - } - bool operator==(const deque_citer & d) const{ - if(container == d.container && element == d.element){ - return true; - } - return false; - } - bool operator!=(const deque_citer & d) const{ - if(container != d.container || element != d.element){ - return true; - } - return false; - } - bool operator<(const deque_citer & d) const{ - if(element < d.element){ - return true; - } - return false; - } - bool operator<=(const deque_citer & d) const{ - if(element <= d.element){ - return true; - } - return false; - } - bool operator>(const deque_citer & d) const{ - if(element > d.element){ - return true; - } - return false; - } - bool operator>=(const deque_citer & d){ - if(element >= d.element){ - return true; - } - return false; - } - deque_citer & operator++(){ - ++element; - return *this; - } - deque_citer operator++(int){ - deque_citer temp(container, element); - ++element; - return temp; - } - deque_citer operator+(typename Allocator::size_type n){ - deque_citer temp(container, element + n); - return temp; - } - deque_citer & operator+=(typename Allocator::size_type n){ - element += n; - return *this; - } - deque_citer & operator--(){ - --element; - return *this; - } - deque_citer operator--(int){ - deque_citer temp(container, element); - --element; - return temp; - } - deque_citer operator-(typename Allocator::size_type n){ - deque_citer temp(container, element - n); - return temp; - } - deque_citer & operator-=(typename Allocator::size_type n){ - element -= n; - return *this; - } - typename Allocator::size_type operator-(const deque_citer & d){ - return element - d.element; - } - - }; - - template deque::deque(const Allocator& al) - : data(0), - data_size(0), elements(0), first_element(0), last_element(0), a(al) - { - data_size = __UCLIBCXX_STL_BUFFER_SIZE__; - data = a.allocate(data_size); - first_element = data_size /2; - last_element = first_element; - } - - - template deque::deque( - size_type n, const T& value, const Allocator& al) - : data(0), - elements(n), first_element(0), last_element(0), a(al) - { - data_size = elements + __UCLIBCXX_STL_BUFFER_SIZE__; - data = a.allocate(data_size); - first_element = (data_size - elements) / 2; - last_element = first_element; - - for(n=first_element ; n < last_element; ++n ){ - a.construct(data+n, value); - } - } - - - template template - deque::deque(InputIterator first, InputIterator last, const Allocator& al) - : data(0), - data_size(0), elements(0), first_element(0), last_element(0), a(al) - { - data_size = __UCLIBCXX_STL_BUFFER_SIZE__; - data = a.allocate(data_size); - first_element = data_size / 4; //Note sure how big, but let's add a little space... - last_element = first_element; - while(first != last){ - push_back(*first); - ++first; - } - } - - - template deque::deque(const deque& x) - : data(0), - elements(0), first_element(0), last_element(0), a(x.a) - { - data_size = x.elements + __UCLIBCXX_STL_BUFFER_SIZE__; - data = a.allocate(data_size); - first_element = (data_size - x.elements) / 2; - last_element = first_element; - for(size_type i=0; i < x.elements; ++i){ - push_back(x[i]); - } - } - - - template deque::~deque(){ - clear(); - a.deallocate(data, data_size); - } - - template deque& deque:: - operator=(const deque& x) - { - if(&x == this){ - return *this; - } - resize(x.elements); - for(size_t i = 0; i < elements; ++i){ - data[array_element(i)] = x[i]; - } - return *this; - } - - - template template void - deque::assign(InputIterator first, InputIterator last) - { - clear(); - while(first !=last){ - push_back(*first); - ++first; - } - } - - - template template void - deque::assign(Size n, const U& u) - { - if(&u == this){ - return; - } - clear(); - for(size_type i = 0; i < n; ++i){ - push_back(u); - } - } - - - template typename deque::allocator_type - deque::get_allocator() const - { - return a; - } - - template typename - deque::iterator deque::begin() - { - return deque_iter(this, 0); - } - - - template typename deque::const_iterator - deque::begin() const - { - return deque_citer(this, 0); - } - - template typename - deque::iterator deque::end() - { - return deque_iter(this, elements); - } - - template typename - deque::const_iterator deque::end() const - { - return deque_citer(this, elements); - } - - template typename - deque::reverse_iterator deque::rbegin() - { - return reverse_iterator(end()); - } - - template typename - deque::const_reverse_iterator deque::rbegin() const - { - return const_reverse_iterator(end()); - } - - template typename - deque::reverse_iterator deque::rend() - { - return reverse_iterator(begin()); - } - - template typename - deque::const_reverse_iterator deque::rend() const - { - return const_reverse_iterator(begin()); - } - - template typename - deque::size_type deque::size() const - { - return elements; - } - - template typename - deque::size_type deque::max_size() const - { - return ((size_type)(-1)) / sizeof(T); - } - - template void deque::resize(size_type sz, T c){ - reserve(sz); - while(sz > size()){ - push_back(c); - } - while(sz < size()){ - pop_back(); - } - } - - template bool deque::empty() const{ - return (elements == 0); - } - - template typename - deque::reference deque::operator[](size_type n) - { - return data[array_element(n)]; - } - - template typename - deque::const_reference deque::operator[](size_type n) const - { - return data[array_element(n)]; - } - - template typename - deque::reference deque::at(size_type n) - { - if(n > elements){ - __throw_out_of_range("Out of deque range"); - } - return data[array_element(n)]; - } - - template typename - deque::const_reference deque::at(size_type n) const - { - if(n > elements){ - __throw_out_of_range("Out of deque range"); - } - return data[array_element(n)]; - } - - template typename - deque::reference deque::front() - { - return data[first_element]; - } - - template typename - deque::const_reference deque::front() const - { - return data[first_element]; - } - - template typename - deque::reference deque::back() - { - return data[array_element(elements-1)]; - } - - template typename - deque::const_reference deque::back() const - { - return data[array_element(elements-1)]; - } - - template void deque::push_front(const T& x){ - reserve(elements + 1); - first_element = first_subtract(1); - a.construct(data + first_element, x); - ++elements; - } - - template void deque::push_back(const T& x){ - reserve(elements + 1); - a.construct(data + last_element, x); - ++elements; - last_element = array_element(elements); - } - - template typename - deque::iterator deque::insert(iterator position, const T& x) - { - reserve(elements+1); - if(position.element > (elements/2)){ - //Push all elements back 1 - push_back(x); - for(size_type i = elements-1; i > position.element; --i){ - at(i) = at(i-1); - } - }else{ - //Push all elements forward 1 - push_front(x); - for(size_type i = 0; i < position.element; ++i){ - at(i) = at(i+1); - } - } - at(position.element) = x; - return deque_iter(this, position.element); - } - - template void deque:: - insert(typename deque::iterator position, size_type n, const T& x) - { - reserve(elements + n); - for(size_t i =0; i < n; ++i){ - position = insert(position, x); - } - } - - template template - void deque::insert (iterator position, InputIterator first, InputIterator last) - { - while(first != last){ - position = insert(position, *first); - ++first; - } - } - - template void deque::pop_front(){ - if(elements == 0){ - __throw_out_of_range("deque pop_front"); - } - a.destroy(data + first_element); - first_element = array_element(1); - --elements; - } - - template void deque::pop_back(){ - last_element = array_element(elements - 1); - a.destroy(data + last_element); - --elements; - } - - template typename - deque::iterator deque::erase(typename deque::iterator position) - { - if(position.element > (elements /2)){ - for(size_type i = position.element; i < elements - 1; ++i){ - at(i) = at(i+1); - } - pop_back(); - }else{ - for(size_type i = position.element; i > 0; --i){ - at(i) = at(i-1); - } - pop_front(); - } - return deque_iter(this, position.element); - } - - template typename deque::iterator - deque:: - erase(typename deque::iterator first, typename deque::iterator last) - { - //Shift backwards - size_type num_move = last.element - first.element; - if( first.element > (elements - last.element) ){ - for(size_type i = last.element; i < elements ; ++i){ - at(i-num_move) = at(i); - } - for(size_type i = 0; i < num_move ; ++i){ - pop_back(); - } - }else{ - for(size_type i = 0; i < first.element ; ++i){ - at(last.element - i - 1) = at(first.element - i - 1); - } - for(size_type i = 0; i < num_move ; ++i){ - pop_front(); - } - } - return deque_iter(this, first.element); - } - - template void deque::swap(deque& x) - { - T * temp_data; - typename deque::size_type temp_size; - - //Swap data pointers - temp_data = x.data; - x.data = data; - data = temp_data; - - //Swap array sizes - temp_size = x.data_size; - x.data_size = data_size; - data_size = temp_size; - - //Swap num array elements - temp_size = x.elements; - x.elements = elements; - elements = temp_size; - - //Swap first_pointer - temp_size = x.first_element; - x.first_element = first_element; - first_element = temp_size; - - //Swap last_pointer - temp_size = x.last_element; - x.last_element = last_element; - last_element = temp_size; - } - - template void deque::clear() - { - while(elements > 0 ){ - pop_back(); - } - } - - - template void deque::reserve(typename deque::size_type n) - { - if(data_size >= n){ - return; - } - - size_type size_temp; - size_type first_temp; - T * data_temp; - size_temp = n + __UCLIBCXX_STL_BUFFER_SIZE__; //Reserve extra 'cause we can - data_temp = a.allocate(size_temp); - - first_temp = (size_temp - elements) / 2; - for(size_type i = 0; i < elements; ++i){ - a.construct(data_temp + first_temp + i, data[array_element(i)]); - a.destroy(data + array_element(i)); - } - - //Now shuffle pointers - a.deallocate(data, data_size); - data = data_temp; - data_size = size_temp; - first_element = first_temp; - last_element = first_element + elements; - } - - - template _UCXXEXPORT - bool - operator==(const deque& x, const deque& y) - { - if(x.elements != y.elements){ - return false; - } - for(typename deque::size_type i = 0; i < x.elements; ++i){ - if(x[i] < y[i] || y[i] < x[i]){ - return false; - } - } - return true; - } - - template bool operator< (const deque& x, const deque& y); - template _UCXXEXPORT - bool - operator!=(const deque& x, const deque& y) - { - if(x == y){ - return false; - } - return true; - } - template bool operator> (const deque& x, const deque& y); - template bool operator>=(const deque& x, const deque& y); - template bool operator<=(const deque& x, const deque& y); - template _UCXXEXPORT void swap(deque& x, deque& y){ - x.swap(y); - } - - - -} - -#pragma GCC visibility pop - -#endif - - - - Index: branches/slice/i386/modules/include/stdexcept =================================================================== --- branches/slice/i386/modules/include/stdexcept (revision 726) +++ branches/slice/i386/modules/include/stdexcept (revision 727) @@ -1,117 +0,0 @@ -/* 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 - -#ifndef HEADER_STD_EXCEPTIONS -#define HEADER_STD_EXCEPTIONS 1 - -//Don't include support if not needed -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ - -#pragma GCC visibility push(default) - -namespace std{ - -//typedef basic_string string; - -class _UCXXEXPORT logic_error : public exception { -protected: - string mstring; -public: - logic_error() throw(); - logic_error(const string& what_arg); - - virtual ~logic_error() throw() {} - virtual const char * what() const throw(); - -}; - -class _UCXXEXPORT domain_error : public logic_error { -public: - domain_error() : logic_error() {} - domain_error(const string& what_arg) : logic_error(what_arg) {} - virtual ~domain_error() throw() {} -}; - -class _UCXXEXPORT invalid_argument : public logic_error { -public: - invalid_argument() : logic_error(){} - invalid_argument(const string& what_arg) : logic_error(what_arg){} - virtual ~invalid_argument() throw() {} -}; - -class _UCXXEXPORT length_error : public logic_error { -public: - length_error() : logic_error(){} - length_error(const string& what_arg) : logic_error(what_arg){} - virtual ~length_error() throw() {} -}; - -class _UCXXEXPORT out_of_range : public logic_error{ -public: - out_of_range(); - out_of_range(const string & what_arg); - virtual ~out_of_range() throw() {} - -}; - -class _UCXXEXPORT runtime_error : public exception{ -protected: - string mstring; -public: - runtime_error(); - runtime_error(const string& what_arg); - - virtual ~runtime_error() throw() {} - virtual const char * what() const throw(); -}; - -class _UCXXEXPORT range_error : public runtime_error{ -public: - range_error() : runtime_error(){} - range_error(const string& what_arg) : runtime_error(what_arg) {} - virtual ~range_error() throw(){ } -}; - - -class _UCXXEXPORT overflow_error : public runtime_error{ -public: - overflow_error() : runtime_error(){} - overflow_error(const string& what_arg) : runtime_error(what_arg) {} - virtual ~overflow_error() throw(){} -}; - -class _UCXXEXPORT underflow_error : public runtime_error{ -public: - underflow_error() : runtime_error(){} - underflow_error(const string& what_arg) : runtime_error(what_arg) {} - virtual ~underflow_error() throw(){} -}; - - - -} - -#pragma GCC visibility pop - -#endif -#endif Index: branches/slice/i386/modules/include/climits =================================================================== --- branches/slice/i386/modules/include/climits (revision 726) +++ branches/slice/i386/modules/include/climits (revision 727) @@ -1,28 +0,0 @@ -/* 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 -*/ - -#ifndef __STD_HEADER_CLIMITS -#define __STD_HEADER_CLIMITS 1 - - -#include - - -#endif - Index: branches/slice/i386/modules/include/cstring =================================================================== --- branches/slice/i386/modules/include/cstring (revision 726) +++ branches/slice/i386/modules/include/cstring (revision 727) @@ -1,78 +0,0 @@ -/* 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 -#include - -#ifndef __HEADER_CSTRING -#define __HEADER_CSTRING 1 - - -namespace std{ - - using ::memchr; - using ::memcmp; - using ::memcpy; - using ::memmove; - using ::memset; - using ::strcat; - using ::strchr; - using ::strcmp; - using ::strcoll; - using ::strcpy; - using ::strcspn; - using ::strerror; - using ::strlen; - using ::strncat; - using ::strncmp; - using ::strncpy; - using ::strpbrk; - using ::strrchr; - using ::strspn; - using ::strstr; - using ::strtok; - using ::strxfrm; - - - //Extra definitions required in c++ spec - - - inline void* memchr(void* s, int c, size_t n){ - return memchr(const_cast(s), c, n); - } - - inline char* strchr(char* s, int c){ - return strchr(const_cast(s), c); - } - - inline char* strpbrk(char* s1, const char* s2){ - return strpbrk(const_cast(s1), s2); - } - - inline char* strrchr(char* s, int c){ - return strrchr(const_cast(s), c); - } - - inline char* strstr(char* s1, const char* s2){ - return strstr(const_cast(s1), s2); - } - -} - -#endif - Index: branches/slice/i386/modules/include/list =================================================================== --- branches/slice/i386/modules/include/list (revision 726) +++ branches/slice/i386/modules/include/list (revision 727) @@ -1,927 +0,0 @@ -/* 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 - -#ifndef __STD_HEADER_LIST -#define __STD_HEADER_LIST 1 - -#pragma GCC visibility push(default) - -namespace std{ - - template > class _UCXXEXPORT list { - public: - typedef typename Allocator::reference reference; - typedef typename Allocator::const_reference const_reference; - typedef typename Allocator::size_type size_type; - typedef typename Allocator::difference_type difference_type; - typedef T value_type; - typedef Allocator allocator_type; - typedef typename Allocator::pointer pointer; - typedef typename Allocator::const_pointer const_pointer; - - protected: - class node; - class iter_list; - - node * list_start; - node * list_end; - size_type elements; - Allocator a; - - public: - - typedef iter_list iterator; - typedef iter_list const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - explicit list(const Allocator& = Allocator()); - explicit list(size_type n, const T& value = T(), const Allocator& = Allocator()); - template list(InputIterator first, InputIterator last, - const Allocator& al= Allocator()); - list(const list& x); - ~list(); - - list& operator=(const list& x){ - if(&x == this){ - return *this; - } - clear(); - iterator i = x.begin(); - while(i != x.end()){ - push_back(*i); - ++i; - } - return *this; - } - - template void assign(InputIterator first, InputIterator last); - template void assign(Size n, const U& u = U()); - allocator_type get_allocator() const; - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - - bool empty() const; - size_type size() const; - size_type max_size() const; - void resize(size_type sz, T c = T()); - - reference front(); - const_reference front() const; - reference back(); - const_reference back() const; - - void push_front(const T& x); - void pop_front(); - void push_back(const T& x); - void pop_back(); - iterator insert(iterator position, const T& x = T()); - void insert(iterator position, size_type n, const T& x); - template void insert(iterator position, InputIterator first, InputIterator last); - iterator erase(iterator position); - iterator erase(iterator position, iterator last); - void swap(list&); - void clear(); - - void splice(iterator position, list& x); - void splice(iterator position, list& x, iterator i); - void splice(iterator position, list& x, iterator first, iterator last); - void remove(const T& value); - template void remove_if(Predicate pred); - void unique(); - template void unique(BinaryPredicate binary_pred); - void merge(list& x); - template void merge(list& x, Compare comp); - void sort(); - template void sort(Compare comp); - void reverse(); - protected: - void swap_nodes(node * x, node * y); - }; - - - //Implementations of List - - //List node - template class _UCXXEXPORT list::node{ - public: - node * previous; - node * next; - T * val; - - node(): previous(0), next(0), val(0){ } - node(const T & t ): previous(0), next(0), val(0) { - val = new T(t); - //FIXME use allocator somehow but only call constructor once - } - node(const T & t, node * p, node * n): previous(p), next(n), val(0) { - val = new T(t); - } - ~node(){ } - }; - - //List iterator - template class _UCXXEXPORT list::iter_list - : public std::iterator< - bidirectional_iterator_tag, - T, - typename Allocator::difference_type, - typename Allocator::pointer, - typename Allocator::reference - > - { - private: - node * current; - public: - iter_list():current(0) { } - iter_list( typename list::node * n): current(n) { } - iter_list(const list::iter_list & l): current(l.current) { } - ~iter_list(){ } - - iter_list & operator=(const list::iter_list & right ){ - current = right.current; - return *this; - } - - T & operator*(){ - return *(current->val); - } - T * operator->(){ - return current->val; - } - const T & operator*() const{ - return *current->val; - } - const T * operator->() const{ - return current->val; - } - - bool operator==(const list::iter_list & right) const { - return (current == right.current); - } - - bool operator!=(const list::iter_list & right) const { - return (current != right.current); - } - - iter_list & operator++(){ - current = current->next; - return *this; - } - - iter_list operator++(int){ - iter_list temp(current); - current = current->next; - return temp; - } - iter_list & operator--(){ - current = current->previous; - return *this; - } - - iter_list operator--(int){ - iter_list temp(current); - current = current->previous; - return temp; - } - node * link_struct(){ - return current; - } - iter_list & operator+=(unsigned int n){ - for(unsigned int i = 0; i < n; ++i){ - current = current->next; - } - return *this; - } - iter_list & operator-=(unsigned int n){ - for(unsigned int i = 0; i < n; ++i){ - current = current->previous; - } - return *this; - } - }; - - - template list::list(const Allocator& al) - :list_start(0), list_end(0), elements(0), a(al) - { - //End node - list_start = new node(); - list_end = list_start; - return; - } - - template list::list - (typename Allocator::size_type n, const T& value, const Allocator& al) - :list_start(0), list_end(0), elements(0), a(al) - { - //End node - list_start = new node(); - list_end = list_start; - - for(typename Allocator::size_type i = 0; i < n ; ++i){ - push_back(value); - } - } - - template template - list::list - (InputIterator first, InputIterator last, const Allocator& al) - : list_start(0), list_end(0), elements(0), a(al) - { - list_start = new node(); - list_end = list_start; - while(first != last){ - push_back(*first); - ++first; - } - } - - template list::list(const list& x) - : list_start(0), list_end(0), elements(0), a(x.a) - { - list_start = new node(); - list_end = list_start; - - iterator i = x.begin(); - while(i != x.end()){ - push_back( *i); - ++i; - } - } - - template list::~list(){ - while(elements > 0){ - pop_front(); - } - delete list_start->val; -#if UCLIBCXX_DEBUG - list_start->val = 0; -#endif - delete list_start; -#if UCLIBCXX_DEBUG - list_start = 0; - list_end = 0; -#endif - } - - - template void list::swap_nodes(node * x, node * y){ - T * v = x->val; - x->val = y->val; - y->val = v; - } - - template typename list::iterator - list::begin() - { - return iterator(list_start); - } - - - template typename list::const_iterator - list::begin() const - { - return const_iterator(list_start); - } - - - template typename list::iterator - list::end() - { - return iterator(list_end); - } - - template typename list::const_iterator - list::end() const - { - return const_iterator(list_end); - } - - template typename list::reverse_iterator - list::rbegin() - { - return reverse_iterator(end()); - } - - template typename list::const_reverse_iterator - list::rbegin() const - { - return const_reverse_iterator(end()); - } - - template typename list::reverse_iterator - list::rend() - { - return reverse_iterator(begin()); - } - - template typename list::const_reverse_iterator - list::rend() const - { - return const_reverse_iterator(begin()); - } - - template bool list::empty() const{ - return (elements == 0); - } - template typename list::size_type list::size() const{ - return elements; - } - template typename list::size_type list::max_size() const{ - return ((size_type)(-1)) / (sizeof(T) + sizeof(node)); - } - template void list::resize(typename Allocator::size_type sz, T c){ -// if(sz > elements){ - for(typename Allocator::size_type i = elements; i < sz; ++i){ - push_back(c); - } -// } -// if(sz < elements){ - for(typename Allocator::size_type i = elements; i > sz; --i){ - pop_back(); - } -// } - } - - template typename list::reference list::front(){ - return *(list_start->val); - } - template typename list::const_reference list::front() const{ - return *(list_start->val); - } - template typename list::reference list::back(){ - return *(list_end->previous->val); - } - template typename list::const_reference list::back() const{ - return *(list_end->previous->val); - } - - - template void list::push_front(const T& x){ - node * temp = new node(x); - list_start->previous = temp; - temp->previous = 0; - temp->next = list_start; - list_start = temp; - ++elements; - } - - template void list::pop_front(){ - if(elements > 0){ - list_start = list_start->next; - delete list_start->previous->val; -#if UCLIBCXX_DEBUG - list_start->previous->val = 0; - list_start->previous->next = 0; - list_start->previous->previous = 0; -#endif - delete list_start->previous; - list_start->previous = 0; - --elements; - } - } - - template void list::push_back(const T& x){ - if(elements == 0){ - //The list is completely empty - list_start = new node(x); - list_end->previous = list_start; - list_start->previous = 0; - list_start->next = list_end; - elements = 1; - }else{ - node * temp = new node(x); - temp->previous = list_end->previous; - temp->next = list_end; - list_end->previous->next = temp; - list_end->previous = temp; - ++elements; - } - } - - template void list::pop_back(){ - if(elements > 0){ - node * temp = list_end->previous; - if(temp == list_start){ - list_end->previous = 0; - list_start = list_end; - }else{ - temp->previous->next = temp->next; - list_end->previous = temp->previous; - } - delete temp->val; -#if UCLIBCXX_DEBUG - temp->val = 0; - temp->next = 0; - temp->previous = 0; -#endif - delete temp; -#if UCLIBCXX_DEBUG - temp = 0; -#endif - --elements; - } - } - - - template typename list::iterator - list::insert(iterator position, const T& x) - { - node * temp = new node(x); - - temp->previous = position.link_struct()->previous; - temp->next = position.link_struct(); - - if(temp->previous == 0){ - list_start = temp; - }else{ - position.link_struct()->previous->next = temp; - } - - position.link_struct()->previous = temp; - - ++elements; - --position; - return position; - } - - template void list::insert(iterator position, size_type n, const T& x){ - for(typename list::size_type i = 0; i < n; ++i){ - position = insert(position, x); - } - } - - template template void - list::insert(iterator position, InputIterator first, InputIterator last) - { - while(first !=last){ - insert(position, *first); - ++first; - } - } - template typename list::iterator - list::erase(iterator position) - { - if(position != end() ){ - node * temp = position.link_struct(); - if(temp == list_start){ - ++position; - temp->next->previous = 0; - list_start = temp->next; - }else{ - --position; - temp->next->previous = temp->previous; - temp->previous->next = temp->next; - ++position; - } - delete temp->val; -#if UCLIBCXX_DEBUG - temp->next = 0; - temp->previous = 0; - temp->val = 0; -#endif - delete temp; -#if UCLIBCXX_DEBUG - temp = 0; -#endif - --elements; - } - return position; - } - template typename list::iterator - list::erase(iterator position, iterator last) - { - iterator temp = position; - while(position !=last){ - position = erase(position); - } - return position; - } - template void list::swap(list& l){ - node * temp; - size_type tempel; - - temp = list_start; - list_start = l.list_start; - l.list_start = temp; - - temp = list_end; - list_end = l.list_end; - l.list_end = temp; - - tempel = elements; - elements = l.elements; - l.elements = tempel; - } - template void list::clear(){ - while(elements > 0){ - pop_front(); - } - } - - template - void list::splice(iterator position, list& x) - { - - //Can't add non-existant elements - if(x.elements == 0){ - return; - } - - elements += x.elements; - x.elements = 0; - - - //Chaining to the begining - if(position == begin()){ - x.list_end->previous->next = list_start; - list_start->previous = x.list_end->previous; - - list_start = x.list_start; - - x.list_start = x.list_end; - x.list_end->previous = 0; - - return; - } - - //Link everything we need - x.list_start->previous = position.link_struct()->previous; - position.link_struct()->previous->next = x.list_start; - - position.link_struct()->previous = x.list_end->previous; - x.list_end->previous->next = position.link_struct(); - - //Clean up the other list - - x.list_start = x.list_end; - x.list_end->previous=0; - - } - - template - void list::splice(iterator position, list& x, iterator i) - { - //Invalid conditions - if( x.elements == 0 || i == position || position.link_struct() == i.link_struct()->next ){ - return; - } - - - //Do we need to adjust the begining pointer? - if(i == x.begin()){ - x.list_start = x.list_start->next; - x.list_start->previous = 0; - } - - - //Insert at begining special case - if(position == begin()){ - - i.link_struct()->previous->next = i.link_struct()->next; - i.link_struct()->next->previous = i.link_struct()->previous; - - i.link_struct()->previous = 0; - i.link_struct()->next = position.link_struct(); - position.link_struct()->previous = i.link_struct(); - - list_start = i.link_struct(); - - --x.elements; - ++elements; - return; - } - - if( i.link_struct()->previous != 0){ - i.link_struct()->previous->next = i.link_struct()->next; - i.link_struct()->next->previous = i.link_struct()->previous; - }else{ - i.link_struct()->next->previous = 0; - x.list_start = i.link_struct()->next; - } - - i.link_struct()->previous = position.link_struct()->previous; - position.link_struct()->previous->next = i.link_struct(); - - i.link_struct()->next = position.link_struct(); - position.link_struct()->previous = i.link_struct(); - - --x.elements; - ++elements; - } - - template - void list::splice(iterator position, list& x, - iterator first, iterator last) - { - if(x.elements == 0){ - return; - } - - iterator temp; - while(first != last){ - temp = first; - ++first; - splice(position, x, temp); - } - } - - - template void list::remove(const T& value){ - iterator temp = begin(); - while( temp != end() ){ - if(*temp == value){ - temp = erase(temp); - }else{ - ++temp; - } - } - } - - - template template void list::remove_if(Predicate pred){ - iterator temp = begin(); - while( temp != end() ){ - if( pred(*temp) ){ - temp = erase(temp); - }else{ - ++temp; - } - } - } - - - template void list::unique(){ - equal_to::value_type> p; - unique(p); - } - - template template - void list::unique(BinaryPredicate binary_pred) - { - iterator temp1 = begin(); - iterator temp2; - ++temp1; - while( temp1 != end() ){ - temp2 = temp1; - --temp2; - if( binary_pred(*temp1, *temp2) ){ - erase(temp1); - temp1 = temp2; - } - ++temp1; - } - } - - template void list::merge(list& x){ - less::iterator>::value_type> c; - merge(x, c); - } - - template template - void list::merge(list& x, Compare comp) - { - iterator source = x.begin(); - iterator temp; - iterator dest = begin(); - - while(source != x.end()){ - while( dest != end() && comp (*dest, *source) ){ - ++dest; - } - ++elements; - --x.elements; - - temp = source; - ++temp; - - if(dest == begin()){ - dest.link_struct()->previous = source.link_struct(); - source.link_struct()->next = dest.link_struct(); - source.link_struct()->previous = 0; - list_start = source.link_struct(); - }else{ - source.link_struct()->previous = dest.link_struct()->previous; - dest.link_struct()->previous->next = source.link_struct(); - source.link_struct()->next = dest.link_struct(); - dest.link_struct()->previous = source.link_struct(); - } - source = temp; - } - - //Fix up x; - x.list_start = x.list_end; - x.list_start->previous = 0; - } - - template void list::sort(){ - less::iterator>::value_type> c; - sort(c); - } - - template template - void list::sort(Compare comp) - { - typename list::iterator i, j, k; - - //FIXME - bubble sort - - if(elements == 0){ - return; - } - - i = end(); - --i; - while(i != begin()){ - j = begin(); - k = j; - ++k; - while(j != i){ - if( comp(*k, *j) ){ - swap_nodes(k.link_struct(), j.link_struct()); - } - ++j; - ++k; - } - --i; - } - } - - - template void list::reverse(){ - if(elements == 0){ - return; - } - - node * current; - node * following; - node * temp; - - //Need to move the list_end element to the begining - - temp = list_end; - list_end = temp->previous; - list_end->next = 0; - - list_start->previous = temp; - temp->previous = 0; - temp->next = list_start; - list_start = temp; - - current = list_start; - - while( current != list_end ){ - following = current->next; - - //Swap the values pointed to/at with the current node - temp = current->next; - current->next = current->previous; - current->previous = temp; - - current = following; - } - - //Swap pointers on the end node - temp = list_end->next; - list_end->next = list_end->previous; - list_end->previous = temp; - - - //Swap the fixed pointers - temp = list_start; - list_start = list_end; - list_end = temp; - - } - - template - bool operator==(const list& x, const list& y){ - if(x.size() != y.size()){ - return false; - } - typename list::const_iterator i = x.begin(); - typename list::const_iterator j = y.begin(); - - while(i != x.end()){ - if( *i != *j){ - return false; - } - ++i; - ++j; - } - return true; - } - - template - bool operator< (const list& x, const list& y){ - typename list::const_iterator i = x.begin(); - typename list::const_iterator j = y.begin(); - while(i != x.end() && j != y.end()){ - if( *i < *j){ - return true; - } - if(*j < *i){ - return false; - } - ++i; - ++j; - } - return (i == x.end() && j != y.end()); - } - - template - bool operator!=(const list& x, const list& y){ - return !(x == y); - } - - template - bool operator> (const list& x, const list& y){ - typename list::const_iterator i = x.begin(); - typename list::const_iterator j = y.begin(); - while(i != x.end() && j != y.end()){ - if( *i > *j){ - return true; - } - if( *j > *i){ - return false; - } - ++i; - ++j; - } - return (i != x.end() && j == y.end()); - } - - template - bool operator>=(const list& x, const list& y){ - typename list::const_iterator i = x.begin(); - typename list::const_iterator j = y.begin(); - while(i != x.end() && j != y.end()){ - if( *i >= *j){ - return true; - } - if(*j >= *i){ - return false; - } - ++i; - ++j; - } - return (i != x.end() && j == y.end()); - } - - template - bool operator<=(const list& x, const list& y){ - typename list::const_iterator i = x.begin(); - typename list::const_iterator j = y.begin(); - while(i != x.end() && j != y.end()){ - if( *i <= *j){ - return true; - } - if(*j <= *i){ - return false; - } - ++i; - ++j; - } - return (i == x.end()); - } - - template - void swap(list& x, list& y){ - x.swap(y); - } - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/basic_definitions =================================================================== --- branches/slice/i386/modules/include/basic_definitions (revision 726) +++ branches/slice/i386/modules/include/basic_definitions (revision 727) @@ -1,66 +0,0 @@ -/* 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 -*/ - -#ifndef __BASIC_DEFINITIONS -#define __BASIC_DEFINITIONS 1 - -#include - -#pragma GCC visibility push(default) - -//The following is used to support GCC symbol visibility patch - -#ifdef GCC_HASCLASSVISIBILITY - #define _UCXXEXPORT __attribute__ ((visibility("default"))) - #define _UCXXLOCAL __attribute__ ((visibility("hidden"))) -#else - #define _UCXXEXPORT - #define _UCXXLOCAL - -#endif - -#ifdef __GCC__ -#define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) -#else -#define __UCLIBCXX_NORETURN -#endif - -#ifdef __UCLIBCXX_HAS_TLS__ - #define __UCLIBCXX_TLS __thread -#else - #define __UCLIBCXX_TLS -#endif - - - -//Testing purposes -#define __STRING_MAX_UNITS 65535 - -namespace std{ - typedef signed long int streamsize; -} - -#pragma GCC visibility pop - -#endif - - -#ifdef __DODEBUG__ - #define UCLIBCXX_DEBUG 1 -#else - #define UCLIBCXX_DEBUG 0 -#endif Index: branches/slice/i386/modules/include/cwctype =================================================================== --- branches/slice/i386/modules/include/cwctype (revision 726) +++ branches/slice/i386/modules/include/cwctype (revision 727) @@ -1,106 +0,0 @@ -// -*- C++ -*- forwarding header. - -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 -// Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, 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 General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: -// - -/** @file cwctype - * This is a Standard C++ Library file. You should @c #include this file - * in your programs, rather than any of the "*.h" implementation files. - * - * This is the C++ version of the Standard C Library header @c wctype.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. - */ - -#ifndef _CPP_CWCTYPE -#define _CPP_CWCTYPE 1 - -#pragma GCC system_header - -//#include - -#ifdef __UCLIBCXX_HAS_WCHAR__ -#include -#endif - -// Get rid of those macros defined in in lieu of real functions. -#undef iswalnum -#undef iswalpha -#undef iswblank -#undef iswcntrl -#undef iswdigit -#undef iswgraph -#undef iswlower -#undef iswprint -#undef iswprint -#undef iswpunct -#undef iswspace -#undef iswupper -#undef iswxdigit -#undef iswctype -#undef towlower -#undef towupper -#undef towctrans -#undef wctrans -#undef wctype - -#if __UCLIBCXX_HAS_WCHAR__ -namespace std -{ - using ::wint_t; // cwchar - - using ::wctype_t; - using ::wctrans_t; - - using ::iswalnum; - using ::iswalpha; - using ::iswblank; - using ::iswcntrl; - using ::iswdigit; - using ::iswgraph; - using ::iswlower; - using ::iswprint; - using ::iswprint; - using ::iswpunct; - using ::iswspace; - using ::iswupper; - using ::iswxdigit; - using ::iswctype; - using ::towlower; - using ::towupper; - using ::towctrans; - using ::wctrans; - using ::wctype; -} -#endif //__ULIBCXX_HAS_WCHAR__ - -#endif Index: branches/slice/i386/modules/include/queue =================================================================== --- branches/slice/i386/modules/include/queue (revision 726) +++ branches/slice/i386/modules/include/queue (revision 727) @@ -1,126 +0,0 @@ -/* 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 - -#ifndef __HEADER_STD_QUEUE -#define __HEADER_STD_QUEUE 1 - -#pragma GCC visibility push(default) - -namespace std{ - - template > class _UCXXEXPORT queue{ - protected: - Container c; - public: - typedef typename Container::value_type value_type; - typedef typename Container::size_type size_type; - typedef Container container_type; - - explicit queue(const Container& a = Container()) : c(a) { } - - bool empty() const { return c.empty(); } - size_type size() const { return c.size(); } - value_type& front() { return c.front(); } - const value_type& front() const { return c.front(); } - value_type& back() { return c.back(); } - const value_type& back() const { return c.back(); } - void push(const value_type& x) { c.push_back(x); } - void pop() { c.pop_front(); } - }; - - - template _UCXXEXPORT bool - operator==(const queue& x, const queue& y) - { - return (x.c == y.c); - } - template _UCXXEXPORT bool - operator< (const queue& x, const queue& y) - { - return (x.c < y.c); - } - template _UCXXEXPORT bool - operator!=(const queue& x, const queue& y) - { - return (x.c != y.c); - } - template _UCXXEXPORT bool - operator> (const queue& x, const queue& y) - { - return (x.c > y.c); - } - template _UCXXEXPORT bool - operator>=(const queue& x, const queue& y) - { - return (x.c >= y.c); - } - template _UCXXEXPORT bool - operator<=(const queue& x, const queue& y) - { - return (x.c <= y.c); - } - - - template , - class Compare = less - > class _UCXXEXPORT priority_queue { - protected: - Container c; - Compare comp; - public: - typedef typename Container::value_type value_type; - typedef typename Container::size_type size_type; - typedef Container container_type; - - explicit priority_queue(const Compare& x = Compare(), const Container& a = Container()) - : c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; } - template priority_queue(InputIterator first, - InputIterator last, - const Compare& x = Compare(), - const Container& y= Container()) - : c(y), comp(c) - { - c.insert(c.end(), first, last); - make_heap(c.begin(), c.end(), comp); - } - - bool empty() const { return c.empty(); } - size_type size() const { return c.size(); } - const value_type& top() const { return c.front(); } - void push(const value_type& x){ - c.push_back(x); - push_heap(c.begin(), c.end(), comp); - } - void pop(){ - pop_heap(c.begin(), c.end(), comp); - c.pop_back(); - } - }; - -} - -#pragma GCC visibility pop - -#endif - - Index: branches/slice/i386/modules/include/cerrno =================================================================== --- branches/slice/i386/modules/include/cerrno (revision 726) +++ branches/slice/i386/modules/include/cerrno (revision 727) @@ -1,19 +0,0 @@ -/* 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 Index: branches/slice/i386/modules/include/streambuf =================================================================== --- branches/slice/i386/modules/include/streambuf (revision 726) +++ branches/slice/i386/modules/include/streambuf (revision 727) @@ -1,329 +0,0 @@ -/* 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 - -#ifndef HEADER_STD_STREAMBUF -#define HEADER_STD_STREAMBUF 1 - -#include - -#pragma GCC visibility push(default) - -namespace std{ - - template class _UCXXEXPORT basic_streambuf{ - public: -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - friend ios_base::Init::Init(); -#endif - // Types: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef traits traits_type; - - virtual ~basic_streambuf(); - - locale pubimbue(const locale &loc); - - locale getloc() const{ - return myLocale; - } - - basic_streambuf* pubsetbuf(char_type* s, streamsize n){ - return setbuf(s,n); - } - pos_type pubseekoff(off_type off, - typename ios_base::seekdir way, - ios_base::openmode which = ios_base::in | - ios_base::out - ) - { - return seekoff(off,way,which); - } - pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out){ - return seekpos(sp,which); - } - int pubsync(){ - return sync(); - } - - streamsize in_avail(); - - int_type snextc(); - - int_type sbumpc(); - - int_type sgetc(); - - streamsize sgetn(char_type* s, streamsize n){ - return xsgetn(s,n); - } - - int_type sputbackc(char_type c); - - int_type sungetc(); - - int_type sputc(char_type c); - - streamsize sputn(const char_type* s, streamsize n){ - if(openedFor & ios_base::app){ - seekoff(0, ios_base::end, ios_base::out); - } - return xsputn(s, n); - } - - protected: - locale myLocale; - //Pointers for the "get" buffers - charT * mgbeg; - charT * mgnext; - charT * mgend; - - //Pointers for the "put" buffers - charT * mpbeg; - charT * mpnext; - charT * mpend; - - //In the event of null buffers Lets us know what the buffer is opened for - ios_base::openmode openedFor; - - basic_streambuf(); - - basic_streambuf(const basic_streambuf > &) - : myLocale(), - mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), - openedFor(0) - { } - basic_streambuf > & operator=(const basic_streambuf > &){ - return *this; - } - - char_type* eback() const{ - return mgbeg; - } - char_type* gptr() const{ - return mgnext; - } - char_type* egptr() const{ - return mgend; - } - void gbump(int n){ - mgnext+=n; - } - void setg(char_type* gbeg, char_type* gnext, char_type* gend){ - mgbeg = gbeg; - mgnext = gnext; - mgend = gend; - } - - char_type* pbase() const{ - return mpbeg; - } - char_type* pptr() const{ - return mpnext; - } - char_type* epptr() const{ - return mpend; - } - void pbump(int n){ - mpnext+=n; - } - void setp(char_type* pbeg, char_type* pend){ - mpbeg = pbeg; - mpnext = pbeg; - mpend = pend; - } - - virtual void imbue(const locale &loc){ - myLocale = loc; - } - - //Virtual functions which we will not implement - - virtual basic_streambuf* setbuf(char_type* , streamsize){ - return 0; - } - virtual pos_type seekoff(off_type , ios_base::seekdir, - ios_base::openmode = ios_base::in | ios_base::out) - { - return 0; - } - virtual pos_type seekpos(pos_type , ios_base::openmode = ios_base::in | ios_base::out){ - return 0; - } - virtual int sync(){ - return 0; - } - - virtual int showmanyc(){ - return 0; - } - virtual streamsize xsgetn(char_type* , streamsize ){ - return 0; - } - virtual int_type underflow(){ - return traits_type::eof(); - } - virtual int_type uflow(){ - int_type ret = underflow(); - if (!traits_type::eq_int_type(ret, traits_type::eof())) - gbump(1); - return ret; - } - - virtual int_type pbackfail(int_type c = traits::eof()){ - return c; - } - virtual streamsize xsputn(const char_type* c, streamsize n){ - //This function is designed to be replaced by subclasses - for(streamsize i = 0; i< n; ++i){ - if(sputc(c[i]) == traits::eof()){ - return i; - } - } - return n; - } - virtual int_type overflow (int_type c = traits::eof()){ - return c; - } - }; - - typedef basic_streambuf streambuf; -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_streambuf wstreambuf; -#endif - - -//Definitions put below to allow for easy expansion of code - - template basic_streambuf::~basic_streambuf(){ } - - template locale basic_streambuf::pubimbue(const locale &loc){ - locale temp = myLocale; - myLocale = loc; - return temp; - } - - template streamsize basic_streambuf::in_avail(){ - if(mgend !=0 && mgnext !=0){ - return mgend - mgnext; - } - return showmanyc(); - } - - template typename basic_streambuf::int_type basic_streambuf::sbumpc(){ - if(mgbeg == 0 || mgnext == mgend){ - return uflow(); - } - int_type retval = T::to_int_type(*gptr()); - gbump(1); - return retval; - } - - template typename basic_streambuf::int_type basic_streambuf::snextc(){ - if(sbumpc() == T::eof() ){ - return T::eof() ; - } - return sgetc(); - } - - template typename basic_streambuf::int_type basic_streambuf::sgetc(){ - if(mgbeg == 0 || mgnext == mgend){ - return underflow(); - } - return T::to_int_type(*gptr()); - } - - template typename basic_streambuf::int_type basic_streambuf::sputbackc(char_type c){ - if(mgbeg == 0 || mgnext == mgbeg || !T::eq(c, gptr()[-1] )){ - return pbackfail(T::to_int_type(c)); - } - gbump(-1); - return T::to_int_type(*gptr()); - } - - template typename basic_streambuf::int_type basic_streambuf::sungetc(){ - if(mgbeg == 0 || mgnext == mgbeg){ - return ios_base::failbit; - } - gbump(-1); - return T::to_int_type(*gptr()); - } - - template typename basic_streambuf::int_type basic_streambuf::sputc(char_type c){ - if(openedFor & ios_base::app){ - seekoff(0, ios_base::end, ios_base::out); - } - if(mpnext < mpend){ - *mpnext = c; - ++mpnext; - }else{ - return overflow( T::to_int_type(c) ); - } - return T::to_int_type(c); - } - - template basic_streambuf::basic_streambuf() - : myLocale(), - mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), - openedFor(0) - { } - - - - - - -#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ -#ifndef __UCLIBCXX_COMPILE_STREAMBUF__ - -#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - template <> _UCXXEXPORT streambuf::basic_streambuf(); - template <> _UCXXEXPORT streambuf::~basic_streambuf(); - -#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ - - 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 -#endif - - - - - -} - -#pragma GCC visibility pop - -#endif Index: branches/slice/i386/modules/include/new =================================================================== --- branches/slice/i386/modules/include/new (revision 726) +++ branches/slice/i386/modules/include/new (revision 727) @@ -1,64 +0,0 @@ -/* 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 - -#ifndef __STD_NEW_OPERATOR -#define __STD_NEW_OPERATOR 1 - -#pragma GCC visibility push(default) - -namespace std{ - class _UCXXEXPORT bad_alloc : public exception {}; - - struct _UCXXEXPORT nothrow_t {}; - extern const nothrow_t nothrow; - - typedef void (*new_handler)(); - _UCXXEXPORT new_handler set_new_handler(new_handler new_p) throw(); -} - - -_UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc); -_UCXXEXPORT void operator delete(void* ptr) throw(); - -_UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc); -_UCXXEXPORT void operator delete[](void * ptr) throw(); - -#ifndef NO_NOTHROW -_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) throw(); -_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) throw(); - -_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) throw(); -_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) throw(); -#endif - - /* Placement operators */ -inline void* operator new(std::size_t, void* ptr) throw() {return ptr; } -inline void operator delete(void* , void *) throw() { } - -inline void* operator new[](std::size_t, void *p) throw() { return p; } -inline void operator delete[](void* , void *) throw() {} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/ios =================================================================== --- branches/slice/i386/modules/include/ios (revision 726) +++ branches/slice/i386/modules/include/ios (revision 727) @@ -1,501 +0,0 @@ -/* 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 - -#ifndef __HEADER_STD_IOS -#define __HEADER_STD_IOS 1 - -#pragma GCC visibility push(default) - -namespace std{ - typedef signed long int streamoff; - - template class fpos; - - class _UCXXEXPORT ios_base { - public: - class failure; -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ - class failure : public exception { - public: - explicit failure(const std::string& msg) { } - explicit failure() { } - virtual const char* what() const throw() { - return "std::ios_base failure exception"; - } - }; -#endif -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - class _UCXXLOCAL Init{ - public: - _UCXXEXPORT Init(); - _UCXXEXPORT ~Init(); - private: - static int init_cnt; - }; -#endif - - public: - - typedef unsigned short int fmtflags; - - static const fmtflags skipws = 0x0001; - - static const fmtflags left = 0x0002; - static const fmtflags right = 0x0004; - static const fmtflags internal = 0x0008; - - static const fmtflags boolalpha = 0x0010; - - static const fmtflags dec = 0x0020; - static const fmtflags oct = 0x0040; - static const fmtflags hex = 0x0080; - - static const fmtflags scientific = 0x0100; - static const fmtflags fixed = 0x0200; - - static const fmtflags showbase = 0x0400; - static const fmtflags showpoint = 0x0800; - static const fmtflags showpos = 0x1000; - static const fmtflags uppercase = 0x2000; - - static const fmtflags adjustfield = left | right | internal; - static const fmtflags basefield = dec | oct | hex; - static const fmtflags floatfield = fixed | scientific; - - static const fmtflags unitbuf = 0x4000; - - typedef unsigned char iostate; - static const iostate goodbit = 0x00; - static const iostate badbit = 0x01; - static const iostate eofbit = 0x02; - static const iostate failbit = 0x04; - - typedef unsigned char openmode; - static const openmode app = 0x01; - static const openmode ate = 0x02; - static const openmode binary = 0x04; - static const openmode in = 0x08; - static const openmode out = 0x10; - static const openmode trunc = 0x20; - - typedef unsigned char seekdir; - static const seekdir beg = 0x01; - static const seekdir cur = 0x02; - static const seekdir end = 0x04; - - _UCXXEXPORT fmtflags flags() const{ - return mformat; - } - _UCXXEXPORT fmtflags flags(fmtflags fmtfl); - - fmtflags setf(fmtflags fmtfl); - fmtflags setf(fmtflags fmtfl, fmtflags mask ); - - _UCXXEXPORT void unsetf(fmtflags mask){ - mformat&= ~mask; - } - - _UCXXEXPORT streamsize precision() const{ - return mprecision; - } - - _UCXXEXPORT streamsize precision(streamsize prec); - - _UCXXEXPORT streamsize width() const{ - return mwidth; - } - - _UCXXEXPORT streamsize width(streamsize wide); - - _UCXXEXPORT locale imbue(const locale& loc); - - _UCXXEXPORT locale getloc() const{ - return mLocale; - } - -// FIXME - These need to be implemented -// static int xalloc(); -// long& iword(int index); -// void*& pword(int index); - - _UCXXEXPORT ~ios_base() { } - - enum event { erase_event, imbue_event, copyfmt_event }; - - typedef void (*event_callback)(event, ios_base&, int index); -// void register_callback(event_call_back fn, int index); - - //We are going to wrap stdio so we don't need implementation of the following: - inline static bool sync_with_stdio(bool = true) { return true; } - - protected: - _UCXXEXPORT ios_base() : mLocale(), mformat(dec | skipws ), mstate(goodbit), - mmode(), mdir(), mprecision(6), mwidth(0) -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - ,mInit() -#endif - { - - } - locale mLocale; - fmtflags mformat; - iostate mstate; - openmode mmode; - seekdir mdir; - streamsize mprecision; - streamsize mwidth; -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - Init mInit; -#endif - }; - - - //ios_base manipulators - - - inline ios_base& boolalpha (ios_base& str){ - str.setf(ios_base::boolalpha); - return str; - } - inline ios_base& noboolalpha(ios_base& str){ - str.unsetf(ios_base::boolalpha); - return str; - } - inline ios_base& showbase (ios_base& str){ - str.setf(ios_base::showbase); - return str; - } - inline ios_base& noshowbase (ios_base& str){ - str.unsetf(ios_base::showbase); - return str; - } - inline ios_base& showpoint (ios_base& str){ - str.setf(ios_base::showpoint); - return str; - } - inline ios_base& noshowpoint(ios_base& str){ - str.unsetf(ios_base::showpoint); - return str; - } - inline ios_base& showpos (ios_base& str){ - str.setf(ios_base::showpos); - return str; - } - inline ios_base& noshowpos (ios_base& str){ - str.unsetf(ios_base::showpos); - return str; - } - inline ios_base& skipws (ios_base& str){ - str.setf(ios_base::skipws); - return str; - } - inline ios_base& noskipws (ios_base& str){ - str.unsetf(ios_base::skipws); - return str; - } - inline ios_base& uppercase (ios_base& str){ - str.setf(ios_base::uppercase); - return str; - } - inline ios_base& nouppercase(ios_base& str){ - str.unsetf(ios_base::uppercase); - return str; - } - - inline ios_base& unitbuf (ios_base& str){ - str.setf(ios_base::unitbuf); - return str; - } - inline ios_base& nounitbuf (ios_base& str){ - str.unsetf(ios_base::unitbuf); - return str; - } - inline ios_base& internal (ios_base& str){ - str.setf(ios_base::internal, ios_base::adjustfield); - return str; - } - inline ios_base& left (ios_base& str){ - str.setf(ios_base::left, ios_base::adjustfield); - return str; - } - inline ios_base& right (ios_base& str){ - str.setf(ios_base::right, ios_base::adjustfield); - return str; - } - - inline ios_base& dec (ios_base& str){ - str.setf(ios_base::dec, ios_base::basefield); - return str; - } - inline ios_base& hex (ios_base& str){ - str.setf(ios_base::hex, ios_base::basefield); - return str; - } - inline ios_base& oct (ios_base& str){ - str.setf(ios_base::oct, ios_base::basefield); - return str; - } - - inline ios_base& fixed (ios_base& str){ - str.setf(ios_base::fixed, ios_base::floatfield); - return str; - } - inline ios_base& scientific (ios_base& str){ - str.setf(ios_base::scientific, ios_base::floatfield); - return str; - } - - - //basic_ios class definition - - - template class _UCXXEXPORT basic_ios - : public ios_base - { - public: - // Types: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - typedef traits traits_type; - - _UCXXEXPORT operator void*() const{ - if(fail() ){ - return 0; - } - return (void *)(1); //Must return a non-NULL pointer (though it can be *any* pointer) - } - - _UCXXEXPORT bool operator!() const{ - return fail(); - } - _UCXXEXPORT iostate rdstate() const{ - return mstate; - } - _UCXXEXPORT void clear(iostate state = goodbit){ - if(rdbuf()!=0){ - mstate = state; - }else{ - mstate = state|ios_base::badbit; - } - } - _UCXXEXPORT void setstate(iostate state) { - clear(rdstate() | state); -#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ - if(rdstate() & throw_mask){ - throw failure(); - } -#endif - } - - _UCXXEXPORT bool good() const{ - return (rdstate() == 0); - } - _UCXXEXPORT bool eof() const{ - if(rdstate() & eofbit){ - return true; - } - return false; - } - _UCXXEXPORT bool fail() const{ - if( mstate & (failbit | badbit) ){ - return true; - } - return false; - } - - _UCXXEXPORT bool bad() const{ - if(mstate & badbit){ - return true; - } - return false; - } - - _UCXXEXPORT iostate exceptions() const{ - return throw_mask; - } - _UCXXEXPORT void exceptions(iostate except){ - throw_mask = except; - } - - explicit _UCXXEXPORT basic_ios(basic_streambuf* sb) : fill_char(' '), mtied(0), mstreambuf(0){ - init(sb); - } - - basic_ios() : mtied(0), mstreambuf(0){ } - - virtual _UCXXEXPORT ~basic_ios(){ - } - - _UCXXEXPORT basic_ostream* tie() const{ - return mtied; - } - _UCXXEXPORT basic_ostream* tie(basic_ostream* tiestr){ - basic_ostream* retval= mtied; - mtied = tiestr; - return retval; - } - _UCXXEXPORT basic_streambuf* rdbuf() const{ - return mstreambuf; - } - _UCXXEXPORT basic_streambuf* rdbuf(basic_streambuf* sb){ - basic_streambuf* retval = mstreambuf; - mstreambuf = sb; - return retval; - } - _UCXXEXPORT basic_ios& copyfmt(const basic_ios& rhs); - _UCXXEXPORT char_type fill() const{ - return fill_char; - } - _UCXXEXPORT char_type fill(char_type ch){ - char_type temp = fill_char; - fill_char = ch; - return temp; - } - - _UCXXEXPORT locale imbue(const locale& loc){ - return ios_base::imbue(loc); - } - _UCXXEXPORT char narrow(char_type c, char dfault) const; - _UCXXEXPORT char_type widen(char c) const; - - protected: - char_type fill_char; - basic_ostream* mtied; - basic_streambuf* mstreambuf; - iostate throw_mask; - _UCXXEXPORT basic_ios(const basic_ios &){ } - _UCXXEXPORT basic_ios & operator=(const basic_ios &){ return *this; } - _UCXXEXPORT void init(basic_streambuf* sb){ - ios_base::mformat = skipws|dec; - mstreambuf = sb; - mstate = goodbit; - throw_mask = goodbit; - } - }; - -#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ -#ifndef __UCLIBCXX_COMPILE_IOS__ - - template <> _UCXXEXPORT void basic_ios >::clear(iostate state); - template <> _UCXXEXPORT void basic_ios >::setstate(iostate state); - -#endif -#endif - - - template - inline char basic_ios::narrow(char_type c, char dfault) const - { - return dfault; - } - - template <> - inline char basic_ios >::narrow(char_type c, char) const - { - return c; - } - -#ifdef __UCLIBCXX_HAS_WCHAR__ - - template <> - inline char basic_ios >::narrow(char_type c, char dfault) const - { - char retval = wctob (c); - if(retval == EOF){ - retval = dfault; - } - return retval; - } - -#endif //__UCLIBCXX_HAS_WCHAR__ - - template - inline typename basic_ios::char_type - basic_ios::widen(char c) const - { - return c; - } - - template <> - inline basic_ios >::char_type - basic_ios >::widen(char c) const - { - return c; - } - -#ifdef __UCLIBCXX_HAS_WCHAR__ - - template <> - inline basic_ios >::char_type - basic_ios >::widen(char c) const - { - return btowc(c); - } - -#endif //__UCLIBCXX_HAS_WCHAR__ - - - template class _UCXXEXPORT fpos{ - public: - _UCXXEXPORT fpos(stateT s){ - st = s; - } - _UCXXEXPORT stateT state() const{ - return st; - } - _UCXXEXPORT void state(stateT s){ - st = s; - } - _UCXXEXPORT bool operator==(const fpos &rhs){ - return st == rhs.st; - } - _UCXXEXPORT bool operator!=(const fpos &rhs){ - return st == rhs.st; - } - _UCXXEXPORT fpos & operator+(const streamoff & o){ - st += o; - return *this; - } - _UCXXEXPORT fpos & operator-(const streamoff & o){ - st -= o; - return *this; - } - _UCXXEXPORT streamoff operator-(const fpos & rhs){ - return st - rhs.st; - } - - - private: - stateT st; - }; - - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/fstream =================================================================== --- branches/slice/i386/modules/include/fstream (revision 726) +++ branches/slice/i386/modules/include/fstream (revision 727) @@ -1,678 +0,0 @@ -/* 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 -*/ -#if 0 -#ifndef __STD_HEADER_FSTREAM -#define __STD_HEADER_FSTREAM 1 - -//#if __UCLIBCXX_SUPPORT_FILEIO__ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef __UCLIBCXX_HAS_WCHAR__ -#include -#include -#endif //__UCLIBCXX_HAS_WCHAR__ - -#pragma GCC visibility push(default) - -namespace std{ - - template class basic_filebuf; - - typedef basic_filebuf filebuf; -#ifdef __UCLIBCXX_HAS_WCHAR__ - typedef basic_filebuf wfilebuf; -#endif - - - template class _UCXXEXPORT basic_filebuf - : public basic_streambuf - { -#ifdef __UCLIBCXX_SUPPORT_CDIR__ - friend ios_base::Init::Init(); //Needed for cout/cin stuff -#endif - public: - // Types (inherited from basic_streambuf: - typedef typename basic_streambuf::char_type char_type; - typedef typename basic_streambuf::int_type int_type; - typedef typename basic_streambuf::pos_type pos_type; - typedef typename basic_streambuf::off_type off_type; - typedef traits traits_type; - - //Constructors/destructor: - - _UCXXEXPORT basic_filebuf() : basic_streambuf(), fp(0), pbuffer(0), gbuffer(0) - { - append=false; - pbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; - gbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; - - setp(pbuffer, pbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); - //Position get buffer so that there is no data available - setg(gbuffer, gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__, - gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); - } - - - _UCXXEXPORT virtual ~basic_filebuf(){ - sync(); - close(); - delete [] pbuffer; - delete [] gbuffer; - pbuffer = 0; - gbuffer = 0; - } - - - //Members: - - _UCXXEXPORT bool is_open() const{ - if(fp == 0){ - return false; - } - return true; - } - - _UCXXEXPORT basic_filebuf* open(const char* s, ios_base::openmode mode){ - bool move_end = (mode & ios_base::ate) != 0; - if(is_open() !=false){ //Must call close() first - return 0; - } - basic_streambuf::openedFor = mode; - mode = mode & ~ios_base::ate; - - if(mode == ios_base::out || mode == (ios_base::out | ios_base::trunc)){ - fp = fopen(s, "w" ); - }else if((mode & ios_base::app) && ! (mode & ios_base::trunc)){ - if(mode & ios_base::binary){ - if(mode & ios_base::in){ - fp = fopen(s, "a+b"); - }else{ - fp = fopen(s, "ab"); - } - }else{ - if(mode & ios_base::in){ - fp = fopen(s, "a+"); - }else{ - fp = fopen(s, "a"); - } - } - }else if(mode == ios_base::in){ - fp = fopen(s, "r"); - }else if(mode == (ios_base::in | ios_base::out)){ - fp = fopen(s, "r+"); - }else if(mode == (ios_base::in | ios_base::out | ios_base::trunc)){ - fp = fopen(s, "w+"); - }else if(mode == (ios_base::binary | ios_base::out)){ - fp = fopen(s, "wb"); - }else if(mode == (ios_base::in | ios_base::binary)){ - fp = fopen(s, "rb"); - }else if(mode == (ios_base::in | ios_base::binary | ios_base::out)){ - fp = fopen(s, "r+b"); - }else if(mode==(ios_base::binary | ios_base::out | ios_base::trunc)){ - fp = fopen(s, "w+b"); - }else if(mode == (ios_base::in | ios_base::binary | ios_base::out | ios_base::trunc)){ - fp = fopen(s, "w+b"); - } - - if(fp == 0){ - return 0; - } - if(ferror(fp)){ - fclose(fp); - fp=0; - return 0; - } - int retval = 0; - - //Check to make sure the stream is good - if(move_end == true){ - retval = fseek(fp, 0, SEEK_END); - }else{ - retval = fseek(fp, 0, SEEK_SET); - } - if(retval!=0){ //Seek error - fclose(fp); - fp=0; - return 0; - } - - basic_streambuf::mgnext = basic_streambuf::mgend; - - return this; - } - _UCXXEXPORT basic_filebuf* close(){ - if(fp != 0 && fp != stdin && fp != stdout && fp !=stderr ){ - overflow(); - sync(); - int retval = fclose(fp); - if(retval !=0){ //Error of some sort - return 0; - } - fp=0; - } - return this; - } - protected: - _UCXXEXPORT basic_filebuf(const basic_filebuf &){ } - _UCXXEXPORT basic_filebuf & operator=(const basic_filebuf &){ return *this; } - - //Overridden virtual functions: - - virtual _UCXXEXPORT int showmanyc(){ - return basic_streambuf::egptr() - basic_streambuf::gptr(); - } - virtual _UCXXEXPORT int_type 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 - - */ - - if(!is_open()){ - return traits::eof(); - } - - if(basic_streambuf::eback() == 0){ - //No buffer, so... - charT c; - int retval; - retval = fread(&c, sizeof(charT), 1, fp); - - if(retval == 0 || feof(fp) || ferror(fp) ){ - return traits::eof(); - } - return traits::to_int_type(c); - } - - if(basic_streambuf::eback() == basic_streambuf::gptr()){ //Buffer is full - return traits::to_int_type(*basic_streambuf::gptr()); - } - //Shift entire buffer back to the begining - size_t offset = basic_streambuf::gptr() - basic_streambuf::eback(); - size_t amountData = basic_streambuf::egptr() - basic_streambuf::gptr(); - - for(charT * i = basic_streambuf::gptr(); i < basic_streambuf::egptr(); ++i){ - *(i-offset) = *i; - } - - size_t retval = 0; - //Save operating flags from file descriptor - int fcntl_flags = fcntl(fileno(fp), F_GETFL); - retval = 0; - - //Set to non_blocking mode - fcntl(fileno(fp), F_SETFL, fcntl_flags | O_NONBLOCK); - - //Fill rest of buffer - retval = fread(basic_streambuf::egptr() - - basic_streambuf::gptr() + basic_streambuf::eback(), - sizeof(charT), - offset, - fp - ); - - //Clear problems where we didn't read in enough characters - if(EAGAIN == errno){ - clearerr(fp); - } - - //Restore file descriptor clase - fcntl(fileno(fp), F_SETFL, fcntl_flags); - - //Now we are going to make sure that we read in at least one character. The hard way. - if(retval == 0){ - fcntl_flags = fcntl(fileno(fp), F_GETFL); - //Set to blocking mode - fcntl(fileno(fp), F_SETFL, fcntl_flags & ~O_NONBLOCK); - - retval = fread(basic_streambuf::egptr() - - basic_streambuf::gptr() + basic_streambuf::eback(), - sizeof(charT), - 1, - fp - ); - - //Restore file descriptor clase - fcntl(fileno(fp), F_SETFL, fcntl_flags); - - } - - if(retval !=offset){ //Slide buffer forward again - for(size_t i = 0; i < amountData + retval; ++i){ - *(basic_streambuf::egptr() - i - 1) = - *(basic_streambuf::eback() + amountData + retval - i - 1); - } - } - - basic_streambuf::mgnext -= retval; - - if( (retval <= 0 && feof(fp)) || ferror(fp) ){ - return traits::eof(); - } - - return traits::to_int_type(*basic_streambuf::gptr()); - } - virtual _UCXXEXPORT int_type uflow(){ - bool dobump = (basic_streambuf::gptr() != 0); - int_type retval = underflow(); - if(dobump){ - basic_streambuf::gbump(1); - } - return retval; - } - virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){ - if(is_open() == false || - basic_streambuf::gptr() == basic_streambuf::eback()) - { - return traits::eof(); - } - if(traits::eq_int_type(c,traits::eof()) == false){ - if(traits::eq(traits::to_char_type(c), basic_streambuf::gptr()[-1]) == true){ - basic_streambuf::gbump(-1); - }else{ - basic_streambuf::gbump(-1); - basic_streambuf::gptr()[0] = c; - } - return c; - }else{ - basic_streambuf::gbump(-1); - return traits::not_eof(c); - } - } - - virtual _UCXXEXPORT int_type overflow(int_type c = traits::eof()){ - if(is_open() == false){ - //Can't do much - return traits::eof(); - } - if(basic_streambuf::pbase() == 0){ //Unbuffered - elliminate dupe code below - if(fputc(c, fp) == EOF){ - return traits::eof(); - } - return c; - } - if(basic_streambuf::pbase() == 0 && traits::eq_int_type(c,traits::eof()) ){ - //Nothing to flush - return traits::not_eof(c); - } - size_t r = basic_streambuf::pptr() - basic_streambuf::pbase(); - - if( r == 0 && traits::eq_int_type(c,traits::eof()) ){ - return traits::not_eof(c); - }else if (r == 0 ){ - if(fputc(c, fp) == EOF){ - return traits::eof(); - } - return c; - } - - size_t totalChars = r; - - char_type *buffer = 0; - if(traits::eq_int_type(c,traits::eof())){ - buffer = new char_type[r]; - }else{ - buffer = new char_type[r+1]; - buffer[r] = c; - totalChars++; - } - - traits::copy(buffer, basic_streambuf::pbase(), r); -// memcpy(buffer, basic_streambuf::pbase(), r); - - size_t retval = fwrite(buffer, sizeof(charT), totalChars, fp); - if(retval !=totalChars){ - if(retval == 0){ - delete [] buffer; - return traits::eof(); - } - basic_streambuf::pbump(-retval); - fprintf(stderr, "***** Did not write the full buffer out. Should be: %d, actually: %d\n", - totalChars, retval); - }else{ - basic_streambuf::pbump(-r); - } - - delete [] buffer; - return traits::not_eof(c); - } - - virtual _UCXXEXPORT basic_streambuf* setbuf(char_type* s, streamsize n){ - if(s == 0 && n == 0){ //Unbuffered - if(pbuffer !=0){ - delete [] pbuffer; - } - if(gbuffer !=0){ - delete [] gbuffer; - } - pbuffer = 0; - gbuffer = 0; - }else if(basic_streambuf::gptr() !=0 && - basic_streambuf::gptr()==basic_streambuf::egptr()) - { - delete [] pbuffer; - pbuffer = s; - } - return this; - } - virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way, - ios_base::openmode = ios_base::in | ios_base::out) - { - if(is_open() == false){ - return -1; - } - int whence = SEEK_SET; // if(way == basic_ios::beg) - off_type position = off; - - if(way == basic_ios::cur){ - whence = SEEK_CUR; - position -= (basic_streambuf::egptr() - basic_streambuf::gptr()); - }else if(way == basic_ios::end){ - whence = SEEK_END; - } - - sync(); - - int retval = fseek( - fp, - sizeof(charT)*(position), - whence - ); - - //Invalidate read buffer - basic_streambuf::gbump( - basic_streambuf::egptr() - basic_streambuf::gptr() - ); - - if(-1 != retval){ - retval = ftell(fp); - } - - return retval; - } - virtual _UCXXEXPORT pos_type seekpos(pos_type sp, ios_base::openmode = ios_base::in | ios_base::out){ - if(is_open() == false){ - return -1; - } - sync(); - - int retval = fseek(fp,sizeof(charT)* sp, SEEK_SET); - - //Invalidate read buffer - basic_streambuf::gbump(basic_streambuf::egptr() - basic_streambuf::gptr()); - if(retval > -1){ - return sp; - } - return -1; - } - virtual _UCXXEXPORT int sync(){ - if(pbuffer !=0){ - if(overflow() == traits::eof()){ - return -1; - } - } - if(0 != fp && 0 != fflush(fp)){ - return -1; - } - return 0; - } - virtual _UCXXEXPORT void imbue(const locale&){ - return; - } - - - virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){ - if(is_open() == false){ - return 0; - } - //Check to see if buffered - - //Check to see if we can buffer the data - streamsize buffer_avail = basic_streambuf::epptr() - basic_streambuf::pptr(); - - if(n > buffer_avail){ //Flush buffer and write directly - overflow(); //Flush the buffer - return fwrite(s, sizeof(charT), n, fp); - } - - //Add to buffer to be written later - - traits::copy(basic_streambuf::pptr(), s, n); - basic_streambuf::pbump(n); - - return n; - } - - FILE * fp; - char_type * pbuffer; - char_type * gbuffer; - bool append; - }; - - -#ifdef __UCLIBCXX_HAS_WCHAR__ - -template <> _UCXXEXPORT basic_filebuf >::int_type - basic_filebuf >::overflow(int_type c); - -template <> _UCXXEXPORT basic_filebuf >::int_type - basic_filebuf >::underflow(); - -#endif //__UCLIBCXX_HAS_WCHAR__ - - - -#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_FSTREAM__ - -#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 c); - template <> _UCXXEXPORT filebuf::int_type filebuf::underflow (); - - template <> _UCXXEXPORT basic_streambuf > * filebuf::setbuf(char * s, streamsize n); - template <> _UCXXEXPORT streamsize filebuf::xsputn(const char* s, streamsize n); - -#endif -#endif - - - template class _UCXXEXPORT basic_ifstream - : public basic_istream - { - public: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - _UCXXEXPORT basic_ifstream(): basic_ios(&sb), basic_istream(&sb){ - //Passing the address of sb - } - explicit _UCXXEXPORT basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in) - : basic_ios(&sb), basic_istream(&sb) - { - if(sb.open(s, mode) == 0){ - basic_ios::setstate(ios_base::failbit); - } - } - - virtual _UCXXEXPORT ~basic_ifstream(){ - - } - - _UCXXEXPORT basic_filebuf* rdbuf() const{ - return (basic_filebuf*)&sb; - } - _UCXXEXPORT bool is_open() const{ - return sb.is_open(); - } - _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::in){ - if(sb.open(s, mode) == 0){ - basic_ios::setstate(ios_base::failbit); - } - } - _UCXXEXPORT void close(){ - sb.close(); - } - private: - basic_filebuf sb; - }; - - - template class _UCXXEXPORT basic_ofstream - : public basic_ostream - { - public: - typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - _UCXXEXPORT basic_ofstream() : basic_ios(&sb), basic_ostream(&sb){ - - } - - virtual _UCXXEXPORT ~basic_ofstream(); - - explicit _UCXXEXPORT basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out | ios_base::trunc) : - basic_ios(&sb), basic_ostream(&sb) - { - if(sb.open(s, mode) == 0){ - basic_ios::setstate(ios_base::failbit); - } - } - - _UCXXEXPORT basic_filebuf* rdbuf() const{ - return (basic_filebuf*)&sb; - } - - _UCXXEXPORT bool is_open() const{ - return sb.is_open(); - } - _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::out | ios_base::trunc){ - if(sb.open(s, mode) == 0){ - basic_ios::setstate(ios_base::failbit); - } - } - _UCXXEXPORT void close(){ - sb.close(); - } - private: - basic_filebuf sb; - }; - - template _UCXXEXPORT basic_ofstream::~basic_ofstream(){ - basic_ostream::flush(); - } - - - template class _UCXXEXPORT basic_fstream - : public basic_iostream - { - public: - typedef charT char_type; - typedef typename traits::int_type ins_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; - - _UCXXEXPORT basic_fstream(): basic_ios(&sb), basic_iostream(&sb){ } - - explicit _UCXXEXPORT basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out): - basic_ios(&sb), basic_iostream(&sb) - { - if(sb.open(s, mode) == 0){ - basic_ios::setstate(ios_base::failbit); - } - } - - _UCXXEXPORT basic_filebuf* rdbuf() const{ - return (basic_filebuf*)&sb; - } - _UCXXEXPORT bool is_open() const{ - return sb.is_open(); - } - _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out){ - if(sb.open(s, mode) == 0){ - basic_ios::setstate(ios_base::failbit); - } - } - _UCXXEXPORT void close(){ - sb.close(); - } - private: - basic_filebuf sb; - }; - - - -#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ -#ifndef __UCLIBCXX_COMPILE_FSTREAM__ - -#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 -#endif - - - -} - -#pragma GCC visibility pop - -#endif - -#endif \ No newline at end of file Index: branches/slice/i386/modules/include/ctime =================================================================== --- branches/slice/i386/modules/include/ctime (revision 726) +++ branches/slice/i386/modules/include/ctime (revision 727) @@ -1,81 +0,0 @@ -// -*- C++ -*- forwarding header. - -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 -// Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, 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 General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -// -// ISO C++ 14882: 20.5 Date and time -// - -/** @file ctime - * This is a Standard C++ Library file. You should @c #include this file - * in your programs, rather than any of the "*.h" implementation files. - * - * This is the C++ version of the Standard C Library header @c time.h, - * and its contents are (mostly) the same as that header, but are all - * contained in the namespace @c std. - */ - -#ifndef _CPP_CTIME -#define _CPP_CTIME 1 - -#pragma GCC system_header - -#include - -#include - -// Get rid of those macros defined in in lieu of real functions. -#undef clock -#undef difftime -#undef mktime -#undef time -#undef asctime -#undef ctime -#undef gmtime -#undef localtime -#undef strftime - -namespace std -{ - using ::clock_t; - using ::time_t; - using ::tm; - - using ::clock; - using ::difftime; - using ::mktime; - using ::time; - using ::asctime; - using ::ctime; - using ::gmtime; - using ::localtime; - using ::strftime; -} - -#endif Index: branches/slice/i386/modules/include/clocale =================================================================== --- branches/slice/i386/modules/include/clocale (revision 726) +++ branches/slice/i386/modules/include/clocale (revision 727) @@ -1,30 +0,0 @@ -/* 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 -*/ - -#ifndef __STD_HEADER_CLOCALE -#define __STD_HEADER_CLOCALE 1 - -#include - -namespace std { - using ::lconv; - using ::setlocale; - using ::localeconv; -} - -#endif // __STD_HEADER_CLOCALE Index: branches/slice/i386/modules/include/char_traits =================================================================== --- branches/slice/i386/modules/include/char_traits (revision 726) +++ branches/slice/i386/modules/include/char_traits (revision 727) @@ -1,198 +0,0 @@ -/* 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 - -#ifdef __UCLIBCXX_HAS_WCHAR__ -#include -#include -#endif - -#ifndef __HEADER_CHAR_TRAITS -#define __HEADER_CHAR_TRAITS 1 - -namespace std{ - /* Inlining all wrapped function calls to shrink the amount of code generated*/ - //Typedefs to use for stuff - typedef signed int char_traits_off_type; - - //Generic char_traits - template struct _UCXXEXPORT char_traits { }; - - //Specialize for char - template<> struct _UCXXEXPORT char_traits { - typedef char char_type; - typedef short int int_type; - typedef char_traits_off_type off_type; - typedef char_traits_off_type pos_type; - typedef char state_type; - - inline static void assign(char_type & c, const char_type & d) { c = d; } - - static bool eq(const char_type& c1, const char_type& c2); - - static char_type to_char_type(const int_type & i); - - inline static int_type to_int_type(const char_type & c){ - return (short int)(unsigned char)c; - } - - inline static bool eq_int_type(const int_type & a, const int_type & b){ - if(a==b){ - return true; - } - return false; - } - - - inline static bool lt(const char_type& c1, const char_type& c2){ - if(strncmp(&c1, &c2, 1) < 0){ - return true; - } - return false; - } - - inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ - return (char*) memmove(s1, s2, n); - } - - inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ - for(unsigned long int i=0; i< n; ++i){ - assign(s1[i], s2[i]); - } - return s1 + n; - } - - inline static char_type* assign(char_type* s, size_t n, char_type a){ - return (char *)memset(s, a, n); - } - - inline static int compare(const char_type* s1, const char_type* s2, size_t n){ - return strncmp(s1, s2, n); - } - - inline static size_t length(const char_type* s){ - return strlen(s); - } - - static const char_type* find(const char_type* s, int n, const char_type& a); - - inline static char_type eos() { return 0; } - inline static int_type eof() { return -1; } - inline static int_type not_eof(const int_type & i) { - if(i == -1){ - return 0; - } else { - return i; - } - } - static state_type get_state(pos_type p){ - p = p; - state_type a; - return a; - } - }; - - -#ifdef __UCLIBCXX_HAS_WCHAR__ - template<> struct _UCXXEXPORT char_traits { - typedef wchar_t char_type; - typedef wint_t int_type; - typedef char_traits_off_type off_type; - typedef char_traits_off_type pos_type; - typedef mbstate_t state_type; - - static void assign(char_type & c, const char_type & d){ c=d; } - - static char_type to_char_type(const int_type & i){ - return i; - } - - static int_type to_int_type(const char_type & c){ - return c; - } - - inline static bool eq_int_type(const int_type & a, const int_type & b){ - if(a==b){ - return true; - } - return false; - } - - inline static bool eq(const char_type& c1, const char_type& c2){ - if(wcsncmp(&c1, &c2, 1) == 0){ - return true; - } - return false; - } - - inline static bool lt(const char_type& c1, const char_type& c2){ - if(wcsncmp(&c1, &c2, 1) < 0){ - return true; - } - return false; - } - - inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ - return (char_type*) memmove(s1, s2, n * sizeof(char_type)); - } - - inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ - for(unsigned long int i=0; i< n; ++i){ - assign(s1[i], s2[i]); - } - return s1 + n; - } - - inline static char_type* assign(char_type* s, size_t n, char_type a){ - return (char_type *)memset(s, a, n); /*FIXME*/ - } - - inline static int compare(const char_type* s1, const char_type* s2, size_t n){ - return wcsncmp(s1, s2, n); - } - - inline static size_t length(const char_type* s){ - return wcslen(s); - } - - static const char_type* find(const char_type* s, int n, const char_type& a); - - inline static char_type eos() { return 0; } - inline static int_type eof() { return WEOF; } - inline static int_type not_eof(const int_type & i) { - if(i == WEOF){ - return (int_type)0; - } else { - return i; - } - } - static state_type get_state(pos_type){ - state_type a; - return a; - } - }; -#endif - -} - -#endif - Index: branches/slice/i386/modules/include/associative_base =================================================================== --- branches/slice/i386/modules/include/associative_base (revision 726) +++ branches/slice/i386/modules/include/associative_base (revision 727) @@ -1,643 +0,0 @@ -/* Copyright (C) 2007 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 - - -#ifndef __STD_HEADER_ASSOCIATIVE_BASE -#define __STD_HEADER_ASSOCIATIVE_BASE - -#pragma GCC visibility push(default) - -namespace std{ - - -/* - * The basic premis here is that most of the code used by map, multimap, set and - * multiset is really common. There are a number of interface additions, and - * considerations about how to address multiple enteries with the same key. - * The goal is that the code tree/storage code should be here, and managing - * single or moultiple counts will be loeft to subclasses. - * Yes, inheritence for the purpose of code sharing is usually a bad idea. However, - * since our goal is to reduce tht total amount of code written and the overall binary - * size, this seems to be the best approach possible. - */ - -template, class Allocator = allocator > class __base_associative; -template class _associative_iter; -template class _associative_citer; - -template, class Allocator = allocator > class __single_associative; -template, class Allocator = allocator > class __multi_associative; - -template class _UCXXEXPORT __base_associative{ - -protected: - -public: - typedef Key key_type; - typedef ValueType value_type; - typedef Compare key_compare; - typedef Allocator allocator_type; - typedef typename Allocator::reference reference; - typedef typename Allocator::const_reference const_reference; - typedef typename Allocator::size_type size_type; - typedef typename Allocator::difference_type difference_type; - typedef typename Allocator::pointer pointer; - typedef typename Allocator::const_pointer const_pointer; - typedef __base_associative associative_type; - - typedef _associative_iter iterator; - typedef _associative_citer const_iterator; - typedef typename std::reverse_iterator reverse_iterator; - typedef typename std::reverse_iterator const_reverse_iterator; - - - explicit __base_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) - : c(comp), value_to_key(v_to_k) { } -protected: - __base_associative(const associative_type& x) - : c(x.c), backing(x.backing), value_to_key(x.value_to_key) { } - -public: - ~__base_associative(){ - } - - bool empty() const{ - return backing.empty(); - } - size_type size() const{ - return backing.size(); - } - size_type max_size() const{ - return backing.max_size(); - } - - iterator begin(){ - return iterator(backing.begin()); - } - - const_iterator begin() const{ - return const_iterator(backing.begin()); - } - - iterator end() { - return iterator(backing.end()); - } - - const_iterator end() const{ - return const_iterator(backing.end()); - } - - reverse_iterator rbegin(){ - return reverse_iterator(end()); - } - - const_reverse_iterator rbegin() const{ - return const_reverse_iterator(end()); - } - - reverse_iterator rend(){ - return reverse_iterator(begin()); - } - - const_reverse_iterator rend() const{ - return const_reverse_iterator(begin()); - } - - - iterator lower_bound(const key_type &x); - const_iterator lower_bound(const key_type &x) const; - iterator upper_bound(const key_type &x); - const_iterator upper_bound(const key_type &x) const; - - pair equal_range(const key_type& x){ - pair retval; - retval.first = lower_bound(x); - retval.second = retval.first; - while(retval.second != end() && !c(x, value_to_key(*retval.second))){ - ++retval.second; - } - return retval; - } - pair equal_range(const key_type& x) const{ - pair retval; - retval.first = lower_bound(x); - retval.second = retval.first; - while(retval.second != end() && !c(x, value_to_key(*retval.second))){ - ++retval.second; - } - return retval; - } - - iterator find(const key_type& x){ - iterator retval = lower_bound(x); - if(retval == end()){ - return retval; - } - if(c(x, value_to_key(*retval))){ - return end(); - } - return retval; - } - const_iterator find(const key_type& x) const{ - const_iterator retval = lower_bound(x); - if(retval == end()){ - return retval; - } - if(c(x, value_to_key(*retval))){ - return end(); - } - return retval; - } - size_type count(const key_type& x) const{ - size_type retval(0); - const_iterator first = lower_bound(x); - while(first != end() && !c(x, value_to_key(*first))){ - ++retval; - ++first; - } - return retval; - } - - void clear(){ - backing.clear(); - } - - void erase(iterator pos){ - backing.erase(pos.base_iterator()); - } - size_type erase(const key_type& x){ - size_type count(0); - iterator start = lower_bound(x); - iterator end = upper_bound(x); - while(start != end){ - start = backing.erase(start.base_iterator()); - ++count; - } - return count; - } - void erase(iterator first, iterator last){ - while(first != last){ - backing.erase(first.base_iterator()); - ++first; - } - } - - key_compare key_comp() const{ - return c; - } - - __base_associative &operator=(const __base_associative & x){ - c = x.c; - backing = x.backing; - value_to_key = x.value_to_key; - return *this; - } - bool operator==(const __base_associative & x){ - return x.backing == backing; - } - bool operator!=(const __base_associative & x){ - return !(x.backing == backing); - } - -protected: - void swap(__base_associative & x); - - Compare c; - std::list backing; - - const key_type (*value_to_key)(const value_type); - -}; - - -/* - * Tree interators for the base associative class - */ - -template class _associative_citer - : public std::iterator< - bidirectional_iterator_tag, - ValueType, - typename Allocator::difference_type, - ValueType*, - ValueType& - > -{ -protected: - typedef std::list listtype; - - typename listtype::const_iterator base_iter; - friend class _associative_iter; -public: - _associative_citer() { } - _associative_citer(const _associative_citer & m) - : base_iter(m.base_iter) { } - _associative_citer(const typename listtype::const_iterator & m) - : base_iter(m) { } - ~_associative_citer() { } - ValueType operator*() const{ - return *base_iter; - } - const ValueType * operator->() const{ - return &(*base_iter); - } - _associative_citer & operator=(const _associative_citer & m){ - base_iter = m.base_iter; - return *this; - } - bool operator==(const _associative_citer & m) const{ - return m.base_iter == base_iter; - } - bool operator!=(const _associative_citer & m) const{ - return m.base_iter != base_iter; - } - _associative_citer & operator++(){ - ++base_iter; - return *this; - } - _associative_citer operator++(int){ - //The following approach ensures that we only need to - //provide code for ++ in one place (above) - _associative_citer temp(base_iter); - ++base_iter; - return temp; - } - _associative_citer & operator--(){ - --base_iter; - return *this; - } - _associative_citer operator--(int){ - //The following approach ensures that we only need to - //provide code for -- in one place (above) - _associative_citer temp(base_iter); - --base_iter; - return temp; - } - - //This is an implementation-defined function designed to make internals work correctly - typename listtype::const_iterator base_iterator(){ - return base_iter; - } - -}; - - -template class _associative_iter - : public std::iterator< - bidirectional_iterator_tag, - ValueType, - typename Allocator::difference_type, - ValueType*, - ValueType& - > -{ -protected: - typedef std::list listtype; - - typename listtype::iterator base_iter; - typedef _associative_citer _associative_citer; - - -public: - _associative_iter() { } - _associative_iter(const _associative_iter & m) - : base_iter(m.base_iter) { } - _associative_iter(const typename listtype::iterator & m) - : base_iter(m) { } - ~_associative_iter() { } - const ValueType & operator*() const{ - return *base_iter; - } - ValueType & operator*(){ - return *base_iter; - } - ValueType * operator->(){ - return &(*base_iter); - } - const ValueType * operator->() const{ - return &(*base_iter); - } - _associative_iter & operator=(const _associative_iter & m){ - base_iter = m.base_iter; - return *this; - } - bool operator==(const _associative_iter & m) const{ - return m.base_iter == base_iter; - } - bool operator==(const _associative_citer & m) const{ - return m.base_iter == base_iter; - } - bool operator!=(const _associative_iter & m) const{ - return m.base_iter != base_iter; - } - bool operator!=(const _associative_citer & m) const{ - return m.base_iter != base_iter; - } - _associative_iter & operator++(){ - ++base_iter; - return *this; - } - _associative_iter operator++(int){ - //The following approach ensures that we only need to - //provide code for ++ in one place (above) - _associative_iter temp(base_iter); - ++base_iter; - return temp; - } - _associative_iter & operator--(){ - --base_iter; - return *this; - } - _associative_iter operator--(int){ - //The following approach ensures that we only need to - //provide code for -- in one place (above) - _associative_iter temp(base_iter); - --base_iter; - return temp; - } - operator _associative_citer() const{ - return _associative_citer(base_iter); - } - typename listtype::iterator base_iterator(){ - return base_iter; - } - const typename listtype::iterator base_iterator() const{ - return base_iter; - } - -}; - - - // The lower_bound code is really crappy linear search. However, it is a dead - // simple implimentation (easy to audit). It can also be easily replaced. - - - template - typename __base_associative::iterator - __base_associative::lower_bound(const key_type &x) - { - iterator retval = begin(); - while(retval != end() && c(value_to_key(*retval), x)){ - ++retval; - } - return retval; - } - - template - typename __base_associative::const_iterator - __base_associative::lower_bound(const key_type &x) const - { - const_iterator retval = begin(); - while(retval != end() && c(value_to_key(*retval), x)){ - ++retval; - } - return retval; - } - - // Upper bound search is linear from the point of lower_bound. This is likely the best solution - // in all but the most pathalogical of cases. - - template - typename __base_associative::iterator - __base_associative::upper_bound(const key_type &x) - { - iterator retval = lower_bound(x); - while(retval != end() && !c(x, value_to_key(*retval))){ - ++retval; - } - return retval; - } - - template - typename __base_associative::const_iterator - __base_associative::upper_bound(const key_type &x) const - { - const_iterator retval = begin(); - while(retval != end() && !c(x, value_to_key(*retval))){ - ++retval; - } - return retval; - } - - - template - void __base_associative::swap(__base_associative& m) - { - Compare n = c; - c = m.c; - m.c = n; - - m.backing.swap(backing); - } - - -template class _UCXXEXPORT __single_associative : - public __base_associative -{ -protected: - typedef __base_associative base; - using base::backing; - - using base::c; - -public: - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - using base::find; - using base::count; - using base::lower_bound; - using base::upper_bound; - using base::equal_range; - - using base::operator=; - using base::operator==; - using base::operator!=; - - explicit __single_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) - : base(comp, A, v_to_k) { } - - template __single_associative( - InputIterator first, - InputIterator last, - const Compare& comp, - const Allocator& A, - const key_type (*v_to_k)(const value_type) - ) : base(comp, A, v_to_k) { - insert(first, last); - } - - pair insert(const value_type& x){ - pair retval; - iterator location = lower_bound(value_to_key(x)); - retval.second = true; - //Empty list or need to insert at end - if(end() == location){ - backing.push_back(x); - retval.first = --(end()); - return retval; - } - //Something in the list - if(c(value_to_key(x), value_to_key(*location))){ - location = backing.insert(location.base_iterator(), x); - retval.first = location; - }else{ - retval.second = false; - retval.first = location; - } - return retval; - } - - iterator insert(iterator position, const value_type& x){ - // FIXME - this is cheeting and probably should be more efficient since we are - // now log(n) to find for inserts - return insert(x).first; - } - - template void insert(InputIterator first, InputIterator last){ - while(first != last){ - insert(*first); - ++first; - } - } - -}; - - -template class _UCXXEXPORT __multi_associative : - public __base_associative -{ -protected: - typedef __base_associative base; - using base::backing; - - using base::c; - -public: - typedef typename base::key_type key_type; - typedef typename base::value_type value_type; - typedef typename base::key_compare key_compare; - typedef typename base::allocator_type allocator_type; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reverse_iterator reverse_iterator; - typedef typename base::const_reverse_iterator const_reverse_iterator; - - using base::begin; - using base::end; - using base::rbegin; - using base::rend; - - using base::empty; - using base::size; - using base::max_size; - - using base::find; - using base::count; - using base::lower_bound; - using base::upper_bound; - using base::equal_range; - - using base::operator=; - using base::operator==; - - - explicit __multi_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) - : base(comp, A, v_to_k) { } - - template __multi_associative( - InputIterator first, - InputIterator last, - const Compare& comp, - const Allocator& A, - const key_type (*v_to_k)(const value_type) - ) : base(comp, A, v_to_k) { - insert(first, last); - } - - iterator insert(const value_type& x){ - iterator location = lower_bound(value_to_key(x)); - - if(location == begin()){ - backing.push_front(x); - location = begin(); - }else{ - location = backing.insert(location.base_iterator(), x); - } - return location; - } - - iterator insert(iterator position, const value_type& x){ - // FIXME - this is cheeting and probably should be more efficient since we are - // now log(n) to find for inserts - return insert(x); - } - - template void insert(InputIterator first, InputIterator last){ - while(first != last){ - insert(*first); - ++first; - } - } -}; - - - - -} - -#pragma GCC visibility pop - -#endif //__STD_HEADER_ASSOCIATIVE_BASE - - Index: branches/slice/i386/modules/include/cassert =================================================================== --- branches/slice/i386/modules/include/cassert (revision 726) +++ branches/slice/i386/modules/include/cassert (revision 727) @@ -1,19 +0,0 @@ -/* 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 Index: branches/slice/i386/modules/include/string_iostream =================================================================== --- branches/slice/i386/modules/include/string_iostream (revision 726) +++ branches/slice/i386/modules/include/string_iostream (revision 727) @@ -1,146 +0,0 @@ -/* 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 - -#ifdef __UCLIBCXX_HAS_WCHAR__ -#include -#include -#endif - -#ifndef __HEADER_STD_STRING_IOSTREAM -#define __HEADER_STD_STRING_IOSTREAM 1 - -#pragma GCC visibility push(default) - -namespace std{ - - - -template _UCXXEXPORT basic_ostream& - operator<<(basic_ostream& os, const basic_string& str) -{ - return os.write(str.data(), str.length()); -} - -template _UCXXEXPORT basic_istream& - operator>>(basic_istream& is, basic_string& str) -{ - - typename basic_istream::sentry s(is); - if(s == false){ - return is; - } - - str.clear(); - - typename basic_istream::int_type c; - typename Allocator::size_type n = is.width(); - bool exitnow = false; - if(n == 0){ - n = str.max_size(); - } - -// //Clear out preliminary spaces first -// c = is.get(); -// while(isspace(c)){ -// c = is.get(); -// } -// -// is.putback(c); - - do{ - c = is.get(); - if(c == traits::eof() || isspace(c) || n == 0){ - is.putback(c); - exitnow = true; - }else{ - str.append(1, traits::to_char_type(c) ); - --n; - } - }while(exitnow == false); - return is; -} - -template _UCXXEXPORT basic_istream& - getline(basic_istream& is, basic_string& str, charT delim) -{ - typename basic_istream::sentry s(is); - if(s == false){ - return is; - } - - str.erase(); - - streamsize i = 0; - typename basic_istream::int_type c_i; - charT c; - unsigned int n = str.max_size(); - for(i=0;i _UCXXEXPORT basic_istream& - getline(basic_istream& is, basic_string& str) -{ - return getline(is, str, '\n'); -} - - -#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ -#ifndef __UCLIBCXX_COMPILE_STRING__ - - -#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ -template<> _UCXXEXPORT basic_istream >& operator>>( - basic_istream >& is, - basic_string, allocator >& str); -#endif - - -#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ -template<> _UCXXEXPORT basic_ostream >& - operator<<(basic_ostream >& os, - const basic_string, std::allocator >& str); - -#endif - - -#endif -#endif - - -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/func_exception =================================================================== --- branches/slice/i386/modules/include/func_exception (revision 726) +++ branches/slice/i386/modules/include/func_exception (revision 727) @@ -1,41 +0,0 @@ -/* 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 - - -#ifndef HEADER_IMPLEMENTATION_FUNC_EXCEPTION -#define HEADER_IMPLEMENTATION_FUNC_EXCEPTION - -#pragma GCC visibility push(default) - -namespace std{ - - _UCXXEXPORT void __throw_bad_alloc(); - _UCXXEXPORT void __throw_out_of_range(const char * message = 0); - _UCXXEXPORT void __throw_overflow_error(const char * message = 0); - _UCXXEXPORT void __throw_length_error(const char * message = 0); - _UCXXEXPORT void __throw_invalid_argument(const char * message = 0); -} - -#pragma GCC visibility pop - -#endif - Index: branches/slice/i386/modules/include/support =================================================================== --- branches/slice/i386/modules/include/support (revision 726) +++ branches/slice/i386/modules/include/support (revision 727) @@ -1,167 +0,0 @@ -/* 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 - -#ifndef HEADER_ULC_SUPPORT -#define HEADER_ULC_SUPPORT 1 - -using namespace std; - -//From C++ ABI spec -typedef enum { - _URC_NO_REASON = 0, - _URC_FOREIGN_EXCEPTION_CAUGHT = 1, - _URC_FATAL_PHASE2_ERROR = 2, - _URC_FATAL_PHASE1_ERROR = 3, - _URC_NORMAL_STOP = 4, - _URC_END_OF_STACK = 5, - _URC_HANDLER_FOUND = 6, - _URC_INSTALL_CONTEXT = 7, - _URC_CONTINUE_UNWIND = 8 -} _Unwind_Reason_Code; - - -typedef void (*_Unwind_Exception_Cleanup_Fn) - (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc); - -//The following definitions were grabbed from the gcc implementation -typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); -typedef unsigned _Unwind_Word __attribute__((__mode__(__word__))); -typedef signed _Unwind_Sword __attribute__((__mode__(__word__))); -typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); -typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, struct _Unwind_Exception *); - -typedef int _Unwind_Action; -static const _Unwind_Action _UA_SEARCH_PHASE = 1; -static const _Unwind_Action _UA_CLEANUP_PHASE = 2; -static const _Unwind_Action _UA_HANDLER_FRAME = 4; -static const _Unwind_Action _UA_FORCE_UNWIND = 8; - -const _Unwind_Exception_Class __uclibcxx_exception_class = (((((((( - _Unwind_Exception_Class) 'u' << 8 | (_Unwind_Exception_Class) 'l') << 8 - | (_Unwind_Exception_Class) 'i') << 8 | (_Unwind_Exception_Class) 'b') << 8 - | (_Unwind_Exception_Class) 'C')<< 8 | (_Unwind_Exception_Class) '+') << 8 - | (_Unwind_Exception_Class) '+') << 8 | (_Unwind_Exception_Class) '\0'); - - -#define _UA_SEARCH_PHASE 1 -#define _UA_CLEANUP_PHASE 2 -#define _UA_HANDLER_FRAME 4 -#define _UA_FORCE_UNWIND 8 -#define _UA_END_OF_STACK 16 - -struct _Unwind_Exception{ - _Unwind_Exception_Class exception_class; //Type of exception, eg ulibC++\0 - _Unwind_Exception_Cleanup_Fn exception_cleanup; //Destructor if from diff runtime - _Unwind_Word private_1; //Don't touch at all! - _Unwind_Word private_2; //Don't touch at all! -} __attribute__((__aligned__)); - - -//The following structure is system-dependent and defined by the compiler -//Thus it's definition was copied from the gcc 3.4.0 header files -struct _Unwind_Context; -//{ -// void *reg[DWARF_FRAME_REGISTERS+1]; -// void *cfa; -// void *ra; -// void *lsda; -// struct dwarf_eh_bases bases; -// _Unwind_Word args_size; -//}; - - - -_Unwind_Reason_Code _Unwind_RaiseException ( struct _Unwind_Exception *exception_object ); - -//_Unwind_ForcedUnwind - -typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) - (int version, _Unwind_Action actions, _Unwind_Exception_Class exceptionClass, - struct _Unwind_Exception *exceptionObject, - struct _Unwind_Context *context, void *stop_parameter ); - -_Unwind_Reason_Code _Unwind_ForcedUnwind ( - struct _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, - void *stop_parameter ); - -void _Unwind_Resume (struct _Unwind_Exception *exception_object); -void _Unwind_DeleteException (struct _Unwind_Exception *exception_object); - -_Unwind_Word _Unwind_GetGR (struct _Unwind_Context *context, int index); -void _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word); - -_Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *context); -void _Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr new_value); - -_Unwind_Ptr _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context); -_Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *context); - -_Unwind_Reason_Code (*__personality_routine) - (int version, //Should be 1 - _Unwind_Action actions, //Actions the routine will perform (bitmask) - _Unwind_Exception_Class exceptionClass, //Type of exception - vendor is high 4 bytes - struct _Unwind_Exception *exceptionObject, //Points to exception header - struct _Unwind_Context *context); //Unwinder state information - - -/*The following part is the Level II ABI which is required for compatability*/ -//This might be the only stuff that *I* need to implement - -struct __cxa_exception { - std::type_info *exceptionType; //Type of thrown exception - void (*exceptionDestructor) (void *); //Pointer to the destructor - unexpected_handler unexpectedHandler; //Unexpected handler to use - terminate_handler terminateHandler; //Terminate handle to use - __cxa_exception *nextException; //per thread linked list - - int handlerCount; //How many handlers have caught this - int handlerSwitchValue; - const char *actionRecord; - const char *languageSpecificData; - void *catchTemp; - void *adjustedPtr; - - _Unwind_Exception unwindHeader; -}; - -struct __cxa_eh_globals { - __cxa_exception *caughtExceptions; - unsigned int uncaughtExceptions; -}; - -extern "C" __cxa_eh_globals *__cxa_get_globals(void); //Return ptr to the eh_globals object for current thread -extern "C" __cxa_eh_globals *__cxa_get_globals_fast(void); //Same as above, assumes that above called at least once - -extern "C" void *__cxa_allocate_exception(size_t thrown_size); //Allocate space for exception plus header -extern "C" void __cxa_free_exception(void *thrown_exception); //Free space allocated from the above - -extern "C" void __cxa_throw (void *thrown_exception, //This is the actual throw call -// std::type_info *tinfo, //Type of object - void * tinfo, //Type of object - void (*dest) (void *) ); //Pointer to destructor destroy object - - -#endif - - - Index: branches/slice/i386/modules/include/types.h =================================================================== --- branches/slice/i386/modules/include/types.h (revision 0) +++ branches/slice/i386/modules/include/types.h (revision 727) @@ -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: branches/slice/i386/modules/uClibc++/include/iostream =================================================================== --- branches/slice/i386/modules/uClibc++/include/iostream (revision 0) +++ branches/slice/i386/modules/uClibc++/include/iostream (revision 727) @@ -0,0 +1,101 @@ +/* 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 + +#ifndef __HEADER_STD_IOSTREAM +#define __HEADER_STD_IOSTREAM 1 + +#include +#include +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +namespace std{ +#ifdef __UCLIBCXX_SUPPORT_CIN__ + extern istream cin; +#endif +#ifdef __UCLIBCXX_SUPPORT_COUT__ + extern ostream cout; +#endif +#ifdef __UCLIBCXX_SUPPORT_CERR__ + extern ostream cerr; +#endif +#ifdef __UCLIBCXX_SUPPORT_CLOG__ + extern ostream clog; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCIN__ + extern wistream wcin; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCOUT__ + extern wostream wcout; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCERR__ + extern wostream wcerr; +#endif +#ifdef __UCLIBCXX_SUPPORT_WCLOG__ + extern wostream wclog; +#endif + + + template class _UCXXEXPORT basic_iostream : + public basic_istream, public basic_ostream + { + public: + // constructor/destructor + explicit _UCXXEXPORT basic_iostream(basic_streambuf* sb); + virtual _UCXXEXPORT ~basic_iostream(); //Below + }; + + template _UCXXEXPORT + basic_iostream:: basic_iostream(basic_streambuf* sb) + : basic_ios(sb), basic_istream(sb), basic_ostream(sb) + { + return; + } + + + template _UCXXEXPORT basic_iostream::~basic_iostream(){ + return; + } + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_IOSTREAM__ + + template <> _UCXXEXPORT basic_iostream >:: + basic_iostream(basic_streambuf >* sb); + template <> _UCXXEXPORT basic_iostream >::~basic_iostream(); + +#endif +#endif +#endif + + + +} + +#pragma GCC visibility pop + +#endif Index: branches/slice/i386/modules/uClibc++/include/cstdio =================================================================== --- branches/slice/i386/modules/uClibc++/include/cstdio (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cstdio (revision 727) @@ -0,0 +1,75 @@ +/* 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 + + 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 + +#ifndef __HEADER_CSTDIO +#define __HEADER_CSTDIO 1 + + +namespace std{ + using ::FILE; + using ::fpos_t; + + using ::clearerr; + using ::fclose; + using ::feof; + using ::ferror; + using ::fflush; + using ::fgetc; + using ::fgetpos; + using ::fgets; + using ::fopen; + using ::fprintf; + using ::fputc; + using ::fputs; + using ::fread; + using ::freopen; + using ::fscanf; + using ::fseek; + using ::fsetpos; + using ::ftell; + using ::fwrite; + using ::getc; + using ::getchar; + using ::gets; + using ::perror; + using ::printf; + using ::putc; + using ::putchar; + using ::puts; + using ::remove; + using ::rename; + using ::rewind; + using ::scanf; + using ::setbuf; + using ::setvbuf; + using ::sprintf; + using ::sscanf; + using ::tmpfile; + using ::tmpnam; + using ::ungetc; + using ::vfprintf; + using ::vprintf; + using ::vsprintf; +} + + + +#endif + Index: branches/slice/i386/modules/uClibc++/include/cstdarg =================================================================== --- branches/slice/i386/modules/uClibc++/include/cstdarg (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cstdarg (revision 727) @@ -0,0 +1,60 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 20.4.6 C library +// + +/** @file cstdarg + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c stdarg.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CSTDARG +#define _CPP_CSTDARG 1 + +#pragma GCC system_header + +#include + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef va_end +#define va_end(ap) va_end (ap) +#endif + +namespace std +{ + using ::va_list; +} + +#endif Index: branches/slice/i386/modules/uClibc++/include/map.old =================================================================== --- branches/slice/i386/modules/uClibc++/include/map.old (revision 0) +++ branches/slice/i386/modules/uClibc++/include/map.old (revision 727) @@ -0,0 +1,1163 @@ +/* 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 + + +#ifndef __STD_HEADER_MAP +#define __STD_HEADER_MAP + +#pragma GCC visibility push(default) + +namespace std{ + + +template, class Allocator = allocator > class __base_map; +template, class Allocator = allocator > class map; +template, class Allocator = allocator > class multimap; + +template class __map_iter; +template class __map_citer; + +/* The code for the map containers is split up into two classes. + * The first class, __base_map holds all of the data and does much of the iterator-based + * work. Then the classes map and multimap inherit from there. This was done to reduce + * the redundancy of code (And thus errors which might crop up), as well as possibly + * reducing the size of binaries if both map and multimap are used, along with the same + * template parameters. + */ + + + +//All base classes first (__base_map, iterators, value_compare) and it's associated code + + +template class _UCXXEXPORT __base_map{ + +protected: + friend class __map_iter; + friend class __map_citer; + +public: + typedef __base_map map_type; + typedef Key key_type; + typedef T mapped_type; + typedef pair value_type; + typedef Compare key_compare; + typedef Allocator allocator_type; + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef __map_iter iterator; + typedef __map_citer const_iterator; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + typedef typename std::reverse_iterator reverse_iterator; + typedef typename std::reverse_iterator const_reverse_iterator; + + class value_compare; + + explicit __base_map(const Compare& comp = Compare(), const Allocator& al = Allocator()); + __base_map(const map_type& x); + ~__base_map(); + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + + bool empty() const; + size_type size() const; + size_type max_size() const; + + iterator lower_bound(const key_type& x); + const_iterator lower_bound(const key_type& x) const; + + void swap(map_type & x); + void clear(); + + key_compare key_comp() const; +// value_compare value_comp() const; + +protected: + + deque, allocator > > data; + Compare c; + +}; + + + //Implementations + + template class _UCXXEXPORT __map_citer + : public std::iterator< + bidirectional_iterator_tag, + std::pair, + typename Allocator::difference_type, + std::pair*, + std::pair& + > + { + protected: + typedef __base_map Map; + + friend class __base_map; + friend class __base_map::iterator; + + friend class map; + friend class multimap; + + typename Map::size_type element; + const Map * container; + public: + __map_citer() : element(0), container(0) { } + __map_citer(const typename Map::const_iterator & m) + : element(m.element), container(m.container) { } + __map_citer(typename Map::size_type e, const Map * const c) + : element(e), container(c) { } + ~__map_citer() { } + + typename Map::value_type operator*() const{ + return container->data[element]; + } + const typename Map::value_type * operator->() const{ + return &(container->data[element]); + } + __map_citer & operator=(const typename Map::const_iterator & m){ + element = m.element; + container = m.container; + return *this; + } + bool operator==(const typename Map::const_iterator & m) const { + return (m.element == element && m.container == container); + } + bool operator!=(const typename Map::const_iterator & m) const { + return (m.element != element || m.container != container); + } + __map_citer & operator++(){ + ++element; + return *this; + } + __map_citer operator++(int){ + __map_citer temp(*this); + ++element; + return temp; + } + __map_citer & operator--(){ + --element; + return *this; + } + __map_citer operator--(int){ + __map_citer temp(*this); + --element; + return temp; + } + + }; + + + template class _UCXXEXPORT __map_iter + : public std::iterator< + bidirectional_iterator_tag, + std::pair, + typename Allocator::difference_type, + std::pair*, + std::pair& + > + { + protected: + typedef class __base_map Map; + + //FIXME - Find a way to use template parameters or something. This will do for now + friend class __base_map; + friend class __base_map::const_iterator; + + friend class map; + friend class multimap; + + typename Map::size_type element; + Map * container; + public: + __map_iter() : element(0), container(0) { } + __map_iter(const typename Map::iterator & m) + : element(m.element), container(m.container) { } + __map_iter(typename Map::size_type e, Map * c) + : element(e), container(c) { } + ~__map_iter() { } + + typename Map::value_type & operator*(){ + return container->data[element]; + } + const typename Map::value_type & operator*() const{ + return container->data[element]; + } + typename Map::value_type * operator->(){ + return &(container->data[element]); + } + __map_iter & operator=(const typename Map::iterator & m){ + element = m.element; + container = m.container; + return *this; + } + bool operator==(const typename Map::iterator & m) const { + return (m.element == element && m.container == container); + } + bool operator!=(const typename Map::iterator & m) const { + return (m.element != element || m.container != container); + } + bool operator==(const typename Map::const_iterator & m) const { + return (m.element == element && m.container == container); + } + bool operator!=(const typename Map::const_iterator & m) const { + return (m.element != element || m.container != container); + } + __map_iter & operator++(){ + ++element; + return *this; + } + __map_iter operator++(int){ + __map_iter temp(*this); + ++element; + return temp; + } + __map_iter & operator--(){ + --element; + return *this; + } + __map_iter operator--(int){ + __map_iter temp(*this); + --element; + return temp; + } + + operator typename Map::const_iterator() const{ + return typename Map::const_iterator(element, container); + } + + }; + + + //Compare the keys of the two items + template class _UCXXEXPORT + __base_map::value_compare : public binary_function< + typename map::value_type, + typename map::value_type, + bool> + { + friend class __base_map; + protected: + Compare comp; + value_compare(Compare c) : comp(c) { } + ~value_compare() { } + public: + bool operator()(const value_type& x, const value_type& y) const { + return comp(x.first, y.first); + } + }; + + template + __base_map::__base_map(const Compare& comp, const Allocator&) + : data(), c(comp) + { + + } + + template + __base_map::__base_map(const __base_map& x) + : data(x.data), c(x.c) + { + + } + + template + __base_map::~__base_map() + { + + } + + + template + typename __base_map::iterator + __base_map::begin() + { + return iterator(0, this); + } + + template + typename __base_map::const_iterator + __base_map::begin() const + { + return const_iterator(0, this); + + } + + template + typename __base_map::iterator + __base_map::end() + { + return iterator(data.size(), this); + } + + template + typename __base_map::const_iterator + __base_map::end() const + { + return const_iterator(data.size(), this); + } + + template + typename __base_map::reverse_iterator + __base_map::rbegin() + { + return reverse_iterator(end()); + } + + template + typename __base_map::const_reverse_iterator + __base_map::rbegin() const + { + return const_reverse_iterator(end()); + } + + template + typename __base_map::reverse_iterator + __base_map::rend() + { + return reverse_iterator(begin()); + } + + template + typename __base_map::const_reverse_iterator + __base_map::rend() const + { + return const_reverse_iterator(begin()); + } + + template + bool __base_map::empty() const + { + return (data.size() == 0); + } + + template + typename __base_map::size_type + __base_map::size() const + { + return data.size(); + } + + template + typename __base_map::size_type + __base_map::max_size() const + { + return data.max_size(); + } + + template + typename __base_map::iterator + __base_map::lower_bound(const key_type &x) + { + size_type low = 0; + size_type high = data.size(); + + while (low < high) { + size_type i = (low + high) / 2; + if( c(data[i].first, x) ){ + low = i + 1; + }else{ + high = i; + } + } + + return iterator(low, this); + } + + template + typename __base_map::const_iterator + __base_map::lower_bound(const key_type &x) const + { + size_type low = 0; + size_type high = data.size(); + + while (low < high) { + size_type i = (low + high) / 2; + if( c(data[i].first, x) ){ + low = i + 1; + }else{ + high = i; + } + } + + return const_iterator(low, this); + } + + template + void __base_map::swap(__base_map& m) + { + Compare n = c; + c = m.c; + m.c = n; + + data.swap(m.data); + } + + + template + void __base_map::clear() + { + data.clear(); + } + + + template + typename __base_map::key_compare + __base_map::key_comp() const + { + return c; + } + +// value_compare value_comp() const; + + + + + +/* This is the implementation for the map container. As noted above, it deviates + * from ISO spec by deriving from a base class in order to reduce code redundancy. + * More code could be reduced by convirting to virtual functions (thus allowing + * much of the erase and insert code to be duplicated), but that would deviate from + * the specifications too much to be worth the risk. + */ + + + + + +//Implementation of map + + +template class _UCXXEXPORT map + : public __base_map +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __base_map base; + typedef typename base::key_type key_type; + typedef typename base::mapped_type mapped_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + using base::value_compare; + + explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al) { } + + template map(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& = Allocator()); + + map(const map& x) : base(x) { } + ~map() { } + + map& operator=(const map& x); + + reference operator[](const key_type& k); + + pair insert(const value_type& x); + iterator insert(iterator position, const value_type& x); + + template void insert(InputIterator first, InputIterator last); + void erase(iterator position); + size_type erase(const key_type& x); + void erase(iterator first, iterator last); + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + iterator find(const key_type& x); + const_iterator find(const key_type& x) const; + size_type count(const key_type& x) const; + iterator upper_bound(const key_type& x); + const_iterator upper_bound(const key_type& x) const; + pair equal_range(const key_type& x); + pair equal_range(const key_type& x) const; + +protected: + friend class base::iterator; + friend class base::const_iterator; + + friend bool operator==(const map& x, const map& y); + + using base::data; + using base::c; + +}; + + + template template + map:: + map(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) + : base(comp, al) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + template + map::map& + map::operator=(const map& x) + { + if( &x == this){ + return *this; + } + c = x.c; + data = x.data; + return *this; + } + + + template + typename map::reference + map::operator[](const key_type & k) + { +/* iterator i = lower_bound(k); + if( !c( i->first, k) && !c(k, i->first) ){ + return i->second; + } + pair t; + t.first = k; + t.second = T(); + return insert(t).first->second; +*/ + //This is from the spec and is quite ugly. + return (*((insert(make_pair(k, T()))).first)).second; + } + + template + pair::iterator, bool> + map::insert(const value_type& x) + { + pair::iterator, bool> retval; + + //Either set is empty or element to insert goes at the begining + if(data.size() == 0 || c(x.first, data[0].first) ){ + data.push_front(x); + retval.first = begin(); + retval.second = true; + return retval; + } + + //Element to insert goes at the end + if( c(data[data.size() - 1].first, x.first) ){ + data.push_back(x); + retval.first = end(); + --retval.first; + retval.second = true; + return retval; + } + + retval.first = __base_map::lower_bound(x.first); + + //No match - this should never happen + if(retval.first == end()){ + retval.second = false; + return retval; + } + + //If we have an exact match + if( !c( retval.first->first, x.first) && !c(x.first, retval.first->first ) ){ + retval.second = false; + return retval; + } + + typename deque, allocator > >::iterator q(&data, retval.first.element); + data.insert(q, x); + + retval.first = __base_map::lower_bound(x.first); //Need to refind because insert can move data around + retval.second = true; + + return retval; + } + + + template + typename map::iterator + map::insert(iterator, const value_type& x) + { + //Just reusing code. It's hard to make improvements over existing algo. + //We aren't using the iterator parameter, but it's only a hint and not required to be used. + insert(x); + return find(x.first); + } + + template + template void + map::insert(InputIterator first, InputIterator last) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + template void + map::erase(iterator position) + { + //Create a deque iterator from position information and then + //Use built in erase feature because it is handy. + typename deque, allocator > >::iterator pos(&data, position.element); + data.erase(pos); + } + + template + typename map::size_type + map::erase(const key_type& x) + { + typename map::iterator i = find(x); + if(i!=end()){ + erase(i); + return 1; + } + return 0; + } + + template + void map::erase(iterator first, iterator last) + { + typename deque, allocator > >::iterator f(&data, first.element); + typename deque, allocator > >::iterator l(&data, last.element); + data.erase(f, l); + } + + template + typename map::iterator + map:: + find(const typename map::key_type& x) + { + if(data.size() == 0){ + return end(); + } + + iterator retval = __base_map::lower_bound(x); + + if(retval == end()){ + return retval; + } + + //Make sure we have an exact match.... + if(!c( retval->first, x) && !c(x, retval->first )){ + return retval; + } + return end(); + + } + + template + typename map::const_iterator + map::find(const key_type& x) const + { + if(data.size() == 0){ + return end(); + } + + const_iterator retval = __base_map::lower_bound(x); + + if(retval == end()){ + return retval; + } + + //Make sure we have an exact match.... + if(!c( retval->first, x) && !c(x, retval->first )){ + return retval; + } + return end(); + + } + + template + typename map::size_type + map::count(const typename map::key_type& x) const + { + if( find(x) == end()){ + return 0; + } + return 1; + } + + template + typename map::iterator + map::upper_bound(const key_type& x) + { + typename map::iterator i = __base_map::lower_bound(x); + if( i != end() && !c(x, i->first) ){ + ++i; + } + return i; + } + + template + typename map::const_iterator + map::upper_bound(const key_type& x) const + { + typename map::const_iterator i = __base_map::lower_bound(x); + if(i != end() && !c(x, i->first)){ + ++i; + } + return i; + } + + + template + pair< typename map::iterator, + typename map::iterator + > map::equal_range(const key_type& x) + { + pair< typename map::iterator, + typename map::iterator + > retval; + retval.first = __base_map::lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + template + pair< typename map::const_iterator, + typename map::const_iterator + > map::equal_range(const key_type& x) const + { + pair< typename map::const_iterator, + typename map::const_iterator + > retval; + retval.first = __base_map::lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + template bool operator== + (const map& x, const map& y) + { + if(x.c == y.c && x.data == y.data){ + return true; + } + return false; + } + + + +//Implementation of multimap + + +template class _UCXXEXPORT multimap + : public __base_map +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __base_map base; + typedef typename base::key_type key_type; + typedef typename base::mapped_type mapped_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al) { } + + template multimap(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& = Allocator()); + + multimap(const multimap& x) : base(x) { } + ~multimap() { } + + multimap& operator=(const multimap& x); + + iterator insert(const value_type& x); + iterator insert(iterator position, const value_type& x); + template void insert(InputIterator first, InputIterator last); + + void erase(iterator position); + size_type erase(const key_type& x); + void erase(iterator first, iterator last); + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + iterator find(const key_type& x); + const_iterator find(const key_type& x) const; + size_type count(const key_type& x) const; + iterator upper_bound(const key_type& x); + const_iterator upper_bound(const key_type& x) const; + pair equal_range(const key_type& x); + pair equal_range(const key_type& x) const; + +protected: + friend class base::iterator; + friend class base::const_iterator; + + using base::data; + using base::c; + +}; + + + + template template + multimap:: + multimap(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) + : base(comp, al) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + template + multimap::multimap& + multimap::operator=(const multimap& x) + { + if( &x == this){ + return *this; + } + c = x.c; + data = x.data; + return *this; + } + + + template + typename multimap::iterator + multimap::insert(const value_type &x) + { + iterator retval; + + //Either set is empty or element to insert goes at the begining + if(data.size() == 0 || c(x.first, data[0].first) ){ + data.push_front(x); + return begin(); + } + + //Element to insert goes at the end + if( c(data[data.size() - 1].first, x.first) ){ + data.push_back(x); + return end(); + } + + retval = __base_map::lower_bound(x.first); + + //No match - this should never happen + if(retval == end()){ + return retval; + } + + if( !c(x.first, retval->first) ){ + ++retval; + } + + typename deque, allocator > >::iterator q(&data, retval.element); + data.insert(q, x); + + return retval; + } + + + template + typename multimap::iterator + multimap::insert(iterator position, const value_type& x) + { + + //Inserting at begining + if(position == begin() && !c(position->first, x.first) ){ + data.push_front(x); + return position; + } + //Inserting at end + if(position == end() && !c(x.first, data[data.size() - 1].first) ){ + data.push_back(x); + return position; + } + + //Inserting in middle + iterator temp = position; + --temp; + if( !c(position->first, x.first) && !c(x.first, temp->first) ){ + typename deque, allocator > >::iterator q(&data, position.element); + data.insert(q, x); + return position; + } + + return insert(x); + } + + template + template void + multimap::insert(InputIterator first, InputIterator last) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + + + template void + multimap::erase(iterator position) + { + //Create a deque iterator from position information and then + //Use built in erase feature because it is handy. + typename deque, allocator > >::iterator pos(&data, position.element); + data.erase(pos); + } + + template + typename multimap::size_type + multimap::erase(const key_type& x) + { + typename multimap::iterator f = __base_map::lower_bound(x); + typename multimap::iterator l = upper_bound(x); + size_type t = l.element - f.element; + erase(f, l); + return t; + } + + + + template + void multimap::erase(iterator first, iterator last) + { + typename deque, allocator > >::iterator f(&data, first.element); + typename deque, allocator > >::iterator l(&data, last.element); + data.erase(f, l); + } + + + template + typename multimap::iterator + multimap::find(const key_type& x) + { + if(data.size() == 0){ + return end(); + } + + iterator retval = __base_map::lower_bound(x); + + if(retval == end()){ + return retval; + } + + if( c(x, retval->first) || c(retval->first, x) ){ + return end(); + } + + while( retval.element > 0 && !c(retval->first, x) && !c(x, retval->first) ){ + --retval; + } + if( c(retval->first, x)){ + ++retval; + } + + return retval; + } + + + template + typename multimap::const_iterator + multimap::find(const key_type& x) const + { + if(data.size() == 0){ + return end(); + } + const_iterator retval = __base_map::lower_bound(x); + + if(retval == end()){ + return retval; + } + + if( c(x, retval->first) || c(retval->first, x) ){ + return end(); + } + + while( retval.element > 0 && !c(retval->first, x) && !c(x, retval->first) ){ + --retval; + } + if( c(retval->first, x)){ + ++retval; + } + + + return retval; + } + + + template + typename multimap::size_type + multimap:: + count(const typename multimap::key_type& x) const + { + pair< typename multimap::const_iterator, + typename multimap::const_iterator + > temp = equal_range(x); + + return temp.second.element - temp.first.element; + } + + template + typename multimap::iterator + multimap::upper_bound(const key_type& x) + { + typename multimap::iterator i = __base_map::lower_bound(x); + + while(i != end() && !c(x, i->first)){ + ++i; + } + return i; + } + + template + typename multimap::const_iterator + multimap::upper_bound(const key_type& x) const + { + typename multimap::const_iterator i = __base_map::lower_bound(x); + + while(i != end() && !c(x, i->first)){ + ++i; + } + return i; + } + + + template + pair< typename multimap::iterator, + typename multimap::iterator + > multimap::equal_range(const key_type& x) + { + pair< typename multimap::iterator, + typename multimap::iterator + > retval; + retval.first = __base_map::lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + template + pair< typename multimap::const_iterator, + typename multimap::const_iterator + > multimap::equal_range(const key_type& x) const + { + pair< typename multimap::const_iterator, + typename multimap::const_iterator + > retval; + retval.first = __base_map::lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + + + + +/* Non-member functions. These are at the end because they are not associated with any + particular class. These will be implemented as I figure out exactly what all of + them are supposed to do, and I have time. + */ + + template _UCXXEXPORT bool operator< + (const map& x, const map& y); + template _UCXXEXPORT bool operator!= + (const map& x, const map& y); + template _UCXXEXPORT bool operator> + (const map& x, const map& y); + template _UCXXEXPORT bool operator>= + (const map& x, const map& y); + template _UCXXEXPORT bool operator<= + (const map& x, const map& y); + template _UCXXEXPORT void swap + (map& x, map& y); + + + template _UCXXEXPORT bool operator== + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator< + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator!= + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator> + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator>= + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator<= + (const multimap& x, const multimap& y); + template _UCXXEXPORT void swap + (multimap& x, multimap& y); + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/unwind-cxx.h =================================================================== --- branches/slice/i386/modules/uClibc++/include/unwind-cxx.h (revision 0) +++ branches/slice/i386/modules/uClibc++/include/unwind-cxx.h (revision 727) @@ -0,0 +1,182 @@ +// -*- C++ -*- Exception handling and frame unwind runtime interface routines. +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// GCC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GCC; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This is derived from the C++ ABI for IA-64. Where we diverge +// for cross-architecture compatibility are noted with "@@@". + +#ifndef _UNWIND_CXX_H +#define _UNWIND_CXX_H 1 + +// Level 2: C++ ABI + +#include +#include +#include +#include "unwind.h" + +#pragma GCC visibility push(default) + +namespace __cxxabiv1 +{ + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +// A C++ exception object consists of a header, which is a wrapper around +// an unwind object header with additional C++ specific information, +// followed by the exception object itself. + +struct __cxa_exception +{ + // Manage the exception object itself. + std::type_info *exceptionType; + void (*exceptionDestructor)(void *); + + // The C++ standard has entertaining rules wrt calling set_terminate + // and set_unexpected in the middle of the exception cleanup process. + std::unexpected_handler unexpectedHandler; + std::terminate_handler terminateHandler; + + // The caught exception stack threads through here. + __cxa_exception *nextException; + + // How many nested handlers have caught this exception. A negated + // value is a signal that this object has been rethrown. + int handlerCount; + + // Cache parsed handler data from the personality routine Phase 1 + // for Phase 2 and __cxa_call_unexpected. + int handlerSwitchValue; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + _Unwind_Ptr catchTemp; + void *adjustedPtr; + + // The generic exception header. Must be last. + _Unwind_Exception unwindHeader; +}; + + // Each thread in a C++ program has access to a __cxa_eh_globals object. +struct __cxa_eh_globals +{ + __cxa_exception *caughtExceptions; + unsigned int uncaughtExceptions; +}; + + +// The __cxa_eh_globals for the current thread can be obtained by using +// either of the following functions. The "fast" version assumes at least +// one prior call of __cxa_get_globals has been made from the current +// thread, so no initialization is necessary. +extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); +extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw(); +#endif + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +// Allocate memory for the exception plus the thown object. +extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw(); + +// Free the space allocated for the exception. +extern "C" void __cxa_free_exception(void *thrown_exception) throw(); + +// Throw the exception. +extern "C" void __cxa_throw (void *thrown_exception, + std::type_info *tinfo, + void (*dest) (void *)) + __attribute__((noreturn)); + +// Used to implement exception handlers. +extern "C" void *__cxa_begin_catch (void *) throw(); +extern "C" void __cxa_end_catch (); +extern "C" void __cxa_rethrow () __attribute__((noreturn)); +#endif + +// These facilitate code generation for recurring situations. +extern "C" void __cxa_bad_cast (); +extern "C" void __cxa_bad_typeid (); + +// @@@ These are not directly specified by the IA-64 C++ ABI. + +// Handles re-checking the exception specification if unexpectedHandler +// throws, and if bad_exception needs to be thrown. Called from the +// compiler. +extern "C" void __cxa_call_unexpected (void *) __attribute__((noreturn)); + +// Invokes given handler, dying appropriately if the user handler was +// so inconsiderate as to return. +extern void __terminate(std::terminate_handler) __attribute__((noreturn)); +extern void __unexpected(std::unexpected_handler) __attribute__((noreturn)); + +// The current installed user handlers. +extern std::terminate_handler __terminate_handler; +extern std::unexpected_handler __unexpected_handler; + +// These are explicitly GNU C++ specific. + +// This is the exception class we report -- "GNUCC++\0". +const _Unwind_Exception_Class __gxx_exception_class += ((((((((_Unwind_Exception_Class) 'G' + << 8 | (_Unwind_Exception_Class) 'N') + << 8 | (_Unwind_Exception_Class) 'U') + << 8 | (_Unwind_Exception_Class) 'C') + << 8 | (_Unwind_Exception_Class) 'C') + << 8 | (_Unwind_Exception_Class) '+') + << 8 | (_Unwind_Exception_Class) '+') + << 8 | (_Unwind_Exception_Class) '\0'); + +// GNU C++ personality routine, Version 0. +extern "C" _Unwind_Reason_Code __gxx_personality_v0 + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *); + +// GNU C++ sjlj personality routine, Version 0. +extern "C" _Unwind_Reason_Code __gxx_personality_sj0 + (int, _Unwind_Action, _Unwind_Exception_Class, + struct _Unwind_Exception *, struct _Unwind_Context *); + + +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ +// Acquire the C++ exception header from the C++ object. +static inline __cxa_exception * +__get_exception_header_from_obj (void *ptr) +{ + return reinterpret_cast<__cxa_exception *>(ptr) - 1; +} + +// Acquire the C++ exception header from the generic exception header. +static inline __cxa_exception * +__get_exception_header_from_ue (_Unwind_Exception *exc) +{ + return reinterpret_cast<__cxa_exception *>(exc + 1) - 1; +} +#endif +} /* namespace __cxxabiv1 */ + +#pragma GCC visibility pop + +#endif // _UNWIND_CXX_H Index: branches/slice/i386/modules/uClibc++/include/iomanip =================================================================== --- branches/slice/i386/modules/uClibc++/include/iomanip (revision 0) +++ branches/slice/i386/modules/uClibc++/include/iomanip (revision 727) @@ -0,0 +1,170 @@ +/* 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 +#include + +#ifndef __STD_IOMANIP +#define __STD_IOMANIP 1 + +#pragma GCC visibility push(default) + +namespace std{ + +// These are the helper classes which we are going to be using to +// hold the required data + +class _UCXXEXPORT __resetiosflags{ +public: + ios_base::fmtflags m; + _UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ } +}; + +class _UCXXEXPORT __setiosflags{ +public: + ios_base::fmtflags m; + _UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ } +}; + +class _UCXXEXPORT __setbase{ +public: + int base; + _UCXXEXPORT __setbase(int b) : base(b){ } +}; + +class _UCXXEXPORT __setfill{ +public: + int character; + _UCXXEXPORT __setfill(int c): character(c){ } +}; + +class _UCXXEXPORT __setprecision{ +public: + int digits; + _UCXXEXPORT __setprecision(int n): digits(n) { } +}; + +class _UCXXEXPORT __setw{ +public: + int width; + _UCXXEXPORT __setw(int n): width(n) { } +}; + + +//Actual manipulator functions + +inline __resetiosflags resetiosflags(ios_base::fmtflags mask){ + return __resetiosflags(mask); +} + +inline __setiosflags setiosflags(ios_base::fmtflags mask){ + return __setiosflags(mask); +} + +inline __setbase setbase(int b){ + return __setbase(b); +} + +inline __setfill setfill(int c){ + return __setfill(c); +} + +inline __setprecision setprecision(int n){ + return __setprecision(n); +} + +inline __setw setw(int n){ + return __setw(n); +} + + +//How to handle interaction with [i|o]stream classes + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __resetiosflags s) +{ + os.setf(ios_base::fmtflags(0),s.m); + return os; +} + +template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, const __resetiosflags s) +{ + is.setf(ios_base::fmtflags(0),s.m); + return is; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setiosflags s) +{ + os.setf(s.m); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setbase s) +{ + ios_base::fmtflags f(0); + switch(s.base){ + case 8: + f = ios_base::oct; + break; + case 10: + f = ios_base::dec; + break; + case 16: + f = ios_base::hex; + break; + default: + break; + + } + os.setf(f, ios_base::basefield); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setfill s) +{ + os.fill(s.character); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setprecision s) +{ + os.precision(s.digits); + return os; +} + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const __setw s) +{ + os.width(s.width); + return os; +} + + + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/numeric =================================================================== --- branches/slice/i386/modules/uClibc++/include/numeric (revision 0) +++ branches/slice/i386/modules/uClibc++/include/numeric (revision 727) @@ -0,0 +1,161 @@ +/* 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 + +#ifndef __STD_NUMERIC_HEADER +#define __STD_NUMERIC_HEADER 1 + +#pragma GCC visibility push(default) + +namespace std{ + template _UCXXEXPORT + T accumulate(InputIterator first, InputIterator last, T init) + { + while(first != last){ + init = init + *first; + ++first; + } + return init; + } + + template _UCXXEXPORT + T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op) + { + while(first != last){ + init = binary_op(init, *first); + ++first; + } + return init; + } + + + template _UCXXEXPORT + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init) + { + while(first1 != last1){ + init = init + *first1 * *first2; + ++first1; + ++first2; + } + return init; + } + + template _UCXXEXPORT + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, + BinaryOperation1 binary_op1, + BinaryOperation2 binary_op2) + { + while(first1 != last1){ + init = binary_op1(init, binary_op2(*first1, *first2)); + ++first1; + ++first2; + } + return init; + } + + template _UCXXEXPORT + OutputIterator partial_sum(InputIterator first, InputIterator last, + OutputIterator result) + { + OutputIterator temp(result); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = *first + *temp; + temp = result; + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + OutputIterator partial_sum(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op) + { + OutputIterator temp(result); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = binary_op(*first, *temp); + temp = result; + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + OutputIterator + adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result) + { + OutputIterator temp(first); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = *first - *temp; + temp = first; + ++first; + ++result; + } + + return result; + } + + + template _UCXXEXPORT + OutputIterator + adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op) + { + OutputIterator temp(first); + *result = *first; + ++first; + ++result; + + while(first != last){ + *result = binary_op(*first, *temp); + temp = first; + ++first; + ++result; + } + + return result; + } + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/utility =================================================================== --- branches/slice/i386/modules/uClibc++/include/utility (revision 0) +++ branches/slice/i386/modules/uClibc++/include/utility (revision 727) @@ -0,0 +1,88 @@ +/* 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 + + +#ifndef __STD_HEADER_UTILITY +#define __STD_HEADER_UTILITY 1 + +#pragma GCC visibility push(default) + +namespace std{ + + namespace rel_ops { + template inline bool operator!=(const T& x, const T& y){ + return !(x == y); + } + + template inline bool operator> (const T& x, const T& y){ + return ( y < x); + } + + template inline bool operator<=(const T& x, const T& y){ + return !( y < x ); + } + + template inline bool operator>=(const T& x, const T& y){ + return !(x < y); + } + } + + template struct _UCXXEXPORT pair { + typedef T1 first_type; + typedef T2 second_type; + + T1 first; + T2 second; + pair() : first(), second() { } + pair(const T1& x, const T2& y) : first(x), second(y) { } + template pair(const pair &p) : first(p.first), second(p.second) { } + }; + + template bool operator==(const pair& x, const pair& y){ + using namespace rel_ops; + return (x.first == y.first && x.second==y.second); + } + template bool operator< (const pair& x, const pair& y){ + return x.first < y.first || (!(y.first < x.first) && x.second < y.second); + } + template bool operator!=(const pair& x, const pair& y){ + return !(x == y); + } + template bool operator> (const pair& x, const pair& y){ + return y < x; + } + template bool operator>=(const pair& x, const pair& y){ + return !(x < y); + } + template bool operator<=(const pair& x, const pair& y){ + return !(y < x); + } + template pair make_pair(const T1& x, const T2& y){ + return pair(x, y); + } + + +} + +#pragma GCC visibility pop + +#endif //__STD_HEADER_UTILITY Index: branches/slice/i386/modules/uClibc++/include/cwchar =================================================================== --- branches/slice/i386/modules/uClibc++/include/cwchar (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cwchar (revision 727) @@ -0,0 +1,86 @@ +/* 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 + + 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 + +#ifndef __HEADER_CWCHAR +#define __HEADER_CWCHAR 1 + + +namespace std{ + using ::mbstate_t; + using ::wint_t; + + using ::btowc; + using ::fgetwc; + using ::fgetws; + using ::fputwc; + using ::fputws; + using ::fwide; + using ::fwprintf; + using ::fwscanf; + using ::getwc; + using ::getwchar; + using ::mbrlen; + using ::mbrtowc; + using ::mbsinit; + using ::mbsrtowcs; + using ::putwc; + using ::putwchar; + using ::swprintf; + using ::swscanf; + using ::ungetwc; + using ::vfwprintf; + using ::vswprintf; + using ::vwprintf; + using ::wcrtomb; + using ::wcscat; + using ::wcschr; + using ::wcscmp; + using ::wcscoll; + using ::wcscpy; + using ::wcscspn; + using ::wcsftime; + using ::wcslen; + using ::wcsncat; + using ::wcsncmp; + using ::wcsncpy; + using ::wcspbrk; + using ::wcsrchr; + using ::wcsrtombs; + using ::wcsspn; + using ::wcsstr; + using ::wcstod; + using ::wcstok; + using ::wcstol; + using ::wcstoul; + using ::wcsxfrm; + using ::wctob; + using ::wmemchr; + using ::wmemcmp; + using ::wmemcpy; + using ::wmemmove; + using ::wmemset; + using ::wprintf; + using ::wscanf; +} + + + +#endif + Index: branches/slice/i386/modules/uClibc++/include/type_traits =================================================================== --- branches/slice/i386/modules/uClibc++/include/type_traits (revision 0) +++ branches/slice/i386/modules/uClibc++/include/type_traits (revision 727) @@ -0,0 +1,92 @@ +/* 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 +#include +#include +#include +#include + +#ifndef __HEADER_TYPE_TRAITS +#define __HEADER_TYPE_TRAITS 1 + +#pragma GCC visibility push(default) + +namespace std{ + + struct _UCXXEXPORT __true_type{}; + struct _UCXXEXPORT __false_type{}; + + template class _UCXXEXPORT __is_integer{ + public: + typedef __false_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + template <> class _UCXXEXPORT __is_integer { + public: + typedef __true_type value; + }; + + + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/memory =================================================================== --- branches/slice/i386/modules/uClibc++/include/memory (revision 0) +++ branches/slice/i386/modules/uClibc++/include/memory (revision 727) @@ -0,0 +1,196 @@ +/* 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 +#include + +#ifndef HEADER_STD_MEMORY +#define HEADER_STD_MEMORY 1 + +#pragma GCC visibility push(default) + +namespace std{ + +template class allocator; + // Specialize for void: + +template <> class _UCXXEXPORT allocator { +public: + typedef void* pointer; + typedef const void* const_pointer; + typedef void value_type; + template struct rebind { typedef allocator other; }; +}; + +template class _UCXXEXPORT allocator{ +public: + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + typedef T* pointer; + typedef const T* const_pointer; + + typedef T& reference; + typedef const T& const_reference; + + pointer address(reference r) const { return &r; } + const_pointer address(const_reference r) const { return &r; } + + allocator() throw(){} + template allocator(const allocator& ) throw(); + ~allocator() throw(){} + + //Space for n Ts + pointer allocate(size_type n, typename allocator::const_pointer = 0){ + return (T*)(::operator new( n * sizeof(T) )); + } + void deallocate(pointer p, size_type){ + ::operator delete(p); + } + + //Use placement new to engage the constructor + void construct(pointer p, const T& val) { new((void*)p) T(val); } + void destroy(pointer p){ ((T*)p)->~T(); } //Call destructor + + size_type max_size() const throw(); + template struct rebind { typedef allocator other; }; + +}; + +template class _UCXXEXPORT raw_storage_iterator + : public iterator +{ + Out p; + +public: + explicit raw_storage_iterator(Out pp) : p (pp) { } + raw_storage_iterator & operator*() { return *this; } + raw_storage_iterator & operator=(const T& val) { + T* pp = &*p; + new(pp) T(val); + return *this; + } + + raw_storage_iterator & operator++() { ++p; return *this; } + raw_storage_iterator operator++(int) { + raw_storage_iterator t = *this; + ++p; + return t; + } +}; + +template _UCXXEXPORT pair get_temporary_buffer(ptrdiff_t n){ + pair retval; + retval.first = static_cast(malloc(n * sizeof(T))); + if(retval.first == 0){ + retval.second = 0; + }else{ + retval.second = n; + } + return retval; +} + +template _UCXXEXPORT void return_temporary_buffer(T* p){ + free(p); +} + + +template class _UCXXEXPORT auto_ptr{ + +private: + T * object; + template struct auto_ptr_ref{ + Y * p; + }; + +public: + + typedef T element_type; + + explicit auto_ptr(T* p =0) throw() : object(p){ } + auto_ptr(auto_ptr& p) throw() : object(p.release()){ } + auto_ptr(auto_ptr_ref r) throw() : object(r.p){ + r.p = 0; + } + template auto_ptr(auto_ptr& p) throw() : object(p.release()){ } + auto_ptr& operator=(auto_ptr& p) throw(){ + if(&p == this){ + return *this; + } + delete object; + object = p.release(); + return *this; + } + template auto_ptr& operator=(auto_ptr& p) throw(){ + if(&p == this){ + return *this; + } + delete object; + object = p.release(); + return *this; + } + ~auto_ptr(){ + delete object; + } + + T& operator*() const throw(){ + return *object; + } + T* operator->() const throw(){ + return object; + } + T* get() const throw(){ + return object; + } + T* release() throw(){ + T * temp(object); + object = 0; + return temp; + } + void reset(T * p=0) throw(){ + if(p != object){ + delete object; + object = p; + } + } + template operator auto_ptr_ref() throw(){ + auto_ptr_ref retval; + retval.p = object; + object = 0; + return retval; + } + template operator auto_ptr() throw(){ + auto_ptr retval(object); + object = 0; + return retval; + } + +}; + +} //namespace std + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/set.old =================================================================== --- branches/slice/i386/modules/uClibc++/include/set.old (revision 0) +++ branches/slice/i386/modules/uClibc++/include/set.old (revision 727) @@ -0,0 +1,1535 @@ +/* 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 + + +#ifndef __STD_HEADER_SET +#define __STD_HEADER_SET + +#pragma GCC visibility push(default) + +namespace std{ + + +template, class Allocator = allocator > class __base_set; +template, class Allocator = allocator > class set; +template, class Allocator = allocator > class multiset; + +template class __set_iter; +template class __set_citer; + +template bool operator== + (const set& x, const set& y); + +template bool operator== + (const multiset& x, const multiset& y); + + + +/* The code for the set containers is split up into two classes. + * The first class, __base_set holds all of the data and does much of the iterator-based + * work. Then the classes set and multiset inherit from there. This was done to reduce + * the redundancy of code (And thus errors which might crop up), as well as possibly + * reducing the size of binaries if both set and multiset are used, along with the same + * template parameters. + */ + + + +//All base classes first (__base_set, iterators, value_compare) and it's associated code + + +template class _UCXXEXPORT __base_set{ + +protected: + friend class __set_iter; + friend class __set_citer; + friend bool operator==<>(const set& x, const set& y); + friend bool operator==<>(const multiset& x, const multiset& y); + +public: + typedef __base_set set_type; + typedef Key key_type; + typedef Key value_type; + typedef Compare key_compare; + typedef Allocator allocator_type; + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef __set_iter iterator; + typedef __set_citer const_iterator; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + typedef typename std::reverse_iterator reverse_iterator; + typedef typename std::reverse_iterator const_reverse_iterator; + + class value_compare; + + explicit __base_set(const Compare& comp = Compare(), const Allocator& al = Allocator()); + __base_set(const set_type& x); + ~__base_set(); + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + + bool empty() const; + size_type size() const; + size_type max_size() const; + + void swap(set_type & x); + void clear(); + + key_compare key_comp() const; + +protected: + + deque > data; + Compare c; + +}; + + + //Implementations + + template class _UCXXEXPORT __set_citer + : public std::iterator< + bidirectional_iterator_tag, + Key, + typename Allocator::difference_type, + typename Allocator::pointer, + typename Allocator::reference + > + { + protected: + typedef class __base_set Set; + + friend class __base_set; + friend class __base_set::iterator; + + friend class set; + friend class multiset; + + typename Set::size_type element; + const Set * container; + public: + __set_citer() : element(0), container(0) { } + __set_citer(const typename Set::const_iterator & m) + : element(m.element), container(m.container) { } + __set_citer(typename Set::size_type e, const Set * const c) + : element(e), container(c) { } + ~__set_citer() { } + + typename Set::value_type operator*(){ + return container->data[element]; + } + const typename Set::value_type * operator->() const{ + return &(container->data[element]); + } + __set_citer & operator=(const typename Set::const_iterator & m){ + element = m.element; + container = m.container; + return *this; + } + bool operator==(const typename Set::const_iterator & m) const { + return (m.element == element && m.container == container); + } + bool operator!=(const typename Set::const_iterator & m) const { + return (m.element != element || m.container != container); + } + __set_citer & operator++(){ + ++element; + return *this; + } + __set_citer operator++(int){ + __set_citer temp(*this); + ++element; + return temp; + } + __set_citer & operator--(){ + --element; + return *this; + } + __set_citer operator--(int){ + __set_citer temp(*this); + --element; + return temp; + } + + }; + + template class _UCXXEXPORT __set_iter + : public std::iterator< + bidirectional_iterator_tag, + Key, + typename Allocator::difference_type, + typename Allocator::pointer, + typename Allocator::reference + > + { + protected: + typedef __base_set Set; + + //FIXME - Find a way to use template parameters or something. This will do for now + friend class __base_set; + friend class __base_set::const_iterator; + + friend class set; + friend class multiset; + + typename Set::size_type element; + Set * container; + public: + __set_iter() : element(0), container(0) { } + __set_iter(const typename Set::iterator & m) + : element(m.element), container(m.container) { } + __set_iter(typename Set::size_type e, Set * c) + : element(e), container(c) { } + ~__set_iter() { } + + typename Set::value_type & operator*(){ + return container->data[element]; + } + const typename Set::value_type & operator*() const{ + return container->data[element]; + } + typename Set::value_type * operator->(){ + return &(container->data[element]); + } + __set_iter & operator=(const typename Set::iterator & m){ + element = m.element; + container = m.container; + return *this; + } + bool operator==(const typename Set::iterator & m) const { + return (m.element == element && m.container == container); + } + bool operator!=(const typename Set::iterator & m) const { + return (m.element != element || m.container != container); + } + bool operator==(const typename Set::const_iterator & m) const { + return (m.element == element && m.container == container); + } + bool operator!=(const typename Set::const_iterator & m) const { + return (m.element != element || m.container != container); + } + __set_iter & operator++(){ + ++element; + return *this; + } + __set_iter operator++(int){ + __set_iter temp(*this); + ++element; + return temp; + } + __set_iter & operator--(){ + --element; + return *this; + } + __set_iter operator--(int){ + __set_iter temp(*this); + --element; + return temp; + } + + //Conversion operator + operator typename Set::const_iterator () const + { + typename Set::const_iterator retval(element, container); +// return typename Set::const_iterator(element, container); + return retval; + } + }; + + + + //Compare the keys of the two items + template class _UCXXEXPORT + __base_set::value_compare : public binary_function< + typename set::value_type, + typename set::value_type, + bool> + { + friend class __base_set; + protected: + Compare comp; + value_compare(Compare c) : comp(c) { } + ~value_compare() { } + public: + bool operator()(const value_type& x, const value_type& y) const { + return comp(x, y); + } + }; + + template + __base_set::__base_set(const Compare& comp, const Allocator&) + : data(), c(comp) + { + + } + + template + __base_set::__base_set(const __base_set& x) + : data(x.data), c(x.c) + { + + } + + template + __base_set::~__base_set() + { + + } + + template + typename __base_set::iterator + __base_set::begin() + { + return iterator(0, this); + } + + template + typename __base_set::const_iterator + __base_set::begin() const + { + return const_iterator(0, this); + + } + + template + typename __base_set::iterator + __base_set::end() + { + return iterator(data.size(), this); + } + + template + typename __base_set::const_iterator + __base_set::end() const + { + return const_iterator(data.size(), this); + } + + template + typename __base_set::reverse_iterator + __base_set::rbegin() + { + return reverse_iterator(end()); + } + + template + typename __base_set::const_reverse_iterator + __base_set::rbegin() const + { + return const_reverse_iterator(end()); + } + + template + typename __base_set::reverse_iterator + __base_set::rend() + { + return reverse_iterator(begin()); + } + + template + typename __base_set::const_reverse_iterator + __base_set::rend() const + { + return const_reverse_iterator(begin()); + } + + template + bool __base_set::empty() const + { + return (data.size() == 0); + } + + template + typename __base_set::size_type + __base_set::size() const + { + return data.size(); + } + + template + typename __base_set::size_type + __base_set::max_size() const + { + return data.max_size(); + } + + + template + void __base_set::swap(__base_set& m) + { + Compare n = c; + c = m.c; + m.c = n; + + data.swap(m.data); + } + + + template + void __base_set::clear() + { + data.clear(); + } + + + template + typename __base_set::key_compare + __base_set::key_comp() const + { + return c; + } + +// value_compare value_comp() const; + + + +/* This is the implementation for the set container. As noted above, it deviates + * from ISO spec by deriving from a base class in order to reduce code redundancy. + * More code could be reduced by convirting to virtual functions (thus allowing + * much of the erase and insert code to be duplicated), but that would deviate from + * the specifications too much to be worth the risk. + */ + + + + + +//Implementation of set + + +template class _UCXXEXPORT set + : public __base_set +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __base_set base; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + using base::value_compare; + + explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al) { } + + template set(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& = Allocator()); + + set(const set& x) : base(x) { } + ~set() { } + + set& operator=(const set& x); + + pair insert(const value_type& x); + iterator insert(iterator position, const value_type& x); + + template void insert(InputIterator first, InputIterator last); + void erase(iterator position); + size_type erase(const key_type& x); + void erase(iterator first, iterator last); + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + iterator find(const key_type& x); + const_iterator find(const key_type& x) const; + size_type count(const key_type& x) const; + iterator lower_bound(const key_type& x); + const_iterator lower_bound(const key_type& x) const; + iterator upper_bound(const key_type& x); + const_iterator upper_bound(const key_type& x) const; + pair equal_range(const key_type& x); + pair equal_range(const key_type& x) const; + +protected: + friend class base::iterator; + friend class base::const_iterator; + + iterator ifind(const key_type& x); //Core find functionality + const_iterator ifind(const key_type& x) const; //Core find functionality + + using base::data; + using base::c; + +}; + + + template template + set:: + set(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) + : base(comp, al) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + template + typename set::iterator + set::ifind(const key_type &x) + { + /* This function is not from the standard. It is an internal + * utility function which returns an iterator to either the + * first matching element, or to the element before which + * an insert should be performed. Will not indicate if the + *insert should be performed before the first element + */ + + if(data.size() == 0){ + return end(); + } + + if(data.size() == 1){ + if( c(data[0], x) ){ + return end(); + } + return begin(); + } + + size_type low; + size_type high; + size_type i; + + low = 0; + high = data.size() - 1; + + //This algorithm assumes no duplicates in stored information + while(( high - low) > 1){ + i = low + ((high - low) /2); + if( c(x, data[i]) ){ + high = i; + }else{ + low = i; + } + } + + if( c(data[low], x) ){ // k >=high + i = high; + }else{ + i = low; + } + + return iterator(i, this); + } + + template + typename set::const_iterator + set::ifind(const key_type &x) const + { + /* This function is not from the standard. It is an internal + * utility function which returns an iterator to either the + * first matching element, or to the element before which + * an insert should be performed. Will not indicate if the + *insert should be performed before the first element + */ + + if(data.size() == 0){ + return end(); + } + + if(data.size() == 1){ + if( c(data[0], x) ){ + return end(); + } + return begin(); + } + + size_type low; + size_type high; + size_type i; + + low = 0; + high = data.size() - 1; + + //This algorithm assumes no duplicates in stored information + while(( high - low) > 1){ + i = low + ((high - low) /2); + if( c(x, data[i]) ){ + high = i; + }else{ + low = i; + } + } + + if( c(data[low], x) ){ // k >=high + i = high; + }else{ + i = low; + } + + return const_iterator(i, this); + } + + + template + set::set& + set::operator=(const set& x) + { + if( &x == this){ + return *this; + } + c = x.c; + data = x.data; + return *this; + } + + + template + pair::iterator, bool> + set::insert(const value_type& x) + { + pair::iterator, bool> retval; + + //Either set is empty or element to insert goes at the begining + if(data.size() == 0 || c(x, data[0]) ){ + data.push_front(x); + retval.first = begin(); + retval.second = true; + return retval; + } + + //Element to insert goes at the end + if( c(data[data.size() - 1], x) ){ + data.push_back(x); + retval.first = end(); + --retval.first; + retval.second = true; + return retval; + } + + retval.first = ifind(x); + + //No match - this should never happen + if(retval.first == end()){ + retval.second = false; + return retval; + } + + //If we have an exact match + if( !c( *(retval.first), x) && !c(x, *(retval.first) ) ){ + retval.second = false; + return retval; + } + + typename deque >::iterator q(&data, retval.first.element); + data.insert(q, x); + + retval.first = ifind(x); //Need to refind because insert can move data around + retval.second = true; + + return retval; + } + + + template + typename set::iterator + set::insert(iterator position, const value_type& x) + { + //Just reusing code. It's hard to make improvements over existing algo. + insert(x); + return find(x); + } + + template + template void + set::insert(InputIterator first, InputIterator last) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + template void + set::erase(iterator position) + { + //Create a deque iterator from position information and then + //Use built in erase feature because it is handy. + typename deque >::iterator pos(&data, position.element); + data.erase(pos); + } + + template + typename set::size_type + set::erase(const key_type& x) + { + typename set::iterator i = find(x); + if(i!=end()){ + erase(i); + return 1; + } + return 0; + } + + template + void set::erase(iterator first, iterator last) + { + typename deque >::iterator f(&data, first.element); + typename deque >::iterator l(&data, last.element); + data.erase(f, l); + } + + template + typename set::iterator + set:: + find(const typename set::key_type& x) + { + if(data.size() == 0){ + return end(); + } + + iterator retval = ifind(x); + + if(retval == end()){ + return retval; + } + + //Make sure we have an exact match.... + if(!c( *retval, x) && !c(x, *retval )){ + return retval; + } + return end(); + + } + + template + typename set::const_iterator + set::find(const key_type& x) const + { + if(data.size() == 0){ + return end(); + } + + const_iterator retval = ifind(x); + + if(retval == end()){ + return retval; + } + + //Make sure we have an exact match.... + if(!c( *retval, x) && !c(x, *retval )){ + return retval; + } + return end(); + + } + + template + typename set::size_type + set::count(const typename set::key_type& x) const + { + if( find(x) == end()){ + return 0; + } + return 1; + } + + template + typename set::iterator + set::lower_bound(const key_type& x) + { + return find(x); + } + + template + typename set::const_iterator + set::lower_bound(const key_type& x) const + { + return find(x); + } + + template + typename set::iterator + set::upper_bound(const key_type& x) + { + typename set::iterator i = find(x); + if(i != end()){ + ++i; + } + return i; + } + + template + typename set::const_iterator + set::upper_bound(const key_type& x) const + { + typename set::const_iterator i = find(x); + if(i != end()){ + ++i; + } + return i; + } + + + template + pair< typename set::iterator, + typename set::iterator + > set::equal_range(const key_type& x) + { + pair< typename set::iterator, + typename set::iterator + > retval; + retval.first = lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + template + pair< typename set::const_iterator, + typename set::const_iterator + > set::equal_range(const key_type& x) const + { + pair< typename set::const_iterator, + typename set::const_iterator + > retval; + retval.first = lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + template bool operator== + (const set& x, const set& y) + { + if(x.data == y.data){ + return true; + } + return false; + } + + + +//Implementation of multiset + + +template class _UCXXEXPORT multiset + : public __base_set +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __base_set base; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al) { } + + template multiset(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& = Allocator()); + + multiset(const multiset& x) : base(x) { } + ~multiset() { } + + multiset& operator=(const multiset& x); + + iterator insert(const value_type& x); + iterator insert(iterator position, const value_type& x); + template void insert(InputIterator first, InputIterator last); + + void erase(iterator position); + size_type erase(const key_type& x); + void erase(iterator first, iterator last); + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + iterator find(const key_type& x); + const_iterator find(const key_type& x) const; + size_type count(const key_type& x) const; + iterator lower_bound(const key_type& x); + const_iterator lower_bound(const key_type& x) const; + iterator upper_bound(const key_type& x); + const_iterator upper_bound(const key_type& x) const; + pair equal_range(const key_type& x); + pair equal_range(const key_type& x) const; + +protected: + friend class base::iterator; + friend class base::const_iterator; + + iterator ifind(const key_type& x); //Core find functionality + const_iterator ifind(const key_type& x) const; //Core find functionality + + using base::data; + using base::c; + +}; + + + + template template + multiset:: + multiset(InputIterator first, InputIterator last, const Compare& comp, const Allocator& al) + : base(comp, al) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + + template + typename multiset::iterator + multiset::ifind(const key_type &x) + { + /* This function is not from the standard. It is an internal + * utility function which returns an iterator to either the + * first matching element, or to the element before which + * an insert should be performed. end() for error. + */ + + if(data.size() == 0){ + return end(); + } + + //Before the first element + if( c(x, data[0]) ){ + return begin(); + } + + + //Element is larger than all known elemenst + if( c( data[data.size()-1], x) ){ + return end(); + } + + //Or if it is the last element + if( !c(x, data[size()-1]) ){ + return iterator(data.size()-1, this); + } + + size_type low; + size_type high; + size_type i=0; + + low = 0; + high = data.size() - 1; + + //This algorithm will accept duplicates in keys + + while( c(data[i+1], x) || c(x, data[i]) || !c(x, data[i+1]) ){ + i = low + ((high - low) /2); + if( c( x, data[i]) ){ + high = i; + }else{ + low = i; + } + } + + if( c(data[i], x) ){ // k >=high + ++i; + } + + return iterator(i, this); + } + + template + typename multiset::const_iterator + multiset::ifind(const key_type &x) const + { + /* This function is not from the standard. It is an internal + * utility function which returns an iterator to either the + * first matching element, or to the element before which + * an insert should be performed. end() for error. + */ + + if(data.size() == 0){ + return end(); + } + + //Before the first element + if( c(x, data[0]) ){ + return begin(); + } + + + //Element is larger than all known elemenst + if( c( data[data.size()-1], x) ){ + return end(); + } + + //Or if it is the last element + if( !c(x, data[size()-1]) ){ + return const_iterator(data.size()-1, this); + } + + size_type low; + size_type high; + size_type i=0; + + low = 0; + high = data.size() - 1; + + //This algorithm will accept duplicates in keys + + while( c(data[i+1], x) || c(x, data[i]) || !c(x, data[i+1]) ){ + i = low + ((high - low) /2); + if( c( x, data[i]) ){ + high = i; + }else{ + low = i; + } + } + + if( c(data[i], x) ){ // k >=high + ++i; + } + + return const_iterator(i, this); + } + + + template + typename multiset::iterator + multiset::insert(const value_type &x) + { + iterator retval; + + //Either set is empty or element to insert goes at the begining + if(data.size() == 0 || c(x, data[0]) ){ + data.push_front(x); + return begin(); + } + + //Element to insert goes at the end + if( c(data[data.size() - 1], x) ){ + data.push_back(x); + return end(); + } + + retval = ifind(x); + + //No match - this should never happen + if(retval == end()){ + return retval; + } + + if( !c(x, *retval) ){ + ++retval; + } + + typename deque >::iterator q(&data, retval.element); + data.insert(q, x); + + return retval; + } + + + template + typename multiset::iterator + multiset::insert(iterator position, const value_type& x) + { + + //Inserting at begining + if(position == begin() && !c(*position, x) ){ + data.push_front(x); + return position; + } + //Inserting at end + if(position == end() && !c(x, data[data.size() - 1]) ){ + data.push_back(x); + return position; + } + + //Inserting in middle + iterator temp = position; + --temp; + if( !c( *position, x) && !c(x, *temp) ){ + typename deque >::iterator q(&data, position.element); + data.insert(q, x); + return position; + } + + return insert(x); + } + + template + template void + multiset::insert(InputIterator first, InputIterator last) + { + while(first !=last){ + insert(*first); + ++first; + } + } + + + template void + multiset::erase(iterator position) + { + //Create a deque iterator from position information and then + //Use built in erase feature because it is handy. + typename deque >::iterator pos(&data, position.element); + data.erase(pos); + } + + + template + typename multiset::size_type + multiset::erase(const key_type& x) + { + typename multiset::iterator f = lower_bound(x); + typename multiset::iterator l = upper_bound(x); + size_type t = l.element - f.element; + erase(f, l); + return t; + } + + + template + void multiset::erase(iterator first, iterator last) + { + typename deque >::iterator f(&data, first.element); + typename deque >::iterator l(&data, last.element); + data.erase(f, l); + } + + + template + typename multiset::iterator + multiset::find(const key_type& x) + { + if(data.size() == 0){ + return end(); + } + + iterator retval = ifind(x); + + if( c(x, *retval) || c(*retval, x) ){ + return end(); + } + + return retval; + } + + + template + typename multiset::const_iterator + multiset::find(const key_type& x) const + { + if(data.size() == 0){ + return end(); + } + const_iterator retval = ifind(x); + + if( c(x, *retval) || c(*retval, x) ){ + return end(); + } + + return retval; + } + + + template + typename multiset::size_type + multiset:: + count(const typename multiset::key_type& x) const + { + pair< typename multiset::const_iterator, + typename multiset::const_iterator + > temp = equal_range(x); + + return temp.second.element - temp.first.element; + } + + + template + typename multiset::iterator + multiset::lower_bound(const key_type& x) + { + //FIXME - linear search - can we do any better? + typename multiset::iterator i = find(x); + if(i == end()){ + return i; + } + while( i.element > 0 && !c( *i, x) && !c(x, *i) ){ + --i; + } + if( c(*i, x)){ + ++i; + } + return i; + } + + template + typename multiset::const_iterator + multiset::lower_bound(const key_type& x) const + { + //FIXME - linear search - can we do any better? + typename multiset::const_iterator i = find(x); + if(i == end()){ + return i; + } + while( i.element >0 && !c( *i, x) && !c(x, *i) ){ + --i; + } + if( c( *i, x)){ + ++i; + } + return i; + } + + template + typename multiset::iterator + multiset::upper_bound(const key_type& x) + { + typename multiset::iterator i = find(x); + if(i != end()){ + ++i; + } + return i; + } + + template + typename multiset::const_iterator + multiset::upper_bound(const key_type& x) const + { + typename multiset::const_iterator i = find(x); + if(i != end()){ + ++i; + } + return i; + } + + + template + pair< typename multiset::iterator, + typename multiset::iterator + > multiset::equal_range(const key_type& x) + { + pair< typename multiset::iterator, + typename multiset::iterator + > retval; + retval.first = lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + template + pair< typename multiset::const_iterator, + typename multiset::const_iterator + > multiset::equal_range(const key_type& x) const + { + pair< typename multiset::const_iterator, + typename multiset::const_iterator + > retval; + retval.first = lower_bound(x); + retval.second = upper_bound(x); + return retval; + } + + + + +/* Non-member functions. These are at the end because they are not associated with any + particular class. These will be implemented as I figure out exactly what all of + them are supposed to do, and I have time. + */ + + template _UCXXEXPORT bool operator< + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + template _UCXXEXPORT bool operator!= + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 != *first2 ){ + return true; + } + ++first1; + ++first2; + } + return first1!=last1 || first2 != last2; + } + + template _UCXXEXPORT bool operator> + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1 && first2 == last2; + } + + template _UCXXEXPORT bool operator>= + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1; + } + + template _UCXXEXPORT bool operator<= + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first2!=last2; + } + template _UCXXEXPORT void swap + (set& x, set& y) + { + x.swap(y); + } + + + template _UCXXEXPORT bool operator== + (const multiset& x, const multiset& y) + { + if(x.data == y.data){ + return true; + } + return false; + } + + template _UCXXEXPORT bool operator< + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + template _UCXXEXPORT bool operator!= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 != *first2 ){ + return true; + } + ++first1; + ++first2; + } + return first1!=last1 || first2 != last2; + } + + template _UCXXEXPORT bool operator> + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1 && first2 == last2; + } + + template _UCXXEXPORT bool operator>= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1; + } + + template _UCXXEXPORT bool operator<= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first2!=last2; + } + + template _UCXXEXPORT void swap + (multiset& x, multiset& y) + { + x.swap(y); + } + + + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/cstddef =================================================================== --- branches/slice/i386/modules/uClibc++/include/cstddef (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cstddef (revision 727) @@ -0,0 +1,58 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 18.1 Types +// + +/** @file cstddef + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c stddef.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CSTDDEF +#define _CPP_CSTDDEF 1 + +#ifdef __GCC__ +#pragma GCC system_header +#endif + +#include + +namespace std +{ + using ::ptrdiff_t; + using ::size_t; +} + +#endif Index: branches/slice/i386/modules/uClibc++/include/Makefile =================================================================== --- branches/slice/i386/modules/uClibc++/include/Makefile (revision 0) +++ branches/slice/i386/modules/uClibc++/include/Makefile (revision 727) @@ -0,0 +1,13 @@ +TOPDIR=../ +include $(TOPDIR)Rules.mak + +all: + +clean: + +distclean: + +HEADERS = $(filter-out .svn CVS Makefile,$(wildcard *)) +install: + $(INSTALL) -d $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR) + $(INSTALL) -m 644 $(HEADERS) $(PREFIX)$(UCLIBCXX_RUNTIME_INCLUDEDIR) Index: branches/slice/i386/modules/uClibc++/include/map =================================================================== --- branches/slice/i386/modules/uClibc++/include/map (revision 0) +++ branches/slice/i386/modules/uClibc++/include/map (revision 727) @@ -0,0 +1,261 @@ +/* Copyright (C) 2004-2007 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 +#include + + +#ifndef __STD_HEADER_MAP +#define __STD_HEADER_MAP + +#pragma GCC visibility push(default) + +namespace std{ + + +template, class Allocator = allocator > class map; +template, class Allocator = allocator > class multimap; + + + //Compare the keys of the two items +/* template class _UCXXEXPORT + __base_map::value_compare : public binary_function< + typename map::value_type, + typename map::value_type, + bool> + { + friend class __base_map; + protected: + Compare comp; + value_compare(Compare c) : comp(c) { } + ~value_compare() { } + public: + bool operator()(const value_type& x, const value_type& y) const { + return comp(x.first, y.first); + } + }; +*/ + +// value_compare value_comp() const; + + + +/* This is the implementation for the map container. As noted above, it deviates + * from ISO spec by deriving from a base class in order to reduce code redundancy. + * More code could be reduced by convirting to virtual functions (thus allowing + * much of the erase and insert code to be duplicated), but that would deviate from + * the specifications too much to be worth the risk. + */ + + + +//Implementation of map + + +template class _UCXXEXPORT map + : public __single_associative, Compare, Allocator> +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it + +public: + + typedef __single_associative, Compare, Allocator> base; + typedef T mapped_type; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + static const key_type v_t_k(const value_type v){ + return v.first; + } + +// using base::value_compare; + + explicit map(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template map(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + map(const map& x) : base(x) { } + ~map() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + + reference operator[](const key_type& k){ + //This is from the spec and is quite ugly. + return (*((insert(make_pair(k, T()))).first)).second; + } + +protected: + using base::backing; +}; + + +//Implementation of multimap + + +template class _UCXXEXPORT multimap + : public __multi_associative, Compare, Allocator> + +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __multi_associative, Compare, Allocator> base; + typedef T mapped_type; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + static const key_type v_t_k(const value_type v){ + return v.first; + } + + explicit multimap(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template multimap(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + + multimap(const multimap& x) : base(x) { } + ~multimap() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + +protected: + + using base::c; + +}; + + +/* Non-member functions. These are at the end because they are not associated with any + particular class. These will be implemented as I figure out exactly what all of + them are supposed to do, and I have time. + */ + + template _UCXXEXPORT bool operator< + (const map& x, const map& y); + template _UCXXEXPORT bool operator!= + (const map& x, const map& y); + template _UCXXEXPORT bool operator> + (const map& x, const map& y); + template _UCXXEXPORT bool operator>= + (const map& x, const map& y); + template _UCXXEXPORT bool operator<= + (const map& x, const map& y); + template _UCXXEXPORT void swap + (map& x, map& y); + + + template _UCXXEXPORT bool operator== + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator< + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator!= + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator> + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator>= + (const multimap& x, const multimap& y); + template _UCXXEXPORT bool operator<= + (const multimap& x, const multimap& y); + template _UCXXEXPORT void swap + (multimap& x, multimap& y); + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/cstdlib =================================================================== --- branches/slice/i386/modules/uClibc++/include/cstdlib (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cstdlib (revision 727) @@ -0,0 +1,71 @@ +/* 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 +#include + +#ifndef __HEADER_CSTDLIB +#define __HEADER_CSTDLIB 1 + + +namespace std{ + using ::abort; + using ::abs; + using ::atexit; + using ::atol; + using ::atof; + using ::atoi; + using ::bsearch; + using ::calloc; + using ::div; + using ::exit; + using ::free; + using ::getenv; + using ::labs; + using ::ldiv; + using ::malloc; + using ::qsort; + using ::rand; + using ::realloc; + using ::srand; + using ::strtod; + using ::strtol; + using ::strtoul; + using ::system; +#ifdef __UCLIBCXX_HAS_WCHAR__ + using ::mblen; + using ::mbstowcs; + using ::mbtowc; + using ::wctomb; + using ::wcstombs; +#endif + + inline long abs(long i){ + return labs(i); + } + + inline ldiv_t div(long i, long j){ + return ldiv(i, j); + } + +} + + + +#endif + Index: branches/slice/i386/modules/uClibc++/include/cctype =================================================================== --- branches/slice/i386/modules/uClibc++/include/cctype (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cctype (revision 727) @@ -0,0 +1,37 @@ +/* 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{ + + using ::isalnum; + using ::isalpha; + using ::iscntrl; + using ::isdigit; + using ::isgraph; + using ::islower; + using ::isprint; + using ::ispunct; + using ::isspace; + using ::isupper; + using ::isxdigit; + using ::tolower; + using ::toupper; + +} Index: branches/slice/i386/modules/uClibc++/include/iterator =================================================================== --- branches/slice/i386/modules/uClibc++/include/iterator (revision 0) +++ branches/slice/i386/modules/uClibc++/include/iterator (revision 727) @@ -0,0 +1,229 @@ +/* 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 + + + +#ifndef __STD_HEADER_ITERATOR +#define __STD_HEADER_ITERATOR 1 + +#pragma GCC visibility push(default) + +namespace std{ + + // subclause _lib.stream.iterators_, stream iterators: + template , class Distance = ptrdiff_t> class istream_iterator; + template bool + operator==(const istream_iterator& x, const istream_iterator& y); + template bool + operator!=(const istream_iterator& x, const istream_iterator& y); + template > class ostream_iterator; + template > class istreambuf_iterator; + template bool + operator==(const istreambuf_iterator& a, const istreambuf_iterator& b); + template bool + operator!=(const istreambuf_iterator& a, const istreambuf_iterator& b); + template > class ostreambuf_iterator; + + + template < class T, class charT, class traits, class Distance > class _UCXXEXPORT istream_iterator + : public iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_istream istream_type; + istream_iterator() : in_stream(0), value(0) {} + istream_iterator(istream_type& s) : in_stream(&s), value() { + *in_stream >> value; + } + istream_iterator(const istream_iterator& x) + : in_stream(x.in_stream), value(x.value) + { } + ~istream_iterator() { } + const T& operator*() const{ + return value; + } + const T* operator->() const{ + return &value; + } + istream_iterator& operator++() { + *in_stream >> value; + return *this; + } + istream_iterator operator++(int){ + istream_iterator tmp = *this; + *in_stream >> value; + return (tmp); + } + bool m_equal(const istream_iterator& x) const{ + return (in_stream == x.in_stream); + } + private: + basic_istream* in_stream; + T value; + }; + + template _UCXXEXPORT + bool operator==(const istream_iterator& x, + const istream_iterator& y) + { + return x.m_equal(y); + } + + template _UCXXEXPORT + bool operator!=(const istream_iterator& x, + const istream_iterator& y) + { + return !(x == y); + } + + template class _UCXXEXPORT ostream_iterator + : public iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_ostream ostream_type; + + ostream_iterator(ostream_type& s) : out_stream(&s), delim(0) { } + ostream_iterator(ostream_type& s, const charT* delimiter) : out_stream(&s), delim(delimiter) { } + ostream_iterator(const ostream_iterator& x) : out_stream(x.out_stream), delim(x.delim) { } + ~ostream_iterator() { } + ostream_iterator& operator=(const T& value){ + *out_stream << value; + if(delim != 0){ + *out_stream << delim; + } + return (*this); + } + ostream_iterator& operator*(){ return *this; } + ostream_iterator& operator++() { return *this; } + ostream_iterator operator++(int) { return *this; } + private: + basic_ostream* out_stream; + const char* delim; + }; + + template class _UCXXEXPORT istreambuf_iterator : + public iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef typename traits::int_type int_type; + typedef basic_streambuf streambuf_type; + typedef basic_istream istream_type; + + class _UCXXEXPORT proxy{ + charT val; + basic_streambuf * buf; + + proxy(charT v, basic_streambuf * b) : val(v), buf(b) { } + public: + charT operator*() { return val; } + }; + + istreambuf_iterator() throw() : sbuf(0) { } + istreambuf_iterator(istream_type& s) throw() : sbuf(s.rdbuf()) { } + istreambuf_iterator(streambuf_type* s) throw() : sbuf(s) { } + istreambuf_iterator(const proxy& p) throw() : sbuf(&p.buf) { } + + charT operator*() const{ + return sbuf->sgetc(); + } + istreambuf_iterator& operator++(){ + sbuf->sbumpc(); + return *this; + } + proxy operator++(int){ + istreambuf_iterator tmp = *this; + sbuf->sbumpc(); + return(tmp); + } + + bool equal(const istreambuf_iterator& b) const{ + return sbuf == b.sbuf || is_eof() && b.is_eof(); + } + private: + streambuf_type* sbuf; + inline bool is_eof() const{ + return sbuf == 0 || sbuf->sgetc() == traits_type::eof(); + } + }; + + template _UCXXEXPORT bool + operator==(const istreambuf_iterator& a, + const istreambuf_iterator& b) + { + return a.equal(b); + } + + template bool _UCXXEXPORT + operator!=(const istreambuf_iterator& a, + const istreambuf_iterator& b) + { + return !a.equal(b); + } + + template class _UCXXEXPORT ostreambuf_iterator + : iterator + { + public: + typedef charT char_type; + typedef traits traits_type; + typedef basic_streambuf streambuf_type; + typedef basic_ostream ostream_type; + public: + ostreambuf_iterator(ostream_type& s) throw() : sbuf(s.rdbuf()), f(false) { } + ostreambuf_iterator(streambuf_type* s) throw() : sbuf(s), f(false) { } + ostreambuf_iterator& operator=(charT c){ + if(failed() == false){ + if(sbuf->sputc(c) == traits::eof()){ + f = true; + } + } + return *this; + } + ostreambuf_iterator& operator*(){ + return *this; + } + ostreambuf_iterator& operator++() { return *this; } + ostreambuf_iterator operator++(int) { return *this; } + bool failed() const throw(){ + return f; + } + + private: + streambuf_type* sbuf; + bool f; + }; + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/bitset =================================================================== --- branches/slice/i386/modules/uClibc++/include/bitset (revision 0) +++ branches/slice/i386/modules/uClibc++/include/bitset (revision 727) @@ -0,0 +1,423 @@ +/* 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 +#include + +#ifndef __STD_BITSET_HEADER +#define __STD_BITSET_HEADER 1 + +#pragma GCC visibility push(default) + +namespace std{ + template class bitset; + + + template bitset operator&(const bitset&, const bitset&); + template bitset operator|(const bitset&, const bitset&); + template bitset operator^(const bitset&, const bitset&); + template basic_istream& + operator>>(basic_istream& is, bitset& x); + + template basic_ostream& + operator<<(basic_ostream& os, const bitset& x); + + //Actual Code + + + template class _UCXXEXPORT bitset { + private: + //Number of characters allocated to hold the bits + static const size_t WORD_SIZE = CHAR_BIT; //Use int maybe? + static const size_t num_bytes = (N + WORD_SIZE - 1) / WORD_SIZE; + + //From the bit number, figure out which byte we are working with + size_t byte_num(size_t bit_num) const{ + if(WORD_SIZE == 8){ + return (bit_num >> 3); + } + if(WORD_SIZE == 16){ + return (bit_num >> 4); + } + if(WORD_SIZE == 32){ + return (bit_num >> 5); + } + if(WORD_SIZE == 64){ + return (bit_num >> 6); + } + return bit_num / WORD_SIZE; + } + //From the bit number, figure out which bit inside the byte we need + size_t bit_num(const size_t bit_num) const{ + return bit_num % WORD_SIZE; + } + + + //Point to the actual data + char data[num_bytes]; + public: + + class _UCXXEXPORT reference { + friend class bitset; + reference() : bit_num(0), parent(0) { } + size_t bit_num; + bitset * parent; + public: + ~reference() { } + reference& operator=(bool x){ // for b[i] = x; + parent->set(bit_num, x); + return *this; + } + reference& operator=(const reference& x){ // for b[i] = b[j]; + parent->set(bit_num, x); + return *this; + } + bool operator~() const{ // flips the bit + return !parent->test(bit_num); + } + operator bool() const{ // for x = b[i]; + return parent->test(bit_num); + } + reference& flip(){ // for b[i].flip(); + parent->flip(bit_num); + return *this; + } + }; + + bitset(){ + reset(); + } + bitset(unsigned long val){ + reset(); + size_t count = sizeof(val) * CHAR_BIT; + if(count > N){ + count = N; + } + for(size_t i = 0; i < count; ++i){ + set(i, ((val >> i) & 1)); + } + } + + bitset(const bitset & val){ + for(size_t i = 0; i < num_bytes; ++i){ + data[i] = val.data[i]; + } + } + + template _UCXXEXPORT + explicit bitset( + const basic_string& str, + typename basic_string::size_type pos = 0, + typename basic_string::size_type n = + basic_string::npos + + ){ + reset(); + if(n > str.length()){ + n = str.length(); + } + size_t width = n; + if (width + pos > str.length()){ + width = str.length() - pos; + } + + for(size_t i = 0; i < width; ++i){ + switch(str[pos + width - i - 1]){ + case '0': + break; + case '1': + set(i); + break; + default: + __throw_invalid_argument(); + } + } + } + + bitset& operator&=(const bitset& rhs){ + for(size_t i =0; i < num_bytes; ++i){ + data[i] &= rhs.data[i]; + } + return *this; + } + + bitset& operator|=(const bitset& rhs){ + for(size_t i =0; i < num_bytes; ++i){ + data[i] |= rhs.data[i]; + } + return *this; + } + bitset& operator^=(const bitset& rhs){ + for(size_t i=0; i < num_bytes; ++i){ + data[i] ^= rhs.data[i]; + } + return *this; + } + + bitset& operator<<=(size_t pos){ + for(size_t i = N-1; i >=pos; --i){ + set(i, test(i - pos)); + } + for(size_t i = 0; i < pos; ++i){ + reset(i); + } + return *this; + } + + bitset& operator>>=(size_t pos){ + for(size_t i = 0; i < (N - pos); ++i){ + set(i, test(i + pos)); + } + for(size_t i = pos; i > 0; --i){ + reset(N - i); + } + return *this; + } + + bitset& set(){ + size_t i; + for(i = 0; i < N ; ++i){ + data[byte_num(i)] |= (1<& set(size_t pos, int val = true){ + if(val == true){ + data[byte_num(pos)] |= (1<& reset(){ + for(size_t i = 0; i <= num_bytes; ++i){ + data[i] = 0; + } + return *this; + } + bitset& reset(size_t pos){ + data[byte_num(pos)] &= ~(1< operator~() const{ + bitset retval(*this); + retval.flip(); + return retval; + } + + bitset& flip(){ + for(size_t i = 0; i <= num_bytes; ++i){ + data[i] = ~data[i]; + } + return *this; + } + bitset& flip(size_t pos){ + char temp = data[byte_num(pos)] & (1 << bit_num(pos)); + if(temp == 0){ //Bit was 0 + data[byte_num(pos)] |= (1 << bit_num(pos)); + }else{ //Bit was 1 + data[byte_num(pos)] &= ~(1< sizeof(unsigned long) * CHAR_BIT){ + __throw_overflow_error(); + } + unsigned long retval = 0; + size_t count = N; + for(size_t i = count; i > 0; --i){ + if(test(i)){ + retval +=1; + } + retval<<=1; + } + if(test(0)){ + retval +=1; + } + return retval; + } + + template + basic_string to_string() const + { + basic_string retval; + retval.reserve(N); + for(size_t i = N ; i > 0; --i){ + if(test(i-1) == true){ + retval.append("1"); + }else{ + retval.append("0"); + } + } + return retval; + } + + + size_t count() const{ + size_t retval = 0; + for(size_t i =0; i < N; ++i){ + if(test(i)){ + ++retval; + } + } + return retval; + } + size_t size() const{ + return N; + } + + bitset& operator=(const bitset & rhs){ + if(&rhs == this){ + return *this; + } + for(size_t i = 0; i <= byte_num(N); ++i){ + data[i] = rhs.data[i]; + } + return *this; + } + + + bool operator==(const bitset& rhs) const{ + for(size_t i =0; i< N; ++i){ + if(test(i) != rhs.test(i)){ + return false; + } + } + return true; + } + + bool operator!=(const bitset& rhs) const{ + for(size_t i =0; i< N; ++i){ + if(test(i) != rhs.test(i)){ + return true; + } + } + return false; + } + + bool test(size_t pos) const{ + return (data[byte_num(pos)] & (1< operator<<(size_t pos) const{ + bitset retval(*this); + retval<<=pos; + return retval; + } + bitset operator>>(size_t pos) const{ + bitset retval(*this); + retval>>=pos; + return retval; + } + }; + + //Non-member functions + + + template _UCXXEXPORT bitset operator&(const bitset& lhs, const bitset& rhs){ + bitset retval(lhs); + retval &= rhs; + return retval; + } + + template _UCXXEXPORT bitset operator|(const bitset& lhs, const bitset& rhs){ + bitset retval(lhs); + retval |= rhs; + return retval; + } + + template _UCXXEXPORT bitset operator^(const bitset& lhs, const bitset& rhs){ + bitset retval(lhs); + retval ^= rhs; + return retval; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, bitset& x) + { + string s; + charT c; + for(size_t i = 0; i < N; ++i){ + is.get(c); + if(!is.good()){ + break; + } + if(c != '1' && c !='0'){ + is.putback(c); + break; + } + s+=c; + } + bitset temp(s); + x = temp; + + return is; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const bitset& x) + { + for(size_t i = N ; i > 0; --i){ + if(x.test(i-1) == true){ + os << "1"; + }else{ + os << "0"; + } + } + return os; + } + + + + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/set =================================================================== --- branches/slice/i386/modules/uClibc++/include/set (revision 0) +++ branches/slice/i386/modules/uClibc++/include/set (revision 727) @@ -0,0 +1,407 @@ +/* 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 +#include + +#ifndef __STD_HEADER_SET +#define __STD_HEADER_SET + +#pragma GCC visibility push(default) + +namespace std{ + + +template, class Allocator = allocator > class set; +template, class Allocator = allocator > class multiset; + + +/* This is the implementation for the set container. As noted above, it deviates + * from ISO spec by deriving from a base class in order to reduce code redundancy. + * More code could be reduced by convirting to virtual functions (thus allowing + * much of the erase and insert code to be duplicated), but that would deviate from + * the specifications too much to be worth the risk. + */ + + +//Implementation of set + + +template class _UCXXEXPORT set + : public __single_associative +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __single_associative base; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + +// using base::value_compare; + + static const key_type v_t_k(const value_type v){ + return v; + } + + explicit set(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template set(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + set(const set& x) : base(x) { } + ~set() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + +protected: + +}; + + +//Implementation of multiset + + +template class _UCXXEXPORT multiset + : public __multi_associative +{ + //Default value of allocator does not meet C++ standard specs, but it works for this library + //Deal with it +public: + + typedef __multi_associative base; + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + static const key_type v_t_k(const value_type v){ + return v; + } + + explicit multiset(const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(comp, al, v_t_k) { } + + template multiset(InputIterator first, InputIterator last, + const Compare& comp = Compare(), const Allocator& al = Allocator()) + : base(first, last, comp, al, v_t_k) { } + + + multiset(const multiset& x) : base(x) { } + ~multiset() { } + + using base::operator=; + using base::operator==; + using base::operator!=; + + using base::insert; + using base::erase; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + + +protected: + +}; + + +/* Non-member functions. These are at the end because they are not associated with any + particular class. These will be implemented as I figure out exactly what all of + them are supposed to do, and I have time. + */ + + template _UCXXEXPORT bool operator< + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + template _UCXXEXPORT bool operator> + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1 && first2 == last2; + } + + template _UCXXEXPORT bool operator>= + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1; + } + + template _UCXXEXPORT bool operator<= + (const set& x, const set& y) + { + typename set::const_iterator first1 = x.begin(); + typename set::const_iterator first2 = y.begin(); + typename set::const_iterator last1 = x.end(); + typename set::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first2!=last2; + } + template _UCXXEXPORT void swap + (set& x, set& y) + { + x.swap(y); + } + + + template _UCXXEXPORT bool operator== + (const multiset& x, const multiset& y) + { + if(x.data == y.data){ + return true; + } + return false; + } + + template _UCXXEXPORT bool operator< + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + template _UCXXEXPORT bool operator!= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 != *first2 ){ + return true; + } + ++first1; + ++first2; + } + return first1!=last1 || first2 != last2; + } + + template _UCXXEXPORT bool operator> + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1 && first2 == last2; + } + + template _UCXXEXPORT bool operator>= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 > *first2 ){ + return true; + } + if( *first2 > *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first1!=last1; + } + + template _UCXXEXPORT bool operator<= + (const multiset& x, const multiset& y) + { + typename multiset::const_iterator first1 = x.begin(); + typename multiset::const_iterator first2 = y.begin(); + typename multiset::const_iterator last1 = x.end(); + typename multiset::const_iterator last2 = y.end(); + + while(first1 != last1 && first2 != last2){ + if( *first1 < *first2 ){ + return true; + } + if( *first2 < *first1 ){ + return false; + } + ++first1; + ++first2; + } + return first2!=last2; + } + + template _UCXXEXPORT void swap + (multiset& x, multiset& y) + { + x.swap(y); + } + + + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/iosfwd =================================================================== --- branches/slice/i386/modules/uClibc++/include/iosfwd (revision 0) +++ branches/slice/i386/modules/uClibc++/include/iosfwd (revision 727) @@ -0,0 +1,114 @@ +/* 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 + + +#ifndef __HEADER_STD_IOSFWD +#define __HEADER_STD_IOSFWD 1 + +#pragma GCC visibility push(default) + +namespace std { + class ios_base; + template<> class char_traits; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template<> class char_traits; +#endif + + template > class basic_ios; + + template > class basic_streambuf; + template > class basic_istream; + template > class basic_ostream; + template > class basic_iostream; + + template , + class Allocator = allocator > class basic_stringbuf; + + template , + class Allocator = allocator > class basic_istringstream; + + template , + class Allocator = allocator > class basic_ostringstream; + + template , + class Allocator = allocator > class basic_stringstream; + + template > class basic_filebuf; + + template > class basic_ifstream; + + template > class basic_ofstream; + + template > class basic_fstream; + + template > class basic_istreambuf_iterator; + + template > class basic_ostreambuf_iterator; + + typedef basic_ios ios; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_ios wios; +#endif + + typedef basic_streambuf streambuf; + typedef basic_istream istream; + typedef basic_ostream ostream; + typedef basic_iostream iostream; + + typedef basic_stringbuf stringbuf; + typedef basic_istringstream istringstream; + typedef basic_ostringstream ostringstream; + typedef basic_stringstream stringstream; + + typedef basic_filebuf filebuf; + typedef basic_ifstream ifstream; + typedef basic_ofstream ofstream; + typedef basic_fstream fstream; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_streambuf wstreambuf; + typedef basic_istream wistream; + typedef basic_ostream wostream; + typedef basic_iostream wiostream; + + typedef basic_stringbuf wstringbuf; + typedef basic_istringstream wistringstream; + typedef basic_ostringstream wostringstream; + typedef basic_stringstream wstringstream; + + typedef basic_filebuf wfilebuf; + typedef basic_ifstream wifstream; + typedef basic_ofstream wofstream; + typedef basic_fstream wfstream; +#endif + + template class fpos; + typedef fpos::state_type> streampos; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef fpos::state_type> wstreampos; +#endif +} + +#pragma GCC visibility pop + +#endif Index: branches/slice/i386/modules/uClibc++/include/cmath =================================================================== --- branches/slice/i386/modules/uClibc++/include/cmath (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cmath (revision 727) @@ -0,0 +1,205 @@ +/* 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 + +#ifndef __STD_HEADER_CMATH +#define __STD_HEADER_CMATH 1 + +namespace std{ + using ::acos; + using ::asin; + using ::atan; + using ::atan2; + using ::ceil; + using ::cos; + using ::cosh; + using ::exp; + using ::fabs; + using ::floor; + using ::fmod; + using ::frexp; + using ::ldexp; + using ::log; + using ::log10; + using ::modf; + using ::pow; + using ::sin; + using ::sinh; + using ::sqrt; + using ::tan; + using ::tanh; + + inline float abs (float x){ + return fabsf(x); + } + inline float acos (float x){ + return acosf(x); + } + inline float asin (float x){ + return asinf(x); + } + inline float atan (float x){ + return atanf(x); + } + inline float atan2(float y, float x){ + return atan2f(y, x); + } + inline float ceil (float x){ + return ceilf(x); + } + inline float cos (float x){ + return cosf(x); + } + inline float cosh (float x){ + return coshf(x); + } + inline float exp (float x){ + return expf(x); + } + inline float fabs (float x){ + return fabsf(x); + } + inline float floor(float x){ + return floorf(x); + } + inline float fmod (float x, float y){ + return fmodf(x, y); + } + inline float frexp(float x, int* exp){ + return frexpf(x, exp); + } + inline float ldexp(float x, int exp){ + return ldexpf(x, exp); + } + inline float log (float x){ + return logf(x); + } + inline float log10(float x){ + return log10f(x); + } + inline float modf (float x, float* inptr){ + return modff(x, inptr); + } + inline float pow (float x, float y){ + return powf(x, y); + } + inline float pow (float x, int y){ + return pow((double)x, (double)y); + } + inline float sin (float x){ + return sinf(x); + } + inline float sinh (float x){ + return sinhf(x); + } + inline float sqrt (float x){ + return sqrtf(x); + } + inline float tan (float x){ + return tanf(x); + } + inline float tanh (float x){ + return tanhf(x); + } + inline double abs(double x){ + return fabs(x); + } + inline double pow(double x, int y){ + return pow((double)x, (double)y); + } + +#ifdef __UCLIBCXX_HAS_LONG_DOUBLE__ + inline long double abs (long double x){ + return fabsl(x); + } + inline long double acos (long double x){ + return acosl(x); + } + inline long double asin (long double x){ + return asinl(x); + } + inline long double atan (long double x){ + return atanl(x); + } + inline long double atan2(long double y, long double x){ + return atan2l(y, x); + } + inline long double ceil (long double x){ + return ceill(x); + } + inline long double cos (long double x){ + return cosl(x); + } + inline long double cosh (long double x){ + return coshl(x); + } + inline long double exp (long double x){ + return expl(x); + } + inline long double fabs (long double x){ + return fabsl(x); + } + inline long double floor(long double x){ + return floorl(x); + } + inline long double frexp(long double x, int* exp){ + return frexpl(x, exp); + } + inline long double fmod (long double x, long double y){ + return fmodl(x, y); + } + inline long double ldexp(long double x, int y){ + return ldexpl(x, y); + } + inline long double log (long double x){ + return logl(x); + } + inline long double log10(long double x){ + return log10l(x); + } + inline long double modf (long double x, long double* iptr){ + return modfl(x, iptr); + } + inline long double pow (long double x, long double y){ + return powl(x, y); + } + inline long double pow (long double x, int y){ + return powl(x, (long double)y ); + } + inline long double sin (long double x){ + return sinl(x); + } + inline long double sinh (long double x){ + return sinhl(x); + } + inline long double sqrt (long double x){ + return sqrtl(x); + } + inline long double tan (long double x){ + return tanl(x); + } + inline long double tanh (long double x){ + return tanhl(x); + } +#endif // __UCLIBCXX_HAS_LONG_DOUBLE__ +} + +#endif //__STD_HEADER_CMATH + Index: branches/slice/i386/modules/uClibc++/include/system_configuration.h =================================================================== --- branches/slice/i386/modules/uClibc++/include/system_configuration.h (revision 0) +++ branches/slice/i386/modules/uClibc++/include/system_configuration.h (revision 727) @@ -0,0 +1,59 @@ +/* + * Automatically generated C config: don't edit + */ +/* + * Version Number + */ +#define __UCLIBCXX_MAJOR__ 0 +#define __UCLIBCXX_MINOR__ 2 +#define __UCLIBCXX_SUBLEVEL__ 2 + +/* + * Target Features and Options + */ +#define __UCLIBCXX_HAS_FLOATS__ 1 +#undef __UCLIBCXX_HAS_LONG_DOUBLE__ +#undef __UCLIBCXX_HAS_TLS__ +#define __WARNINGS__ "-Wall" +#define __BUILD_EXTRA_LIBRARIES__ "" +#define __HAVE_DOT_CONFIG__ 1 + +/* + * String and I/O Stream Support + */ +#undef __UCLIBCXX_HAS_WCHAR__ +#define __UCLIBCXX_IOSTREAM_BUFSIZE__ 32 +#define __UCLIBCXX_HAS_LFS__ 1 +#define __UCLIBCXX_SUPPORT_CDIR__ 0 +#define __UCLIBCXX_SUPPORT_CIN__ 0 +#define __UCLIBCXX_SUPPORT_COUT__ 0 +#define __UCLIBCXX_SUPPORT_CERR__ 0 +#undef __UCLIBCXX_SUPPORT_CLOG__ + +/* + * STL and Code Expansion + */ +#define __UCLIBCXX_STL_BUFFER_SIZE__ 32 +#define __UCLIBCXX_CODE_EXPANSION__ 1 +#undef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ +#define __UCLIBCXX_EXPAND_STRING_CHAR__ 1 +#define __UCLIBCXX_EXPAND_VECTOR_BASIC__ 1 +#define __UCLIBCXX_EXPAND_IOS_CHAR__ 1 +#define __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ 1 +#define __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 1 +#define __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 1 +#define __UCLIBCXX_EXPAND_FSTREAM_CHAR__ 1 +#define __UCLIBCXX_EXPAND_SSTREAM_CHAR__ 1 + +/* + * Library Installation Options + */ +#define __UCLIBCXX_RUNTIME_PREFIX__ "." +#define __UCLIBCXX_RUNTIME_INCLUDE_SUBDIR__ "/include" +#define __UCLIBCXX_RUNTIME_LIB_SUBDIR__ "/lib" +#define __UCLIBCXX_RUNTIME_BIN_SUBDIR__ "/bin" +#undef __UCLIBCXX_EXCEPTION_SUPPORT__ +#define __BUILD_STATIC_LIB__ 1 +#define __BUILD_ONLY_STATIC_LIB__ 1 +#undef __DODEBUG__ + Index: branches/slice/i386/modules/uClibc++/include/limits =================================================================== --- branches/slice/i386/modules/uClibc++/include/limits (revision 0) +++ branches/slice/i386/modules/uClibc++/include/limits (revision 727) @@ -0,0 +1,615 @@ +/* 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 + +#ifndef __STD_HEADER_LIMITS +#define __STD_HEADER_LIMITS 1 + +//#warning limits header is nowhere complete or accurate + +#pragma GCC visibility push(default) + +namespace std{ + +enum float_round_style{ + round_indeterminate =-1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, + round_toward_neg_infinity = 3 +}; + +template struct __bits_to_base_10{ + static const int size = -1; +}; +template <> struct __bits_to_base_10<7>{ + static const int size = 2; +}; +template <> struct __bits_to_base_10<8>{ + static const int size = 2; +}; +template <> struct __bits_to_base_10<9>{ + static const int size = 2; +}; +template <> struct __bits_to_base_10<10>{ + static const int size = 3; +}; +template <> struct __bits_to_base_10<15>{ + static const int size = 4; +}; +template <> struct __bits_to_base_10<16>{ + static const int size = 4; +}; +template <> struct __bits_to_base_10<17>{ + static const int size = 5; +}; +template <> struct __bits_to_base_10<18>{ + static const int size = 5; +}; +template <> struct __bits_to_base_10<31>{ + static const int size = 9; +}; +template <> struct __bits_to_base_10<32>{ + static const int size = 9; +}; +template <> struct __bits_to_base_10<35>{ + static const int size = 10; +}; +template <> struct __bits_to_base_10<36>{ + static const int size = 10; +}; +template <> struct __bits_to_base_10<63>{ + static const int size = 18; +}; +template <> struct __bits_to_base_10<64>{ + static const int size = 19; +}; +template <> struct __bits_to_base_10<71>{ + static const int size = 21; +}; +template <> struct __bits_to_base_10<72>{ + static const int size = 21; +}; +template <> struct __bits_to_base_10<79>{ + static const int size = 23; +}; +template <> struct __bits_to_base_10<80>{ + static const int size = 24; +}; +template <> struct __bits_to_base_10<127>{ + static const int size = 38; +}; +template <> struct __bits_to_base_10<128>{ + static const int size = 38; +}; + + + + + + +template class numeric_limits { +public: + // General -- meaningful for all specializations. + + static const bool is_specialized = false; + static T min(); + static T max(); + static const int radix; + static const int digits; + static const int digits10; + static const bool is_signed; + static const bool is_integer; + static const bool is_exact; + static const bool traps; + static const bool is_modulo; + static const bool is_bounded; + + // Floating point specific. + + static T epsilon(); + static T round_error(); + static const int min_exponent10; + static const int max_exponent10; + static const int min_exponent; + + static const int max_exponent; + static const bool has_infinity; + static const bool has_quiet_NaN; + static const bool has_signaling_NaN; + static const bool is_iec559; + static const bool has_denorm; + static const bool tinyness_before; + static const float_round_style round_style; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned char T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return UCHAR_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT; + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed char T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return SCHAR_MIN; + } + static T max(){ + return SCHAR_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT - 1; + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef char T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return CHAR_MIN; + } + static T max(){ + return CHAR_MAX; + } + static const int radix = 2; + static const int digits = (CHAR_MIN != 0) ? CHAR_BIT - 1 : CHAR_BIT; + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = (CHAR_MIN != 0); + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned short T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return USHRT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed short T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return SHRT_MIN; + } + static T max(){ + return SHRT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return UINT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return INT_MIN; + } + static T max(){ + return INT_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef unsigned long int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return 0; + } + static T max(){ + return ULONG_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = false; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { +public: + typedef signed long int T; + // General -- meaningful for all specializations. + static const bool is_specialized = true; + static T min(){ + return LONG_MIN; + } + static T max(){ + return LONG_MAX; + } + static const int radix = 2; + static const int digits = CHAR_BIT * sizeof(T); + static const int digits10 = __bits_to_base_10::size; + static const bool is_signed = true; + static const bool is_integer = true; + static const bool is_exact = true; + static const bool traps = false; + static const bool is_modulo = true; + static const bool is_bounded = true; + + // Floating point specific. + + static T epsilon(){ + return 0; + } + static T round_error(){ + return 0; + } + static const int min_exponent10 = 0; + static const int max_exponent10 = 0; + static const int min_exponent = 0; + + static const int max_exponent = 0; + static const bool has_infinity = false; + static const bool has_quiet_NaN = false; + static const bool has_signaling_NaN = false; + static const bool is_iec559 = false; + static const bool has_denorm = false; + static const bool tinyness_before = false; + static const float_round_style round_style = round_indeterminate; + static T denorm_min(); + static T infinity(); + static T quiet_NaN(); + static T signaling_NaN(); +}; + +template <> class numeric_limits { + typedef double numeric_type; + + static const bool is_specialized = true; + static numeric_type min () { return __DBL_MIN__; } + static numeric_type max () { return __DBL_MAX__; } + static const int radix = __FLT_RADIX__; + static const int digits = __DBL_MANT_DIG__; + static const int digits10 = __DBL_DIG__; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = false; + static const bool traps = false; // this is a guess + static const bool is_modulo = false; + static const bool is_bounded = true; + + // Floating point specific. + + static numeric_type epsilon () { return __DBL_EPSILON__; } + static numeric_type round_error () { return 0.5; } + static const int min_exponent10 = -1; //How do I properly get this? + static const int max_exponent10 = -1; //How do I properly get this? + static const int min_exponent = -1; //How do I properly get this? + static const int max_exponent = -1; //How do I properly get this? + static const bool has_infinity = false; //I don't know, so until I can find out, I'm saying no + static const bool has_quiet_NaN = false; //I don't know, so until I can find out, I'm saying no + static const bool has_signaling_NaN = false; //I don't know, so until I can find out, I'm saying no + static const bool has_denorm = false; //I don't know, so until I can find out, I'm saying no + + static const bool is_iec559 = false; //I don't know, so until I can find out, I'm saying no + static const bool tinyness_before = false; // more questions + static const float_round_style round_style = round_to_nearest; // more questions + static numeric_type denorm_min () { return -1; } //How do I properly get this? + static numeric_type infinity () { return -1; } //How do I properly get this? + static numeric_type quiet_NaN () { return -1; } //How do I properly get this? + static numeric_type signaling_NaN () { return -1; } //How do I properly get this? +}; + + + + + +} + +#pragma GCC visibility pop + +#endif Index: branches/slice/i386/modules/uClibc++/include/functional =================================================================== --- branches/slice/i386/modules/uClibc++/include/functional (revision 0) +++ branches/slice/i386/modules/uClibc++/include/functional (revision 727) @@ -0,0 +1,439 @@ +/* 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 +*/ + + +#ifndef __STD_HEADER_FUNCTIONAL +#define __STD_HEADER_FUNCTIONAL 1 + +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template struct unary_function; + template struct binary_function; + + template struct plus; + template struct minus; + template struct multiplies; + template struct divides; + template struct modulus; + template struct negate; + + template struct equal_to; + template struct not_equal_to; + template struct greater; + template struct less; + template struct greater_equal; + template struct less_equal; + + template struct logical_and; + template struct logical_or; + template struct logical_not; + + template struct unary_negate; + template unary_negate not1(const Predicate&); + template struct binary_negate; + template binary_negate not2(const Predicate&); + + + template class binder1st; + template binder1st bind1st(const Operation&, const T&); + template class binder2nd; + template binder2nd bind2nd(const Operation&, const T&); + + template class pointer_to_unary_function; + template pointer_to_unary_function ptr_fun(Result (*)(Arg)); + template class pointer_to_binary_function; + template + pointer_to_binary_function ptr_fun(Result (*)(Arg1,Arg2)); + + template class mem_fun_t; + template class mem_fun1_t; + template class const_mem_fun_t; + template class const_mem_fun1_t; + template mem_fun_t mem_fun(S (T::*f)()); + template mem_fun1_t mem_fun(S (T::*f)(A)); + template class mem_fun_ref_t; + template class mem_fun1_ref_t; + template mem_fun_ref_t mem_fun_ref(S (T::*f)()); + template mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A)); + + //Implementation + + template struct _UCXXEXPORT unary_function{ + typedef Arg argument_type; + typedef Result result_type; + }; + + + template struct _UCXXEXPORT binary_function{ + typedef Arg1 first_argument_type; + typedef Arg2 second_argument_type; + typedef Result result_type; + }; + + template struct _UCXXEXPORT plus : binary_function{ + T operator()(const T& x, const T& y) const{ + return x + y; + } + }; + + template struct _UCXXEXPORT minus : binary_function{ + T operator()(const T& x, const T& y) const{ + return x - y; + } + }; + + template struct _UCXXEXPORT multiplies : binary_function{ + T operator()(const T& x, const T& y) const{ + return x * y; + } + }; + + template struct _UCXXEXPORT divides : binary_function{ + T operator()(const T& x, const T& y) const{ + return x / y; + } + }; + + template struct _UCXXEXPORT modulus : binary_function{ + T operator()(const T& x, const T& y) const{ + return x % y; + } + }; + + template struct _UCXXEXPORT negate : unary_function{ + T operator()(const T& x) const{ + return -x; + } + }; + + template struct _UCXXEXPORT equal_to : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x == y); + } + }; + + template struct _UCXXEXPORT not_equal_to : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x != y); + } + }; + + template struct _UCXXEXPORT greater : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x > y); + } + }; + + template struct _UCXXEXPORT less : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x < y); + } + }; + + template struct _UCXXEXPORT greater_equal : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x >= y); + } + }; + + template struct _UCXXEXPORT less_equal : binary_function{ + bool operator()(const T& x, const T& y) const{ + return (x <= y); + } + }; + + template struct _UCXXEXPORT logical_and : binary_function { + bool operator()(const T& x, const T& y) const{ + return (x && y); + } + }; + + template struct _UCXXEXPORT logical_or : binary_function { + bool operator()(const T& x, const T& y) const{ + return (x || y); + } + }; + + template struct _UCXXEXPORT logical_not : unary_function { + bool operator()(const T& x) const{ + return !x; + } + }; + + template class _UCXXEXPORT unary_negate + : public unary_function + { + public: + explicit unary_negate(const Predicate& pred) : p(pred) { } + bool operator()(const typename Predicate::argument_type& x) const{ + return !p(x); + } + private: + Predicate p; + }; + + + template _UCXXEXPORT unary_negate not1(const Predicate& pred){ + return unary_negate(pred); + } + + + template class _UCXXEXPORT binary_negate : public + binary_function + { + public: + explicit binary_negate(const Predicate& pred) : p(pred) { } + bool operator()(const typename Predicate::first_argument_type& x, + const typename Predicate::second_argument_type& y) const + { + return !p(x, y); + } + private: + Predicate p; + }; + + + template _UCXXEXPORT binary_negate not2(const Predicate& pred){ + return binary_negate(pred); + } + + + template class _UCXXEXPORT binder1st + : public unary_function + { + protected: + Operation op; + typename Operation::first_argument_type value; + public: + binder1st(const Operation& x, const typename Operation::first_argument_type& y) : op(x), value(y){ } + typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const{ + return op(value,x); + } + }; + + + template _UCXXEXPORT binder1st bind1st(const Operation& op, const T& x){ + return binder1st(op, typename Operation::first_argument_type(x)); + } + + + template class _UCXXEXPORT binder2nd + : public unary_function + { + protected: + Operation op; + typename Operation::second_argument_type value; + public: + binder2nd(const Operation& x, const typename Operation::second_argument_type& y) : op(x), value(y) { } + typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const{ + return op(x,value); + } + }; + + + template _UCXXEXPORT + binder2nd bind2nd(const Operation& op, const T& x) + { + return binder2nd(op, typename Operation::second_argument_type(x)); + } + + + template class _UCXXEXPORT + pointer_to_unary_function : public unary_function + { + protected: + Result (*func)(Arg); + public: + explicit pointer_to_unary_function(Result (*f)(Arg)) : func(f) { } + Result operator()(Arg x) const{ + return func(x); + } + }; + + + template _UCXXEXPORT pointer_to_unary_function ptr_fun(Result (*f)(Arg)){ + return pointer_to_unary_function(f); + } + + + template class _UCXXEXPORT + pointer_to_binary_function : public binary_function + { + protected: + Result (*func)(Arg1, Arg2); + public: + explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) : func(f) { } + Result operator()(Arg1 x, Arg2 y) const{ + return func(x, y); + } + }; + + template _UCXXEXPORT + pointer_to_binary_function ptr_fun(Result (*f)(Arg1, Arg2)) + { + return pointer_to_binary_function(f); + } + + + template class _UCXXEXPORT mem_fun_t + : public unary_function + { + public: + explicit mem_fun_t(S (T::*p)()) : m(p) { } + S operator()(T* p) const { return (p->*m)(); } + private: + S (T::*m)(); + }; + + + template class _UCXXEXPORT mem_fun1_t + : public binary_function + { + public: + explicit mem_fun1_t(S (T::*p)(A)) : m(p) { } + S operator()(T* p, A x) const { return (p->*m)(x); } + private: + S (T::*m)(A); + }; + + + template class _UCXXEXPORT const_mem_fun_t + : public unary_function + { + public: + explicit const_mem_fun_t(S (T::*p)() const) : m(p) { } + S operator()(const T* p) const { return (p->*m)(); } + private: + S (T::*m)() const; + }; + + + template class _UCXXEXPORT const_mem_fun1_t + : public binary_function + { + public: + explicit const_mem_fun1_t(S (T::*p)(A) const) : m(p) { } + S operator()(const T* p, A x) const { return (p->*m)(x); } + private: + S (T::*m)(A) const; + }; + + + template _UCXXEXPORT mem_fun_t mem_fun(S (T::*f)()){ + return mem_fun_t(f); + } + + template _UCXXEXPORT const_mem_fun_t mem_fun(S (T::*f)() const){ + return const_mem_fun_t(f); + } + + template _UCXXEXPORT mem_fun1_t mem_fun(S (T::*f)(A)){ + return mem_fun1_t(f); + } + + template _UCXXEXPORT const_mem_fun1_t mem_fun(S (T::*f)(A) const){ + return const_mem_fun1_t(f); + } + + template class _UCXXEXPORT mem_fun_ref_t + : public unary_function + { + public: + explicit mem_fun_ref_t(S (T::*p)()) : mf(p) { } + S operator()(T& p) { return (p.*mf)(); } + private: + S (T::*mf)(); + }; + + template class _UCXXEXPORT mem_fun1_ref_t + : public binary_function + { + public: + explicit mem_fun1_ref_t(S (T::*p)(A)) : mf(p) { } + S operator()(T& p, A x) { return (p.*mf)(x); } + private: + S (T::*mf)(A); + }; + + template _UCXXEXPORT mem_fun_ref_t mem_fun_ref(S (T::*f)()){ + return mem_fun_ref_t(f); + } + + template _UCXXEXPORT mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A)){ + return mem_fun1_ref_t(f); + } + + +} + + +//These are SGI extensions which are checked for by some conformance checks. They +// are *NOT* part of the C++ standard, however + +template class _UCXXEXPORT unary_compose : + public std::unary_function +{ +protected: + Op1 mf1; + Op2 mf2; +public: + unary_compose(const Op1& x, const Op2& y) : mf1(x), mf2(y) { } + typename Op1::result_type operator()(const typename Op2::argument_type& x) const { + return mf1(mf2(x)); + } +}; + +template _UCXXEXPORT +inline unary_compose +compose1(const Op1& fn1, const Op2& fn2){ + return unary_compose(fn1, fn2); +} + +template class _UCXXEXPORT binary_compose : + public std::unary_function +{ +protected: + Op1 mf1; + Op2 mf2; + Op3 mf3; +public: + binary_compose(const Op1 & x, const Op2 & y, const Op3 & z) + : mf1(x), mf2(y), mf3(z){ } + typename Op1::result_type operator()(const typename Op2::argument_type & x) const { + return mf1(mf2(x), mf3(x)); + } +}; + +template inline _UCXXEXPORT binary_compose +compose2(const Op1 & fn1, const Op2 & fn2, const Op3 & fn3){ + return binary_compose(fn1, fn2, fn3); +} + +#pragma GCC visibility pop + +#endif + + + Index: branches/slice/i386/modules/uClibc++/include/types =================================================================== --- branches/slice/i386/modules/uClibc++/include/types (revision 0) +++ branches/slice/i386/modules/uClibc++/include/types (revision 727) @@ -0,0 +1,3 @@ +extern "C" { + #include "types.h" +} \ No newline at end of file Index: branches/slice/i386/modules/uClibc++/include/istream =================================================================== --- branches/slice/i386/modules/uClibc++/include/istream (revision 0) +++ branches/slice/i386/modules/uClibc++/include/istream (revision 727) @@ -0,0 +1,601 @@ +/* Copyright (C) 2004 Garrett A. Kajmowicz + + This file is part of the uClibc C++ Library. This library is free + software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this library; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. +*/ + +#include +#include +#include +#include +#include + +#ifndef __STD_HEADER_ISTREAM +#define __STD_HEADER_ISTREAM 1 + +#pragma GCC visibility push(default) + +namespace std{ + + typedef basic_istream istream; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_istream wistream; +#endif + + template basic_istream& ws(basic_istream& is); + + template class _UCXXEXPORT basic_istream : + virtual public basic_ios + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef basic_streambuf streambuf_type; + typedef traits traits_type; + + explicit basic_istream(basic_streambuf* sb) + : basic_ios(sb), count_last_ufmt_input(0) + { + basic_ios::init(sb); + } + virtual ~basic_istream() { } + + class sentry; + + basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); + basic_istream& operator>>(basic_ios& (*pf)(basic_ios&)); + basic_istream& operator>>(ios_base& (*pf)(ios_base&)); + basic_istream& operator>>(bool& n); + basic_istream& operator>>(short& n); + basic_istream& operator>>(unsigned short& n); + basic_istream& operator>>(int& n); + basic_istream& operator>>(unsigned int& n); + basic_istream& operator>>(long& n); + basic_istream& operator>>(unsigned long& n); + basic_istream& operator>>(void*& p); + basic_istream& operator>>(basic_streambuf* sb); + +#ifdef __UCLIBCXX_HAS_FLOATS__ + basic_istream& operator>>(float& f); + basic_istream& operator>>(double& f); + basic_istream& operator>>(long double& f); +#endif + + _UCXXEXPORT streamsize gcount() const{ + return count_last_ufmt_input; + } + + _UCXXEXPORT int_type get(); //below + _UCXXEXPORT basic_istream& get(char_type& c); //Below + + _UCXXEXPORT basic_istream& get(char_type* s, streamsize n){ + return get(s, n, basic_ios::widen('\n')); + } + + _UCXXEXPORT basic_istream& get(char_type* s, streamsize n, char_type delim){ + sentry(*this, true); + streamsize i = 0; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + basic_ios::mstreambuf->sbumpc(); + if(c == traits::eof() ){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + }else{ + basic_ios::setstate(ios_base::eofbit); + } + break; + } + if(c == delim){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + } + basic_ios::mstreambuf->sputbackc(c); + break; + } + s[i] = c; + } + s[i] = traits::eos(); + count_last_ufmt_input = i; + return *this; + } + + _UCXXEXPORT basic_istream& get(basic_streambuf& sb){ + return get(sb, basic_ios::widen('\n')); + } + + _UCXXEXPORT basic_istream& get(basic_streambuf& sb, char_type delim){ + sentry(*this, true); + streamsize i = 0; + int_type c; + while(1){ //We will exit internally based upon error conditions + c = basic_ios::mstreambuf->sgetc(); + if(c == traits::eof()){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + }else{ + basic_ios::setstate(ios_base::eofbit); + } + count_last_ufmt_input = i; + return *this; + } + if(c == delim){ + if(i==0){ + basic_ios::setstate(ios_base::failbit); + } + count_last_ufmt_input = i; + return *this; + } + if(sb.sputc(c) != c){ //Error doing output + count_last_ufmt_input = i; + return *this; + } + ++i; + basic_ios::mstreambuf->sbumpc(); + } + } + + _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n){ + return getline(s, n, basic_ios::widen('\n')); + } + + _UCXXEXPORT basic_istream& getline(char_type* s, streamsize n, char_type delim){ + sentry(*this, true); + streamsize i = 0; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + if(c == traits::eof() ){ + if( basic_ios::eof() ){ + basic_ios::setstate(ios_base::failbit); + }else{ + basic_ios::setstate(ios_base::eofbit); + } + count_last_ufmt_input = i; + s[i] = traits::eos(); + return *this; + } + if(basic_ios::mstreambuf->sbumpc()==traits::eof() ){ + basic_ios::setstate(ios_base::eofbit); + } + if(c == delim){ + count_last_ufmt_input = i+1; + s[i] = traits::eos(); + return *this; + } + s[i] = c; + } + s[n-1] = traits::eos(); + return *this; + } + + _UCXXEXPORT basic_istream& ignore (streamsize n = 1, int_type delim = traits::eof()){ + sentry(*this, true); + streamsize i; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + if(c == traits::eof()){ + basic_ios::setstate(ios_base::eofbit); + return *this; + } + basic_ios::mstreambuf->sbumpc(); + if(c == delim){ + return *this; + } + } + return *this; + } + + _UCXXEXPORT int_type peek(){ + if(basic_ios::good() == false){ + return traits::eof(); + }else{ + int_type c = basic_ios::mstreambuf->sgetc(); + if(c == traits::eof()){ + basic_ios::setstate(ios_base::eofbit); + } + return basic_ios::mstreambuf->sgetc(); + } + } + + _UCXXEXPORT basic_istream& read (char_type* s, streamsize n){ + sentry(*this, true); + streamsize i; + int_type c; + for(i=0;i::mstreambuf->sgetc(); + + if(c == traits::eof()){ + basic_ios::setstate(ios_base::failbit); + basic_ios::setstate(ios_base::eofbit); + count_last_ufmt_input = i; + return *this; + } + basic_ios::mstreambuf->sbumpc(); + s[i] = c; + } + count_last_ufmt_input = n; + return *this; + } + + _UCXXEXPORT streamsize readsome(char_type* s, streamsize n){ + sentry(*this, true); + if(!basic_ios::good()){ + count_last_ufmt_input = 0; + basic_ios::setstate(ios_base::failbit); + return 0; + } + + if( basic_ios::mstreambuf->in_avail() == -1){ + count_last_ufmt_input=0; + basic_ios::setstate(ios_base::eofbit); + return 0; + } + + if(n > basic_ios::mstreambuf->in_avail() ){ + n = basic_ios::mstreambuf->in_avail(); + } + + streamsize i; + int_type c; + + for(i=0;i::mstreambuf->sgetc(); + basic_ios::mstreambuf->sbumpc(); + s[i] = c; + } + count_last_ufmt_input = n; + return n; + } + + _UCXXEXPORT basic_istream& putback(char_type c){ + sentry(*this, true); + if(!basic_ios::good()){ + basic_ios::setstate(ios_base::failbit); + return *this; + } + if(basic_ios::mstreambuf == 0){ + basic_ios::setstate(ios_base::badbit); + return *this; + } + if(basic_ios::mstreambuf->sputbackc(c) == traits::eof()){ + basic_ios::setstate(ios_base::badbit); + return *this; + } + return *this; + } + + _UCXXEXPORT basic_istream& unget(){ + sentry(*this, true); + if(!basic_ios::good()){ + basic_ios::setstate(ios_base::failbit); + return *this; + } + if(basic_ios::mstreambuf == 0){ + basic_ios::setstate(ios_base::failbit); + return *this; + } + if(basic_ios::mstreambuf->sungetc() == traits::eof()){ + basic_ios::setstate(ios_base::failbit); + } + return *this; + } + + _UCXXEXPORT int sync(){ + sentry(*this, true); + if(basic_ios::mstreambuf == 0){ + return -1; + } + if(basic_ios::mstreambuf->pubsync() == -1){ + basic_ios::setstate(ios_base::badbit); + return traits::eof(); + } + return 0; + } + + _UCXXEXPORT pos_type tellg(){ + if(basic_ios::fail() !=false){ + return pos_type(-1); + } + return basic_ios::mstreambuf->pubseekoff(0, ios_base::cur, ios_base::in); + } + + _UCXXEXPORT basic_istream& seekg(pos_type pos){ + if(basic_ios::fail() !=true){ + basic_ios::mstreambuf->pubseekpos(pos); + } + return *this; + } + + _UCXXEXPORT basic_istream& seekg(off_type off, ios_base::seekdir dir){ + if(basic_ios::fail() !=true){ + basic_ios::mstreambuf->pubseekoff(off, dir); + } + return *this; + } + + protected: + _UCXXEXPORT basic_istream(const basic_istream &): basic_ios() { } + _UCXXEXPORT basic_istream & operator=(const basic_istream &){ return *this; } + streamsize count_last_ufmt_input; + + }; + + template > class _UCXXEXPORT basic_istream::sentry { + bool ok; + public: + explicit _UCXXEXPORT sentry(basic_istream& os, bool noskipws = false){ + if(os.good() !=0){ //Prepare for output + } + + //Flush any tied buffer + if(os.tie() != 0){ + os.tie()->flush(); + } + if(!noskipws){ + __skipws(os); + } + + ok = true; + } + _UCXXEXPORT ~sentry() { } + _UCXXEXPORT operator bool() { + return ok; + } + }; + + //Template implementations of basic_istream functions which may be partially specialized + //For code reduction + + template + _UCXXEXPORT typename basic_istream::int_type basic_istream::get(){ + sentry(*this, true); + int_type retval = basic_ios::mstreambuf->sgetc(); + if(retval == traits::eof()){ + count_last_ufmt_input = 0; + basic_ios::setstate(ios_base::eofbit); + }else{ + count_last_ufmt_input = 1; + basic_ios::mstreambuf->sbumpc(); + } + return retval; + } + + template + _UCXXEXPORT basic_istream& basic_istream::get(char_type& c){ + sentry(*this, true); + int_type retval = basic_ios::mstreambuf->sgetc(); + if(retval == traits::eof()){ + count_last_ufmt_input = 0; + basic_ios::setstate(ios_base::eofbit); + basic_ios::setstate(ios_base::failbit); + }else{ + count_last_ufmt_input = 1; + c = traits::to_char_type(retval); + basic_ios::mstreambuf->sbumpc(); + } + return *this; + } + + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(bool& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(short& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(unsigned short& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& basic_istream::operator>>(int& n){ + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& basic_istream::operator>>(unsigned int& n){ + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& basic_istream::operator>>(long int& n){ + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(unsigned long int& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + +#ifdef __UCLIBCXX_HAS_FLOATS__ + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(float& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(double& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(long double& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } +#endif + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(void *& n) + { + sentry(*this); + __istream_readin::readin(*this, n); + return *this; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, charT& c) + { + typename basic_istream::sentry s(is); + is.get(c); + return is; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, unsigned char& c) + { + typename basic_istream::sentry s(is); + char b; + is.get(b); + c = b; + return is; + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, signed char& c) + { + typename basic_istream::sentry s(is); + is.get(c); + return is; + } + + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, charT* c) + { + typename basic_istream::sentry s(is); + int n = is.width(); + if(n == 0){ + n = __STRING_MAX_UNITS; + } + is.get(c, n); + return is; + + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, unsigned char* c) + { + typename basic_istream::sentry s(is); + int n = is.width(); + if(n == 0){ + n = __STRING_MAX_UNITS; + } + is.get(c, n); + return is; + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, signed char* c) + { + typename basic_istream::sentry s(is); + int n = is.width(); + if(n == 0){ + n = __STRING_MAX_UNITS; + } + is.get(c, n); + return is; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(basic_istream& (*pf)(basic_istream&)) + { + sentry(*this); + pf(*this); + return *this; + } + + template _UCXXEXPORT basic_istream& + basic_istream::operator>>(basic_ios& (*pf)(basic_ios&)) + { + sentry(*this); + pf(*this); + return *this; + } + + template _UCXXEXPORT basic_istream& + ws(basic_istream& is) + { + __skipws(is); + return is; + } + + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_ISTREAM__ + + + template <> _UCXXEXPORT istream & basic_istream >::get(char & c); + template <> _UCXXEXPORT istream::int_type basic_istream >::get(); + + 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); + +#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 istream & operator>>(istream & is, char & c); + + template <> _UCXXEXPORT void __skipws(basic_istream >& is); + +#endif +#endif + + + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/stack =================================================================== --- branches/slice/i386/modules/uClibc++/include/stack (revision 0) +++ branches/slice/i386/modules/uClibc++/include/stack (revision 727) @@ -0,0 +1,84 @@ +/* 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 + +#ifndef __HEADER_STD_STACK +#define __HEADER_STD_STACK 1 + +#pragma GCC visibility push(default) + +namespace std{ + + template > class _UCXXEXPORT stack{ + protected: + Container c; + + public: + typedef typename Container::value_type value_type; + typedef typename Container::size_type size_type; + typedef Container container_type; + + explicit stack(const Container& a = Container()) : c(a) { }; + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + value_type& top() { return c.back(); } + const value_type& top() const { return c.back(); } + void push(const value_type& x) { c.push_back(x); } + void pop() { c.pop_back(); } + + bool operator==(const stack &x) const{ + return x.c == c; + } + + }; + + + template _UCXXEXPORT bool + operator< (const stack& x, const stack& y) + { + return (x.c < y.c); + } + template _UCXXEXPORT bool + operator!=(const stack& x, const stack& y) + { + return (x.c != y.c); + } + template _UCXXEXPORT bool + operator> (const stack& x, const stack& y) + { + return (x.c > y.c); + } + template _UCXXEXPORT bool + operator>=(const stack& x, const stack& y) + { + return (x.c >= y.c); + } + template _UCXXEXPORT bool + operator<=(const stack& x, const stack& y) + { + return (x.c <= y.c); + } + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/csetjmp =================================================================== --- branches/slice/i386/modules/uClibc++/include/csetjmp (revision 0) +++ branches/slice/i386/modules/uClibc++/include/csetjmp (revision 727) @@ -0,0 +1,44 @@ +/* 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 + +#ifndef __STD_HEADER_CSETJMP +#define __STD_HEADER_CSETJMP 1 + + +//From GCC Header files +#undef longjmp + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef setjmp +#define setjmp(env) setjmp (env) +#endif + +//Mine again + + +namespace std{ + using ::longjmp; + using ::jmp_buf; +} + + +#endif + Index: branches/slice/i386/modules/uClibc++/include/string =================================================================== --- branches/slice/i386/modules/uClibc++/include/string (revision 0) +++ branches/slice/i386/modules/uClibc++/include/string (revision 727) @@ -0,0 +1,1042 @@ +/* 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 +#include + + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif + +#ifndef __HEADER_STD_STRING +#define __HEADER_STD_STRING 1 + +#pragma GCC visibility push(default) + +namespace std{ + + //Basic basic_string + + template, class A = allocator > class basic_string; + + typedef basic_string string; + #ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_string wstring; + #endif + + + +//template, class A = allocator > class _UCXXEXPORT basic_string +template class basic_string + : public std::vector +{ +public: + typedef Tr traits_type; + typedef typename Tr::char_type value_type; + typedef A allocator_type; + typedef typename A::size_type size_type; + typedef typename A::difference_type difference_type; + + typedef typename A::reference reference; + typedef typename A::const_reference const_reference; + typedef typename A::pointer pointer; + typedef typename A::const_pointer const_pointer; + + typedef typename vector::iterator iterator; + typedef typename vector::const_iterator const_iterator; + + typedef typename vector::reverse_iterator reverse_iterator; + typedef typename vector::const_reverse_iterator const_reverse_iterator; + + static const size_type npos = (size_type)-1; + + explicit _UCXXEXPORT basic_string(const A& al = A()) : vector(al){ return; } + + _UCXXEXPORT basic_string(const basic_string& str, size_type pos = 0, size_type n = npos, const A& al = A()); //Below + + _UCXXEXPORT basic_string(const Ch* s, size_type n, const A& al = A()) + : vector(al) + { + if(n == npos){ + __throw_out_of_range(); + } + if(s > 0){ + resize(n); + Tr::copy(vector::data, s, vector::elements); + } + } + + _UCXXEXPORT basic_string(const Ch* s, const A& al = A()); //Below + + _UCXXEXPORT basic_string(size_type n, Ch c, const A& al = A()) + : vector(n, c, al) + { + } + + template _UCXXEXPORT basic_string(InputIterator begin, InputIterator end, const A& a = A()) + :vector(begin, end) + { + + } + + _UCXXEXPORT ~basic_string() { + return; + } + + _UCXXEXPORT basic_string& operator=(const basic_string& str); //Below + + _UCXXEXPORT basic_string& operator=(const Ch* s){ + vector::clear(); + if(s!=0){ + size_type len = Tr::length(s); + resize(len); + Tr::copy( vector::data, s, len); + } + return *this; + } + + _UCXXEXPORT basic_string& operator=(Ch c){ + vector::clear(); + vector::push_back(c); + return *this; + } + + inline _UCXXEXPORT size_type length() const { return vector::size(); } + + void _UCXXEXPORT resize(size_type n, Ch c = Ch()){ + vector::resize(n, c); + } + + _UCXXEXPORT basic_string& operator+=(const basic_string& str){ + return append(str); + } + + _UCXXEXPORT basic_string& operator+=(const Ch * s){ + return append(s); + } + + _UCXXEXPORT basic_string& operator+=(Ch c){ + vector::push_back(c); + return *this; + } + + _UCXXEXPORT basic_string& append(const basic_string& str){ + size_t temp = vector::elements; + resize(vector::elements + str.elements); + Tr::copy( vector::data + temp, str.vector::data, str.elements); + + return *this; + } + + _UCXXEXPORT basic_string& append(const basic_string& str, size_type pos, size_type n){ + if(pos > str.size()){ + __throw_out_of_range(); + } + + size_type rlen = str.elements - pos; + if(rlen > n){ + rlen = n; + } + if(vector::elements > npos - rlen){ + __throw_length_error(); + } + size_t temp = vector::elements; + resize(vector::elements + rlen); + Tr::copy( vector::data + temp, str.vector::data + pos, rlen); + return *this; + } + + _UCXXEXPORT basic_string& append(const Ch* s, size_type n){ + size_t temp = vector::elements; + resize(vector::elements + n); + Tr::copy( vector::data + temp, s, n); + return *this; + } + + _UCXXEXPORT basic_string& append(const Ch* s){ + size_type strLen = Tr::length(s); + size_t temp = vector::elements; + resize(vector::elements + strLen); + Tr::copy( vector::data + temp, s, strLen); + return *this; + } + + _UCXXEXPORT basic_string& append(size_type n, Ch c){ + vector::resize(vector::elements + n, c); + return *this; + } + + _UCXXEXPORT basic_string& assign(const basic_string& str){ + operator=(str); + return *this; + } + + _UCXXEXPORT basic_string& assign(const basic_string& str, size_type pos, size_type n){ + if(pos > str.elements){ + __throw_out_of_range(); + } + size_type r = str.elements - pos; + if(r > n){ + r = n; + } + resize(r); + Tr::copy(vector::data, str.vector::data + pos, r); + return *this; + } + + _UCXXEXPORT basic_string& assign(const Ch* s, size_type n){ + resize(n); + Tr::copy(vector::data, s, n); + return *this; + } + + _UCXXEXPORT basic_string& assign(const Ch* s){ + size_type len = Tr::length(s); + return assign(s, len); + } + + _UCXXEXPORT basic_string& assign(size_type n, Ch c){ + vector::clear(); + vector::resize(n, Ch() ); + return *this; + } + + template _UCXXEXPORT basic_string& assign(InputIterator first, InputIterator last){ + vector::resize(0, Ch()); + while (first != last){ + append(*first); + ++first; + } + return *this; + } + + _UCXXEXPORT basic_string& insert(size_type pos1, const basic_string& str, size_type pos2=0, size_type n=npos){ + if(pos1 > vector::elements || pos2 > str.elements){ + __throw_out_of_range(); + } + size_type r = str.elements - pos2; + if( r > n){ + r = n; + } + if(vector::elements > npos - r){ + __throw_length_error(); + } + size_type temp = vector::elements; + resize(vector::elements + r); + Tr::move(vector::data + pos1 + r, vector::data + pos1, temp - pos1); + Tr::copy(vector::data + pos1, str.vector::data + pos2, r); + return *this; + } + + _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s, size_type n){ + if(pos > vector::elements){ + __throw_out_of_range(); + } + if(vector::elements > npos - n){ + __throw_length_error(); + } + size_type temp = vector::elements; + resize(vector::elements + n); + Tr::move(vector::data + pos + n, vector::data + pos, temp - pos); + Tr::copy(vector::data + pos, s, n); + return *this; + } + + inline _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s){ + size_type len = Tr::length(s); + return insert(pos, s, len); + } + + _UCXXEXPORT basic_string& insert(size_type pos, size_type n, Ch c){ + if(pos > vector::elements){ + __throw_out_of_range(); + } + if(vector::elements > npos - n){ + __throw_length_error(); + } + size_type temp = vector::elements; + resize(vector::elements + n); + Tr::move(vector::data + pos + n, vector::data + pos, temp - pos); + Tr::assign(vector::data + pos, n, c); + return *this; + } + +// iterator insert(iterator p, charT c = charT()); +// void insert(iterator p, size_type n, charT c); +// template void insert(iterator p, InputIterator first, InputIterator last); + + _UCXXEXPORT basic_string& erase(size_type pos = 0, size_type n = npos){ + size_type xlen = vector::elements - pos; + + if(xlen > n){ + xlen = n; + } + size_type temp = vector::elements; + + Tr::move(vector::data + pos, vector::data + pos + xlen, temp - pos - xlen); + resize(temp - xlen); + return *this; + } + + _UCXXEXPORT iterator erase(iterator position){ + if(position == vector::end()){ + return position; + } + + ++position; + + iterator temp = position; + + while(position != vector::end()){ + *(position-1) = *position; + ++position; + } + vector::pop_back(); + return temp; + } + + _UCXXEXPORT iterator erase(iterator first, iterator last){ + size_t count = last - first; + + iterator temp = last; + + while(last != vector::end()){ + *(last - count) = *last; + ++last; + } + + resize( vector::elements-count); + + return temp; + } + + _UCXXEXPORT basic_string& + replace(size_type pos1, size_type n1, const basic_string& str, size_type pos2=0, size_type n2=npos) + { + if(pos1 > vector::elements){ + __throw_out_of_range(); + } + size_type xlen = vector::elements - pos1; + if(xlen > n1){ + xlen = n1; + } + size_type rlen = str.elements - pos2; + if(rlen > n2){ + rlen = n2; + } + if((vector::elements - xlen) >= (npos - rlen)){ + __throw_length_error(); + } + + size_t temp = vector::elements; + + if(rlen > xlen){ //Only if making larger + resize(temp - xlen + rlen); + } + + //Final length = vector::elements - xlen + rlen + //Initial block is of size pos1 + //Block 2 is of size len + + Tr::move(vector::data + pos1 + rlen, vector::data + pos1 + xlen, temp - pos1 - xlen); + Tr::copy(vector::data + pos1, str.vector::data + pos2, rlen); + resize(temp - xlen + rlen); + return *this; + } + + _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s, size_type n2){ + return replace(pos,n1,basic_string(s,n2)); + + } + + inline _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s){ + return replace(pos,n1,basic_string(s)); + } + + _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, size_type n2, Ch c){ + return replace(pos,n1,basic_string(n2,c)); + } +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const basic_string& str); +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s, size_type n); +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s); +// _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, size_type n, Ch c); +/* template _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, + InputIterator j1, InputIterator j2);*/ + + size_type _UCXXEXPORT copy(Ch* s, size_type n, size_type pos = 0) const{ + if(pos > vector::elements){ + __throw_out_of_range(); + } + size_type r = vector::elements - pos; + if(r > n){ + r = n; + } + Tr::copy(s, vector::data + pos, r); + return r; + } + + _UCXXEXPORT void swap(basic_string& s){ + //Data pointers + + vector::swap(s); + } + + _UCXXEXPORT const Ch* c_str() const{ + const_cast *>(this)->reserve(vector::elements+1); + vector::data[vector::elements] = 0; //Add 0 at the end + return vector::data; + } + + _UCXXEXPORT const Ch* data() const{ + return vector::data; + } + _UCXXEXPORT allocator_type get_allocator() const{ + return vector::a; + } + + _UCXXEXPORT size_type find (const basic_string& str, size_type pos = 0) const; //Below + + _UCXXEXPORT size_type find (const Ch* s, size_type pos, size_type n) const{ + return find(basic_string(s,n), pos); + } + _UCXXEXPORT size_type find (const Ch* s, size_type pos = 0) const{ + return find(basic_string(s), pos); + } + _UCXXEXPORT size_type find (Ch c, size_type pos = 0) const{ + for(size_type i = pos; i < length(); ++i){ + if(operator[](i) == c){ + return i; + } + } + return npos; + } + _UCXXEXPORT size_type rfind(const basic_string& str, size_type pos = npos) const{ + if(pos >= length()){ + pos = length(); + } + for(size_type i = pos; i > 0; --i){ + if(str == substr(i-1, str.length())){ + return i-1; + } + } + return npos; + } + _UCXXEXPORT size_type rfind(const Ch* s, size_type pos, size_type n) const{ + return rfind(basic_string(s,n),pos); + } + _UCXXEXPORT size_type rfind(const Ch* s, size_type pos = npos) const{ + return rfind(basic_string(s),pos); + } + _UCXXEXPORT size_type rfind(Ch c, size_type pos = npos) const{ + return rfind(basic_string(1,c),pos); + } + + _UCXXEXPORT size_type find_first_of(const basic_string& str, size_type pos = 0) const{ + for(size_type i = pos; i < length(); ++i){ + for(size_type j = 0; j < str.length() ; ++j){ + if( Tr::eq(str[j], operator[](i)) ){ + return i; + } + } + } + return npos; + } + + _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos, size_type n) const{ + return find_first_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos = 0) const{ + return find_first_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_first_of(Ch c, size_type pos = 0) const{ + for(size_type i = pos; i< length(); ++i){ + if( Tr::eq(operator[](i), c) ){ + return i; + } + } + return npos; + } + + _UCXXEXPORT size_type find_last_of (const basic_string& str, size_type pos = npos) const{ + if(pos > length()){ + pos = length(); + } + for(size_type i = pos; i >0 ; --i){ + for(size_type j = 0 ; j < str.length(); ++j){ + if( Tr::eq(operator[](i-1), str[j]) ){ + return i-1; + } + } + } + return npos; + } + _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos, size_type n) const{ + return find_last_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos = npos) const{ + return find_last_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_last_of (Ch c, size_type pos = npos) const{ + if(pos > length()){ + pos = length(); + } + for(size_type i = pos; i >0 ; --i){ + if( Tr::eq(operator[](i-1), c) ){ + return i-1; + } + } + return npos; + } + + _UCXXEXPORT size_type find_first_not_of(const basic_string& str, size_type pos = 0) const{ + bool foundCharacter; + for(size_type i = pos; i < length(); ++i){ + foundCharacter = false; + for(size_type j = 0; j < str.length() ; ++j){ + if( Tr::eq(str[j], operator[](i)) ){ + foundCharacter = true; + } + } + if(foundCharacter == false){ + return i; + } + } + return npos; + } + + _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos, size_type n) const{ + return find_first_not_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos = 0) const{ + return find_first_not_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_first_not_of(Ch c, size_type pos = 0) const{ + for(size_type i = pos; i < length() ; ++i){ + if(operator[](i) != c){ + return i; + } + } + return npos; + } + _UCXXEXPORT size_type find_last_not_of (const basic_string& str, size_type pos = npos) const{ + size_type xpos(length() - 1); + if(xpos > pos){ + xpos = pos; + } + + while(xpos != npos && npos != str.find_first_of(at(xpos))){ + --xpos; + } + + return xpos; + } + + _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos, size_type n) const{ + return find_last_not_of(basic_string(s,n),pos); + } + _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos = npos) const{ + return find_last_not_of(basic_string(s),pos); + } + _UCXXEXPORT size_type find_last_not_of (Ch c, size_type pos = npos) const{ + size_type xpos(length() - 1); + if(xpos > pos){ + xpos = pos; + } + while(xpos != npos && Tr::eq(at(xpos), c)){ + --xpos; + } + return xpos; + + } + + _UCXXEXPORT basic_string substr(size_type pos = 0, size_type n = npos) const; + + _UCXXEXPORT int compare(const basic_string& str) const{ + size_type rlen = vector::elements; + if(rlen > str.elements){ + rlen = str.elements; + } + int retval = Tr::compare(vector::data, str.vector::data, rlen); + if(retval == 0){ + if(vector::elements < str.elements){ + retval = -1; + } + if(vector::elements > str.elements){ + retval = 1; + } + } + return retval; + } + + _UCXXEXPORT int compare(size_type pos1, size_type n1, const basic_string& str, + size_type pos2=0, size_type n2=npos) const{ + size_type len1 = vector::elements - pos1; + if(len1 > n1){ + len1 = n1; + } + size_type len2 = str.vector::elements - pos2; + if(len2 > n2){ + len2 = n2; + } + size_type rlen = len1; + if(rlen > len2){ + rlen = len2; + } + int retval = Tr::compare(vector::data + pos1, str.vector::data + pos2, rlen); + if(retval == 0){ + if(len1 < len2){ + retval = -1; + } + if(len1 > len2){ + retval = 1; + } + } + return retval; + } + + _UCXXEXPORT int compare(const Ch* s) const{ + size_type slen = Tr::length(s); + size_type rlen = slen; + if(rlen > vector::elements){ + rlen=vector::elements; + } + int retval = Tr::compare(vector::data, s, rlen); + if(retval==0){ + if(vector::elements < slen){ + retval = -1; + } + if(vector::elements > slen){ + retval = 1; + } + } + return retval; + } + + _UCXXEXPORT int compare(size_type pos1, size_type n1, const Ch* s, size_type n2 = npos) const{ + size_type len1 = vector::elements - pos1; + if(len1 > n1){ + len1 = n1; + } + size_type slen = Tr::length(s); + size_type len2 = slen; + if(len2 > n2){ + len2 = n2; + } + size_type rlen = len1; + if(rlen > len2){ + rlen = len2; + } + int retval = Tr::compare(vector::data + pos1, s, rlen); + if(retval == 0){ + if(len1 < len2){ + retval = -1; + } + if(len1 > len2){ + retval = 1; + } + } + return retval; + } + +}; + + +//Functions + +template _UCXXEXPORT basic_string::basic_string(const Ch* s, const A& al) + : vector(al) +{ + if(s!=0){ + size_type temp = Tr::length(s); + append(s, temp); + } +} + +template _UCXXEXPORT basic_string:: + basic_string(const basic_string& str, size_type pos, size_type n, const A& al) + : vector(al) +{ + if(pos>str.size()){ + __throw_out_of_range(); + } + size_type rlen = str.size() - pos; + if( rlen > n){ + rlen = n; + } + resize(rlen); + Tr::copy(vector::data, str.vector::data + pos, vector::elements); +} + +template _UCXXEXPORT basic_string& + basic_string::operator=(const basic_string & str) +{ + if(&str == this){ //Check if we are doing a=a + return *this; + } + vector::clear(); + resize(str.elements); + Tr::copy( vector::data, str.vector::data, str.elements); + return *this; +} + + +template _UCXXEXPORT typename basic_string::size_type + basic_string::find (const basic_string& str, size_type pos) const +{ + if(str.length() > length()){ + return npos; + } + size_type max_string_start = 1 + length() - str.length(); + for(size_type i = pos; i < max_string_start; ++i){ + if(str == substr(i, str.length())){ + return i; + } + } + return npos; +} + + +template + _UCXXEXPORT basic_string basic_string::substr(size_type pos, size_type n) const +{ + if(pos > vector::elements){ + __throw_out_of_range(); + } + size_type rlen = vector::elements - pos; + if(rlen > n){ + rlen = n; + } + return basic_string(vector::data + pos,rlen); +} + + + + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STRING__ + +#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 + + 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, 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); + +#endif +#endif + + + + +//typedef basic_string string; + +template _UCXXEXPORT basic_string + operator+(const basic_string& lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + temp.append(rhs); + return temp; +} + +template _UCXXEXPORT basic_string + operator+(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + temp.append(rhs); + return temp; +} + + +template _UCXXEXPORT basic_string + operator+(charT lhs, const basic_string& rhs) +{ + basic_string temp(1, lhs); + temp.append(rhs); + return temp; +} + +template _UCXXEXPORT basic_string + operator+(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(lhs); + temp.append(rhs); + return temp; +} + +template _UCXXEXPORT basic_string + operator+(const basic_string& lhs, charT rhs) +{ + basic_string temp(lhs); + temp+=rhs; + return temp; +} + +template _UCXXEXPORT bool + operator==(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) == 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator==(const charT* lhs, const basic_string& rhs) +{ + if(rhs.compare(lhs) == 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator==(const basic_string& lhs, const charT* rhs) +{ + if(lhs.compare(rhs)==0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator!=(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) !=0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator!=(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + return (temp != rhs); +} + +template _UCXXEXPORT bool + operator!=(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + return (lhs != temp); +} + +template _UCXXEXPORT bool + operator< (const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) < 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator< (const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(rhs) < 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator< (const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) < 0){ + return true; + } + return false; +} + + +template _UCXXEXPORT bool + operator> (const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) > 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator> (const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(rhs) > 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator> (const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) > 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator<=(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) <=0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator<=(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(temp) <=0 ){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator<=(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) <= 0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator>=(const basic_string& lhs, const basic_string& rhs) +{ + if(lhs.compare(rhs) >=0){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator>=(const basic_string& lhs, const charT* rhs) +{ + basic_string temp(rhs); + if(lhs.compare(temp) >=0 ){ + return true; + } + return false; +} + +template _UCXXEXPORT bool + operator>=(const charT* lhs, const basic_string& rhs) +{ + basic_string temp(lhs); + if(temp.compare(rhs) >=0 ){ + return true; + } + return false; +} + +template _UCXXEXPORT void + swap(basic_string& lhs, basic_string& rhs) +{ + lhs.swap(rhs); +} + +/*template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const basic_string& str) +{ + return os.write(str.data(), str.length()); +}*/ + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STRING__ + +//Operators we can avoid duplication of + +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); + + +#endif +#endif + + +} + +#pragma GCC visibility pop + +#endif Index: branches/slice/i386/modules/uClibc++/include/complex =================================================================== --- branches/slice/i386/modules/uClibc++/include/complex (revision 0) +++ branches/slice/i386/modules/uClibc++/include/complex (revision 727) @@ -0,0 +1,327 @@ +/* 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 + +#ifndef __STD_HEADER_COMPLEX +#define __STD_HEADER_COMPLEX 1 + + +namespace std { +// class complex; +// class complex; +// class complex; + + template class _UCXXEXPORT complex{ + public: + typedef T value_type; + + complex(const T& re = T(), const T& im = T()) : r(re), i(im) { } + complex(const complex& c): r(c.r), i(c.i){ } + template complex(const complex& c): r(c.r), i(c.i){ } + + inline T real() const{ + return r; + } + inline T imag() const{ + return i; + } + + complex& operator= (const T& v){ + r = v; + i = 0; + return *this; + } + complex& operator+=(const T& v){ + r +=v; + return *this; + } + complex& operator-=(const T& v){ + r -=v; + return *this; + } + complex& operator*=(const T& v){ + r*=v; + i*=v; + return *this; + } + complex& operator/=(const T& v){ + r/=v; + i/=v; + return *this; + } + complex& operator=(const complex& v){ + if(&v != this){ + r = v.r; + i = v.i; + } + return *this; + } + template complex& operator= (const complex& v){ + r = v.r; + i = v.i; + return *this; + } + template complex& operator+=(const complex& v){ + r+=v.r; + i+=v.i; + return *this; + } + template complex& operator-=(const complex& v){ + r-=v.r; + i-=v.i; + return *this; + } + template complex& operator*=(const complex& v){ + T tempr = r*v.r - i*v.i; + T tempi = r*v.i + i*v.r; + r = tempr; + i = tempi; + return *this; + } + template complex& operator/=(const complex& v){ + T tempr = (r*v.r + i*v.i) / (v.r*v.r + v.i*v.i); + T tempi = (i*v.r - r*v.i) / (v.r*v.r + v.i*v.i); + r = tempr; + i = tempi; + return *this; + } + private: + T r; + T i; + }; + + template _UCXXEXPORT complex operator+(const complex& ls, const complex& rs){ + complex retval(ls); + retval += rs; + return retval; + } + template _UCXXEXPORT complex operator+(const complex& ls, const T& rs){ + complex retval(ls); + ls += rs; + return retval; + } + template _UCXXEXPORT inline complex operator+(const T& ls, const complex& rs){ + return rs + ls; + } + template _UCXXEXPORT complex operator-(const complex& ls, const complex& rs){ + complex retval(ls); + retval -= rs; + return retval; + } + template _UCXXEXPORT complex operator-(const complex& ls, const T& rs){ + complex retval(ls); + retval -= rs; + return retval; + } + template _UCXXEXPORT complex operator-(const T& ls, const complex& rs){ + complex retval(ls); + retval -= rs; + return retval; + } + template _UCXXEXPORT complex operator*(const complex& ls, const complex& rs){ + complex retval(ls); + retval *= rs; + return retval; + } + template _UCXXEXPORT complex operator*(const complex& ls, const T& rs){ + complex retval(ls); + retval *= rs; + return retval; + } + template _UCXXEXPORT complex operator*(const T& ls, const complex& rs){ + complex retval(ls); + retval *=rs; + return retval; + } + template _UCXXEXPORT complex operator/(const complex& ls, const complex& rs){ + complex retval(ls); + retval/=rs; + return retval; + } + template _UCXXEXPORT complex operator/(const complex& ls, const T& rs){ + complex retval(ls); + retval/=rs; + return retval; + } + template _UCXXEXPORT complex operator/(const T& ls, const complex& rs){ + complex retval(ls); + retval/=rs; + return retval; + } + template _UCXXEXPORT complex operator+(const complex& v){ + return v; + } + template _UCXXEXPORT complex operator-(const complex& v){ + return complex (-v.real(), -v.imag()); + } + template _UCXXEXPORT bool operator==(const complex& ls, const complex& rs){ + if( ls.real() == rs.real() && ls.imag() == rs.image()){ + return true; + } + return false; + } + template _UCXXEXPORT bool operator==(const complex& ls, const T& rs){ + if(ls.real() == rs && ls.imag() == T()){ + return true; + } + return false; + } + template _UCXXEXPORT bool operator==(const T& ls, const complex& rs){ + if(ls == rs.real() && rs.imag() == T()){ + return true; + } + return false; + } + template _UCXXEXPORT bool operator!=(const complex& ls, const complex& rs){ + if(ls == rs){ + return false; + } + return true; + } + template _UCXXEXPORT bool operator!=(const complex& ls, const T& rs){ + if(ls == rs){ + return false; + } + return true; + } + template _UCXXEXPORT bool operator!=(const T& ls, const complex& rs){ + if(ls == rs){ + return false; + } + return true; + } + template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, complex& v) + { + T tempr; + T tempi; + is >> tempr; + is.get(); + is >> tempi; + v = complex(tempr, tempi); + return is; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const complex&v) + { + os << v.real() << ", " << v.imag(); + return os; + } + + template _UCXXEXPORT T real(const complex& v){ + return v.real(); + } + + template _UCXXEXPORT T imag(const complex& v){ + return v.imag(); + } + + template _UCXXEXPORT T norm(const complex& v){ + return (v.real() * v.real() + v.imag() * v.imag()); + } + + template _UCXXEXPORT complex conj(const complex& v){ + return complex(v.real(), -v.imag()); + } + +#ifdef __UCLIBCXX_SUPPORT_MATH__ //Can we link with libm? + + template _UCXXEXPORT T abs(const complex& v){ + return sqrt(v.real() * v.real() + v.imag() * v.imag()); + } + + template _UCXXEXPORT T arg(const complex& v){ + return atan2(v.imag(), v.real()); + } + + template _UCXXEXPORT complex polar(const T& rho, const T& theta){ + return complex(rho * cos(theta), rho * sin(theta)); + } + + template _UCXXEXPORT complex cos (const complex& v){ + return complex(cos(v.real()) * cosh(v.imag()), -sin(v.real()) * sinh(v.imag())); + } + + template _UCXXEXPORT complex cosh (const complex& v){ + return complex(cosh(v.real()) * cos(v.imag()), sinh(v.real()) * sin(v.imag())); + } + + template _UCXXEXPORT complex exp (const complex& v){ + return polar(exp(v.real()), v.imag()); + } + + template _UCXXEXPORT complex log (const complex& v){ + return complex(log(abs(v)), arg(v)); + } + + template _UCXXEXPORT complex log10(const complex& v){ + return (log(v) / log(T(10.0))); + } + + template _UCXXEXPORT complex pow(const complex& v, int p){ + T rho = pow(abs(v), p); + T theta = arg(v); + return complex(rho * cos(p * theta), rho * sin(p * theta) ); + } + + template _UCXXEXPORT complex pow(const complex& v, const T& p){ + return polar( pow(abs(v),p), arg(v)*p ); + } + + template _UCXXEXPORT complex pow(const complex& v, const complex& p){ + if(v == T()){ + //We are using "0" as the value + return T(); + } + return exp(p * log(v)); + } + + template _UCXXEXPORT complex pow(const T& v, const complex& p){ + if(v == T()){ + return T(); + } + return polar(pow(v,p.real()), y.imag() * log(x) ); + } + + template _UCXXEXPORT complex sin (const complex& v){ + return complex(sin(v.real()) * cosh(v.imag()), cosh(v.real()) * sin(v.imag())); + } + + template _UCXXEXPORT complex sinh (const complex& v){ + return complext(sinh(v.real()) * cos(v.imag()), cosh(v.real()) * sin(v.imag()) ); + } + + template _UCXXEXPORT complex sqrt (const complex&); + template _UCXXEXPORT complex tan (const complex& v){ + return sin(v) / cos(v); + } + + template _UCXXEXPORT complex tanh (const complex& v){ + return sinh(v) / cosh(v); + } + +#endif + +} + +#endif + Index: branches/slice/i386/modules/uClibc++/include/cfloat =================================================================== --- branches/slice/i386/modules/uClibc++/include/cfloat (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cfloat (revision 727) @@ -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 + +#ifndef __STD_HEADER_CFLOAT +#define __STD_HEADER_CFLOAT 1 + + +#include + + +#endif + Index: branches/slice/i386/modules/uClibc++/include/ostream =================================================================== --- branches/slice/i386/modules/uClibc++/include/ostream (revision 0) +++ branches/slice/i386/modules/uClibc++/include/ostream (revision 727) @@ -0,0 +1,483 @@ +/* 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 + +#ifndef STD_HEADER_OSTREAM +#define STD_HEADER_OSTREAM 1 + +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +namespace std { + template class basic_ostream; + typedef basic_ostream ostream; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_ostream wostream; +#endif + + template basic_ostream& endl(basic_ostream& os); + template basic_ostream& ends(basic_ostream& os); + template basic_ostream& flush(basic_ostream& os); + + template class _UCXXEXPORT basic_ostream + : virtual public basic_ios + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + + _UCXXEXPORT basic_ostream(basic_streambuf* sb) + : basic_ios(sb) + { + basic_ios::init(sb); + } + virtual _UCXXEXPORT ~basic_ostream(); + + class sentry; + + _UCXXEXPORT basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&)){ + return pf(*this); + } + _UCXXEXPORT basic_ostream& operator<<(basic_ios& (*pf)(basic_ios&)){ + pf(*this); + return *this; + } + _UCXXEXPORT basic_ostream& operator<<(ios_base& (*pf)(ios_base&)){ + pf(*this); + return *this; + } + basic_ostream& operator<<(bool n); + basic_ostream& operator<<(short n); + basic_ostream& operator<<(unsigned short n); + basic_ostream& operator<<(int n); + basic_ostream& operator<<(unsigned int n); + basic_ostream& operator<<(long n); + basic_ostream& operator<<(unsigned long n); + basic_ostream& operator<<(float f); + basic_ostream& operator<<(double f); + basic_ostream& operator<<(long double f); + basic_ostream& operator<<(void* p); + basic_ostream& operator<<(basic_streambuf* sb); + + _UCXXEXPORT basic_ostream& put(char_type c){ + if(basic_ostream::traits_type::eq_int_type( + basic_ios::mstreambuf->sputc(c), + basic_ostream::traits_type::eof())) + { + basic_ios::setstate(ios_base::eofbit); + } + return *this; + } + _UCXXEXPORT basic_ostream& write(const char_type* s, streamsize n){ + if(basic_ostream::traits_type::eq_int_type( + basic_ios::mstreambuf->sputn(s, n), + basic_ostream::traits_type::eof()) + ){ + basic_ios::setstate(ios_base::eofbit); + } + return *this; + } + _UCXXEXPORT basic_ostream& flush(){ + if(basic_ios::mstreambuf->pubsync() == -1){ + basic_ios::setstate(ios_base::badbit); + } + return *this; + } + _UCXXEXPORT pos_type tellp(){ + if(basic_ios::fail() != false){ + return pos_type(-1); + } + return basic_ios::rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + } + _UCXXEXPORT basic_ostream& seekp(pos_type pos){ + if( basic_ios::fail() != true ){ + basic_ios::rdbuf()->pubseekpos(pos); + } + return *this; + } + _UCXXEXPORT basic_ostream& seekp(off_type off, ios_base::seekdir dir){ + if( basic_ios::fail() != true){ + basic_ios::rdbuf()->pubseekoff(off, dir); + } + return *this; + } + + protected: + basic_ostream(const basic_ostream &){ } + basic_ostream & operator=(const basic_ostream &){ return *this; } + }; + + //Implementations of template functions. To allow for partial specialization + + template _UCXXEXPORT basic_ostream::~basic_ostream(){ } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(bool n){ + sentry s(*this); + if( basic_ios::flags() & ios_base::boolalpha){ + if(n){ + write("true", 4); + }else{ + write("false", 5); + } + }else{ + if(n){ + write("1", 1); + }else{ + write("0", 1); + } + } + if(basic_ios::flags() & ios_base::unitbuf){ + flush(); + } + return *this; + } + + template _UCXXEXPORT basic_ostream& + basic_ostream::operator<<(unsigned short n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(short n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(int n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(unsigned int n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long n){ + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& + basic_ostream::operator<<(unsigned long n) + { + sentry s(*this); + __ostream_printout::printout(*this, n); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(float f){ + sentry s(*this); + __ostream_printout::printout(*this, f); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(double f){ + sentry s(*this); + __ostream_printout::printout(*this, f); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(long double f){ + sentry s(*this); + __ostream_printout::printout(*this, f); + return *this; + } + + template _UCXXEXPORT basic_ostream& basic_ostream::operator<<(void* p){ + sentry s(*this); + char buffer[20]; + write(buffer, snprintf(buffer, 20, "%p", p) ); + if(basic_ios::flags() & ios_base::unitbuf){ + flush(); + } + return *this; + } + + template _UCXXEXPORT basic_ostream& + basic_ostream::operator<<(basic_streambuf* sb) + { + sentry s(*this); + if(sb == 0){ + basic_ios::setstate(ios_base::badbit); + return *this; + } + + typename traits::int_type c; + + while(basic_ios::good() && (c = sb->sbumpc()) != traits::eof() ){ + put(c); + } + + if(basic_ios::flags() & ios_base::unitbuf){ + flush(); + } + return *this; + } + + /*Template Specializations*/ + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_OSTREAM__ + +#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); +#endif +#endif + + template > + class _UCXXEXPORT basic_ostream::sentry + { + bool ok; + public: + explicit _UCXXEXPORT sentry(basic_ostream& os): ok(true){ + if(os.good() !=0){ //Prepare for output + } + + //Flush any tied buffer + if(os.tie() !=0 ){ + os.tie()->flush(); + } + } + _UCXXEXPORT ~sentry() { } + _UCXXEXPORT operator bool() { + return ok; + } + }; + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_OSTREAM__ +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT ostream::sentry::sentry(ostream & os); + template <> _UCXXEXPORT ostream::sentry::~sentry(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ +#endif +#endif + + + //Non - class functions + + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, charT c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + // signed and unsigned + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, signed char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, unsigned char c) + { + typename basic_ostream::sentry s(out); + out.put(c); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const charT* c) + { + typename basic_ostream::sentry s(out); + out.write(c, traits::length(c) ); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const char* c) + { + typename basic_ostream::sentry s(out); + out.write(c, char_traits::length(c) ); + return out; + } + + // partial specializations + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const char* c) + { + typename basic_ostream::sentry s(out); + out.write(c, traits::length(c)); + return out; + } + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const char* c) + { + typename basic_ostream::sentry s(out); + size_t numChars = char_traits::length(c); + wchar_t * temp = new wchar_t[numChars]; + + for(size_t i=0; i < numChars; ++i){ + temp[i] = out.widen(c[i]); + } + + out.write(temp, numChars); + return out; + } +#endif + + // signed and unsigned + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const signed char* c) + { + typename basic_ostream::sentry s(out); + out.write(reinterpret_cast(c), traits::length( reinterpret_cast(c))); + return out; + } + + template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& out, const unsigned char* c) + { + typename basic_ostream::sentry s(out); + out.write(reinterpret_cast(c), traits::length( reinterpret_cast(c))); + return out; + } + + template _UCXXEXPORT basic_ostream& + endl(basic_ostream& os) + { + typename basic_ostream::sentry s(os); + os.put('\n'); + os.flush(); + return os; + } + + template _UCXXEXPORT basic_ostream& + ends(basic_ostream& os) + { + typename basic_ostream::sentry s(os); + os.put(traits::eos()); + return os; + } + + template _UCXXEXPORT basic_ostream& flush(basic_ostream& os){ + typename basic_ostream::sentry s(os); + os.flush(); + return os; + } + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_OSTREAM__ + 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, unsigned const char* c); + +#endif +#endif + + +#ifndef __STRICT_ANSI__ + +//Support for output of long long data types + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, signed long long int i) +{ + typename basic_ostream::sentry s(os); + __ostream_printout::printout(os, i); + return os; +} + + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, unsigned long long int i) +{ + typename basic_ostream::sentry s(os); + __ostream_printout::printout(os, i); + return os; +} + + +#endif //__STRICT_ANSI__ + + + + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/sstream =================================================================== --- branches/slice/i386/modules/uClibc++/include/sstream (revision 0) +++ branches/slice/i386/modules/uClibc++/include/sstream (revision 727) @@ -0,0 +1,384 @@ +/* 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 + +#ifndef HEADER_STD_SSTREAM +#define HEADER_STD_SSTREAM 1 + +#include +#include +#include +#include +#include +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template + class _UCXXEXPORT basic_stringbuf : public basic_streambuf + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef typename Allocator::size_type size_type; + + explicit _UCXXEXPORT basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out) + : data(), ielement(0), oelement(0) + { + basic_streambuf::openedFor = which; + } + + explicit _UCXXEXPORT basic_stringbuf(const basic_string& str, + ios_base::openmode which = ios_base::in | ios_base::out) + : data(str), ielement(0), oelement(0) + { + if(which & ios_base::ate){ + oelement = data.length(); + } + basic_streambuf::openedFor = which; + } + + virtual _UCXXEXPORT ~basic_stringbuf() { } + + _UCXXEXPORT basic_string str() const{ + return data; + } + + _UCXXEXPORT void str(const basic_string& s){ + data = s; + ielement = 0; + if(basic_streambuf::openedFor & ios_base::ate){ + oelement = data.length(); + }else{ + oelement = 0; + } + } + + protected: + virtual _UCXXEXPORT int sync(){ + return 0; + } + virtual _UCXXEXPORT int_type underflow(){ + if(ielement >= data.length()){ + return traits::eof(); + } + return traits::to_int_type(data[ielement]); + } + + virtual _UCXXEXPORT int_type uflow(){ + int_type retval = underflow(); + if(retval != traits::eof()){ + ++ielement; + } + return retval; + } + + virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){ + //Error possibilities + if(ielement == 0){ + return traits::eof(); + } + if(ielement > data.length()){ + ielement = data.length(); + return traits::eof(); + } + //eof passed in + if(traits::eq_int_type(c,traits::eof())==true){ + --ielement; + return traits::not_eof(c); + } + if(traits::eq(traits::to_char_type(c),data[ielement-1]) == true){ + --ielement; + return c; + } + if(basic_streambuf::openedFor & ios_base::out){ + --ielement; + data[ielement] = c; + return c; + } + return traits::eof(); + } + + virtual _UCXXEXPORT int showmanyc(){ + return data.length() - ielement; + } + virtual _UCXXEXPORT streamsize xsgetn(char_type* c, streamsize n){ + streamsize i = 0; + while(ielement < data.length() && i < n ){ + c[i] = data[ielement]; + ++i; + ++ielement; + } + return i; + } + + virtual _UCXXEXPORT int_type overflow (int_type c = traits::eof()){ + //Nothing to do + if(traits::eq_int_type(c,traits::eof())){ + return traits::not_eof(c); + } + + //Actually add character, if possible + if(basic_streambuf::openedFor & ios_base::out){ + if(oelement >= data.length()){ + data.push_back(c); + }else{ + data[oelement] = c; + } + ++oelement; + return c; + } + //Not possible + return traits::eof(); + } + + virtual _UCXXEXPORT basic_streambuf* setbuf(charT*, streamsize){ + //This function does nothing + return this; + } + + virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){ + data.replace(oelement, n, s, n); + oelement += n; + return n; + } + + virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way, + ios_base::openmode which = ios_base::in | ios_base::out) + { + //Test for invalid option + if( (which & ios_base::in) && (which & ios_base::out) && (way == ios_base::cur)){ + return -1; + } + + //Calculate new location + size_type newpos = 0; + + if(way == ios_base::beg){ + newpos = off; + }else if(way == ios_base::cur){ + if(which & ios_base::out){ + newpos = data.length() + off; + } + if(which & ios_base::in){ + newpos = ielement + off; + } + + }else{ + newpos = data.length() + off; + } + + //Test for error conditions + if(newpos > data.length()){ + return -1; + } + + //Shuffle pointers + + if(which & ios_base::in){ + ielement = newpos; + } + if(which & ios_base::out){ + data.resize(newpos); + if(ielement > data.length()){ + ielement = data.length(); + } + } + + return newpos; + } + + virtual _UCXXEXPORT pos_type seekpos(pos_type sp, + ios_base::openmode which = ios_base::in | ios_base::out) + { + return seekoff(sp, ios_base::beg, which); + } + + basic_string data; + size_type ielement; + size_type oelement; + }; + + + template class _UCXXEXPORT basic_istringstream + : public basic_istream + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + + explicit _UCXXEXPORT basic_istringstream(ios_base::openmode m = ios_base::in) + : basic_ios(&sb), basic_istream(&sb), sb(m) + { + } + explicit _UCXXEXPORT basic_istringstream( const basic_string& str, + ios_base::openmode which = ios_base::in) + : basic_ios(&sb), basic_istream(&sb), sb(str, which) + { + } + virtual _UCXXEXPORT ~basic_istringstream() { } + _UCXXEXPORT basic_stringbuf* rdbuf() const{ + return &sb; + } + _UCXXEXPORT basic_string str() const{ + return sb.str(); + } + _UCXXEXPORT void str(const basic_string& s){ + sb.str(s); + basic_istream::clear(); + } + private: + basic_stringbuf sb; + }; + + + template class _UCXXEXPORT basic_ostringstream + : public basic_ostream + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + explicit _UCXXEXPORT basic_ostringstream(ios_base::openmode m = ios_base::out) + : basic_ios(&sb), basic_ostream(&sb), sb(m) + { + } + explicit _UCXXEXPORT basic_ostringstream(const basic_string& str, + ios_base::openmode which = ios_base::out) + : basic_ios(&sb), basic_ostream(&sb), sb(str, which) + { + } + virtual _UCXXEXPORT ~basic_ostringstream() { } + + _UCXXEXPORT basic_stringbuf* rdbuf() const{ + return &sb; + } + _UCXXEXPORT basic_string str() const{ + return sb.str(); + } + _UCXXEXPORT void str(const basic_string& s){ + sb.str(s); + basic_ostream::clear(); + } + private: + basic_stringbuf sb; + }; + + + template class _UCXXEXPORT basic_stringstream + : public basic_iostream + { + public: + + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + explicit _UCXXEXPORT basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in) + : basic_ios(&sb), basic_iostream(&sb), sb(which) + { + } + + explicit _UCXXEXPORT basic_stringstream(const basic_string& str, + ios_base::openmode which = ios_base::out|ios_base::in) + : basic_ios(&sb), basic_iostream(&sb), sb(str, which) + { + } + virtual _UCXXEXPORT ~basic_stringstream(){ } + + _UCXXEXPORT basic_stringbuf* rdbuf(){ + return &sb; + } + _UCXXEXPORT basic_string str() const{ + return sb.str(); + } + _UCXXEXPORT void str(const basic_string& s){ + sb.str(s); + basic_iostream::clear(); + } + private: + basic_stringbuf sb; + }; + +#ifdef __UCLIBCXX_EXPAND_SSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_SSTREAM__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT basic_stringbuf, allocator >:: + basic_stringbuf(ios_base::openmode which); + template <> _UCXXEXPORT basic_stringbuf, allocator >::~basic_stringbuf(); + +#endif // __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT basic_string, allocator > + basic_stringbuf, allocator >::str() const; + + template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type + basic_stringbuf, allocator >:: + pbackfail(basic_stringbuf, allocator >::int_type c); + + template <> _UCXXEXPORT basic_stringbuf, allocator >::pos_type + basic_stringbuf, allocator >:: + seekoff (basic_stringbuf, allocator >::off_type off, + ios_base::seekdir way, + ios_base::openmode which + ); + + template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type + basic_stringbuf, allocator >:: + overflow (basic_stringbuf, allocator >::int_type c); + + template <> _UCXXEXPORT basic_stringbuf, allocator >::int_type + basic_stringbuf, allocator >::underflow (); + + template <> _UCXXEXPORT streamsize basic_stringbuf, allocator >:: + xsputn(const char* s, streamsize n); + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT basic_stringstream, allocator >:: + basic_stringstream(ios_base::openmode which); + template <> _UCXXEXPORT basic_stringstream, allocator >::~basic_stringstream(); + template <> _UCXXEXPORT basic_istringstream, allocator >::~basic_istringstream(); + template <> _UCXXEXPORT basic_ostringstream, allocator >::~basic_ostringstream(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + +#endif +#endif + +#pragma GCC visibility pop + +} + + +#endif Index: branches/slice/i386/modules/uClibc++/include/csignal =================================================================== --- branches/slice/i386/modules/uClibc++/include/csignal (revision 0) +++ branches/slice/i386/modules/uClibc++/include/csignal (revision 727) @@ -0,0 +1,61 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 20.4.6 C library +// + +/** @file csignal + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c signal.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CSIGNAL +#define _CPP_CSIGNAL 1 + +#pragma GCC system_header + +#include + +// Get rid of those macros defined in in lieu of real functions. +#undef raise + +namespace std +{ + using ::sig_atomic_t; + using ::signal; + using ::raise; +} + +#endif Index: branches/slice/i386/modules/uClibc++/include/valarray =================================================================== --- branches/slice/i386/modules/uClibc++/include/valarray (revision 0) +++ branches/slice/i386/modules/uClibc++/include/valarray (revision 727) @@ -0,0 +1,996 @@ +/* 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 + +#ifndef __HEADER_STD_VALARRAY +#define __HEADER_STD_VALARRAY 1 + +#include +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template class valarray; + class slice; + template class slice_array; + class gslice; + template class gslice_array; + template class mask_array; + template class indirect_array; + + //Actual class definitions + + + class _UCXXEXPORT slice { + protected: + size_t sta; + size_t siz; + size_t str; + + public: + slice() : sta(0), siz(0), str(0){ } + slice(size_t a, size_t b, size_t c) : sta(a), siz(b), str(c) { } + slice(const slice& s) : sta(s.sta), siz(s.siz), str(s.str) { } + ~slice() { } + size_t start() const{ + return sta; + } + size_t size() const{ + return siz; + } + size_t stride() const{ + return str; + } + }; + + + + template class _UCXXEXPORT valarray { + friend class slice_array; + protected: + T * data; + size_t length; + + public: + typedef T value_type; + + valarray() : data(0), length(0) { } + + explicit valarray(size_t t) : data(0), length(t){ + data = new T[length]; + } + + valarray(const T& v, size_t t) : data(0), length(t){ + data = new T[length]; + for(size_t i = 0; i < length; ++i){ + data[i] = v; + } + } + valarray(const T* p, size_t t) : data(0), length(t) { + data = new T[length]; + for(size_t i = 0; i < length; ++i){ + data[i] = p[i]; + } + } + valarray(const valarray& v) : data(0), length(v.length){ + data = new T[length]; + for(size_t i = 0; i < length; ++i){ + data[i] = v.data[i]; + } + } + valarray(const slice_array & sa) : data(0), length(sa.s.size()){ + data = new T[length]; + for(unsigned int i = 0; i < length; ++i){ + data[i] = sa.array->data[sa.s.start() + i * sa.s.stride()]; + } + } + valarray(const gslice_array&); + valarray(const mask_array&); + valarray(const indirect_array&); + ~valarray(){ + delete [] data; + data = 0; + length = 0; + } + + valarray& operator=(const valarray& v){ + for(size_t i =0; i< length; ++i){ + data[i] = v.data[i]; + } + return *this; + } + valarray& operator=(const T& t){ + for(size_t i = 0; i < length; ++i){ + data[i] = t; + } + return *this; + } + valarray& operator=(const slice_array& sa){ + for(size_t i =0; i < length; ++i){ + data[i] = sa.data[sa.s.start() + i * sa.s.stride()]; + } + return *this; + } + valarray& operator=(const gslice_array&); + valarray& operator=(const mask_array&); + valarray& operator=(const indirect_array&); + + T operator[](size_t t) const{ + return data[t]; + } + T& operator[](size_t t){ + return data[t]; + } + + valarray operator[](slice s) const{ + valarray retval(s.size()); + for(unsigned int i = 0; i< s.size(); ++i){ + retval.data[i] = data[s.start() + i * s.stride()]; + } + return retval; + } + + slice_array operator[](slice sl){ + slice_array retval; + retval.s = sl; + retval.array = this; + return retval; + } + + valarray operator[](const gslice&) const; + gslice_array operator[](const gslice&); + valarray operator[](const valarray&) const; + mask_array operator[](const valarray&); + valarray operator[](const valarray&) const; + indirect_array operator[](const valarray&); + + valarray operator+() const{ + valarray retval(length); + for(size_t i = 0; i< length ; ++i){ + retval.data[i] = +data[i]; + } + return retval; + } + valarray operator-() const{ + valarray retval(length); + for(size_t i = 0; i< length; ++i){ + retval.data[i] = -data[i]; + } + return retval; + } + valarray operator~() const{ + valarray retval(length); + for(size_t i = 0; i< length ; ++i){ + retval.data[i] = ~data[i]; + } + return retval; + } + valarray operator!() const{ + valarray retval(length); + for(size_t i = 0; i< length ; ++i){ + retval.data[i] = !data[i]; + } + return retval; + } + valarray& operator*= (const T& t){ + for(size_t i=0;i& operator/= (const T& t){ + for(size_t i=0;i& operator%= (const T& t){ + for(size_t i=0;i& operator+= (const T& t){ + for(size_t i=0;i& operator-= (const T& t){ + for(size_t i=0;i& operator^= (const T& t){ + for(size_t i=0;i& operator&= (const T& t){ + for(size_t i=0;i& operator|= (const T& t){ + for(size_t i=0;i& operator<<=(const T& t){ + for(size_t i=0;i& operator>>=(const T& t){ + for(size_t i=0;i>= t; + } + return *this; + } + valarray& operator*= (const valarray& a){ + for(size_t i=0;i& operator/= (const valarray& a){ + for(size_t i=0;i& operator%= (const valarray& a){ + for(size_t i=0;i& operator+= (const valarray& a){ + for(size_t i=0;i& operator-= (const valarray& a){ + for(size_t i=0;i& operator^= (const valarray& a){ + for(size_t i=0;i& operator|= (const valarray& a){ + for(size_t i=0;i& operator&= (const valarray& a){ + for(size_t i=0;i& operator<<=(const valarray& a){ + for(size_t i=0;i& operator>>=(const valarray& a){ + for(size_t i=0;i>= a.data[i]; + } + return *this; + } + + size_t size() const{ + return length; + } + + T sum() const{ + T retval(data[0]); + for(size_t i = 1; i< length; ++i){ + retval += data[i]; + } + return retval; + } + + T min() const{ + T retval(data[0]); + for(size_t i = 1; i< length; ++i){ + if(data[i] < retval){ + retval = data[i]; + } + } + return retval; + } + + T max() const{ + T retval(data[0]); + for(size_t i = 1; i< length; ++i){ + if(retval < data[i]){ + retval = data[i]; + } + } + return retval; + } + + valarray shift (int n) const{ + valarray retval(length); + for(size_t i = 0; i < length ; ++i){ + if(i + n > 0 && i + n < length){ + retval.data[i] = data[i + n]; + } + } + return retval; + } + valarray cshift(int n) const{ + valarray retval(length); + for(size_t i = 0; i < length ; ++i){ + retval.data[i] = data[ (i + n) % length ]; + } + return retval; + } + valarray apply(T func(T) ) const{ + valarray retval(length); + for(size_t i = 0; i< length; ++i){ + retval.data[i] = func(data[i]); + } + return retval; + } + valarray apply(T func(const T&)) const{ + valarray retval(length); + for(size_t i = 0; i< length; ++i){ + retval.data[i] = func(data[i]); + } + return retval; + } + void resize(size_t sz, T c = T()){ + delete [] data; + data = 0; + if(sz > 0){ + data = new T[sz]; + for(size_t i = 0; i < sz; ++i){ + data[i] = c; + } + } + length = sz; + } + }; + + + + template class _UCXXEXPORT slice_array { + friend class valarray; + public: + typedef T value_type; + + void operator= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] = v[i]; + } + } + void operator= (const T & v){ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] = v; + } + } + void fill(const T & v){ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] = v; + } + } + void operator*= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] *= v[i]; + } + } + void operator/= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] /= v[i]; + } + } + void operator%= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] %= v[i]; + } + } + void operator+= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] += v[i]; + } + } + void operator-= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] -= v[i]; + } + } + void operator^= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] ^= v[i]; + } + } + void operator&= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] &= v[i]; + } + } + void operator|= (const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] |= v[i]; + } + } + void operator<<=(const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] <<= v[i]; + } + } + void operator>>=(const valarray& v) const{ + for(unsigned int i = 0; i < s.size(); ++i){ + array->data[s.start() + i * s.stride()] >>= v[i]; + } + } + ~slice_array(){ + array = 0; + } + + private: + slice_array() : array(0){ } + + public: + slice_array(const slice_array& sa) : array(sa.array), s(sa.s){ } + slice_array& operator=(const slice_array& sa){ + array = sa.array; + s = sa.s; + } + + private: + valarray * array; + slice s; + }; + + + class _UCXXEXPORT gslice { + private: + size_t sta; + valarray siz; + valarray str; + + public: + gslice() : sta(0) { } + gslice(size_t s, const valarray& l, const valarray& d) + : sta(s), siz(l), str(d) { } + + size_t start() const{ + return sta; + } + valarray size() const{ + return siz; + } + valarray stride() const{ + return str; + } + }; + + template class gslice_array { + private: + friend class valarray; + + public: + ~gslice_array(); + + void operator=(const valarray& array) const; + void operator*=(const valarray& array) const; + void operator/=(const valarray& array) const; + void operator%=(const valarray& array) const; + void operator+=(const valarray& array) const; + void operator-=(const valarray& array) const; + void operator^=(const valarray& array) const; + void operator&=(const valarray& array) const; + void operator|=(const valarray& array) const; + void operator<<=(const valarray& array) const; + void operator>>=(const valarray& array) const; + + void operator=(const T&); + + private: + gslice_array(); + gslice_array(const gslice_array&); + gslice_array& operator= (const gslice_array& array); + }; + + + + template valarray operator* (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval *= rhs; + return retval; + } + + template valarray operator* (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval *= rhs; + return retval; + } + template valarray operator* (const T& lhs, const valarray& rhs){ + valarray retval(rhs); + retval *= lhs; + return retval; + } + template valarray operator/ (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval /= rhs; + return retval; + } + template valarray operator/ (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval /= rhs; + return retval; + } + template valarray operator/ (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval /= rhs; + return retval; + } + template valarray operator% (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval %= rhs; + return retval; + } + template valarray operator% (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval %= rhs; + return retval; + } + template valarray operator% (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval %= rhs; + return retval; + } + template valarray operator+ (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval += rhs; + return retval; + } + template valarray operator+ (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval += rhs; + return retval; + } + template valarray operator+ (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval += rhs; + return retval; + } + template valarray operator- (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval -= rhs; + return retval; + } + template valarray operator- (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval-= rhs; + return retval; + } + template valarray operator- (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval -= rhs; + return retval; + } + template valarray operator^ (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval ^= rhs; + return retval; + } + template valarray operator^ (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval ^= rhs; + return retval; + } + template valarray operator^ (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval ^= rhs; + return retval; + } + template valarray operator& (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval &= rhs; + return retval; + } + template valarray operator& (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval &= rhs; + return retval; + } + template valarray operator& (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval &= rhs; + return retval; + } + template valarray operator| (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval |= rhs; + return retval; + } + template valarray operator| (const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval |= rhs; + return retval; + } + template valarray operator| (const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval |= rhs; + return retval; + } + template valarray operator<<(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval <<= rhs; + return retval; + } + template valarray operator<<(const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval <<= rhs; + return retval; + } + template valarray operator<<(const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval <<= rhs; + return retval; + } + template valarray operator>>(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs); + retval >>= rhs; + return retval; + } + template valarray operator>>(const valarray& lhs, const T& rhs){ + valarray retval(lhs); + retval >>= rhs; + return retval; + } + template valarray operator>>(const T& lhs, const valarray& rhs){ + valarray retval(lhs, rhs.size()); + retval >>= rhs; + return retval; + } + + template valarray operator&&(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs[i] && rhs[i]; + } + return retval; + } + template valarray operator&&(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator&&(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator||(const valarray&lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator||(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator||(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs || rhs[i]; + } + return retval; + } + + template valarray operator==(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator==(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs[i] == rhs; + } + return retval; + } + template valarray operator==(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = lhs == rhs[i]; + } + return retval; + } + template valarray operator!=(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator!=(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator!=(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator< (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator< (const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator< (const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator> (const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i rhs[i]; + } + return retval; + } + template valarray operator> (const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i rhs; + } + return retval; + } + template valarray operator> (const T& rhs, const valarray& lhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i rhs[i]; + } + return retval; + } + template valarray operator<=(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator<=(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i valarray operator<=(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i valarray operator>=(const valarray& lhs, const valarray& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i = rhs[i]; + } + return retval; + } + template valarray operator>=(const valarray& lhs, const T& rhs){ + valarray retval(lhs.size()); + for(size_t i = 0; i = rhs; + } + return retval; + } + template valarray operator>=(const T& lhs, const valarray& rhs){ + valarray retval(rhs.size()); + for(size_t i = 0; i = rhs[i]; + } + return retval; + } + template T min(const valarray& x){ + T retval(x[0]); + for(size_t i = 1; i < x.size(); ++i){ + if(x[i] < retval){ + retval = x[i]; + } + } + } + template T max(const valarray& x){ + T retval(x[0]); + for(size_t i = 1; i < x.size(); ++i){ + if(x[i] > retval){ + retval = x[i]; + } + } + } + + template valarray abs (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = abs(x[i]); + } + } + template valarray acos (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = acos(x[i]); + } + } + template valarray asin (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = asin(x[i]); + } + } + template valarray atan (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = atan(x[i]); + } + } + template valarray atan2(const valarray& y, const valarray& x){ + valarray retval(y.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = atan2(y[i], x[i]); + } + } + template valarray atan2(const valarray& y, const T& x){ + valarray retval(y.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = atan2(y[i], x); + } + } + template valarray atan2(const T& y, const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = abs(y, x[i]); + } + } + template valarray cos (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = cos(x[i]); + } + } + template valarray cosh (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = cosh(x[i]); + } + } + template valarray exp (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = exp(x[i]); + } + } + template valarray log (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = log(x[i]); + } + } + template valarray log10(const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = log10(x[i]); + } + } + template valarray pow (const valarray& x, const valarray& y){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = pow(x[i], y[i]); + } + } + template valarray pow (const valarray& x, const T& y){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = pow(x[i], y); + } + } + template valarray pow (const T& x, const valarray& y){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = pow(x, y[i]); + } + } + template valarray sin (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = sin(x[i]); + } + } + template valarray sinh (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = sinh(x[i]); + } + } + template valarray sqrt (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = sqrt(x[i]); + } + } + template valarray tan (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = tan(x[i]); + } + } + template valarray tanh (const valarray& x){ + valarray retval(x.size()); + for(size_t i = 0; i < retval.size(); ++i){ + retval[i] = tanh(x[i]); + } + } + +} + +#pragma GCC visibility pop + +#endif Index: branches/slice/i386/modules/uClibc++/include/iterator_base =================================================================== --- branches/slice/i386/modules/uClibc++/include/iterator_base (revision 0) +++ branches/slice/i386/modules/uClibc++/include/iterator_base (revision 727) @@ -0,0 +1,305 @@ +/* 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 + +#ifndef __STD_HEADER_ITERATOR_BASE +#define __STD_HEADER_ITERATOR_BASE 1 + +#pragma GCC visibility push(default) + +namespace std{ + template struct iterator_traits; + template struct iterator_traits; + + template struct iterator; + + struct _UCXXEXPORT input_iterator_tag {}; + struct _UCXXEXPORT output_iterator_tag {}; + struct _UCXXEXPORT forward_iterator_tag: public input_iterator_tag {}; + struct _UCXXEXPORT bidirectional_iterator_tag: public forward_iterator_tag {}; + struct _UCXXEXPORT random_access_iterator_tag: public bidirectional_iterator_tag {}; + + template _UCXXEXPORT void advance(InputIterator& i, Distance n){ + while(n > 0){ + --n; + ++i; + } + } + + template _UCXXEXPORT typename iterator_traits::difference_type + distance(InputIterator first, InputIterator last) + { + typename iterator_traits::difference_type d = 0; + while(first++ !=last){ + d++; + } + return d; + } + + // subclause _lib.predef.iterators_, predefined iterators: + template class reverse_iterator; + template bool operator==(const reverse_iterator& x, const reverse_iterator& y); + template bool operator<(const reverse_iterator& x, const reverse_iterator& y); + template bool operator!=(const reverse_iterator& x, const reverse_iterator& y); + template bool operator>(const reverse_iterator& x, const reverse_iterator& y); + template bool operator>=(const reverse_iterator& x, const reverse_iterator& y); + template bool operator<=(const reverse_iterator& x, const reverse_iterator& y); + template typename reverse_iterator::difference_type + operator-( const reverse_iterator& x, const reverse_iterator& y); + template reverse_iterator + operator+( typename reverse_iterator::difference_type n, const reverse_iterator& x); + template class back_insert_iterator; + template back_insert_iterator back_inserter(Container& x); + template class front_insert_iterator; + template front_insert_iterator front_inserter(Container& x); + template class insert_iterator; + template + insert_iterator inserter(Container& x, Iterator i); + + //Actual Template definitions + + template struct _UCXXEXPORT iterator_traits { + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + typedef typename Iterator::iterator_category iterator_category; + }; + + //Pointer specialization - required by standard + template struct _UCXXEXPORT iterator_traits { + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef random_access_iterator_tag iterator_category; + }; + + //Specialization recomended by standard +/* template struct _UCXXEXPORT iterator_traits { + typedef long difference_type; + typedef T value_type; + typedef T __far* pointer; + typedef T __far& reference; + typedef random_access_iterator_tag iterator_category; + };*/ + +/* template _UCXXEXPORT void + reverse(BidirectionalIterator first, BidirectionalIterator last) + { + typename iterator_traits::difference_type n = distance(first, last); + --n; + while(n > 0){ + typename iterator_traits::value_type tmp = *first; + *first++ = * --last; + *last = tmp; + n -= 2; + } + };*/ + + + template + struct _UCXXEXPORT iterator + { + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; + typedef Category iterator_category; + }; + + + template class _UCXXEXPORT reverse_iterator + : public iterator::iterator_category, + typename iterator_traits::value_type, typename iterator_traits::difference_type, + typename iterator_traits::pointer, typename iterator_traits::reference> + { + protected: + Iterator current; + friend bool operator== (const reverse_iterator& x, const reverse_iterator& y); + friend bool operator< (const reverse_iterator& x, const reverse_iterator& y); + + public: + typedef Iterator iterator_type; + + reverse_iterator() : current(){}; + explicit reverse_iterator(Iterator x) : current(x) { } + template reverse_iterator(const reverse_iterator &x) : current(x.base()){} + + Iterator base() const { return current; } // explicit + + typename iterator_traits::reference operator*() const { Iterator tmp = current; return *--tmp; } + typename iterator_traits::pointer operator->() const { return &(operator*()); } + typename iterator_traits::reference operator[](typename iterator_traits::difference_type n) const{ + return current[-n-1]; + } + + reverse_iterator& operator++(){ --current; return *this; } + reverse_iterator operator++(int) {reverse_iterator tmp = *this; --current; return tmp; } + reverse_iterator& operator--() { ++ current; return *this; } + reverse_iterator operator--(int) {reverse_iterator tmp = *this; ++current; return tmp; } + + reverse_iterator operator+ (typename iterator_traits::difference_type n) const{ + reverse_iterator retval( *this ); + retval+=n; + return retval; + } + reverse_iterator& operator+=(typename iterator_traits::difference_type n){ + current -= n; + return *this; + } + reverse_iterator operator- (typename iterator_traits::difference_type n) const{ + reverse_iterator retval( *this ); + retval-=n; + return retval; + } + reverse_iterator& operator-=(typename iterator_traits::difference_type n){ + current += n; + return *this; + } + }; + + + template _UCXXEXPORT bool + operator==(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() == y.base(); + } + template _UCXXEXPORT bool + operator<(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() < y.base(); + } + template _UCXXEXPORT bool + operator!=(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() != y.base(); + } + template _UCXXEXPORT bool + operator>(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() > y.base(); + } + template _UCXXEXPORT bool + operator>=(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() >= y.base(); + } + template _UCXXEXPORT bool + operator<=(const reverse_iterator& x, const reverse_iterator& y) + { + return x.base() <= y.base(); + } + template _UCXXEXPORT typename reverse_iterator::difference_type + operator-( const reverse_iterator& x, const reverse_iterator& y) + { + return y.base() - x.base(); + } + template _UCXXEXPORT reverse_iterator + operator+(typename reverse_iterator::difference_type n, const reverse_iterator& x) + { + return reverse_iterator (x.base() - n); + } + + template class _UCXXEXPORT back_insert_iterator : + public iterator + { + protected: + Container& container; + public: + typedef Container container_type; + explicit back_insert_iterator(Container& x):container(x) {}; + back_insert_iterator& operator=(const typename Container::value_type& value){ + container.push_back(value); + return *this; + } + back_insert_iterator& operator*(){ + return *this; + } + back_insert_iterator& operator++(){ + return *this; + } + back_insert_iterator operator++(int){ + return *this; + } + }; + + template _UCXXEXPORT back_insert_iterator + back_inserter(Container& x) + { + return back_insert_iterator(x); + } + + template class _UCXXEXPORT front_insert_iterator + : public iterator + { + protected: + Container& container; + public: + typedef Container container_type; + explicit front_insert_iterator(Container& x): container(x) {} + front_insert_iterator& operator=(const typename Container::value_type& value){ + container.push_front(value); + return *this; + } + + front_insert_iterator& operator*() { return *this; } + front_insert_iterator& operator++() { return *this; } + front_insert_iterator operator++(int) { return *this; } + }; + + template _UCXXEXPORT front_insert_iterator + front_inserter(Container& x) + { + return front_insert_iterator(x); + } + + template class _UCXXEXPORT insert_iterator + : public iterator + { + protected: + Container& container; + typename Container::iterator iter; + public: + typedef Container container_type; + insert_iterator(Container& x, typename Container::iterator i) : container(x), iter(i) {} + insert_iterator& operator=(const typename Container::value_type& value){ + iter = container.insert(iter, value); + ++iter; + return *this; + } + insert_iterator& operator*() { return *this; } + insert_iterator& operator++() { return *this; } + insert_iterator operator++(int) { return *this; } + }; + + template _UCXXEXPORT insert_iterator + inserter(Container& x, Iterator i) + { + return insert_iterator(x,typename Container::iterator(i)); + } + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/algorithm =================================================================== --- branches/slice/i386/modules/uClibc++/include/algorithm (revision 0) +++ branches/slice/i386/modules/uClibc++/include/algorithm (revision 727) @@ -0,0 +1,1695 @@ +/* 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 + +#ifndef __STD_HEADER_ALGORITHM +#define __STD_HEADER_ALGORITHM 1 + +//Elliminate any previously defined macro +#undef min +#undef max + +#pragma GCC visibility push(default) + +namespace std{ + + // subclause _lib.alg.nonmodifying_, non-modifying sequence operations: + template _UCXXEXPORT + Function for_each(InputIterator first, InputIterator last, Function f) + { + while(first !=last){ + f(*first); + ++first; + } + return f; + } + + + template _UCXXEXPORT + InputIterator find(InputIterator first, InputIterator last, const T& value) + { + while(first !=last && *first != value){ + ++first; + } + return first; + } + + template _UCXXEXPORT + InputIterator find_if(InputIterator first, InputIterator last, Predicate pred) + { + while(first !=last && !pred(*first)){ + ++first; + } + return first; + } + + template _UCXXEXPORT ForwardIterator1 + find_end(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2) + { + ForwardIterator1 retval = last1; + while(first1 !=last1){ + ForwardIterator1 temp1(first1); + ForwardIterator2 temp2(first2); + while(temp2!=last2 && temp1!= last1){ + if(*temp1 != *temp2){ + break; //Exit while loop + } + ++temp1; + ++temp2; + if(temp2 == last2){ //Have successfully checked the whole sequence + retval = first1; + } + } + } + return retval; + } + + template _UCXXEXPORT + ForwardIterator1 + find_end(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred) + { + ForwardIterator1 retval = last1; + while(first1 !=last1){ + ForwardIterator1 temp1(first1); + ForwardIterator2 temp2(first2); + while(temp2!=last2 && temp1!= last1){ + if( ! pred(*temp1, *temp2)){ + break; //Exit while loop + } + ++temp1; + ++temp2; + if(temp2 == last2){ //Have successfully checked the whole sequence + retval = first1; + } + } + } + return retval; + } + + template _UCXXEXPORT + ForwardIterator1 + find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2) + { + while(first1 != last1){ + ForwardIterator2 temp2(first2); + while(temp2 != last2 ){ + if(*temp2 == first1){ + return first1; + } + ++temp2; + } + + } + return last1; + } + + template _UCXXEXPORT + ForwardIterator1 + find_first_of(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred) + { + while(first1 != last1){ + ForwardIterator2 temp2(first2); + while(temp2 != last2 ){ + if(*temp2 == first1){ + return first1; + } + ++temp2; + } + + } + return last1; + } + + template _UCXXEXPORT ForwardIterator + adjacent_find(ForwardIterator first, ForwardIterator last) + { + ForwardIterator temp; + while(first != last){ + temp = first; + ++temp; + if(*temp == *first){ + return first; + } + ++first; + } + return first; + } + + template _UCXXEXPORT + ForwardIterator + adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) + { + ForwardIterator temp; + while(first != last){ + temp = first; + ++temp; + if( pred(*temp, *first)){ + return first; + } + ++first; + } + return first; + } + + template _UCXXEXPORT + typename iterator_traits::difference_type + count(InputIterator first, InputIterator last, const T& value) + { + typename iterator_traits::difference_type i = 0; + while(first!=last){ + if(*first == value){ + ++i; + } + ++first; + } + return i; + } + + template _UCXXEXPORT + typename iterator_traits::difference_type + count_if(InputIterator first, InputIterator last, Predicate pred) + { + typename iterator_traits::difference_type i = 0; + while(first!=last){ + if( pred(*first) ){ + ++i; + } + ++first; + } + return i; + } + + template _UCXXEXPORT + pair + mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) + { + while(first1 != last1){ + if(*first1 != *first2){ + break; + } + ++first1; + ++first2; + } + + pair retval; + retval.first = first1; + retval.second = first2; + return retval; + } + + template _UCXXEXPORT + pair + mismatch(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, BinaryPredicate pred) + { + while(first1 != last1){ + if( !pred(*first1, *first2) ){ + break; + } + ++first1; + ++first2; + } + + pair retval; + retval.first = first1; + retval.second = first2; + return retval; + } + + template _UCXXEXPORT + bool + equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) + { + while(first1 !=last1){ + if(*first1 != *first2){ + return false; + } + ++first1; + ++first2; + } + return true; + } + + template _UCXXEXPORT + bool + equal(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, BinaryPredicate pred) + { + while(first1 !=last1){ + if( !pred(*first1, *first2) ){ + return false; + } + ++first1; + ++first2; + } + return true; + } + + template _UCXXEXPORT + ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2) + { + equal_to::value_type> c; + return search(first1, last1, first2, last2, c); + } + + + template _UCXXEXPORT + ForwardIterator1 + search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate pred) + { + while(first1 != last1){ + ForwardIterator1 temp1(first1); + ForwardIterator2 temp2(first2); + while(temp2 != last2 && temp1 != last1){ + if( !pred(*temp2, *temp1) ){ + break; + } + ++temp1; + ++temp2; + if(temp2 == last2){ + return first1; + } + } + ++first1; + } + return last1; + } + + + template _UCXXEXPORT + ForwardIterator + search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value) + { + while( first != last ){ + if(*first == value){ + ForwardIterator temp(first); + Size i = 1; + ++first; //Avoid doing the same comparison over again + while(i < count && *temp == value){ + ++first; + ++i; + } + if(i == count){ + return first; + } + } + ++first; + } + return first; + } + + + template _UCXXEXPORT + ForwardIterator + search_n(ForwardIterator first, ForwardIterator last, + Size count, const T& value, BinaryPredicate pred) + { + while( first != last ){ + if( pred(*first, value) ){ + ForwardIterator temp(first); + Size i = 1; + ++first; //Avoid doing the same comparison over again + while(i < count && pred(*temp, value) ){ + ++first; + ++i; + } + if(i == count){ + return first; + } + } + ++first; + } + return first; + + } + + // subclause _lib.alg.modifying.operations_, modifying sequence operations: + + template _UCXXEXPORT + OutputIterator + copy(InputIterator first, InputIterator last, OutputIterator result) + { + while(first != last){ + *result = *first; + ++first; + ++result; + } + return result; + } + + template _UCXXEXPORT + BidirectionalIterator2 + copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, + BidirectionalIterator2 result) + { + while(first !=last ){ + --result; + --last; + *result = *last; + } + return result; + } + + template _UCXXEXPORT void swap(T& a, T& b){ + T temp(a); + a = b; + b = temp; + } + + template _UCXXEXPORT + ForwardIterator2 + swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) + { + while(first1 != last1){ + iter_swap(first1, first2); + ++first1; + ++first2; + } + return first2; + } + + + template _UCXXEXPORT + void + iter_swap(ForwardIterator1 a, ForwardIterator2 b) + { + typename iterator_traits::value_type temp(*a); + *a = *b; + *b = temp; + } + + + template _UCXXEXPORT + OutputIterator + transform(InputIterator first, InputIterator last, + OutputIterator result, UnaryOperation op) + { + while(first != last){ + *result = op(*first); + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + OutputIterator transform(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, OutputIterator result, + BinaryOperation binary_op) + { + while(first1 != last1){ + *result = binary_op(*first1, *first2); + ++first1; + ++first2; + ++result; + } + return result; + } + + + template _UCXXEXPORT + void + replace(ForwardIterator first, ForwardIterator last, + const T& old_value, const T& new_value) + { + while(first != last){ + if(*first == old_value){ + *first = new_value; + } + ++first; + } + } + + template _UCXXEXPORT + void + replace_if(ForwardIterator first, ForwardIterator last, + Predicate pred, const T& new_value) + { + while(first != last){ + if( pred(*first) ){ + *first = new_value; + } + ++first; + } + } + + + template _UCXXEXPORT + OutputIterator + replace_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& old_value, const T& new_value) + { + while(first != last){ + if(*first == old_value){ + *result = new_value; + }else{ + *result = *first; + } + ++first; + ++result; + } + return result; + } + + template _UCXXEXPORT + OutputIterator + replace_copy_if(Iterator first, Iterator last, + OutputIterator result, Predicate pred, const T& new_value) + { + while(first != last){ + if( pred(*first) ){ + *result = new_value; + }else{ + *result = *first; + } + ++first; + ++result; + } + return result; + } + + template _UCXXEXPORT + void + fill(ForwardIterator first, ForwardIterator last, const T& value) + { + while(first != last){ + *first = value; + ++first; + } + } + + template _UCXXEXPORT + void + fill_n(OutputIterator first, Size n, const T& value) + { + while(n != 0){ + *first = value; + --n; + ++first; + } + } + + template _UCXXEXPORT + void + generate(ForwardIterator first, ForwardIterator last, Generator gen) + { + while(first != last){ + *first = gen(); + ++first; + } + } + + template _UCXXEXPORT + void + generate_n(OutputIterator first, Size n, Generator gen) + { + while(n !=0){ + *first = gen(); + --n; + ++first; + } + } + + template _UCXXEXPORT + ForwardIterator + remove(ForwardIterator first, ForwardIterator last, const T& value) + { + ForwardIterator temp(first); + while(temp !=last){ + if(*temp == value){ + + }else{ + *first = *temp; + ++first; + } + ++temp; + } + return first; + } + + template _UCXXEXPORT + ForwardIterator + remove_if(ForwardIterator first, ForwardIterator last, Predicate pred) + { + ForwardIterator temp(first); + while(temp !=last){ + if( pred(*temp) ){ + + }else{ + *first = *temp; + ++first; + } + ++temp; + } + return first; + } + + + template _UCXXEXPORT + OutputIterator + remove_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& value) + { + while(first !=last){ + if(*first != value){ + *result = *first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + OutputIterator + remove_copy_if(InputIterator first, InputIterator last, + OutputIterator result, Predicate pred) + { + while(first !=last){ + if( !pred(*first) ){ + *result = *first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + ForwardIterator + unique(ForwardIterator first, ForwardIterator last) + { + ForwardIterator new_val(first); + ForwardIterator old_val(first); + + while(new_val !=last){ + if(*new_val == *old_val && new_val != old_val){ + + }else{ + *first = *new_val; + old_val = new_val; + ++first; + } + ++new_val; + } + return first; + } + + template _UCXXEXPORT + ForwardIterator + unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) + { + ForwardIterator new_val(first); + ForwardIterator old_val(first); + + while(new_val !=last){ + if( pred(*new_val, *old_val) && new_val != old_val){ + + }else{ + *first = *new_val; + old_val = new_val; + ++first; + } + ++new_val; + } + return first; + } + + template _UCXXEXPORT + OutputIterator + unique_copy(InputIterator first, InputIterator last, OutputIterator result) + { + InputIterator temp(first); + while(first !=last ){ + if(*first == *temp && first != temp){ + + }else{ + *result = *first; + temp = first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + OutputIterator + unique_copy(InputIterator first, InputIterator last, + OutputIterator result, BinaryPredicate pred) + { + InputIterator temp(first); + while(first !=last ){ + if( pred(*first, *temp) && first != temp){ + + }else{ + *result = *first; + temp = first; + ++result; + } + ++first; + } + return result; + } + + template _UCXXEXPORT + void + reverse(BidirectionalIterator first, BidirectionalIterator last) + { + --last; //Don't work with one past the end element + while(first < last){ + iter_swap(first, last); + ++first; + --last; + } + } + + template _UCXXEXPORT + OutputIterator + reverse_copy(BidirectionalIterator first, BidirectionalIterator last, + OutputIterator result) + { + while(last > first){ + --last; + *result = *last; + ++result; + } + return result; + } + + template _UCXXEXPORT + void + rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last) + { + if ((first == middle) || (last == middle)){ + return; + } + + ForwardIterator first2 = middle; + + do { + swap(*first, *first2); + first++; + first2++; + if(first == middle){ + middle = first2; + } + } while(first2 != last); + + first2 = middle; + + while (first2 != last) { + swap(*first, *first2); + first++; + first2++; + if (first == middle){ + middle = first2; + }else if (first2 == last){ + first2 = middle; + } + } + } + + template _UCXXEXPORT + OutputIterator + rotate_copy(ForwardIterator first, ForwardIterator middle, + ForwardIterator last, OutputIterator result) + { + ForwardIterator temp(middle); + while(temp !=last){ + *result = *temp; + ++temp; + ++result; + } + while(first != middle){ + *result = *first; + ++first; + ++result; + } + return result; + } + + + template _UCXXEXPORT + void + random_shuffle(RandomAccessIterator first, RandomAccessIterator last) + { + --last; + while(first != last){ + iter_swap(first, (first + (rand() % (last - first) ) ) ); + ++first; + } + } + + template _UCXXEXPORT + void + random_shuffle(RandomAccessIterator first, RandomAccessIterator last, + RandomNumberGenerator& rand) + { + --last; + while(first != last){ + iter_swap(first, (first + (rand(last - first) ) ) ); + ++first; + } + } + + // _lib.alg.partitions_, partitions: + template _UCXXEXPORT BidirectionalIterator + partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred) + { + return stable_partition(first, last, pred); + } + + template _UCXXEXPORT BidirectionalIterator + stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred) + { + //first now points to the first non-desired element + while( first != last && pred(*first) ){ + ++first; + } + + BidirectionalIterator tempb; + BidirectionalIterator tempe = first; + + while( tempe != last ){ + //Find the next desired element + while( !pred(*tempe) ){ + ++tempe; + + //See if we should exit + if(tempe == last){ + return first; + } + } + + //Rotate the element back to the begining + tempb = tempe; + while(tempb != first){ + iter_swap(tempb, tempb-1 ); + --tempb; + } + //First now has a desired element + ++first; + } + + return first; + } + + template _UCXXEXPORT + void sort(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + sort(first, last, c ); + } + + template _UCXXEXPORT + void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + stable_sort(first, last, comp); + } + + template _UCXXEXPORT + void stable_sort(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + stable_sort(first, last, c); + } + + template _UCXXEXPORT + void stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + //FIXME - bubble sort + RandomAccessIterator temp; + --last; + while(last - first > 0){ + temp = last; + while(temp != first){ + if( comp( *temp, *(temp-1) ) ){ + iter_swap( temp-1, temp); + } + --temp; + } + ++first; + } + } + + template _UCXXEXPORT + void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last) + { + less::value_type> c; + partial_sort(first, middle, last, c); + } + template _UCXXEXPORT + void partial_sort(RandomAccessIterator first, RandomAccessIterator middle, + RandomAccessIterator last, Compare comp) + { + //Fixme - partial bubble sort + RandomAccessIterator temp; + --last; + while(first < middle){ + temp = last; + while(temp != first){ + if( comp(*temp, *(temp -1 ) ) ) { + iter_swap( temp-1, temp); + } + --temp; + } + ++first; + } + } + template _UCXXEXPORT + RandomAccessIterator + partial_sort_copy(InputIterator first, InputIterator last, + RandomAccessIterator result_first, RandomAccessIterator result_last) + { + less::value_type> c; + return partial_sort_copy(first, last, result_first, result_last, c); + } + template _UCXXEXPORT + RandomAccessIterator + partial_sort_copy(InputIterator first, InputIterator last, + RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp) + { + size_t output_size = last-first; + size_t temp_size = result_last - result_first; + if(temp_size < output_size){ + output_size = temp_size; + } + + RandomAccessIterator middle = result_first + output_size; + RandomAccessIterator temp = result_first; + + while(temp != middle){ + *temp = *first; + ++temp; + ++first; + } + sort(result_first, middle, comp); + + while( first != last){ + if( comp( *first, *(middle-1) ) ){ + *(middle-1) = *first; + sort(result_first, middle, comp); + } + ++first; + } + + return middle; + } + template _UCXXEXPORT + void nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last) + { + less::value_type> c; + nth_element(first, nth, last, c); + } + template _UCXXEXPORT + void nth_element(RandomAccessIterator first, RandomAccessIterator nth, + RandomAccessIterator last, Compare comp) + { + partial_sort(first, nth, last, comp); + } + + template _UCXXEXPORT + ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, + const T& value) + { + less::value_type> c; + return lower_bound(first, last, value, c); + } + + template _UCXXEXPORT + ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) + { + if(first == last){ + return last; + } + //If below or equal to the first element + if( comp(*first, value) == false){ + return first; + } + ForwardIterator middle; + + //If greater than the top element + middle = first; + advance(middle, distance(first, last) - 1); + if( comp(*middle, value) ){ + return last; + } + + //Now begin the actual search for the begining + while( distance(first, last) > 1 ){ + //Find middle + middle = first; + advance(middle, (distance(first, last)/2) ); + if( !comp(*middle, value) ){ + last = middle; + }else{ + first = middle; + } + } + + if( !comp(*first, value) ){ + return first; + } + return last; + } + + template _UCXXEXPORT + ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, + const T& value) + { + less::value_type> c; + return upper_bound(first, last, value, c); + } + + + template _UCXXEXPORT + ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) + { + if(first == last){ + return last; + } + //If below the first element + if( comp(value, *first) == true){ + return first; + } + + ForwardIterator middle; + + //If greater than the top element + middle = first; + advance(middle, distance(first, last) - 1); + if( comp(*middle, value) ){ + return last; + } + + //Now begin the actual search for the end + while( distance(first, last) > 1 ){ + //Find middle + middle = first; + advance(middle, (distance(first, last)/2) ); + if( comp(value, *middle) ){ + last = middle; + }else{ + first = middle; + } + } + + if( comp(value, *first) ){ + return first; + } + return last; + } + + + template _UCXXEXPORT + pair + equal_range(ForwardIterator first, ForwardIterator last, const T& value) + { + less::value_type> c; + return equal_range(first, last, value, c); + } + + template _UCXXEXPORT + pair + equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp) + { + pair retval; + retval.first = lower_bound(first, last, value, comp); + //Reuse retval.first in order to (possibly) save a few comparisons + retval.second = upper_bound(retval.first, last, value, comp); + return retval; + + } + + template _UCXXEXPORT + bool binary_search(ForwardIterator first, ForwardIterator last, + const T& value) + { + less::value_type> c; + return binary_search(first, last, value, c); + } + + template _UCXXEXPORT + bool binary_search(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) + { + if( distance(first, last) == 0){ + return false; + } + + ForwardIterator middle; + + while( distance(first, last) > 1 ){ + //Set middle between first and last + middle = first; + advance(middle, distance(first, last)/2 ); + + if( comp(*middle, value ) == true){ + first = middle; + }else{ + last = middle; + } + } + + if( !comp(*first, value) && !comp(value, *first) ){ + return true; + } + if( !comp(*last, value) && !comp(value, *last) ){ + return true; + } + + return false; + } + + // _lib.alg.merge_, merge: + template _UCXXEXPORT + OutputIterator + merge(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return merge(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator + merge(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + //If in this order so first1 elements which are equal come first + if( comp(*first2, *first1) ){ + *result = *first2; + ++first2; + }else{ + *result = *first1; + ++first1; + } + ++result; + } + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++first1; + ++result; + } + while(first2 != last2){ + *result = *first2; + ++first2; + ++result; + } + return result; + } + template _UCXXEXPORT + void inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, BidirectionalIterator last) + { + less::value_type> c; + inplace_merge(first, middle, last, c); + } + template _UCXXEXPORT + void inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, BidirectionalIterator last, Compare comp) + { + //FIXME - using a bubble exchange method + while(first != middle && middle !=last){ + if( comp(*middle, *first) ){ + BidirectionalIterator temp(middle); + while( temp != first){ + iter_swap(temp, temp-1); + --temp; + } + ++middle; + } + ++first; + } + } + + // _lib.alg.set.operations_, set operations: + template _UCXXEXPORT + bool includes(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) + { + less::value_type> c; + return includes(first1, last1, first2, last2, c ); + } + + template _UCXXEXPORT + bool includes(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, Compare comp) + { + while(first2 != last2){ + //Advance the large set until no longer smaller than the element we are looking for + while( comp(*first1, *first2) ){ + ++first1; + //If we are at the end of the list, we don't have the desired element + if(first1 == last1){ + return false; + } + } + //If we are past the element we want, it isn't here + if( comp(*first2, *first1) ){ + return false; + } + ++first2; //Move to next element + } + return true; + } + + template _UCXXEXPORT + OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_union(first1, last1, first2, last2, result, c); + } + + template _UCXXEXPORT + OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first2, *first1) ){ + *result = *first2; + + //Elliminate duplicates + InputIterator2 temp = first2; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + }else{ + *result = *first1; + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + ++result; + } + + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + } + + while(first2 != last2){ + *result = *first2; + ++result; + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + return result; + } + + template _UCXXEXPORT + OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_intersection(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first2, *first1) ){ + ++first2; + }else if( comp(*first1, *first2) ) { + ++first1; + }else{ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + ++first2; + } + } + return result; + } + template _UCXXEXPORT + OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_difference(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first1, *first2) ){ + *result = *first1; + ++result; + + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + }else if( comp(*first2, *first1) ){ + + //Elliminate duplicates + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + + }else{ //They are identical - skip + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + } + + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + } + + return result; + } + template _UCXXEXPORT + OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result) + { + less::value_type> c; + return set_symmetric_difference(first1, last1, first2, last2, result, c); + } + template _UCXXEXPORT + OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp) + { + while( first1 != last1 && first2 != last2){ + if( comp(*first1, *first2) ){ + *result = *first1; + ++result; + + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + }else if( comp(*first2, *first1) ){ + *result = *first2; + ++result; + + //Elliminate duplicates + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + + }else{ //They are identical - skip + //Elliminate duplicates + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + } + + //Clean up remaining elements + while(first1 != last1){ + *result = *first1; + ++result; + InputIterator1 temp = first1; + while( first1 != last1 && !comp( *temp, *first1) ){ + ++first1; + } + } + + while(first2 != last2){ + *result = *first2; + ++result; + InputIterator2 temp = first2; + while( first2 != last2 && !comp( *temp, *first2) ){ + ++first2; + } + } + + return result; + } + + // _lib.alg.heap.operations_, heap operations: + + template _UCXXEXPORT + void push_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + push_heap(first, last, c); + } + + template _UCXXEXPORT + void push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + // *(last - 1) is the last element + RandomAccessIterator begin, middle, end; + begin = first; + end = last - 2; + if(last - first < 2){ //Empty heap + return; + } + if ( comp(*(last-1), *end) ){ //Belongs past the end - already in place + return; + } + while(end - begin > 1){ + middle = begin + ((end - begin)/2); + if( comp(*middle, *(last-1) ) ){ + end = middle; + }else{ + begin = middle; + } + } + + if( comp(*begin, *(last-1)) ){ + middle = begin; + }else{ + middle = end; + } + + //Now all we do is swap the elements up to the begining + --last; + + while(last > middle){ + iter_swap(last, last-1); + --last; + } + } + + template _UCXXEXPORT + void pop_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + pop_heap(first, last, c); + } + template _UCXXEXPORT + void pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare) + { + --last; + while(first < last){ + iter_swap( first, first+1); + ++first; + } + } + + template _UCXXEXPORT + void make_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + make_heap(first, last, c); + } + template _UCXXEXPORT + void make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + sort( reverse_iterator(last), reverse_iterator(first), comp); + } + template _UCXXEXPORT + void sort_heap(RandomAccessIterator first, RandomAccessIterator last) + { + less::value_type> c; + sort_heap(first, last, c); + } + template _UCXXEXPORT + void sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp) + { + sort( first, last, comp); + } + + + // _lib.alg.min.max_, minimum and maximum: + template _UCXXEXPORT + const T& min(const T& a, const T& b) + { + if(b < a){ + return b; + } + return a; + } + + template _UCXXEXPORT + const T& min(const T& a, const T& b, Compare comp) + { + if( comp(b, a) == true){ + return b; + } + return a; + } + + template _UCXXEXPORT + const T& max(const T& a, const T& b) + { + if( a < b){ + return b; + } + return a; + } + + template _UCXXEXPORT + const T& max(const T& a, const T& b, Compare comp) + { + if( comp(a, b) ){ + return b; + } + return a; + } + + template _UCXXEXPORT + ForwardIterator min_element(ForwardIterator first, ForwardIterator last) + { + less::value_type> c; + return min_element(first, last, c); + } + + template _UCXXEXPORT + ForwardIterator min_element(ForwardIterator first, ForwardIterator last, Compare comp) + { + ForwardIterator retval = first; + ++first; + while(first != last){ + if( comp( *first, *retval) ){ + retval = first; + } + ++first; + } + return retval; + } + + template _UCXXEXPORT + ForwardIterator max_element(ForwardIterator first, ForwardIterator last) + { + less::value_type> c; + return max_element(first, last, c); + } + + template _UCXXEXPORT + ForwardIterator max_element(ForwardIterator first, ForwardIterator last, Compare comp) + { + ForwardIterator retval = first; + ++first; + while(first != last){ + if( comp( *retval, *first ) ){ + retval = first; + } + ++first; + } + return retval; + } + + template _UCXXEXPORT + bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) + { + less::value_type> c; + return lexicographical_compare(first1, last1, first2, last2, c); + } + + template _UCXXEXPORT + bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, Compare comp) + { + while(first1 != last1 && first2 != last2){ + if( comp(*first1, *first2) ){ + return true; + } + if( comp(*first2, *first1) ){ + return false; + } + ++first1; + ++first2; + } + return first1==last1 && first2 != last2; + } + + // _lib.alg.permutation.generators_, permutations + template _UCXXEXPORT + bool next_permutation(BidirectionalIterator first, BidirectionalIterator last) + { + less::value_type> c; + return next_permutation(first, last, c); + } + + template _UCXXEXPORT + bool next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp) + { + if(first == last){ + return false; // No data + } + BidirectionalIterator i = last; + --i; + if(i == first){ + return false; //Only one element + } + BidirectionalIterator ii = i; + --ii; + //If the last two items are in order, swap them and call it done + if( comp(*ii, *i) ){ + iter_swap(ii, i); + return true; + } + + + //This part of the algorithm copied from G++ header files ver. 3.4.2 + i = last; + --i; + for(;;){ + ii = i; + --i; + if ( comp(*i, *ii) ){ + BidirectionalIterator j = last; + --j; + while ( !comp(*i, *j)){ + --j; + } + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first){ + reverse(first, last); + return false; + } + } + + + } + + template _UCXXEXPORT + bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last) + { + less::value_type> c; + return prev_permutation(first, last, c); + } + + template _UCXXEXPORT + bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp) + { + if(first == last){ + return false; // No data + } + BidirectionalIterator i = last; + --i; + if(i == first){ + return false; //Only one element + } + BidirectionalIterator ii = i; + --ii; + //If the last two items are in reverse order, swap them and call it done + if( comp(*i, *ii) ){ + iter_swap(ii, i); + return true; + } + + //Copied from GNU GCC header files version 3.4.2 + i = last; + --i; + + for(;;){ + ii = i; + --i; + if ( comp(*ii, *i)){ + BidirectionalIterator j = last; + --j; + while ( !comp(*j, *i)){ + --j; + } + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first){ + reverse(first, last); + return false; + } + } + + } + +} + +#pragma GCC visibility pop + +#endif + + + Index: branches/slice/i386/modules/uClibc++/include/istream_helpers =================================================================== --- branches/slice/i386/modules/uClibc++/include/istream_helpers (revision 0) +++ branches/slice/i386/modules/uClibc++/include/istream_helpers (revision 727) @@ -0,0 +1,344 @@ +/* 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 + +#ifndef __STD_HEADER_ISTREAM_HELPERS +#define __STD_HEADER_ISTREAM_HELPERS 1 + +#pragma GCC visibility push(default) + +namespace std{ + + + /* We are making the following template class for serveral reasons. Firstly, + * we want to keep the main istream code neat and tidy. Secondly, we want it + * to be easy to do partial specialization of the istream code so that it can + * be expanded and put into the library. This will allow us to make application + * code smaller at the expense of increased library size. This is a fair + * trade-off when there are multiple applications being compiled. Also, this + * feature will be used optionally via configuration options. It will also + * allow us to keep the code bases in sync, dramatically simplifying the + * maintenance required. We specialized for char because wchar and others + * require different scanf functions + */ + + template _UCXXEXPORT + basic_string _readToken(basic_istream& stream) + { + basic_string temp; + typename traits::int_type c; + while(true){ + c = stream.rdbuf()->sgetc(); + if(c != traits::eof() && isspace(c) == false){ + stream.rdbuf()->sbumpc(); + temp.append(1, traits::to_char_type(c)); + }else{ + break; + } + } + if (temp.size() == 0) + stream.setstate(ios_base::eofbit|ios_base::failbit); + + return temp; + } + + template _UCXXEXPORT + basic_string _readTokenDecimal(basic_istream& stream) + { + basic_string temp; + typename traits::int_type c; + while(true){ + c = stream.rdbuf()->sgetc(); + if(c != traits::eof() && isspace(c) == false && (isdigit(c) || c == '.' || c == ',' )){ + stream.rdbuf()->sbumpc(); + temp.append(1, traits::to_char_type(c)); + }else{ + break; + } + } + if (temp.size() == 0) + stream.setstate(ios_base::eofbit|ios_base::failbit); + + return temp; + } + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ + + template <> _UCXXEXPORT string _readToken >(istream & stream); + +#endif + + + template class _UCXXEXPORT __istream_readin{ + public: + static void readin(basic_istream& stream, dataType & var); + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, bool & var) + { + basic_string temp; + temp = _readToken( stream); + if(temp == "true" || temp == "True" || temp == "TRUE" || temp == "1"){ + var = true; + }else{ + var = false; + } + } + }; + + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, short & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%hd", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%hi", &var); + + } + } + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, unsigned short & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%hu", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%ho", &var); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%hX", &var ); + }else{ + sscanf(temp.c_str(), "%hx", &var); + } + }else{ + sscanf(temp.c_str(), "%hi", (signed short int*)(&var) ); + } + } + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%d", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%i", &var); + } + } + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, unsigned int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%u", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%i", (int *)(&var) ); + } + } + + } + }; + + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, long int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%ld", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var) ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var) ); + }else{ + sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var) ); + } + }else{ + sscanf(temp.c_str(), "%li", (long int *)(&var) ); + } + } + + } + }; + + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, unsigned long int & var) + { + basic_string temp; + + if(stream.flags() & ios_base::dec){ + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%lu", &var ); + }else{ + temp = _readToken( stream); + if( stream.flags() & ios_base::oct){ + sscanf(temp.c_str(), "%lo", &var ); + }else if(stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::uppercase){ + sscanf(temp.c_str(), "%lX", &var ); + }else{ + sscanf(temp.c_str(), "%lx", &var); + } + }else{ + sscanf(temp.c_str(), "%li", (long int *)(&var) ); + } + } + } + }; + + +#ifdef __UCLIBCXX_HAS_FLOATS__ + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, float & var) + { + basic_string temp; + temp = _readTokenDecimal( stream); + + sscanf(temp.c_str(), "%g", &var); + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, double & var) + { + basic_string temp; + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%lg", &var); + } + }; + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, long double & var) + { + basic_string temp; + temp = _readTokenDecimal( stream); + sscanf(temp.c_str(), "%Lg", &var); + } + }; + +#endif // ifdef __UCLIBCXX_HAS_FLOATS__ + + template class _UCXXEXPORT __istream_readin{ + public: + inline static void readin(basic_istream& stream, void* & var) + { + basic_string temp; + temp = _readToken( stream); + sscanf(temp.c_str(), "%p", &var); + } + }; + + + template void __skipws(basic_istream& is){ + const typename basic_istream::int_type eof = traits::eof(); + typename basic_istream::int_type c; + //While the next character normally read doesn't equal eof + //and that character is a space, advance to the next read position + //Thus itterating through all whitespace until we get to the meaty stuff + while ( + !traits::eq_int_type((c = is.rdbuf()->sgetc()), eof) + && isspace(c) + ) + { + is.rdbuf()->sbumpc(); + } + if(traits::eq_int_type(c, eof)){ + is.setstate(ios_base::eofbit); + } + } +} + +#pragma GCC visibility pop + +#endif + + + Index: branches/slice/i386/modules/uClibc++/include/ostream_helpers =================================================================== --- branches/slice/i386/modules/uClibc++/include/ostream_helpers (revision 0) +++ branches/slice/i386/modules/uClibc++/include/ostream_helpers (revision 727) @@ -0,0 +1,490 @@ +/* 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 + +#ifndef __STD_HEADER_OSTREAM_HELPERS +#define __STD_HEADER_OSTREAM_HELPERS 1 + +#pragma GCC visibility push(default) + +namespace std{ + + /* We are making the following template class for serveral reasons. Firstly, + * we want to keep the main ostream code neat and tidy. Secondly, we want it + * to be easy to do partial specialization of the ostream code so that it can + * be expanded and put into the library. This will allow us to make application + * code smaller at the expense of increased library size. This is a fair + * trade-off when there are multiple applications being compiled. Also, this + * feature will be used optionally via configuration options. It will also + * allow us to keep the code bases in sync, dramatically simplifying the + * maintenance required. We specialized for char because wchar and others + * require different scanf functions + */ + + + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const dataType n); + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long int n) + { + char buffer[20]; + const char * c_ld = "%ld"; + const char * c_lo = "%lo"; + const char * c_lX = "%lX"; + const char * c_lx = "%lx"; + const char * c_hashlo = "%#lo"; + const char * c_hashlX = "%#lX"; + const char * c_hashlx = "%#lx"; + + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = c_ld; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = c_hashlo; + }else{ + formatString = c_lo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = c_hashlX; + }else{ + formatString = c_hashlx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = c_lX; + }else{ + formatString = c_lx; + } + } + } + + stream.write(buffer, snprintf(buffer, 20, formatString, n) ); + + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long int n) + { + char buffer[20]; + const char * c_lo = "%lo"; + const char * c_lu = "%lu"; + const char * c_lX = "%lX"; + const char * c_lx = "%lx"; + const char * c_hashlo = "%#lo"; + const char * c_hashlX = "%#lX"; + const char * c_hashlx = "%#lx"; + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = c_lu; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = c_hashlo; + }else{ + formatString = c_lo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = c_hashlX; + }else{ + formatString = c_hashlx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = c_lX; + }else{ + formatString = c_lx; + } + } + } + + stream.write(buffer, snprintf(buffer, 20, formatString, n)); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + +#ifndef __STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long long int n) + { + char buffer[28]; + const char * lld = "%lld"; + const char * llo = "%llo"; + const char * llX = "%llX"; + const char * llx = "%llx"; + const char * hashllo = "%#llo"; + const char * hashllX = "%#llX"; + const char * hashllx = "%#llx"; + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = lld; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = hashllo; + }else{ + formatString = llo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = hashllX; + }else{ + formatString = hashllx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = llX; + }else{ + formatString = llx; + } + } + } + + stream.write(buffer, snprintf(buffer, 27, formatString, n) ); + + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long long int n) + { + char buffer[28]; + const char * llo = "%llo"; + const char * llu = "%llu"; + const char * llX = "%llX"; + const char * llx = "%llx"; + const char * hashllo = "%#llo"; + const char * hashllX = "%#llX"; + const char * hashllx = "%#llx"; + const char * formatString=0; + + if( stream.flags() & ios_base::dec){ + formatString = llu; + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + formatString = hashllo; + }else{ + formatString = llo; + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + formatString = hashllX; + }else{ + formatString = hashllx; + } + }else{ + if(stream.flags() & ios_base::uppercase){ + formatString = llX; + }else{ + formatString = llx; + } + } + } + + stream.write(buffer, snprintf(buffer, 27, formatString, n) ); + + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + +#endif //__STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const double f) + { + char buffer[32]; + int length; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + length = snprintf(buffer, 32, "%*.*E", static_cast(stream.width()),static_cast(stream.precision()), f); + }else{ + length = snprintf(buffer, 32, "%*.*e", static_cast(stream.width()),static_cast(stream.precision()), f); + } + } else if(stream.flags() & ios_base::fixed){ + length = snprintf(buffer, 32, "%*.*f",static_cast(stream.width()),static_cast(stream.precision()), f); + } else { + length = snprintf(buffer, 32, "%*.*g",static_cast(stream.width()),static_cast(stream.precision()), f); + } + stream.write(buffer, length); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const long double f) + { + char buffer[32]; + int length; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + length = snprintf(buffer, 32, "%*.*LE", static_cast(stream.width()), static_cast(stream.precision()), f); + }else{ + length = snprintf(buffer, 32, "%*.*Le", static_cast(stream.width()), static_cast(stream.precision()), f); + } + } else if(stream.flags() & ios_base::fixed){ + length = snprintf(buffer, 32, "%*.*Lf", static_cast(stream.width()), static_cast(stream.precision()), f); + } else { + length = snprintf(buffer, 32, "%*.*Lg", static_cast(stream.width()), static_cast(stream.precision()), f); + } + stream.write(buffer, length); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + + } + }; + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long int n) + { + wchar_t buffer[20]; + if( stream.flags() & ios_base::dec){ + stream.write(buffer, swprintf(buffer, 20, L"%ld", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.write(buffer, swprintf(buffer, 20, L"%#lo", n)); + }else{ + stream.write(buffer, swprintf(buffer, 20, L"%lo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 20, L"%lX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 20, L"%lx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long int n) + { + wchar_t buffer[20]; + if( stream.flags() & ios_base::dec){ + stream.write(buffer, swprintf(buffer, 20, L"%lu", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.write(buffer, swprintf(buffer, 20, L"%#lo", n)); + }else{ + stream.write(buffer, swprintf(buffer, 20, L"%lo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 20, L"%lX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 20, L"%lx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + +#ifndef __STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const signed long long int n) + { + wchar_t buffer[28]; + if( stream.flags() & ios_base::dec){ + stream.write(buffer, swprintf(buffer, 27, L"%lld", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.write(buffer, swprintf(buffer, 27, L"%#llo", n)); + }else{ + stream.write(buffer, swprintf(buffer, 27, L"%llo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 27, L"%llX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 27, L"%llx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const unsigned long long int n) + { + wchar_t buffer[28]; + if( stream.flags() & ios_base::dec){ + stream.write(buffer, swprintf(buffer, 27, L"%llu", n)); + }else if( stream.flags() & ios_base::oct){ + if( stream.flags() & ios_base::showbase){ + stream.write(buffer, swprintf(buffer, 27, L"%#llo", n)); + }else{ + stream.write(buffer, swprintf(buffer, 27, L"%llo", n) ); + } + }else if (stream.flags() & ios_base::hex){ + if(stream.flags() & ios_base::showbase){ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) ); + } + }else{ + if(stream.flags() & ios_base::uppercase){ + stream.write(buffer, swprintf(buffer, 27, L"%llX", n) ); + }else{ + stream.write(buffer, swprintf(buffer, 27, L"%llx", n) ); + } + } + } + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + +#endif //__STRICT_ANSI__ + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const double f) + { + wchar_t buffer[32]; + wchar_t format_string[32]; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + swprintf(format_string, 32, L"%%%u.%uE", static_cast(stream.width()), static_cast(stream.precision())); + }else{ + swprintf(format_string, 32, L"%%%u.%ue", static_cast(stream.width()), static_cast(stream.precision())); + } + } else if(stream.flags() & ios_base::fixed){ + swprintf(format_string, 32, L"%%%u.%uf", static_cast(stream.width()), static_cast(stream.precision())); + } else { + swprintf(format_string, 32, L"%%%u.%ug", static_cast(stream.width()), static_cast(stream.precision())); + } + stream.write(buffer, swprintf(buffer, 32, format_string, f) ); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + + template class _UCXXEXPORT __ostream_printout{ + public: + static void printout(basic_ostream& stream, const long double f) + { + wchar_t buffer[32]; + wchar_t format_string[32]; + if(stream.flags() & ios_base::scientific){ + if(stream.flags() & ios_base::uppercase){ + swprintf(format_string, 32, L"%%%u.%uLE", static_cast(stream.width()), static_cast(stream.precision())); + }else{ + swprintf(format_string, 32, L"%%%u.%uLe", static_cast(stream.width()), static_cast(stream.precision())); + } + } else if(stream.flags() & ios_base::fixed){ + swprintf(format_string, 32, L"%%%u.%uLf", static_cast(stream.width()), static_cast(stream.precision())); + } else { + swprintf(format_string, 32, L"%%%u.%uLg", static_cast(stream.width()), static_cast(stream.precision())); + } + stream.write(buffer, swprintf(buffer, 32, format_string, f) ); + if(stream.flags() & ios_base::unitbuf){ + stream.flush(); + } + } + }; + +#endif //__UCLIBCXX_HAS_WCHAR__ + +} + +#pragma GCC visibility pop + +#endif + + + Index: branches/slice/i386/modules/uClibc++/include/typeinfo =================================================================== --- branches/slice/i386/modules/uClibc++/include/typeinfo (revision 0) +++ branches/slice/i386/modules/uClibc++/include/typeinfo (revision 727) @@ -0,0 +1,156 @@ +// RTTI support for -*- C++ -*- +// Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 +// Free Software Foundation +// +// This file is part of GNU CC. +// +// GNU CC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// GNU CC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GNU CC; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file typeinfo + * This header provides RTTI support. + */ + +#ifndef __TYPEINFO__ +#define __TYPEINFO__ + +#include + +extern "C++" { + +namespace __cxxabiv1 +{ + class __class_type_info; +} // namespace __cxxabiv1 + +#if !__GXX_WEAK__ + // If weak symbols are not supported, typeinfo names are not merged. + #define __GXX_MERGED_TYPEINFO_NAMES 0 +#else + // On platforms that support weak symbols, typeinfo names are merged. + #define __GXX_MERGED_TYPEINFO_NAMES 1 +#endif + +namespace std +{ + /** + * @brief Part of RTTI. + * + * The @c type_info class describes type information generated by + * an implementation. + */ + class type_info + { + public: + /** Destructor. Being the first non-inline virtual function, this + * controls in which translation unit the vtable is emitted. The + * compiler makes use of that information to know where to emit + * the runtime-mandated type_info structures in the new-abi. */ + virtual ~type_info(); + + private: + /// Assigning type_info is not supported. Made private. + type_info& operator=(const type_info&); + type_info(const type_info&); + + protected: + const char *__name; + + protected: + explicit type_info(const char *__n): __name(__n) { } + + public: + // the public interface + /** Returns an @e implementation-defined byte string; this is not + * portable between compilers! */ + const char* name() const + { return __name; } + +#if !__GXX_MERGED_TYPEINFO_NAMES + bool before(const type_info& __arg) const; + // In old abi, or when weak symbols are not supported, there can + // be multiple instances of a type_info object for one + // type. Uniqueness must use the _name value, not object address. + bool operator==(const type_info& __arg) const; +#else + /** Returns true if @c *this precedes @c __arg in the implementation's + * collation order. */ + // In new abi we can rely on type_info's NTBS being unique, + // and therefore address comparisons are sufficient. + bool before(const type_info& __arg) const + { return __name < __arg.__name; } + bool operator==(const type_info& __arg) const + { return __name == __arg.__name; } +#endif + bool operator!=(const type_info& __arg) const + { return !operator==(__arg); } + + // the internal interface + public: + // return true if this is a pointer type of some kind + virtual bool __is_pointer_p() const; + // return true if this is a function type + virtual bool __is_function_p() const; + + // Try and catch a thrown type. Store an adjusted pointer to the + // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then + // THR_OBJ points to the thrown object. If THR_TYPE is a pointer + // type, then THR_OBJ is the pointer itself. OUTER indicates the + // number of outer pointers, and whether they were const + // qualified. + virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, + unsigned __outer) const; + + // internally used during catch matching + virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, + void **__obj_ptr) const; + }; + + /** + * @brief Thrown during incorrect typecasting. + * + * If you attempt an invalid @c dynamic_cast expression, an instance of + * this class (or something derived from this class) is thrown. */ + class bad_cast : public exception + { + public: + bad_cast() throw() { } + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_cast() throw(); + }; + + /** If you use a NULL pointer in a @c typeid expression, this is thrown. */ + class bad_typeid : public exception + { + public: + bad_typeid () throw() { } + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_typeid() throw(); + }; +} // namespace std + +} // extern "C++" +#endif Index: branches/slice/i386/modules/uClibc++/include/exception =================================================================== --- branches/slice/i386/modules/uClibc++/include/exception (revision 0) +++ branches/slice/i386/modules/uClibc++/include/exception (revision 727) @@ -0,0 +1,120 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002 +// Free Software Foundation +// +// This file is part of GNU CC. +// +// GNU CC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// GNU CC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with GNU CC; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file exception + * This header defines several types and functions relating to the + * handling of exceptions in a C++ program. + */ + +#ifndef __EXCEPTION__ +#define __EXCEPTION__ + +#include + +extern "C++" { + +namespace std +{ + /** + * @brief Base class for all library exceptions. + * + * This is the base class for all exceptions thrown by the standard + * library, and by certain language expressions. You are free to derive + * your own %exception classes, or use a different hierarchy, or to + * throw non-class data (e.g., fundamental types). + */ + class exception + { + public: + exception() throw() { } + virtual ~exception() throw(); + /** Returns a C-style character string describing the general cause + * of the current error. */ + virtual const char* what() const throw(); + }; + + /** If an %exception is thrown which is not listed in a function's + * %exception specification, one of these may be thrown. */ + class bad_exception : public exception + { + public: + bad_exception() throw() { } + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_exception() throw(); + }; + + /// If you write a replacement %terminate handler, it must be of this type. + typedef void (*terminate_handler) (); + /// If you write a replacement %unexpected handler, it must be of this type. + typedef void (*unexpected_handler) (); + + /// Takes a new handler function as an argument, returns the old function. + terminate_handler set_terminate(terminate_handler) throw(); + /** The runtime will call this function if %exception handling must be + * abandoned for any reason. */ + void terminate() __UCLIBCXX_NORETURN; + + /// Takes a new handler function as an argument, returns the old function. + unexpected_handler set_unexpected(unexpected_handler) throw(); + /** The runtime will call this function if an %exception is thrown which + * violates the function's %exception specification. */ + void unexpected() __UCLIBCXX_NORETURN; + + /** [18.6.4]/1: "Returns true after completing evaluation of a + * throw-expression until either completing initialization of the + * exception-declaration in the matching handler or entering @c unexpected() + * due to the throw; or after entering @c terminate() for any reason + * other than an explicit call to @c terminate(). [Note: This includes + * stack unwinding [15.2]. end note]" + * + * 2: "When @c uncaught_exception() is true, throwing an %exception can + * result in a call of @c terminate() (15.5.1)." + */ + bool uncaught_exception() throw(); +} // namespace std + +namespace __gnu_cxx +{ + /** A replacement for the standard terminate_handler which prints more + information about the terminating exception (if any) on stderr. Call + @code + std::set_terminate (__gnu_cxx::__verbose_terminate_handler) + @endcode + to use. For more info, see + http://gcc.gnu.org/onlinedocs/libstdc++/19_diagnostics/howto.html#4 + */ + void __verbose_terminate_handler (); +} // namespace __gnu_cxx + +} // extern "C++" + +#endif Index: branches/slice/i386/modules/uClibc++/include/locale =================================================================== --- branches/slice/i386/modules/uClibc++/include/locale (revision 0) +++ branches/slice/i386/modules/uClibc++/include/locale (revision 727) @@ -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 +*/ + +#include +#include +#include + +#ifndef __HEADER_STD_LOCALE +#define __HEADER_STD_LOCALE 1 + +#pragma GCC visibility push(default) + +namespace std{ + class _UCXXEXPORT locale { + public: + // types: + class facet; + class id; + typedef unsigned char category; + + static const category + none = 0, + collate = 0x01, ctype = 0x02, + monetary = 0x04, numeric = 0x08, + time = 0x10, messages = 0x20, + all = collate | ctype | monetary | numeric | time | messages; + + // construct/copy/destroy: + locale() throw(){ + return; + } + locale(const locale& other) throw(){ + (void)other; + return; + } + locale(const char *) throw(){ + return; + } + ~locale() throw(){ + return; + } + + const locale& operator=(const locale&) throw(){ + return *this; + } + std::string name() const { return "C"; } + }; + + class _UCXXEXPORT locale::facet { + friend class locale; + explicit facet(size_t = 0){ + return; + } + virtual ~facet(){ + return; + } + }; + + class _UCXXEXPORT locale::id { + id(){ } + }; + +} + +#pragma GCC visibility pop + +#endif Index: branches/slice/i386/modules/uClibc++/include/vector =================================================================== --- branches/slice/i386/modules/uClibc++/include/vector (revision 0) +++ branches/slice/i386/modules/uClibc++/include/vector (revision 727) @@ -0,0 +1,517 @@ +/* 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 +#include + + +#ifndef __STD_HEADER_VECTOR +#define __STD_HEADER_VECTOR + +#pragma GCC visibility push(default) + +namespace std{ + + template > class vector; + template bool operator==(const vector& x, const vector& y); + template bool operator< (const vector& x, const vector& y); + template bool operator!=(const vector& x, const vector& y); + template bool operator> (const vector& x, const vector& y); + template bool operator>=(const vector& x, const vector& y); + template bool operator<=(const vector& x, const vector& y); + template void swap(vector& x, vector& y); + + template class _UCXXEXPORT vector { + public: + + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + + typedef T* iterator; + typedef const T* const_iterator; + typedef T value_type; + typedef Allocator allocator_type; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + explicit _UCXXEXPORT vector(const Allocator& al= Allocator()): data(0), //defaultValue(T()), + data_size(__UCLIBCXX_STL_BUFFER_SIZE__), elements(0), a(al) + { + data = a.allocate(data_size); + } + + explicit _UCXXEXPORT vector(size_type n, const T& value = T(), const Allocator& al= Allocator()) : + data(0), data_size(0), elements(0), a(al) + { + data_size = n + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + + resize(n, value); + } + + template _UCXXEXPORT + vector(InputIterator first, InputIterator last, const Allocator& al = Allocator()): + data(0), data_size(__UCLIBCXX_STL_BUFFER_SIZE__), elements(0), a(al) + { + data = a.allocate(data_size); + assign(first, last); + } + + _UCXXEXPORT vector(const vector& x){ + a = x.a; + + elements = x.elements; + data_size = elements + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + + for(size_type i = 0; i < elements; i++){ + a.construct(data+i, x.data[i]); + } + } + + _UCXXEXPORT ~vector(); //Below + + _UCXXEXPORT vector& operator=(const vector& x){ + if(&x == this){ + return *this; + } + + reserve(x.elements); //Make sure that we have enough actual memory + + + //Copy as many elements as possible + + size_t minElements = elements; + if(minElements > x.elements){ + minElements = x.elements; + } + for(size_t i = 0; i < minElements; ++i){ + data[i] = x.data[i]; + } + + //If we need to add new elements + if(elements < x.elements){ + for(size_t i = elements; i< x.elements; ++i){ + a.construct(data+i, x.data[i]); + ++elements; + } + } + + if(elements > x.elements){ + downsize(x.elements); + } + + return *this; + } + + template _UCXXEXPORT void assign(InputIterator first, InputIterator last){ + clear(); + insert(begin(), first, last); + } + + template _UCXXEXPORT void assign(Size n, const U& u = U()){ + clear(); + resize(n, u); + } + + inline allocator_type get_allocator() const{ + return a; + } + + inline iterator begin(){ + return data; + } + + inline const_iterator begin() const{ + return data; + } + + inline iterator end(){ + return (data + elements); + } + + inline const_iterator end() const{ + return (data + elements); + } + + inline reverse_iterator rbegin(){ + return reverse_iterator(end()); + } + + inline const_reverse_iterator rbegin() const{ + return const_reverse_iterator(end()); + } + + inline reverse_iterator rend(){ + return reverse_iterator(begin()); + } + + inline const_reverse_iterator rend() const{ + return const_reverse_iterator(begin()); + } + + inline size_type size() const{ + return elements; + } + + _UCXXEXPORT size_type max_size() const{ + return ((size_type)(-1)) / sizeof(T); + } + + void downsize(size_type sz); + void resize(size_type sz, const T & c = T()); + + inline size_type capacity() const{ + return data_size; + } + + inline bool empty() const{ + return (size() == 0); + } + + void reserve(size_type n); + + inline reference operator[](size_type n){ + return data[n]; + } + + inline const_reference operator[](size_type n) const{ + return data[n]; + } + + _UCXXEXPORT const_reference at(size_type n) const{ + if(n >= elements){ + __throw_out_of_range("Invalid subscript"); + } + return data[n]; + } + + _UCXXEXPORT reference at(size_type n){ + if(n >= elements){ + __throw_out_of_range("Invalid subscript"); + } + return data[n]; + } + + inline reference front(){ + return data[0]; + } + + inline const_reference front() const{ + return data[0]; + } + + inline reference back(){ + return data[ size() - 1]; + } + + inline const_reference back() const{ + return data[ size() - 1 ]; + } + + inline void push_back(const T& x){ + resize( size() + 1, x); + } + + inline void pop_back(){ + downsize(size() - 1); + } + + _UCXXEXPORT iterator insert(iterator position, const T& x = T()){ + size_type index = position - data; + resize(size() + 1, x); + for(size_type i = elements - 1; i > index; --i){ + data[i] = data[i-1]; + } + data[index] = x; + return (data + index); + } + + _UCXXEXPORT void _insert_fill(iterator position, size_type n, const T & x){ + size_type index = position - data; + resize(size() + n, x); + + for(size_type i = elements -1; (i > (index+n-1)); --i){ + data[i] = data[i-n]; + } + for(size_type i = 0; i < n; i++){ + data[i + index] = x; + } + } + + template _UCXXEXPORT + void _insert_from_iterator(iterator position, InputIterator first, InputIterator last) + { + T temp; + while(first !=last){ + temp = *first; + position = insert(position, temp); + ++position; + ++first; + } + } + + template + inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __true_type) + { + _insert_fill(position, first, last); + } + + template + inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __false_type) + { + _insert_from_iterator(position, first, last); + } + + inline void insert(iterator position, size_type n, const T& x ){ + _insert_fill(position, n, x); + } + + template inline void insert(iterator position, InputIterator first, InputIterator last){ + typedef typename __is_integer::value __some_type; + _dispatch_insert(position, first, last, __some_type()); + } + + _UCXXEXPORT iterator erase(iterator position){ + size_type index = position - data; + for(size_type i = index; i < (elements - 1); ++i){ + data[i] = data[i+1]; + } + downsize(size() - 1); + return (data + index); + } + + _UCXXEXPORT iterator erase(iterator first, iterator last){ + size_type index = first - data; + size_type width = last - first; + for(size_type i = index; i < (elements - width) ;++i){ + data[i] = data[i+width]; + } + downsize(size() - width); + return (data + index); + } + + _UCXXEXPORT void swap(vector& v){ + if(this == &v){ //Avoid dv.swap(v) + return; + } + T* ptr; + size_type temp; + + //Swap pointers first + ptr = data; + data = v.data; + v.data = ptr; + + //Swap element counts + temp = elements; + elements = v.elements; + v.elements = temp; + + //Swap data size + temp = data_size; + data_size = v.data_size; + v.data_size = temp; + } + + _UCXXEXPORT void clear(){ + downsize(0); + } + + protected: + T* data; + size_type data_size; + size_type elements; + Allocator a; + }; + + + + //Here go template instantiations + + template _UCXXEXPORT vector::~vector(){ + for(size_t i = 0; i < elements; ++i){ + a.destroy(data + i); + } + a.deallocate(data, data_size); + } + + + template _UCXXEXPORT void vector::reserve(size_type n){ + if(n > data_size){ //We never shrink... + T * temp_ptr = data; + size_type temp_size = data_size; + + data_size = n; + data = a.allocate(data_size); + + for(size_type i = 0; i _UCXXEXPORT void vector::resize(size_type sz, const T & c){ + if(sz > elements){ //Need to actually call constructor + if(sz > data_size){ + reserve(sz + __UCLIBCXX_STL_BUFFER_SIZE__); + } + + for(size_type i = elements; i _UCXXEXPORT void vector::downsize(size_type sz){ + if(sz < elements){ //Actually are downsizing + for(size_t i = sz; i< elements; ++i){ + a.destroy(data+i); + } + elements = sz; + } + } + + +#ifndef __UCLIBCXX_COMPILE_VECTOR__ +#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 + + template<> _UCXXEXPORT void vector >::reserve(size_type n); + template<> _UCXXEXPORT void vector >::resize(size_type sz, const char & c); + +#endif +#endif + + + + template _UCXXEXPORT bool + operator==(const vector& x, const vector& y) + { + if(x.size() !=y.size() ){ + return false; + } + for(size_t i = 0; i < x.size(); ++i){ + if(x[i] != y[i]){ + return false; + } + } + return true; + } + + template _UCXXEXPORT bool + operator< (const vector& x, const vector& y) + { + less::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + template _UCXXEXPORT bool + operator!=(const vector& x, const vector& y) + { + return !(x == y); + } + template _UCXXEXPORT bool + operator> (const vector& x, const vector& y) + { + greater::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + template _UCXXEXPORT bool + operator>=(const vector& x, const vector& y) + { + greater_equal::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + template _UCXXEXPORT bool + operator<=(const vector& x, const vector& y) + { + less_equal::iterator >::value_type> c; + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), c); + } + + template _UCXXEXPORT void swap(vector& x, vector& y){ + x.swap(y); + } + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/deque =================================================================== --- branches/slice/i386/modules/uClibc++/include/deque (revision 0) +++ branches/slice/i386/modules/uClibc++/include/deque (revision 727) @@ -0,0 +1,811 @@ +/* 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 + +#pragma GCC visibility push(default) + +#ifndef __STD_HEADER_DEQUE +#define __STD_HEADER_DEQUE + + +namespace std{ + template > class deque; + template bool operator==(const deque& x, const deque& y); + template bool operator< (const deque& x, const deque& y); + template bool operator!=(const deque& x, const deque& y); + template bool operator> (const deque& x, const deque& y); + template bool operator>=(const deque& x, const deque& y); + template bool operator<=(const deque& x, const deque& y); + template void swap(deque& x, deque& y); + + template class _UCXXEXPORT deque { + public: + friend bool operator==<>(const deque& x, const deque& y); + friend class deque_iter; + friend class deque_citer; + class deque_iter; + class deque_citer; + + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef deque_iter iterator; + typedef deque_citer const_iterator; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef T value_type; + typedef Allocator allocator_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + explicit deque(const Allocator& al = Allocator()); + explicit deque(size_type n, const T& value = T(), const Allocator& al = Allocator()); + template deque(InputIterator first, InputIterator last, const Allocator& = Allocator()); + deque(const deque& x); + ~deque(); + + deque& operator=(const deque& x); + template void assign(InputIterator first, InputIterator last); + template void assign(Size n, const U& u = U()); + allocator_type get_allocator() const; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + + size_type size() const; + size_type max_size() const; + void resize(size_type sz, T c = T()); + bool empty() const; + + reference operator[](size_type n); + const_reference operator[](size_type n) const; + reference at(size_type n); + const_reference at(size_type n) const; + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + void push_front(const T& x); + void push_back(const T& x); + iterator insert(iterator position, const T& x = T()); + void insert(iterator position, size_type n, const T& x); + template void insert (iterator position, InputIterator first, InputIterator last); + void pop_front(); + void pop_back(); + + iterator erase(iterator position); + iterator erase(iterator first, iterator last); + void swap(deque&); + void clear(); + + protected: + void reserve(size_type n); + inline size_type array_element(size_type deque_element) const{ + if(deque_element < (data_size - first_element)){ + return first_element + deque_element; + } + return deque_element - (data_size - first_element); + } + inline size_type first_subtract(size_type sub_size) const{ + if(sub_size > first_element){ + return (data_size - first_element) - sub_size; + } + return first_element - sub_size; + } + + T * data; + size_type data_size; //Physical size of array + size_type elements; //Elements in array + size_type first_element; //Element number of array 0..n + size_type last_element; //Element number of array 0..n + Allocator a; + + }; + + + template class _UCXXEXPORT deque::deque_iter + : public std::iterator< + random_access_iterator_tag, + T, + typename Allocator::difference_type, + typename Allocator::pointer, + typename Allocator::reference + > + { + friend class deque; + protected: + deque * container; + typename Allocator::size_type element; + + public: + deque_iter() : container(0), element(0) { } + deque_iter(const deque_iter & d) : container (d.container), element(d.element) { } + deque_iter(deque * c, typename Allocator::size_type e) + : container(c), element(e) + { + return; + } + ~deque_iter() { } + deque_iter & operator=(const deque_iter & d){ + container = d.container; + element = d.element; + return *this; + } + T & operator*(){ + return container->data[container->array_element(element)]; + } + T * operator->(){ + return container->data + container->array_element(element); + } + const T & operator*() const{ + return container->data[container->array_element(element)]; + } + const T * operator->() const{ + return container->data + container->array_element(element); + } + bool operator==(const deque_iter & d) const{ + if(container == d.container && element == d.element){ + return true; + } + return false; + } + bool operator!=(const deque_iter & d) const{ + if(container != d.container || element != d.element){ + return true; + } + return false; + } + bool operator<(const deque_iter & d) const{ + if(element < d.element){ + return true; + } + return false; + } + bool operator<=(const deque_iter & d) const{ + if(element <= d.element){ + return true; + } + return false; + } + bool operator>(const deque_iter & d) const{ + if(element > d.element){ + return true; + } + return false; + } + bool operator>=(const deque_iter & d) const{ + if(element >= d.element){ + return true; + } + return false; + } + deque_iter & operator++(){ + ++element; + return *this; + } + deque_iter operator++(int){ + deque_iter temp(container, element); + ++element; + return temp; + } + deque_iter operator+(typename Allocator::size_type n){ + deque_iter temp(container, element + n); + return temp; + } + deque_iter & operator+=(typename Allocator::size_type n){ + element += n; + return *this; + } + deque_iter & operator--(){ + --element; + return *this; + } + deque_iter operator--(int){ + deque_iter temp(container, element); + --element; + return temp; + } + deque_iter operator-(typename Allocator::size_type n){ + deque_iter temp(container, element - n); + return temp; + } + deque_iter & operator-=(typename Allocator::size_type n){ + element -= n; + return *this; + } + typename Allocator::size_type operator-(const deque_iter & d){ + return element - d.element; + } + + }; + + template class _UCXXEXPORT deque::deque_citer + : public std::iterator< + random_access_iterator_tag, + T, + typename Allocator::difference_type, + typename Allocator::const_pointer, + typename Allocator::const_reference + > + { + friend class deque; + protected: + const deque * container; + typename Allocator::size_type element; + + public: + deque_citer() : container(0), element(0) { } + deque_citer(const deque_citer & d) : container (d.container), element(d.element) { } + deque_citer(const deque * c, typename Allocator::size_type e) + : container(c), element(e) + { + return; + } + ~deque_citer() { } + deque_citer & operator=(const deque_iter & d){ + container = d.container; + element = d.element; + return *this; + } + const T & operator*() const{ + return container->data[container->array_element(element)]; + } + const T * operator->() const{ + return container->data + container->array_element(element); + } + bool operator==(const deque_citer & d) const{ + if(container == d.container && element == d.element){ + return true; + } + return false; + } + bool operator!=(const deque_citer & d) const{ + if(container != d.container || element != d.element){ + return true; + } + return false; + } + bool operator<(const deque_citer & d) const{ + if(element < d.element){ + return true; + } + return false; + } + bool operator<=(const deque_citer & d) const{ + if(element <= d.element){ + return true; + } + return false; + } + bool operator>(const deque_citer & d) const{ + if(element > d.element){ + return true; + } + return false; + } + bool operator>=(const deque_citer & d){ + if(element >= d.element){ + return true; + } + return false; + } + deque_citer & operator++(){ + ++element; + return *this; + } + deque_citer operator++(int){ + deque_citer temp(container, element); + ++element; + return temp; + } + deque_citer operator+(typename Allocator::size_type n){ + deque_citer temp(container, element + n); + return temp; + } + deque_citer & operator+=(typename Allocator::size_type n){ + element += n; + return *this; + } + deque_citer & operator--(){ + --element; + return *this; + } + deque_citer operator--(int){ + deque_citer temp(container, element); + --element; + return temp; + } + deque_citer operator-(typename Allocator::size_type n){ + deque_citer temp(container, element - n); + return temp; + } + deque_citer & operator-=(typename Allocator::size_type n){ + element -= n; + return *this; + } + typename Allocator::size_type operator-(const deque_citer & d){ + return element - d.element; + } + + }; + + template deque::deque(const Allocator& al) + : data(0), + data_size(0), elements(0), first_element(0), last_element(0), a(al) + { + data_size = __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = data_size /2; + last_element = first_element; + } + + + template deque::deque( + size_type n, const T& value, const Allocator& al) + : data(0), + elements(n), first_element(0), last_element(0), a(al) + { + data_size = elements + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = (data_size - elements) / 2; + last_element = first_element; + + for(n=first_element ; n < last_element; ++n ){ + a.construct(data+n, value); + } + } + + + template template + deque::deque(InputIterator first, InputIterator last, const Allocator& al) + : data(0), + data_size(0), elements(0), first_element(0), last_element(0), a(al) + { + data_size = __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = data_size / 4; //Note sure how big, but let's add a little space... + last_element = first_element; + while(first != last){ + push_back(*first); + ++first; + } + } + + + template deque::deque(const deque& x) + : data(0), + elements(0), first_element(0), last_element(0), a(x.a) + { + data_size = x.elements + __UCLIBCXX_STL_BUFFER_SIZE__; + data = a.allocate(data_size); + first_element = (data_size - x.elements) / 2; + last_element = first_element; + for(size_type i=0; i < x.elements; ++i){ + push_back(x[i]); + } + } + + + template deque::~deque(){ + clear(); + a.deallocate(data, data_size); + } + + template deque& deque:: + operator=(const deque& x) + { + if(&x == this){ + return *this; + } + resize(x.elements); + for(size_t i = 0; i < elements; ++i){ + data[array_element(i)] = x[i]; + } + return *this; + } + + + template template void + deque::assign(InputIterator first, InputIterator last) + { + clear(); + while(first !=last){ + push_back(*first); + ++first; + } + } + + + template template void + deque::assign(Size n, const U& u) + { + if(&u == this){ + return; + } + clear(); + for(size_type i = 0; i < n; ++i){ + push_back(u); + } + } + + + template typename deque::allocator_type + deque::get_allocator() const + { + return a; + } + + template typename + deque::iterator deque::begin() + { + return deque_iter(this, 0); + } + + + template typename deque::const_iterator + deque::begin() const + { + return deque_citer(this, 0); + } + + template typename + deque::iterator deque::end() + { + return deque_iter(this, elements); + } + + template typename + deque::const_iterator deque::end() const + { + return deque_citer(this, elements); + } + + template typename + deque::reverse_iterator deque::rbegin() + { + return reverse_iterator(end()); + } + + template typename + deque::const_reverse_iterator deque::rbegin() const + { + return const_reverse_iterator(end()); + } + + template typename + deque::reverse_iterator deque::rend() + { + return reverse_iterator(begin()); + } + + template typename + deque::const_reverse_iterator deque::rend() const + { + return const_reverse_iterator(begin()); + } + + template typename + deque::size_type deque::size() const + { + return elements; + } + + template typename + deque::size_type deque::max_size() const + { + return ((size_type)(-1)) / sizeof(T); + } + + template void deque::resize(size_type sz, T c){ + reserve(sz); + while(sz > size()){ + push_back(c); + } + while(sz < size()){ + pop_back(); + } + } + + template bool deque::empty() const{ + return (elements == 0); + } + + template typename + deque::reference deque::operator[](size_type n) + { + return data[array_element(n)]; + } + + template typename + deque::const_reference deque::operator[](size_type n) const + { + return data[array_element(n)]; + } + + template typename + deque::reference deque::at(size_type n) + { + if(n > elements){ + __throw_out_of_range("Out of deque range"); + } + return data[array_element(n)]; + } + + template typename + deque::const_reference deque::at(size_type n) const + { + if(n > elements){ + __throw_out_of_range("Out of deque range"); + } + return data[array_element(n)]; + } + + template typename + deque::reference deque::front() + { + return data[first_element]; + } + + template typename + deque::const_reference deque::front() const + { + return data[first_element]; + } + + template typename + deque::reference deque::back() + { + return data[array_element(elements-1)]; + } + + template typename + deque::const_reference deque::back() const + { + return data[array_element(elements-1)]; + } + + template void deque::push_front(const T& x){ + reserve(elements + 1); + first_element = first_subtract(1); + a.construct(data + first_element, x); + ++elements; + } + + template void deque::push_back(const T& x){ + reserve(elements + 1); + a.construct(data + last_element, x); + ++elements; + last_element = array_element(elements); + } + + template typename + deque::iterator deque::insert(iterator position, const T& x) + { + reserve(elements+1); + if(position.element > (elements/2)){ + //Push all elements back 1 + push_back(x); + for(size_type i = elements-1; i > position.element; --i){ + at(i) = at(i-1); + } + }else{ + //Push all elements forward 1 + push_front(x); + for(size_type i = 0; i < position.element; ++i){ + at(i) = at(i+1); + } + } + at(position.element) = x; + return deque_iter(this, position.element); + } + + template void deque:: + insert(typename deque::iterator position, size_type n, const T& x) + { + reserve(elements + n); + for(size_t i =0; i < n; ++i){ + position = insert(position, x); + } + } + + template template + void deque::insert (iterator position, InputIterator first, InputIterator last) + { + while(first != last){ + position = insert(position, *first); + ++first; + } + } + + template void deque::pop_front(){ + if(elements == 0){ + __throw_out_of_range("deque pop_front"); + } + a.destroy(data + first_element); + first_element = array_element(1); + --elements; + } + + template void deque::pop_back(){ + last_element = array_element(elements - 1); + a.destroy(data + last_element); + --elements; + } + + template typename + deque::iterator deque::erase(typename deque::iterator position) + { + if(position.element > (elements /2)){ + for(size_type i = position.element; i < elements - 1; ++i){ + at(i) = at(i+1); + } + pop_back(); + }else{ + for(size_type i = position.element; i > 0; --i){ + at(i) = at(i-1); + } + pop_front(); + } + return deque_iter(this, position.element); + } + + template typename deque::iterator + deque:: + erase(typename deque::iterator first, typename deque::iterator last) + { + //Shift backwards + size_type num_move = last.element - first.element; + if( first.element > (elements - last.element) ){ + for(size_type i = last.element; i < elements ; ++i){ + at(i-num_move) = at(i); + } + for(size_type i = 0; i < num_move ; ++i){ + pop_back(); + } + }else{ + for(size_type i = 0; i < first.element ; ++i){ + at(last.element - i - 1) = at(first.element - i - 1); + } + for(size_type i = 0; i < num_move ; ++i){ + pop_front(); + } + } + return deque_iter(this, first.element); + } + + template void deque::swap(deque& x) + { + T * temp_data; + typename deque::size_type temp_size; + + //Swap data pointers + temp_data = x.data; + x.data = data; + data = temp_data; + + //Swap array sizes + temp_size = x.data_size; + x.data_size = data_size; + data_size = temp_size; + + //Swap num array elements + temp_size = x.elements; + x.elements = elements; + elements = temp_size; + + //Swap first_pointer + temp_size = x.first_element; + x.first_element = first_element; + first_element = temp_size; + + //Swap last_pointer + temp_size = x.last_element; + x.last_element = last_element; + last_element = temp_size; + } + + template void deque::clear() + { + while(elements > 0 ){ + pop_back(); + } + } + + + template void deque::reserve(typename deque::size_type n) + { + if(data_size >= n){ + return; + } + + size_type size_temp; + size_type first_temp; + T * data_temp; + size_temp = n + __UCLIBCXX_STL_BUFFER_SIZE__; //Reserve extra 'cause we can + data_temp = a.allocate(size_temp); + + first_temp = (size_temp - elements) / 2; + for(size_type i = 0; i < elements; ++i){ + a.construct(data_temp + first_temp + i, data[array_element(i)]); + a.destroy(data + array_element(i)); + } + + //Now shuffle pointers + a.deallocate(data, data_size); + data = data_temp; + data_size = size_temp; + first_element = first_temp; + last_element = first_element + elements; + } + + + template _UCXXEXPORT + bool + operator==(const deque& x, const deque& y) + { + if(x.elements != y.elements){ + return false; + } + for(typename deque::size_type i = 0; i < x.elements; ++i){ + if(x[i] < y[i] || y[i] < x[i]){ + return false; + } + } + return true; + } + + template bool operator< (const deque& x, const deque& y); + template _UCXXEXPORT + bool + operator!=(const deque& x, const deque& y) + { + if(x == y){ + return false; + } + return true; + } + template bool operator> (const deque& x, const deque& y); + template bool operator>=(const deque& x, const deque& y); + template bool operator<=(const deque& x, const deque& y); + template _UCXXEXPORT void swap(deque& x, deque& y){ + x.swap(y); + } + + + +} + +#pragma GCC visibility pop + +#endif + + + + Index: branches/slice/i386/modules/uClibc++/include/stdexcept =================================================================== --- branches/slice/i386/modules/uClibc++/include/stdexcept (revision 0) +++ branches/slice/i386/modules/uClibc++/include/stdexcept (revision 727) @@ -0,0 +1,117 @@ +/* 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 + +#ifndef HEADER_STD_EXCEPTIONS +#define HEADER_STD_EXCEPTIONS 1 + +//Don't include support if not needed +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + +#pragma GCC visibility push(default) + +namespace std{ + +//typedef basic_string string; + +class _UCXXEXPORT logic_error : public exception { +protected: + string mstring; +public: + logic_error() throw(); + logic_error(const string& what_arg); + + virtual ~logic_error() throw() {} + virtual const char * what() const throw(); + +}; + +class _UCXXEXPORT domain_error : public logic_error { +public: + domain_error() : logic_error() {} + domain_error(const string& what_arg) : logic_error(what_arg) {} + virtual ~domain_error() throw() {} +}; + +class _UCXXEXPORT invalid_argument : public logic_error { +public: + invalid_argument() : logic_error(){} + invalid_argument(const string& what_arg) : logic_error(what_arg){} + virtual ~invalid_argument() throw() {} +}; + +class _UCXXEXPORT length_error : public logic_error { +public: + length_error() : logic_error(){} + length_error(const string& what_arg) : logic_error(what_arg){} + virtual ~length_error() throw() {} +}; + +class _UCXXEXPORT out_of_range : public logic_error{ +public: + out_of_range(); + out_of_range(const string & what_arg); + virtual ~out_of_range() throw() {} + +}; + +class _UCXXEXPORT runtime_error : public exception{ +protected: + string mstring; +public: + runtime_error(); + runtime_error(const string& what_arg); + + virtual ~runtime_error() throw() {} + virtual const char * what() const throw(); +}; + +class _UCXXEXPORT range_error : public runtime_error{ +public: + range_error() : runtime_error(){} + range_error(const string& what_arg) : runtime_error(what_arg) {} + virtual ~range_error() throw(){ } +}; + + +class _UCXXEXPORT overflow_error : public runtime_error{ +public: + overflow_error() : runtime_error(){} + overflow_error(const string& what_arg) : runtime_error(what_arg) {} + virtual ~overflow_error() throw(){} +}; + +class _UCXXEXPORT underflow_error : public runtime_error{ +public: + underflow_error() : runtime_error(){} + underflow_error(const string& what_arg) : runtime_error(what_arg) {} + virtual ~underflow_error() throw(){} +}; + + + +} + +#pragma GCC visibility pop + +#endif +#endif Index: branches/slice/i386/modules/uClibc++/include/climits =================================================================== --- branches/slice/i386/modules/uClibc++/include/climits (revision 0) +++ branches/slice/i386/modules/uClibc++/include/climits (revision 727) @@ -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 +*/ + +#ifndef __STD_HEADER_CLIMITS +#define __STD_HEADER_CLIMITS 1 + + +#include + + +#endif + Index: branches/slice/i386/modules/uClibc++/include/cstring =================================================================== --- branches/slice/i386/modules/uClibc++/include/cstring (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cstring (revision 727) @@ -0,0 +1,78 @@ +/* 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 +#include + +#ifndef __HEADER_CSTRING +#define __HEADER_CSTRING 1 + + +namespace std{ + + using ::memchr; + using ::memcmp; + using ::memcpy; + using ::memmove; + using ::memset; + using ::strcat; + using ::strchr; + using ::strcmp; + using ::strcoll; + using ::strcpy; + using ::strcspn; + using ::strerror; + using ::strlen; + using ::strncat; + using ::strncmp; + using ::strncpy; + using ::strpbrk; + using ::strrchr; + using ::strspn; + using ::strstr; + using ::strtok; + using ::strxfrm; + + + //Extra definitions required in c++ spec + + + inline void* memchr(void* s, int c, size_t n){ + return memchr(const_cast(s), c, n); + } + + inline char* strchr(char* s, int c){ + return strchr(const_cast(s), c); + } + + inline char* strpbrk(char* s1, const char* s2){ + return strpbrk(const_cast(s1), s2); + } + + inline char* strrchr(char* s, int c){ + return strrchr(const_cast(s), c); + } + + inline char* strstr(char* s1, const char* s2){ + return strstr(const_cast(s1), s2); + } + +} + +#endif + Index: branches/slice/i386/modules/uClibc++/include/list =================================================================== --- branches/slice/i386/modules/uClibc++/include/list (revision 0) +++ branches/slice/i386/modules/uClibc++/include/list (revision 727) @@ -0,0 +1,927 @@ +/* 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 + +#ifndef __STD_HEADER_LIST +#define __STD_HEADER_LIST 1 + +#pragma GCC visibility push(default) + +namespace std{ + + template > class _UCXXEXPORT list { + public: + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef T value_type; + typedef Allocator allocator_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + + protected: + class node; + class iter_list; + + node * list_start; + node * list_end; + size_type elements; + Allocator a; + + public: + + typedef iter_list iterator; + typedef iter_list const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + explicit list(const Allocator& = Allocator()); + explicit list(size_type n, const T& value = T(), const Allocator& = Allocator()); + template list(InputIterator first, InputIterator last, + const Allocator& al= Allocator()); + list(const list& x); + ~list(); + + list& operator=(const list& x){ + if(&x == this){ + return *this; + } + clear(); + iterator i = x.begin(); + while(i != x.end()){ + push_back(*i); + ++i; + } + return *this; + } + + template void assign(InputIterator first, InputIterator last); + template void assign(Size n, const U& u = U()); + allocator_type get_allocator() const; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + + bool empty() const; + size_type size() const; + size_type max_size() const; + void resize(size_type sz, T c = T()); + + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + void push_front(const T& x); + void pop_front(); + void push_back(const T& x); + void pop_back(); + iterator insert(iterator position, const T& x = T()); + void insert(iterator position, size_type n, const T& x); + template void insert(iterator position, InputIterator first, InputIterator last); + iterator erase(iterator position); + iterator erase(iterator position, iterator last); + void swap(list&); + void clear(); + + void splice(iterator position, list& x); + void splice(iterator position, list& x, iterator i); + void splice(iterator position, list& x, iterator first, iterator last); + void remove(const T& value); + template void remove_if(Predicate pred); + void unique(); + template void unique(BinaryPredicate binary_pred); + void merge(list& x); + template void merge(list& x, Compare comp); + void sort(); + template void sort(Compare comp); + void reverse(); + protected: + void swap_nodes(node * x, node * y); + }; + + + //Implementations of List + + //List node + template class _UCXXEXPORT list::node{ + public: + node * previous; + node * next; + T * val; + + node(): previous(0), next(0), val(0){ } + node(const T & t ): previous(0), next(0), val(0) { + val = new T(t); + //FIXME use allocator somehow but only call constructor once + } + node(const T & t, node * p, node * n): previous(p), next(n), val(0) { + val = new T(t); + } + ~node(){ } + }; + + //List iterator + template class _UCXXEXPORT list::iter_list + : public std::iterator< + bidirectional_iterator_tag, + T, + typename Allocator::difference_type, + typename Allocator::pointer, + typename Allocator::reference + > + { + private: + node * current; + public: + iter_list():current(0) { } + iter_list( typename list::node * n): current(n) { } + iter_list(const list::iter_list & l): current(l.current) { } + ~iter_list(){ } + + iter_list & operator=(const list::iter_list & right ){ + current = right.current; + return *this; + } + + T & operator*(){ + return *(current->val); + } + T * operator->(){ + return current->val; + } + const T & operator*() const{ + return *current->val; + } + const T * operator->() const{ + return current->val; + } + + bool operator==(const list::iter_list & right) const { + return (current == right.current); + } + + bool operator!=(const list::iter_list & right) const { + return (current != right.current); + } + + iter_list & operator++(){ + current = current->next; + return *this; + } + + iter_list operator++(int){ + iter_list temp(current); + current = current->next; + return temp; + } + iter_list & operator--(){ + current = current->previous; + return *this; + } + + iter_list operator--(int){ + iter_list temp(current); + current = current->previous; + return temp; + } + node * link_struct(){ + return current; + } + iter_list & operator+=(unsigned int n){ + for(unsigned int i = 0; i < n; ++i){ + current = current->next; + } + return *this; + } + iter_list & operator-=(unsigned int n){ + for(unsigned int i = 0; i < n; ++i){ + current = current->previous; + } + return *this; + } + }; + + + template list::list(const Allocator& al) + :list_start(0), list_end(0), elements(0), a(al) + { + //End node + list_start = new node(); + list_end = list_start; + return; + } + + template list::list + (typename Allocator::size_type n, const T& value, const Allocator& al) + :list_start(0), list_end(0), elements(0), a(al) + { + //End node + list_start = new node(); + list_end = list_start; + + for(typename Allocator::size_type i = 0; i < n ; ++i){ + push_back(value); + } + } + + template template + list::list + (InputIterator first, InputIterator last, const Allocator& al) + : list_start(0), list_end(0), elements(0), a(al) + { + list_start = new node(); + list_end = list_start; + while(first != last){ + push_back(*first); + ++first; + } + } + + template list::list(const list& x) + : list_start(0), list_end(0), elements(0), a(x.a) + { + list_start = new node(); + list_end = list_start; + + iterator i = x.begin(); + while(i != x.end()){ + push_back( *i); + ++i; + } + } + + template list::~list(){ + while(elements > 0){ + pop_front(); + } + delete list_start->val; +#if UCLIBCXX_DEBUG + list_start->val = 0; +#endif + delete list_start; +#if UCLIBCXX_DEBUG + list_start = 0; + list_end = 0; +#endif + } + + + template void list::swap_nodes(node * x, node * y){ + T * v = x->val; + x->val = y->val; + y->val = v; + } + + template typename list::iterator + list::begin() + { + return iterator(list_start); + } + + + template typename list::const_iterator + list::begin() const + { + return const_iterator(list_start); + } + + + template typename list::iterator + list::end() + { + return iterator(list_end); + } + + template typename list::const_iterator + list::end() const + { + return const_iterator(list_end); + } + + template typename list::reverse_iterator + list::rbegin() + { + return reverse_iterator(end()); + } + + template typename list::const_reverse_iterator + list::rbegin() const + { + return const_reverse_iterator(end()); + } + + template typename list::reverse_iterator + list::rend() + { + return reverse_iterator(begin()); + } + + template typename list::const_reverse_iterator + list::rend() const + { + return const_reverse_iterator(begin()); + } + + template bool list::empty() const{ + return (elements == 0); + } + template typename list::size_type list::size() const{ + return elements; + } + template typename list::size_type list::max_size() const{ + return ((size_type)(-1)) / (sizeof(T) + sizeof(node)); + } + template void list::resize(typename Allocator::size_type sz, T c){ +// if(sz > elements){ + for(typename Allocator::size_type i = elements; i < sz; ++i){ + push_back(c); + } +// } +// if(sz < elements){ + for(typename Allocator::size_type i = elements; i > sz; --i){ + pop_back(); + } +// } + } + + template typename list::reference list::front(){ + return *(list_start->val); + } + template typename list::const_reference list::front() const{ + return *(list_start->val); + } + template typename list::reference list::back(){ + return *(list_end->previous->val); + } + template typename list::const_reference list::back() const{ + return *(list_end->previous->val); + } + + + template void list::push_front(const T& x){ + node * temp = new node(x); + list_start->previous = temp; + temp->previous = 0; + temp->next = list_start; + list_start = temp; + ++elements; + } + + template void list::pop_front(){ + if(elements > 0){ + list_start = list_start->next; + delete list_start->previous->val; +#if UCLIBCXX_DEBUG + list_start->previous->val = 0; + list_start->previous->next = 0; + list_start->previous->previous = 0; +#endif + delete list_start->previous; + list_start->previous = 0; + --elements; + } + } + + template void list::push_back(const T& x){ + if(elements == 0){ + //The list is completely empty + list_start = new node(x); + list_end->previous = list_start; + list_start->previous = 0; + list_start->next = list_end; + elements = 1; + }else{ + node * temp = new node(x); + temp->previous = list_end->previous; + temp->next = list_end; + list_end->previous->next = temp; + list_end->previous = temp; + ++elements; + } + } + + template void list::pop_back(){ + if(elements > 0){ + node * temp = list_end->previous; + if(temp == list_start){ + list_end->previous = 0; + list_start = list_end; + }else{ + temp->previous->next = temp->next; + list_end->previous = temp->previous; + } + delete temp->val; +#if UCLIBCXX_DEBUG + temp->val = 0; + temp->next = 0; + temp->previous = 0; +#endif + delete temp; +#if UCLIBCXX_DEBUG + temp = 0; +#endif + --elements; + } + } + + + template typename list::iterator + list::insert(iterator position, const T& x) + { + node * temp = new node(x); + + temp->previous = position.link_struct()->previous; + temp->next = position.link_struct(); + + if(temp->previous == 0){ + list_start = temp; + }else{ + position.link_struct()->previous->next = temp; + } + + position.link_struct()->previous = temp; + + ++elements; + --position; + return position; + } + + template void list::insert(iterator position, size_type n, const T& x){ + for(typename list::size_type i = 0; i < n; ++i){ + position = insert(position, x); + } + } + + template template void + list::insert(iterator position, InputIterator first, InputIterator last) + { + while(first !=last){ + insert(position, *first); + ++first; + } + } + template typename list::iterator + list::erase(iterator position) + { + if(position != end() ){ + node * temp = position.link_struct(); + if(temp == list_start){ + ++position; + temp->next->previous = 0; + list_start = temp->next; + }else{ + --position; + temp->next->previous = temp->previous; + temp->previous->next = temp->next; + ++position; + } + delete temp->val; +#if UCLIBCXX_DEBUG + temp->next = 0; + temp->previous = 0; + temp->val = 0; +#endif + delete temp; +#if UCLIBCXX_DEBUG + temp = 0; +#endif + --elements; + } + return position; + } + template typename list::iterator + list::erase(iterator position, iterator last) + { + iterator temp = position; + while(position !=last){ + position = erase(position); + } + return position; + } + template void list::swap(list& l){ + node * temp; + size_type tempel; + + temp = list_start; + list_start = l.list_start; + l.list_start = temp; + + temp = list_end; + list_end = l.list_end; + l.list_end = temp; + + tempel = elements; + elements = l.elements; + l.elements = tempel; + } + template void list::clear(){ + while(elements > 0){ + pop_front(); + } + } + + template + void list::splice(iterator position, list& x) + { + + //Can't add non-existant elements + if(x.elements == 0){ + return; + } + + elements += x.elements; + x.elements = 0; + + + //Chaining to the begining + if(position == begin()){ + x.list_end->previous->next = list_start; + list_start->previous = x.list_end->previous; + + list_start = x.list_start; + + x.list_start = x.list_end; + x.list_end->previous = 0; + + return; + } + + //Link everything we need + x.list_start->previous = position.link_struct()->previous; + position.link_struct()->previous->next = x.list_start; + + position.link_struct()->previous = x.list_end->previous; + x.list_end->previous->next = position.link_struct(); + + //Clean up the other list + + x.list_start = x.list_end; + x.list_end->previous=0; + + } + + template + void list::splice(iterator position, list& x, iterator i) + { + //Invalid conditions + if( x.elements == 0 || i == position || position.link_struct() == i.link_struct()->next ){ + return; + } + + + //Do we need to adjust the begining pointer? + if(i == x.begin()){ + x.list_start = x.list_start->next; + x.list_start->previous = 0; + } + + + //Insert at begining special case + if(position == begin()){ + + i.link_struct()->previous->next = i.link_struct()->next; + i.link_struct()->next->previous = i.link_struct()->previous; + + i.link_struct()->previous = 0; + i.link_struct()->next = position.link_struct(); + position.link_struct()->previous = i.link_struct(); + + list_start = i.link_struct(); + + --x.elements; + ++elements; + return; + } + + if( i.link_struct()->previous != 0){ + i.link_struct()->previous->next = i.link_struct()->next; + i.link_struct()->next->previous = i.link_struct()->previous; + }else{ + i.link_struct()->next->previous = 0; + x.list_start = i.link_struct()->next; + } + + i.link_struct()->previous = position.link_struct()->previous; + position.link_struct()->previous->next = i.link_struct(); + + i.link_struct()->next = position.link_struct(); + position.link_struct()->previous = i.link_struct(); + + --x.elements; + ++elements; + } + + template + void list::splice(iterator position, list& x, + iterator first, iterator last) + { + if(x.elements == 0){ + return; + } + + iterator temp; + while(first != last){ + temp = first; + ++first; + splice(position, x, temp); + } + } + + + template void list::remove(const T& value){ + iterator temp = begin(); + while( temp != end() ){ + if(*temp == value){ + temp = erase(temp); + }else{ + ++temp; + } + } + } + + + template template void list::remove_if(Predicate pred){ + iterator temp = begin(); + while( temp != end() ){ + if( pred(*temp) ){ + temp = erase(temp); + }else{ + ++temp; + } + } + } + + + template void list::unique(){ + equal_to::value_type> p; + unique(p); + } + + template template + void list::unique(BinaryPredicate binary_pred) + { + iterator temp1 = begin(); + iterator temp2; + ++temp1; + while( temp1 != end() ){ + temp2 = temp1; + --temp2; + if( binary_pred(*temp1, *temp2) ){ + erase(temp1); + temp1 = temp2; + } + ++temp1; + } + } + + template void list::merge(list& x){ + less::iterator>::value_type> c; + merge(x, c); + } + + template template + void list::merge(list& x, Compare comp) + { + iterator source = x.begin(); + iterator temp; + iterator dest = begin(); + + while(source != x.end()){ + while( dest != end() && comp (*dest, *source) ){ + ++dest; + } + ++elements; + --x.elements; + + temp = source; + ++temp; + + if(dest == begin()){ + dest.link_struct()->previous = source.link_struct(); + source.link_struct()->next = dest.link_struct(); + source.link_struct()->previous = 0; + list_start = source.link_struct(); + }else{ + source.link_struct()->previous = dest.link_struct()->previous; + dest.link_struct()->previous->next = source.link_struct(); + source.link_struct()->next = dest.link_struct(); + dest.link_struct()->previous = source.link_struct(); + } + source = temp; + } + + //Fix up x; + x.list_start = x.list_end; + x.list_start->previous = 0; + } + + template void list::sort(){ + less::iterator>::value_type> c; + sort(c); + } + + template template + void list::sort(Compare comp) + { + typename list::iterator i, j, k; + + //FIXME - bubble sort + + if(elements == 0){ + return; + } + + i = end(); + --i; + while(i != begin()){ + j = begin(); + k = j; + ++k; + while(j != i){ + if( comp(*k, *j) ){ + swap_nodes(k.link_struct(), j.link_struct()); + } + ++j; + ++k; + } + --i; + } + } + + + template void list::reverse(){ + if(elements == 0){ + return; + } + + node * current; + node * following; + node * temp; + + //Need to move the list_end element to the begining + + temp = list_end; + list_end = temp->previous; + list_end->next = 0; + + list_start->previous = temp; + temp->previous = 0; + temp->next = list_start; + list_start = temp; + + current = list_start; + + while( current != list_end ){ + following = current->next; + + //Swap the values pointed to/at with the current node + temp = current->next; + current->next = current->previous; + current->previous = temp; + + current = following; + } + + //Swap pointers on the end node + temp = list_end->next; + list_end->next = list_end->previous; + list_end->previous = temp; + + + //Swap the fixed pointers + temp = list_start; + list_start = list_end; + list_end = temp; + + } + + template + bool operator==(const list& x, const list& y){ + if(x.size() != y.size()){ + return false; + } + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + + while(i != x.end()){ + if( *i != *j){ + return false; + } + ++i; + ++j; + } + return true; + } + + template + bool operator< (const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i < *j){ + return true; + } + if(*j < *i){ + return false; + } + ++i; + ++j; + } + return (i == x.end() && j != y.end()); + } + + template + bool operator!=(const list& x, const list& y){ + return !(x == y); + } + + template + bool operator> (const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i > *j){ + return true; + } + if( *j > *i){ + return false; + } + ++i; + ++j; + } + return (i != x.end() && j == y.end()); + } + + template + bool operator>=(const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i >= *j){ + return true; + } + if(*j >= *i){ + return false; + } + ++i; + ++j; + } + return (i != x.end() && j == y.end()); + } + + template + bool operator<=(const list& x, const list& y){ + typename list::const_iterator i = x.begin(); + typename list::const_iterator j = y.begin(); + while(i != x.end() && j != y.end()){ + if( *i <= *j){ + return true; + } + if(*j <= *i){ + return false; + } + ++i; + ++j; + } + return (i == x.end()); + } + + template + void swap(list& x, list& y){ + x.swap(y); + } + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/basic_definitions =================================================================== --- branches/slice/i386/modules/uClibc++/include/basic_definitions (revision 0) +++ branches/slice/i386/modules/uClibc++/include/basic_definitions (revision 727) @@ -0,0 +1,66 @@ +/* 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 +*/ + +#ifndef __BASIC_DEFINITIONS +#define __BASIC_DEFINITIONS 1 + +#include + +#pragma GCC visibility push(default) + +//The following is used to support GCC symbol visibility patch + +#ifdef GCC_HASCLASSVISIBILITY + #define _UCXXEXPORT __attribute__ ((visibility("default"))) + #define _UCXXLOCAL __attribute__ ((visibility("hidden"))) +#else + #define _UCXXEXPORT + #define _UCXXLOCAL + +#endif + +#ifdef __GCC__ +#define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) +#else +#define __UCLIBCXX_NORETURN +#endif + +#ifdef __UCLIBCXX_HAS_TLS__ + #define __UCLIBCXX_TLS __thread +#else + #define __UCLIBCXX_TLS +#endif + + + +//Testing purposes +#define __STRING_MAX_UNITS 65535 + +namespace std{ + typedef signed long int streamsize; +} + +#pragma GCC visibility pop + +#endif + + +#ifdef __DODEBUG__ + #define UCLIBCXX_DEBUG 1 +#else + #define UCLIBCXX_DEBUG 0 +#endif Index: branches/slice/i386/modules/uClibc++/include/cwctype =================================================================== --- branches/slice/i386/modules/uClibc++/include/cwctype (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cwctype (revision 727) @@ -0,0 +1,106 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: +// + +/** @file cwctype + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c wctype.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CWCTYPE +#define _CPP_CWCTYPE 1 + +#pragma GCC system_header + +//#include + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#endif + +// Get rid of those macros defined in in lieu of real functions. +#undef iswalnum +#undef iswalpha +#undef iswblank +#undef iswcntrl +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef iswctype +#undef towlower +#undef towupper +#undef towctrans +#undef wctrans +#undef wctype + +#if __UCLIBCXX_HAS_WCHAR__ +namespace std +{ + using ::wint_t; // cwchar + + using ::wctype_t; + using ::wctrans_t; + + using ::iswalnum; + using ::iswalpha; + using ::iswblank; + using ::iswcntrl; + using ::iswdigit; + using ::iswgraph; + using ::iswlower; + using ::iswprint; + using ::iswprint; + using ::iswpunct; + using ::iswspace; + using ::iswupper; + using ::iswxdigit; + using ::iswctype; + using ::towlower; + using ::towupper; + using ::towctrans; + using ::wctrans; + using ::wctype; +} +#endif //__ULIBCXX_HAS_WCHAR__ + +#endif Index: branches/slice/i386/modules/uClibc++/include/queue =================================================================== --- branches/slice/i386/modules/uClibc++/include/queue (revision 0) +++ branches/slice/i386/modules/uClibc++/include/queue (revision 727) @@ -0,0 +1,126 @@ +/* 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 + +#ifndef __HEADER_STD_QUEUE +#define __HEADER_STD_QUEUE 1 + +#pragma GCC visibility push(default) + +namespace std{ + + template > class _UCXXEXPORT queue{ + protected: + Container c; + public: + typedef typename Container::value_type value_type; + typedef typename Container::size_type size_type; + typedef Container container_type; + + explicit queue(const Container& a = Container()) : c(a) { } + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + value_type& front() { return c.front(); } + const value_type& front() const { return c.front(); } + value_type& back() { return c.back(); } + const value_type& back() const { return c.back(); } + void push(const value_type& x) { c.push_back(x); } + void pop() { c.pop_front(); } + }; + + + template _UCXXEXPORT bool + operator==(const queue& x, const queue& y) + { + return (x.c == y.c); + } + template _UCXXEXPORT bool + operator< (const queue& x, const queue& y) + { + return (x.c < y.c); + } + template _UCXXEXPORT bool + operator!=(const queue& x, const queue& y) + { + return (x.c != y.c); + } + template _UCXXEXPORT bool + operator> (const queue& x, const queue& y) + { + return (x.c > y.c); + } + template _UCXXEXPORT bool + operator>=(const queue& x, const queue& y) + { + return (x.c >= y.c); + } + template _UCXXEXPORT bool + operator<=(const queue& x, const queue& y) + { + return (x.c <= y.c); + } + + + template , + class Compare = less + > class _UCXXEXPORT priority_queue { + protected: + Container c; + Compare comp; + public: + typedef typename Container::value_type value_type; + typedef typename Container::size_type size_type; + typedef Container container_type; + + explicit priority_queue(const Compare& x = Compare(), const Container& a = Container()) + : c(a), comp(x) { make_heap(c.begin(), c.end(), comp) ; } + template priority_queue(InputIterator first, + InputIterator last, + const Compare& x = Compare(), + const Container& y= Container()) + : c(y), comp(c) + { + c.insert(c.end(), first, last); + make_heap(c.begin(), c.end(), comp); + } + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + const value_type& top() const { return c.front(); } + void push(const value_type& x){ + c.push_back(x); + push_heap(c.begin(), c.end(), comp); + } + void pop(){ + pop_heap(c.begin(), c.end(), comp); + c.pop_back(); + } + }; + +} + +#pragma GCC visibility pop + +#endif + + Index: branches/slice/i386/modules/uClibc++/include/cerrno =================================================================== --- branches/slice/i386/modules/uClibc++/include/cerrno (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cerrno (revision 727) @@ -0,0 +1,19 @@ +/* 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 Index: branches/slice/i386/modules/uClibc++/include/streambuf =================================================================== --- branches/slice/i386/modules/uClibc++/include/streambuf (revision 0) +++ branches/slice/i386/modules/uClibc++/include/streambuf (revision 727) @@ -0,0 +1,329 @@ +/* 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 + +#ifndef HEADER_STD_STREAMBUF +#define HEADER_STD_STREAMBUF 1 + +#include + +#pragma GCC visibility push(default) + +namespace std{ + + template class _UCXXEXPORT basic_streambuf{ + public: +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + friend ios_base::Init::Init(); +#endif + // Types: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + virtual ~basic_streambuf(); + + locale pubimbue(const locale &loc); + + locale getloc() const{ + return myLocale; + } + + basic_streambuf* pubsetbuf(char_type* s, streamsize n){ + return setbuf(s,n); + } + pos_type pubseekoff(off_type off, + typename ios_base::seekdir way, + ios_base::openmode which = ios_base::in | + ios_base::out + ) + { + return seekoff(off,way,which); + } + pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out){ + return seekpos(sp,which); + } + int pubsync(){ + return sync(); + } + + streamsize in_avail(); + + int_type snextc(); + + int_type sbumpc(); + + int_type sgetc(); + + streamsize sgetn(char_type* s, streamsize n){ + return xsgetn(s,n); + } + + int_type sputbackc(char_type c); + + int_type sungetc(); + + int_type sputc(char_type c); + + streamsize sputn(const char_type* s, streamsize n){ + if(openedFor & ios_base::app){ + seekoff(0, ios_base::end, ios_base::out); + } + return xsputn(s, n); + } + + protected: + locale myLocale; + //Pointers for the "get" buffers + charT * mgbeg; + charT * mgnext; + charT * mgend; + + //Pointers for the "put" buffers + charT * mpbeg; + charT * mpnext; + charT * mpend; + + //In the event of null buffers Lets us know what the buffer is opened for + ios_base::openmode openedFor; + + basic_streambuf(); + + basic_streambuf(const basic_streambuf > &) + : myLocale(), + mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), + openedFor(0) + { } + basic_streambuf > & operator=(const basic_streambuf > &){ + return *this; + } + + char_type* eback() const{ + return mgbeg; + } + char_type* gptr() const{ + return mgnext; + } + char_type* egptr() const{ + return mgend; + } + void gbump(int n){ + mgnext+=n; + } + void setg(char_type* gbeg, char_type* gnext, char_type* gend){ + mgbeg = gbeg; + mgnext = gnext; + mgend = gend; + } + + char_type* pbase() const{ + return mpbeg; + } + char_type* pptr() const{ + return mpnext; + } + char_type* epptr() const{ + return mpend; + } + void pbump(int n){ + mpnext+=n; + } + void setp(char_type* pbeg, char_type* pend){ + mpbeg = pbeg; + mpnext = pbeg; + mpend = pend; + } + + virtual void imbue(const locale &loc){ + myLocale = loc; + } + + //Virtual functions which we will not implement + + virtual basic_streambuf* setbuf(char_type* , streamsize){ + return 0; + } + virtual pos_type seekoff(off_type , ios_base::seekdir, + ios_base::openmode = ios_base::in | ios_base::out) + { + return 0; + } + virtual pos_type seekpos(pos_type , ios_base::openmode = ios_base::in | ios_base::out){ + return 0; + } + virtual int sync(){ + return 0; + } + + virtual int showmanyc(){ + return 0; + } + virtual streamsize xsgetn(char_type* , streamsize ){ + return 0; + } + virtual int_type underflow(){ + return traits_type::eof(); + } + virtual int_type uflow(){ + int_type ret = underflow(); + if (!traits_type::eq_int_type(ret, traits_type::eof())) + gbump(1); + return ret; + } + + virtual int_type pbackfail(int_type c = traits::eof()){ + return c; + } + virtual streamsize xsputn(const char_type* c, streamsize n){ + //This function is designed to be replaced by subclasses + for(streamsize i = 0; i< n; ++i){ + if(sputc(c[i]) == traits::eof()){ + return i; + } + } + return n; + } + virtual int_type overflow (int_type c = traits::eof()){ + return c; + } + }; + + typedef basic_streambuf streambuf; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_streambuf wstreambuf; +#endif + + +//Definitions put below to allow for easy expansion of code + + template basic_streambuf::~basic_streambuf(){ } + + template locale basic_streambuf::pubimbue(const locale &loc){ + locale temp = myLocale; + myLocale = loc; + return temp; + } + + template streamsize basic_streambuf::in_avail(){ + if(mgend !=0 && mgnext !=0){ + return mgend - mgnext; + } + return showmanyc(); + } + + template typename basic_streambuf::int_type basic_streambuf::sbumpc(){ + if(mgbeg == 0 || mgnext == mgend){ + return uflow(); + } + int_type retval = T::to_int_type(*gptr()); + gbump(1); + return retval; + } + + template typename basic_streambuf::int_type basic_streambuf::snextc(){ + if(sbumpc() == T::eof() ){ + return T::eof() ; + } + return sgetc(); + } + + template typename basic_streambuf::int_type basic_streambuf::sgetc(){ + if(mgbeg == 0 || mgnext == mgend){ + return underflow(); + } + return T::to_int_type(*gptr()); + } + + template typename basic_streambuf::int_type basic_streambuf::sputbackc(char_type c){ + if(mgbeg == 0 || mgnext == mgbeg || !T::eq(c, gptr()[-1] )){ + return pbackfail(T::to_int_type(c)); + } + gbump(-1); + return T::to_int_type(*gptr()); + } + + template typename basic_streambuf::int_type basic_streambuf::sungetc(){ + if(mgbeg == 0 || mgnext == mgbeg){ + return ios_base::failbit; + } + gbump(-1); + return T::to_int_type(*gptr()); + } + + template typename basic_streambuf::int_type basic_streambuf::sputc(char_type c){ + if(openedFor & ios_base::app){ + seekoff(0, ios_base::end, ios_base::out); + } + if(mpnext < mpend){ + *mpnext = c; + ++mpnext; + }else{ + return overflow( T::to_int_type(c) ); + } + return T::to_int_type(c); + } + + template basic_streambuf::basic_streambuf() + : myLocale(), + mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), + openedFor(0) + { } + + + + + + +#ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STREAMBUF__ + +#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + template <> _UCXXEXPORT streambuf::basic_streambuf(); + template <> _UCXXEXPORT streambuf::~basic_streambuf(); + +#endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ + + 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 +#endif + + + + + +} + +#pragma GCC visibility pop + +#endif Index: branches/slice/i386/modules/uClibc++/include/new =================================================================== --- branches/slice/i386/modules/uClibc++/include/new (revision 0) +++ branches/slice/i386/modules/uClibc++/include/new (revision 727) @@ -0,0 +1,64 @@ +/* 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 + +#ifndef __STD_NEW_OPERATOR +#define __STD_NEW_OPERATOR 1 + +#pragma GCC visibility push(default) + +namespace std{ + class _UCXXEXPORT bad_alloc : public exception {}; + + struct _UCXXEXPORT nothrow_t {}; + extern const nothrow_t nothrow; + + typedef void (*new_handler)(); + _UCXXEXPORT new_handler set_new_handler(new_handler new_p) throw(); +} + + +_UCXXEXPORT void* operator new(std::size_t numBytes) throw(std::bad_alloc); +_UCXXEXPORT void operator delete(void* ptr) throw(); + +_UCXXEXPORT void* operator new[](std::size_t numBytes) throw(std::bad_alloc); +_UCXXEXPORT void operator delete[](void * ptr) throw(); + +#ifndef NO_NOTHROW +_UCXXEXPORT void* operator new(std::size_t numBytes, const std::nothrow_t& ) throw(); +_UCXXEXPORT void operator delete(void* ptr, const std::nothrow_t& ) throw(); + +_UCXXEXPORT void* operator new[](std::size_t numBytes, const std::nothrow_t& ) throw(); +_UCXXEXPORT void operator delete[](void* ptr, const std::nothrow_t& ) throw(); +#endif + + /* Placement operators */ +inline void* operator new(std::size_t, void* ptr) throw() {return ptr; } +inline void operator delete(void* , void *) throw() { } + +inline void* operator new[](std::size_t, void *p) throw() { return p; } +inline void operator delete[](void* , void *) throw() {} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/ios =================================================================== --- branches/slice/i386/modules/uClibc++/include/ios (revision 0) +++ branches/slice/i386/modules/uClibc++/include/ios (revision 727) @@ -0,0 +1,501 @@ +/* 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 + +#ifndef __HEADER_STD_IOS +#define __HEADER_STD_IOS 1 + +#pragma GCC visibility push(default) + +namespace std{ + typedef signed long int streamoff; + + template class fpos; + + class _UCXXEXPORT ios_base { + public: + class failure; +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + class failure : public exception { + public: + explicit failure(const std::string& msg) { } + explicit failure() { } + virtual const char* what() const throw() { + return "std::ios_base failure exception"; + } + }; +#endif +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + class _UCXXLOCAL Init{ + public: + _UCXXEXPORT Init(); + _UCXXEXPORT ~Init(); + private: + static int init_cnt; + }; +#endif + + public: + + typedef unsigned short int fmtflags; + + static const fmtflags skipws = 0x0001; + + static const fmtflags left = 0x0002; + static const fmtflags right = 0x0004; + static const fmtflags internal = 0x0008; + + static const fmtflags boolalpha = 0x0010; + + static const fmtflags dec = 0x0020; + static const fmtflags oct = 0x0040; + static const fmtflags hex = 0x0080; + + static const fmtflags scientific = 0x0100; + static const fmtflags fixed = 0x0200; + + static const fmtflags showbase = 0x0400; + static const fmtflags showpoint = 0x0800; + static const fmtflags showpos = 0x1000; + static const fmtflags uppercase = 0x2000; + + static const fmtflags adjustfield = left | right | internal; + static const fmtflags basefield = dec | oct | hex; + static const fmtflags floatfield = fixed | scientific; + + static const fmtflags unitbuf = 0x4000; + + typedef unsigned char iostate; + static const iostate goodbit = 0x00; + static const iostate badbit = 0x01; + static const iostate eofbit = 0x02; + static const iostate failbit = 0x04; + + typedef unsigned char openmode; + static const openmode app = 0x01; + static const openmode ate = 0x02; + static const openmode binary = 0x04; + static const openmode in = 0x08; + static const openmode out = 0x10; + static const openmode trunc = 0x20; + + typedef unsigned char seekdir; + static const seekdir beg = 0x01; + static const seekdir cur = 0x02; + static const seekdir end = 0x04; + + _UCXXEXPORT fmtflags flags() const{ + return mformat; + } + _UCXXEXPORT fmtflags flags(fmtflags fmtfl); + + fmtflags setf(fmtflags fmtfl); + fmtflags setf(fmtflags fmtfl, fmtflags mask ); + + _UCXXEXPORT void unsetf(fmtflags mask){ + mformat&= ~mask; + } + + _UCXXEXPORT streamsize precision() const{ + return mprecision; + } + + _UCXXEXPORT streamsize precision(streamsize prec); + + _UCXXEXPORT streamsize width() const{ + return mwidth; + } + + _UCXXEXPORT streamsize width(streamsize wide); + + _UCXXEXPORT locale imbue(const locale& loc); + + _UCXXEXPORT locale getloc() const{ + return mLocale; + } + +// FIXME - These need to be implemented +// static int xalloc(); +// long& iword(int index); +// void*& pword(int index); + + _UCXXEXPORT ~ios_base() { } + + enum event { erase_event, imbue_event, copyfmt_event }; + + typedef void (*event_callback)(event, ios_base&, int index); +// void register_callback(event_call_back fn, int index); + + //We are going to wrap stdio so we don't need implementation of the following: + inline static bool sync_with_stdio(bool = true) { return true; } + + protected: + _UCXXEXPORT ios_base() : mLocale(), mformat(dec | skipws ), mstate(goodbit), + mmode(), mdir(), mprecision(6), mwidth(0) +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + ,mInit() +#endif + { + + } + locale mLocale; + fmtflags mformat; + iostate mstate; + openmode mmode; + seekdir mdir; + streamsize mprecision; + streamsize mwidth; +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + Init mInit; +#endif + }; + + + //ios_base manipulators + + + inline ios_base& boolalpha (ios_base& str){ + str.setf(ios_base::boolalpha); + return str; + } + inline ios_base& noboolalpha(ios_base& str){ + str.unsetf(ios_base::boolalpha); + return str; + } + inline ios_base& showbase (ios_base& str){ + str.setf(ios_base::showbase); + return str; + } + inline ios_base& noshowbase (ios_base& str){ + str.unsetf(ios_base::showbase); + return str; + } + inline ios_base& showpoint (ios_base& str){ + str.setf(ios_base::showpoint); + return str; + } + inline ios_base& noshowpoint(ios_base& str){ + str.unsetf(ios_base::showpoint); + return str; + } + inline ios_base& showpos (ios_base& str){ + str.setf(ios_base::showpos); + return str; + } + inline ios_base& noshowpos (ios_base& str){ + str.unsetf(ios_base::showpos); + return str; + } + inline ios_base& skipws (ios_base& str){ + str.setf(ios_base::skipws); + return str; + } + inline ios_base& noskipws (ios_base& str){ + str.unsetf(ios_base::skipws); + return str; + } + inline ios_base& uppercase (ios_base& str){ + str.setf(ios_base::uppercase); + return str; + } + inline ios_base& nouppercase(ios_base& str){ + str.unsetf(ios_base::uppercase); + return str; + } + + inline ios_base& unitbuf (ios_base& str){ + str.setf(ios_base::unitbuf); + return str; + } + inline ios_base& nounitbuf (ios_base& str){ + str.unsetf(ios_base::unitbuf); + return str; + } + inline ios_base& internal (ios_base& str){ + str.setf(ios_base::internal, ios_base::adjustfield); + return str; + } + inline ios_base& left (ios_base& str){ + str.setf(ios_base::left, ios_base::adjustfield); + return str; + } + inline ios_base& right (ios_base& str){ + str.setf(ios_base::right, ios_base::adjustfield); + return str; + } + + inline ios_base& dec (ios_base& str){ + str.setf(ios_base::dec, ios_base::basefield); + return str; + } + inline ios_base& hex (ios_base& str){ + str.setf(ios_base::hex, ios_base::basefield); + return str; + } + inline ios_base& oct (ios_base& str){ + str.setf(ios_base::oct, ios_base::basefield); + return str; + } + + inline ios_base& fixed (ios_base& str){ + str.setf(ios_base::fixed, ios_base::floatfield); + return str; + } + inline ios_base& scientific (ios_base& str){ + str.setf(ios_base::scientific, ios_base::floatfield); + return str; + } + + + //basic_ios class definition + + + template class _UCXXEXPORT basic_ios + : public ios_base + { + public: + // Types: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + _UCXXEXPORT operator void*() const{ + if(fail() ){ + return 0; + } + return (void *)(1); //Must return a non-NULL pointer (though it can be *any* pointer) + } + + _UCXXEXPORT bool operator!() const{ + return fail(); + } + _UCXXEXPORT iostate rdstate() const{ + return mstate; + } + _UCXXEXPORT void clear(iostate state = goodbit){ + if(rdbuf()!=0){ + mstate = state; + }else{ + mstate = state|ios_base::badbit; + } + } + _UCXXEXPORT void setstate(iostate state) { + clear(rdstate() | state); +#ifdef __UCLIBCXX_EXCEPTION_SUPPORT__ + if(rdstate() & throw_mask){ + throw failure(); + } +#endif + } + + _UCXXEXPORT bool good() const{ + return (rdstate() == 0); + } + _UCXXEXPORT bool eof() const{ + if(rdstate() & eofbit){ + return true; + } + return false; + } + _UCXXEXPORT bool fail() const{ + if( mstate & (failbit | badbit) ){ + return true; + } + return false; + } + + _UCXXEXPORT bool bad() const{ + if(mstate & badbit){ + return true; + } + return false; + } + + _UCXXEXPORT iostate exceptions() const{ + return throw_mask; + } + _UCXXEXPORT void exceptions(iostate except){ + throw_mask = except; + } + + explicit _UCXXEXPORT basic_ios(basic_streambuf* sb) : fill_char(' '), mtied(0), mstreambuf(0){ + init(sb); + } + + basic_ios() : mtied(0), mstreambuf(0){ } + + virtual _UCXXEXPORT ~basic_ios(){ + } + + _UCXXEXPORT basic_ostream* tie() const{ + return mtied; + } + _UCXXEXPORT basic_ostream* tie(basic_ostream* tiestr){ + basic_ostream* retval= mtied; + mtied = tiestr; + return retval; + } + _UCXXEXPORT basic_streambuf* rdbuf() const{ + return mstreambuf; + } + _UCXXEXPORT basic_streambuf* rdbuf(basic_streambuf* sb){ + basic_streambuf* retval = mstreambuf; + mstreambuf = sb; + return retval; + } + _UCXXEXPORT basic_ios& copyfmt(const basic_ios& rhs); + _UCXXEXPORT char_type fill() const{ + return fill_char; + } + _UCXXEXPORT char_type fill(char_type ch){ + char_type temp = fill_char; + fill_char = ch; + return temp; + } + + _UCXXEXPORT locale imbue(const locale& loc){ + return ios_base::imbue(loc); + } + _UCXXEXPORT char narrow(char_type c, char dfault) const; + _UCXXEXPORT char_type widen(char c) const; + + protected: + char_type fill_char; + basic_ostream* mtied; + basic_streambuf* mstreambuf; + iostate throw_mask; + _UCXXEXPORT basic_ios(const basic_ios &){ } + _UCXXEXPORT basic_ios & operator=(const basic_ios &){ return *this; } + _UCXXEXPORT void init(basic_streambuf* sb){ + ios_base::mformat = skipws|dec; + mstreambuf = sb; + mstate = goodbit; + throw_mask = goodbit; + } + }; + +#ifdef __UCLIBCXX_EXPAND_IOS_CHAR__ +#ifndef __UCLIBCXX_COMPILE_IOS__ + + template <> _UCXXEXPORT void basic_ios >::clear(iostate state); + template <> _UCXXEXPORT void basic_ios >::setstate(iostate state); + +#endif +#endif + + + template + inline char basic_ios::narrow(char_type c, char dfault) const + { + return dfault; + } + + template <> + inline char basic_ios >::narrow(char_type c, char) const + { + return c; + } + +#ifdef __UCLIBCXX_HAS_WCHAR__ + + template <> + inline char basic_ios >::narrow(char_type c, char dfault) const + { + char retval = wctob (c); + if(retval == EOF){ + retval = dfault; + } + return retval; + } + +#endif //__UCLIBCXX_HAS_WCHAR__ + + template + inline typename basic_ios::char_type + basic_ios::widen(char c) const + { + return c; + } + + template <> + inline basic_ios >::char_type + basic_ios >::widen(char c) const + { + return c; + } + +#ifdef __UCLIBCXX_HAS_WCHAR__ + + template <> + inline basic_ios >::char_type + basic_ios >::widen(char c) const + { + return btowc(c); + } + +#endif //__UCLIBCXX_HAS_WCHAR__ + + + template class _UCXXEXPORT fpos{ + public: + _UCXXEXPORT fpos(stateT s){ + st = s; + } + _UCXXEXPORT stateT state() const{ + return st; + } + _UCXXEXPORT void state(stateT s){ + st = s; + } + _UCXXEXPORT bool operator==(const fpos &rhs){ + return st == rhs.st; + } + _UCXXEXPORT bool operator!=(const fpos &rhs){ + return st == rhs.st; + } + _UCXXEXPORT fpos & operator+(const streamoff & o){ + st += o; + return *this; + } + _UCXXEXPORT fpos & operator-(const streamoff & o){ + st -= o; + return *this; + } + _UCXXEXPORT streamoff operator-(const fpos & rhs){ + return st - rhs.st; + } + + + private: + stateT st; + }; + + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/fstream =================================================================== --- branches/slice/i386/modules/uClibc++/include/fstream (revision 0) +++ branches/slice/i386/modules/uClibc++/include/fstream (revision 727) @@ -0,0 +1,678 @@ +/* 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 +*/ +#if 0 +#ifndef __STD_HEADER_FSTREAM +#define __STD_HEADER_FSTREAM 1 + +//#if __UCLIBCXX_SUPPORT_FILEIO__ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif //__UCLIBCXX_HAS_WCHAR__ + +#pragma GCC visibility push(default) + +namespace std{ + + template class basic_filebuf; + + typedef basic_filebuf filebuf; +#ifdef __UCLIBCXX_HAS_WCHAR__ + typedef basic_filebuf wfilebuf; +#endif + + + template class _UCXXEXPORT basic_filebuf + : public basic_streambuf + { +#ifdef __UCLIBCXX_SUPPORT_CDIR__ + friend ios_base::Init::Init(); //Needed for cout/cin stuff +#endif + public: + // Types (inherited from basic_streambuf: + typedef typename basic_streambuf::char_type char_type; + typedef typename basic_streambuf::int_type int_type; + typedef typename basic_streambuf::pos_type pos_type; + typedef typename basic_streambuf::off_type off_type; + typedef traits traits_type; + + //Constructors/destructor: + + _UCXXEXPORT basic_filebuf() : basic_streambuf(), fp(0), pbuffer(0), gbuffer(0) + { + append=false; + pbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; + gbuffer = new char_type[__UCLIBCXX_IOSTREAM_BUFSIZE__]; + + setp(pbuffer, pbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); + //Position get buffer so that there is no data available + setg(gbuffer, gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__, + gbuffer + __UCLIBCXX_IOSTREAM_BUFSIZE__); + } + + + _UCXXEXPORT virtual ~basic_filebuf(){ + sync(); + close(); + delete [] pbuffer; + delete [] gbuffer; + pbuffer = 0; + gbuffer = 0; + } + + + //Members: + + _UCXXEXPORT bool is_open() const{ + if(fp == 0){ + return false; + } + return true; + } + + _UCXXEXPORT basic_filebuf* open(const char* s, ios_base::openmode mode){ + bool move_end = (mode & ios_base::ate) != 0; + if(is_open() !=false){ //Must call close() first + return 0; + } + basic_streambuf::openedFor = mode; + mode = mode & ~ios_base::ate; + + if(mode == ios_base::out || mode == (ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w" ); + }else if((mode & ios_base::app) && ! (mode & ios_base::trunc)){ + if(mode & ios_base::binary){ + if(mode & ios_base::in){ + fp = fopen(s, "a+b"); + }else{ + fp = fopen(s, "ab"); + } + }else{ + if(mode & ios_base::in){ + fp = fopen(s, "a+"); + }else{ + fp = fopen(s, "a"); + } + } + }else if(mode == ios_base::in){ + fp = fopen(s, "r"); + }else if(mode == (ios_base::in | ios_base::out)){ + fp = fopen(s, "r+"); + }else if(mode == (ios_base::in | ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w+"); + }else if(mode == (ios_base::binary | ios_base::out)){ + fp = fopen(s, "wb"); + }else if(mode == (ios_base::in | ios_base::binary)){ + fp = fopen(s, "rb"); + }else if(mode == (ios_base::in | ios_base::binary | ios_base::out)){ + fp = fopen(s, "r+b"); + }else if(mode==(ios_base::binary | ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w+b"); + }else if(mode == (ios_base::in | ios_base::binary | ios_base::out | ios_base::trunc)){ + fp = fopen(s, "w+b"); + } + + if(fp == 0){ + return 0; + } + if(ferror(fp)){ + fclose(fp); + fp=0; + return 0; + } + int retval = 0; + + //Check to make sure the stream is good + if(move_end == true){ + retval = fseek(fp, 0, SEEK_END); + }else{ + retval = fseek(fp, 0, SEEK_SET); + } + if(retval!=0){ //Seek error + fclose(fp); + fp=0; + return 0; + } + + basic_streambuf::mgnext = basic_streambuf::mgend; + + return this; + } + _UCXXEXPORT basic_filebuf* close(){ + if(fp != 0 && fp != stdin && fp != stdout && fp !=stderr ){ + overflow(); + sync(); + int retval = fclose(fp); + if(retval !=0){ //Error of some sort + return 0; + } + fp=0; + } + return this; + } + protected: + _UCXXEXPORT basic_filebuf(const basic_filebuf &){ } + _UCXXEXPORT basic_filebuf & operator=(const basic_filebuf &){ return *this; } + + //Overridden virtual functions: + + virtual _UCXXEXPORT int showmanyc(){ + return basic_streambuf::egptr() - basic_streambuf::gptr(); + } + virtual _UCXXEXPORT int_type 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 + + */ + + if(!is_open()){ + return traits::eof(); + } + + if(basic_streambuf::eback() == 0){ + //No buffer, so... + charT c; + int retval; + retval = fread(&c, sizeof(charT), 1, fp); + + if(retval == 0 || feof(fp) || ferror(fp) ){ + return traits::eof(); + } + return traits::to_int_type(c); + } + + if(basic_streambuf::eback() == basic_streambuf::gptr()){ //Buffer is full + return traits::to_int_type(*basic_streambuf::gptr()); + } + //Shift entire buffer back to the begining + size_t offset = basic_streambuf::gptr() - basic_streambuf::eback(); + size_t amountData = basic_streambuf::egptr() - basic_streambuf::gptr(); + + for(charT * i = basic_streambuf::gptr(); i < basic_streambuf::egptr(); ++i){ + *(i-offset) = *i; + } + + size_t retval = 0; + //Save operating flags from file descriptor + int fcntl_flags = fcntl(fileno(fp), F_GETFL); + retval = 0; + + //Set to non_blocking mode + fcntl(fileno(fp), F_SETFL, fcntl_flags | O_NONBLOCK); + + //Fill rest of buffer + retval = fread(basic_streambuf::egptr() - + basic_streambuf::gptr() + basic_streambuf::eback(), + sizeof(charT), + offset, + fp + ); + + //Clear problems where we didn't read in enough characters + if(EAGAIN == errno){ + clearerr(fp); + } + + //Restore file descriptor clase + fcntl(fileno(fp), F_SETFL, fcntl_flags); + + //Now we are going to make sure that we read in at least one character. The hard way. + if(retval == 0){ + fcntl_flags = fcntl(fileno(fp), F_GETFL); + //Set to blocking mode + fcntl(fileno(fp), F_SETFL, fcntl_flags & ~O_NONBLOCK); + + retval = fread(basic_streambuf::egptr() - + basic_streambuf::gptr() + basic_streambuf::eback(), + sizeof(charT), + 1, + fp + ); + + //Restore file descriptor clase + fcntl(fileno(fp), F_SETFL, fcntl_flags); + + } + + if(retval !=offset){ //Slide buffer forward again + for(size_t i = 0; i < amountData + retval; ++i){ + *(basic_streambuf::egptr() - i - 1) = + *(basic_streambuf::eback() + amountData + retval - i - 1); + } + } + + basic_streambuf::mgnext -= retval; + + if( (retval <= 0 && feof(fp)) || ferror(fp) ){ + return traits::eof(); + } + + return traits::to_int_type(*basic_streambuf::gptr()); + } + virtual _UCXXEXPORT int_type uflow(){ + bool dobump = (basic_streambuf::gptr() != 0); + int_type retval = underflow(); + if(dobump){ + basic_streambuf::gbump(1); + } + return retval; + } + virtual _UCXXEXPORT int_type pbackfail(int_type c = traits::eof()){ + if(is_open() == false || + basic_streambuf::gptr() == basic_streambuf::eback()) + { + return traits::eof(); + } + if(traits::eq_int_type(c,traits::eof()) == false){ + if(traits::eq(traits::to_char_type(c), basic_streambuf::gptr()[-1]) == true){ + basic_streambuf::gbump(-1); + }else{ + basic_streambuf::gbump(-1); + basic_streambuf::gptr()[0] = c; + } + return c; + }else{ + basic_streambuf::gbump(-1); + return traits::not_eof(c); + } + } + + virtual _UCXXEXPORT int_type overflow(int_type c = traits::eof()){ + if(is_open() == false){ + //Can't do much + return traits::eof(); + } + if(basic_streambuf::pbase() == 0){ //Unbuffered - elliminate dupe code below + if(fputc(c, fp) == EOF){ + return traits::eof(); + } + return c; + } + if(basic_streambuf::pbase() == 0 && traits::eq_int_type(c,traits::eof()) ){ + //Nothing to flush + return traits::not_eof(c); + } + size_t r = basic_streambuf::pptr() - basic_streambuf::pbase(); + + if( r == 0 && traits::eq_int_type(c,traits::eof()) ){ + return traits::not_eof(c); + }else if (r == 0 ){ + if(fputc(c, fp) == EOF){ + return traits::eof(); + } + return c; + } + + size_t totalChars = r; + + char_type *buffer = 0; + if(traits::eq_int_type(c,traits::eof())){ + buffer = new char_type[r]; + }else{ + buffer = new char_type[r+1]; + buffer[r] = c; + totalChars++; + } + + traits::copy(buffer, basic_streambuf::pbase(), r); +// memcpy(buffer, basic_streambuf::pbase(), r); + + size_t retval = fwrite(buffer, sizeof(charT), totalChars, fp); + if(retval !=totalChars){ + if(retval == 0){ + delete [] buffer; + return traits::eof(); + } + basic_streambuf::pbump(-retval); + fprintf(stderr, "***** Did not write the full buffer out. Should be: %d, actually: %d\n", + totalChars, retval); + }else{ + basic_streambuf::pbump(-r); + } + + delete [] buffer; + return traits::not_eof(c); + } + + virtual _UCXXEXPORT basic_streambuf* setbuf(char_type* s, streamsize n){ + if(s == 0 && n == 0){ //Unbuffered + if(pbuffer !=0){ + delete [] pbuffer; + } + if(gbuffer !=0){ + delete [] gbuffer; + } + pbuffer = 0; + gbuffer = 0; + }else if(basic_streambuf::gptr() !=0 && + basic_streambuf::gptr()==basic_streambuf::egptr()) + { + delete [] pbuffer; + pbuffer = s; + } + return this; + } + virtual _UCXXEXPORT pos_type seekoff(off_type off, ios_base::seekdir way, + ios_base::openmode = ios_base::in | ios_base::out) + { + if(is_open() == false){ + return -1; + } + int whence = SEEK_SET; // if(way == basic_ios::beg) + off_type position = off; + + if(way == basic_ios::cur){ + whence = SEEK_CUR; + position -= (basic_streambuf::egptr() - basic_streambuf::gptr()); + }else if(way == basic_ios::end){ + whence = SEEK_END; + } + + sync(); + + int retval = fseek( + fp, + sizeof(charT)*(position), + whence + ); + + //Invalidate read buffer + basic_streambuf::gbump( + basic_streambuf::egptr() - basic_streambuf::gptr() + ); + + if(-1 != retval){ + retval = ftell(fp); + } + + return retval; + } + virtual _UCXXEXPORT pos_type seekpos(pos_type sp, ios_base::openmode = ios_base::in | ios_base::out){ + if(is_open() == false){ + return -1; + } + sync(); + + int retval = fseek(fp,sizeof(charT)* sp, SEEK_SET); + + //Invalidate read buffer + basic_streambuf::gbump(basic_streambuf::egptr() - basic_streambuf::gptr()); + if(retval > -1){ + return sp; + } + return -1; + } + virtual _UCXXEXPORT int sync(){ + if(pbuffer !=0){ + if(overflow() == traits::eof()){ + return -1; + } + } + if(0 != fp && 0 != fflush(fp)){ + return -1; + } + return 0; + } + virtual _UCXXEXPORT void imbue(const locale&){ + return; + } + + + virtual _UCXXEXPORT streamsize xsputn(const char_type* s, streamsize n){ + if(is_open() == false){ + return 0; + } + //Check to see if buffered + + //Check to see if we can buffer the data + streamsize buffer_avail = basic_streambuf::epptr() - basic_streambuf::pptr(); + + if(n > buffer_avail){ //Flush buffer and write directly + overflow(); //Flush the buffer + return fwrite(s, sizeof(charT), n, fp); + } + + //Add to buffer to be written later + + traits::copy(basic_streambuf::pptr(), s, n); + basic_streambuf::pbump(n); + + return n; + } + + FILE * fp; + char_type * pbuffer; + char_type * gbuffer; + bool append; + }; + + +#ifdef __UCLIBCXX_HAS_WCHAR__ + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::overflow(int_type c); + +template <> _UCXXEXPORT basic_filebuf >::int_type + basic_filebuf >::underflow(); + +#endif //__UCLIBCXX_HAS_WCHAR__ + + + +#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_FSTREAM__ + +#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 c); + template <> _UCXXEXPORT filebuf::int_type filebuf::underflow (); + + template <> _UCXXEXPORT basic_streambuf > * filebuf::setbuf(char * s, streamsize n); + template <> _UCXXEXPORT streamsize filebuf::xsputn(const char* s, streamsize n); + +#endif +#endif + + + template class _UCXXEXPORT basic_ifstream + : public basic_istream + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + _UCXXEXPORT basic_ifstream(): basic_ios(&sb), basic_istream(&sb){ + //Passing the address of sb + } + explicit _UCXXEXPORT basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in) + : basic_ios(&sb), basic_istream(&sb) + { + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + + virtual _UCXXEXPORT ~basic_ifstream(){ + + } + + _UCXXEXPORT basic_filebuf* rdbuf() const{ + return (basic_filebuf*)&sb; + } + _UCXXEXPORT bool is_open() const{ + return sb.is_open(); + } + _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::in){ + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + _UCXXEXPORT void close(){ + sb.close(); + } + private: + basic_filebuf sb; + }; + + + template class _UCXXEXPORT basic_ofstream + : public basic_ostream + { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + _UCXXEXPORT basic_ofstream() : basic_ios(&sb), basic_ostream(&sb){ + + } + + virtual _UCXXEXPORT ~basic_ofstream(); + + explicit _UCXXEXPORT basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out | ios_base::trunc) : + basic_ios(&sb), basic_ostream(&sb) + { + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + + _UCXXEXPORT basic_filebuf* rdbuf() const{ + return (basic_filebuf*)&sb; + } + + _UCXXEXPORT bool is_open() const{ + return sb.is_open(); + } + _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::out | ios_base::trunc){ + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + _UCXXEXPORT void close(){ + sb.close(); + } + private: + basic_filebuf sb; + }; + + template _UCXXEXPORT basic_ofstream::~basic_ofstream(){ + basic_ostream::flush(); + } + + + template class _UCXXEXPORT basic_fstream + : public basic_iostream + { + public: + typedef charT char_type; + typedef typename traits::int_type ins_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + + _UCXXEXPORT basic_fstream(): basic_ios(&sb), basic_iostream(&sb){ } + + explicit _UCXXEXPORT basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out): + basic_ios(&sb), basic_iostream(&sb) + { + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + + _UCXXEXPORT basic_filebuf* rdbuf() const{ + return (basic_filebuf*)&sb; + } + _UCXXEXPORT bool is_open() const{ + return sb.is_open(); + } + _UCXXEXPORT void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out){ + if(sb.open(s, mode) == 0){ + basic_ios::setstate(ios_base::failbit); + } + } + _UCXXEXPORT void close(){ + sb.close(); + } + private: + basic_filebuf sb; + }; + + + +#ifdef __UCLIBCXX_EXPAND_FSTREAM_CHAR__ +#ifndef __UCLIBCXX_COMPILE_FSTREAM__ + +#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 +#endif + + + +} + +#pragma GCC visibility pop + +#endif + +#endif \ No newline at end of file Index: branches/slice/i386/modules/uClibc++/include/ctime =================================================================== --- branches/slice/i386/modules/uClibc++/include/ctime (revision 0) +++ branches/slice/i386/modules/uClibc++/include/ctime (revision 727) @@ -0,0 +1,81 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 20.5 Date and time +// + +/** @file ctime + * This is a Standard C++ Library file. You should @c #include this file + * in your programs, rather than any of the "*.h" implementation files. + * + * This is the C++ version of the Standard C Library header @c time.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std. + */ + +#ifndef _CPP_CTIME +#define _CPP_CTIME 1 + +#pragma GCC system_header + +#include + +#include + +// Get rid of those macros defined in in lieu of real functions. +#undef clock +#undef difftime +#undef mktime +#undef time +#undef asctime +#undef ctime +#undef gmtime +#undef localtime +#undef strftime + +namespace std +{ + using ::clock_t; + using ::time_t; + using ::tm; + + using ::clock; + using ::difftime; + using ::mktime; + using ::time; + using ::asctime; + using ::ctime; + using ::gmtime; + using ::localtime; + using ::strftime; +} + +#endif Index: branches/slice/i386/modules/uClibc++/include/clocale =================================================================== --- branches/slice/i386/modules/uClibc++/include/clocale (revision 0) +++ branches/slice/i386/modules/uClibc++/include/clocale (revision 727) @@ -0,0 +1,30 @@ +/* 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 +*/ + +#ifndef __STD_HEADER_CLOCALE +#define __STD_HEADER_CLOCALE 1 + +#include + +namespace std { + using ::lconv; + using ::setlocale; + using ::localeconv; +} + +#endif // __STD_HEADER_CLOCALE Index: branches/slice/i386/modules/uClibc++/include/char_traits =================================================================== --- branches/slice/i386/modules/uClibc++/include/char_traits (revision 0) +++ branches/slice/i386/modules/uClibc++/include/char_traits (revision 727) @@ -0,0 +1,198 @@ +/* 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 + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif + +#ifndef __HEADER_CHAR_TRAITS +#define __HEADER_CHAR_TRAITS 1 + +namespace std{ + /* Inlining all wrapped function calls to shrink the amount of code generated*/ + //Typedefs to use for stuff + typedef signed int char_traits_off_type; + + //Generic char_traits + template struct _UCXXEXPORT char_traits { }; + + //Specialize for char + template<> struct _UCXXEXPORT char_traits { + typedef char char_type; + typedef short int int_type; + typedef char_traits_off_type off_type; + typedef char_traits_off_type pos_type; + typedef char state_type; + + inline static void assign(char_type & c, const char_type & d) { c = d; } + + static bool eq(const char_type& c1, const char_type& c2); + + static char_type to_char_type(const int_type & i); + + inline static int_type to_int_type(const char_type & c){ + return (short int)(unsigned char)c; + } + + inline static bool eq_int_type(const int_type & a, const int_type & b){ + if(a==b){ + return true; + } + return false; + } + + + inline static bool lt(const char_type& c1, const char_type& c2){ + if(strncmp(&c1, &c2, 1) < 0){ + return true; + } + return false; + } + + inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ + return (char*) memmove(s1, s2, n); + } + + inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ + for(unsigned long int i=0; i< n; ++i){ + assign(s1[i], s2[i]); + } + return s1 + n; + } + + inline static char_type* assign(char_type* s, size_t n, char_type a){ + return (char *)memset(s, a, n); + } + + inline static int compare(const char_type* s1, const char_type* s2, size_t n){ + return strncmp(s1, s2, n); + } + + inline static size_t length(const char_type* s){ + return strlen(s); + } + + static const char_type* find(const char_type* s, int n, const char_type& a); + + inline static char_type eos() { return 0; } + inline static int_type eof() { return -1; } + inline static int_type not_eof(const int_type & i) { + if(i == -1){ + return 0; + } else { + return i; + } + } + static state_type get_state(pos_type p){ + p = p; + state_type a; + return a; + } + }; + + +#ifdef __UCLIBCXX_HAS_WCHAR__ + template<> struct _UCXXEXPORT char_traits { + typedef wchar_t char_type; + typedef wint_t int_type; + typedef char_traits_off_type off_type; + typedef char_traits_off_type pos_type; + typedef mbstate_t state_type; + + static void assign(char_type & c, const char_type & d){ c=d; } + + static char_type to_char_type(const int_type & i){ + return i; + } + + static int_type to_int_type(const char_type & c){ + return c; + } + + inline static bool eq_int_type(const int_type & a, const int_type & b){ + if(a==b){ + return true; + } + return false; + } + + inline static bool eq(const char_type& c1, const char_type& c2){ + if(wcsncmp(&c1, &c2, 1) == 0){ + return true; + } + return false; + } + + inline static bool lt(const char_type& c1, const char_type& c2){ + if(wcsncmp(&c1, &c2, 1) < 0){ + return true; + } + return false; + } + + inline static char_type* move(char_type* s1, const char_type* s2, size_t n){ + return (char_type*) memmove(s1, s2, n * sizeof(char_type)); + } + + inline static char_type* copy(char_type* s1, const char_type* s2, size_t n){ + for(unsigned long int i=0; i< n; ++i){ + assign(s1[i], s2[i]); + } + return s1 + n; + } + + inline static char_type* assign(char_type* s, size_t n, char_type a){ + return (char_type *)memset(s, a, n); /*FIXME*/ + } + + inline static int compare(const char_type* s1, const char_type* s2, size_t n){ + return wcsncmp(s1, s2, n); + } + + inline static size_t length(const char_type* s){ + return wcslen(s); + } + + static const char_type* find(const char_type* s, int n, const char_type& a); + + inline static char_type eos() { return 0; } + inline static int_type eof() { return WEOF; } + inline static int_type not_eof(const int_type & i) { + if(i == WEOF){ + return (int_type)0; + } else { + return i; + } + } + static state_type get_state(pos_type){ + state_type a; + return a; + } + }; +#endif + +} + +#endif + Index: branches/slice/i386/modules/uClibc++/include/associative_base =================================================================== --- branches/slice/i386/modules/uClibc++/include/associative_base (revision 0) +++ branches/slice/i386/modules/uClibc++/include/associative_base (revision 727) @@ -0,0 +1,643 @@ +/* Copyright (C) 2007 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 + + +#ifndef __STD_HEADER_ASSOCIATIVE_BASE +#define __STD_HEADER_ASSOCIATIVE_BASE + +#pragma GCC visibility push(default) + +namespace std{ + + +/* + * The basic premis here is that most of the code used by map, multimap, set and + * multiset is really common. There are a number of interface additions, and + * considerations about how to address multiple enteries with the same key. + * The goal is that the code tree/storage code should be here, and managing + * single or moultiple counts will be loeft to subclasses. + * Yes, inheritence for the purpose of code sharing is usually a bad idea. However, + * since our goal is to reduce tht total amount of code written and the overall binary + * size, this seems to be the best approach possible. + */ + +template, class Allocator = allocator > class __base_associative; +template class _associative_iter; +template class _associative_citer; + +template, class Allocator = allocator > class __single_associative; +template, class Allocator = allocator > class __multi_associative; + +template class _UCXXEXPORT __base_associative{ + +protected: + +public: + typedef Key key_type; + typedef ValueType value_type; + typedef Compare key_compare; + typedef Allocator allocator_type; + typedef typename Allocator::reference reference; + typedef typename Allocator::const_reference const_reference; + typedef typename Allocator::size_type size_type; + typedef typename Allocator::difference_type difference_type; + typedef typename Allocator::pointer pointer; + typedef typename Allocator::const_pointer const_pointer; + typedef __base_associative associative_type; + + typedef _associative_iter iterator; + typedef _associative_citer const_iterator; + typedef typename std::reverse_iterator reverse_iterator; + typedef typename std::reverse_iterator const_reverse_iterator; + + + explicit __base_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) + : c(comp), value_to_key(v_to_k) { } +protected: + __base_associative(const associative_type& x) + : c(x.c), backing(x.backing), value_to_key(x.value_to_key) { } + +public: + ~__base_associative(){ + } + + bool empty() const{ + return backing.empty(); + } + size_type size() const{ + return backing.size(); + } + size_type max_size() const{ + return backing.max_size(); + } + + iterator begin(){ + return iterator(backing.begin()); + } + + const_iterator begin() const{ + return const_iterator(backing.begin()); + } + + iterator end() { + return iterator(backing.end()); + } + + const_iterator end() const{ + return const_iterator(backing.end()); + } + + reverse_iterator rbegin(){ + return reverse_iterator(end()); + } + + const_reverse_iterator rbegin() const{ + return const_reverse_iterator(end()); + } + + reverse_iterator rend(){ + return reverse_iterator(begin()); + } + + const_reverse_iterator rend() const{ + return const_reverse_iterator(begin()); + } + + + iterator lower_bound(const key_type &x); + const_iterator lower_bound(const key_type &x) const; + iterator upper_bound(const key_type &x); + const_iterator upper_bound(const key_type &x) const; + + pair equal_range(const key_type& x){ + pair retval; + retval.first = lower_bound(x); + retval.second = retval.first; + while(retval.second != end() && !c(x, value_to_key(*retval.second))){ + ++retval.second; + } + return retval; + } + pair equal_range(const key_type& x) const{ + pair retval; + retval.first = lower_bound(x); + retval.second = retval.first; + while(retval.second != end() && !c(x, value_to_key(*retval.second))){ + ++retval.second; + } + return retval; + } + + iterator find(const key_type& x){ + iterator retval = lower_bound(x); + if(retval == end()){ + return retval; + } + if(c(x, value_to_key(*retval))){ + return end(); + } + return retval; + } + const_iterator find(const key_type& x) const{ + const_iterator retval = lower_bound(x); + if(retval == end()){ + return retval; + } + if(c(x, value_to_key(*retval))){ + return end(); + } + return retval; + } + size_type count(const key_type& x) const{ + size_type retval(0); + const_iterator first = lower_bound(x); + while(first != end() && !c(x, value_to_key(*first))){ + ++retval; + ++first; + } + return retval; + } + + void clear(){ + backing.clear(); + } + + void erase(iterator pos){ + backing.erase(pos.base_iterator()); + } + size_type erase(const key_type& x){ + size_type count(0); + iterator start = lower_bound(x); + iterator end = upper_bound(x); + while(start != end){ + start = backing.erase(start.base_iterator()); + ++count; + } + return count; + } + void erase(iterator first, iterator last){ + while(first != last){ + backing.erase(first.base_iterator()); + ++first; + } + } + + key_compare key_comp() const{ + return c; + } + + __base_associative &operator=(const __base_associative & x){ + c = x.c; + backing = x.backing; + value_to_key = x.value_to_key; + return *this; + } + bool operator==(const __base_associative & x){ + return x.backing == backing; + } + bool operator!=(const __base_associative & x){ + return !(x.backing == backing); + } + +protected: + void swap(__base_associative & x); + + Compare c; + std::list backing; + + const key_type (*value_to_key)(const value_type); + +}; + + +/* + * Tree interators for the base associative class + */ + +template class _associative_citer + : public std::iterator< + bidirectional_iterator_tag, + ValueType, + typename Allocator::difference_type, + ValueType*, + ValueType& + > +{ +protected: + typedef std::list listtype; + + typename listtype::const_iterator base_iter; + friend class _associative_iter; +public: + _associative_citer() { } + _associative_citer(const _associative_citer & m) + : base_iter(m.base_iter) { } + _associative_citer(const typename listtype::const_iterator & m) + : base_iter(m) { } + ~_associative_citer() { } + ValueType operator*() const{ + return *base_iter; + } + const ValueType * operator->() const{ + return &(*base_iter); + } + _associative_citer & operator=(const _associative_citer & m){ + base_iter = m.base_iter; + return *this; + } + bool operator==(const _associative_citer & m) const{ + return m.base_iter == base_iter; + } + bool operator!=(const _associative_citer & m) const{ + return m.base_iter != base_iter; + } + _associative_citer & operator++(){ + ++base_iter; + return *this; + } + _associative_citer operator++(int){ + //The following approach ensures that we only need to + //provide code for ++ in one place (above) + _associative_citer temp(base_iter); + ++base_iter; + return temp; + } + _associative_citer & operator--(){ + --base_iter; + return *this; + } + _associative_citer operator--(int){ + //The following approach ensures that we only need to + //provide code for -- in one place (above) + _associative_citer temp(base_iter); + --base_iter; + return temp; + } + + //This is an implementation-defined function designed to make internals work correctly + typename listtype::const_iterator base_iterator(){ + return base_iter; + } + +}; + + +template class _associative_iter + : public std::iterator< + bidirectional_iterator_tag, + ValueType, + typename Allocator::difference_type, + ValueType*, + ValueType& + > +{ +protected: + typedef std::list listtype; + + typename listtype::iterator base_iter; + typedef _associative_citer _associative_citer; + + +public: + _associative_iter() { } + _associative_iter(const _associative_iter & m) + : base_iter(m.base_iter) { } + _associative_iter(const typename listtype::iterator & m) + : base_iter(m) { } + ~_associative_iter() { } + const ValueType & operator*() const{ + return *base_iter; + } + ValueType & operator*(){ + return *base_iter; + } + ValueType * operator->(){ + return &(*base_iter); + } + const ValueType * operator->() const{ + return &(*base_iter); + } + _associative_iter & operator=(const _associative_iter & m){ + base_iter = m.base_iter; + return *this; + } + bool operator==(const _associative_iter & m) const{ + return m.base_iter == base_iter; + } + bool operator==(const _associative_citer & m) const{ + return m.base_iter == base_iter; + } + bool operator!=(const _associative_iter & m) const{ + return m.base_iter != base_iter; + } + bool operator!=(const _associative_citer & m) const{ + return m.base_iter != base_iter; + } + _associative_iter & operator++(){ + ++base_iter; + return *this; + } + _associative_iter operator++(int){ + //The following approach ensures that we only need to + //provide code for ++ in one place (above) + _associative_iter temp(base_iter); + ++base_iter; + return temp; + } + _associative_iter & operator--(){ + --base_iter; + return *this; + } + _associative_iter operator--(int){ + //The following approach ensures that we only need to + //provide code for -- in one place (above) + _associative_iter temp(base_iter); + --base_iter; + return temp; + } + operator _associative_citer() const{ + return _associative_citer(base_iter); + } + typename listtype::iterator base_iterator(){ + return base_iter; + } + const typename listtype::iterator base_iterator() const{ + return base_iter; + } + +}; + + + // The lower_bound code is really crappy linear search. However, it is a dead + // simple implimentation (easy to audit). It can also be easily replaced. + + + template + typename __base_associative::iterator + __base_associative::lower_bound(const key_type &x) + { + iterator retval = begin(); + while(retval != end() && c(value_to_key(*retval), x)){ + ++retval; + } + return retval; + } + + template + typename __base_associative::const_iterator + __base_associative::lower_bound(const key_type &x) const + { + const_iterator retval = begin(); + while(retval != end() && c(value_to_key(*retval), x)){ + ++retval; + } + return retval; + } + + // Upper bound search is linear from the point of lower_bound. This is likely the best solution + // in all but the most pathalogical of cases. + + template + typename __base_associative::iterator + __base_associative::upper_bound(const key_type &x) + { + iterator retval = lower_bound(x); + while(retval != end() && !c(x, value_to_key(*retval))){ + ++retval; + } + return retval; + } + + template + typename __base_associative::const_iterator + __base_associative::upper_bound(const key_type &x) const + { + const_iterator retval = begin(); + while(retval != end() && !c(x, value_to_key(*retval))){ + ++retval; + } + return retval; + } + + + template + void __base_associative::swap(__base_associative& m) + { + Compare n = c; + c = m.c; + m.c = n; + + m.backing.swap(backing); + } + + +template class _UCXXEXPORT __single_associative : + public __base_associative +{ +protected: + typedef __base_associative base; + using base::backing; + + using base::c; + +public: + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + + using base::operator=; + using base::operator==; + using base::operator!=; + + explicit __single_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) + : base(comp, A, v_to_k) { } + + template __single_associative( + InputIterator first, + InputIterator last, + const Compare& comp, + const Allocator& A, + const key_type (*v_to_k)(const value_type) + ) : base(comp, A, v_to_k) { + insert(first, last); + } + + pair insert(const value_type& x){ + pair retval; + iterator location = lower_bound(value_to_key(x)); + retval.second = true; + //Empty list or need to insert at end + if(end() == location){ + backing.push_back(x); + retval.first = --(end()); + return retval; + } + //Something in the list + if(c(value_to_key(x), value_to_key(*location))){ + location = backing.insert(location.base_iterator(), x); + retval.first = location; + }else{ + retval.second = false; + retval.first = location; + } + return retval; + } + + iterator insert(iterator position, const value_type& x){ + // FIXME - this is cheeting and probably should be more efficient since we are + // now log(n) to find for inserts + return insert(x).first; + } + + template void insert(InputIterator first, InputIterator last){ + while(first != last){ + insert(*first); + ++first; + } + } + +}; + + +template class _UCXXEXPORT __multi_associative : + public __base_associative +{ +protected: + typedef __base_associative base; + using base::backing; + + using base::c; + +public: + typedef typename base::key_type key_type; + typedef typename base::value_type value_type; + typedef typename base::key_compare key_compare; + typedef typename base::allocator_type allocator_type; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reverse_iterator reverse_iterator; + typedef typename base::const_reverse_iterator const_reverse_iterator; + + using base::begin; + using base::end; + using base::rbegin; + using base::rend; + + using base::empty; + using base::size; + using base::max_size; + + using base::find; + using base::count; + using base::lower_bound; + using base::upper_bound; + using base::equal_range; + + using base::operator=; + using base::operator==; + + + explicit __multi_associative(const Compare& comp, const Allocator& A, const key_type (*v_to_k)(const value_type)) + : base(comp, A, v_to_k) { } + + template __multi_associative( + InputIterator first, + InputIterator last, + const Compare& comp, + const Allocator& A, + const key_type (*v_to_k)(const value_type) + ) : base(comp, A, v_to_k) { + insert(first, last); + } + + iterator insert(const value_type& x){ + iterator location = lower_bound(value_to_key(x)); + + if(location == begin()){ + backing.push_front(x); + location = begin(); + }else{ + location = backing.insert(location.base_iterator(), x); + } + return location; + } + + iterator insert(iterator position, const value_type& x){ + // FIXME - this is cheeting and probably should be more efficient since we are + // now log(n) to find for inserts + return insert(x); + } + + template void insert(InputIterator first, InputIterator last){ + while(first != last){ + insert(*first); + ++first; + } + } +}; + + + + +} + +#pragma GCC visibility pop + +#endif //__STD_HEADER_ASSOCIATIVE_BASE + + Index: branches/slice/i386/modules/uClibc++/include/cassert =================================================================== --- branches/slice/i386/modules/uClibc++/include/cassert (revision 0) +++ branches/slice/i386/modules/uClibc++/include/cassert (revision 727) @@ -0,0 +1,19 @@ +/* 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 Index: branches/slice/i386/modules/uClibc++/include/func_exception =================================================================== --- branches/slice/i386/modules/uClibc++/include/func_exception (revision 0) +++ branches/slice/i386/modules/uClibc++/include/func_exception (revision 727) @@ -0,0 +1,41 @@ +/* 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 + + +#ifndef HEADER_IMPLEMENTATION_FUNC_EXCEPTION +#define HEADER_IMPLEMENTATION_FUNC_EXCEPTION + +#pragma GCC visibility push(default) + +namespace std{ + + _UCXXEXPORT void __throw_bad_alloc(); + _UCXXEXPORT void __throw_out_of_range(const char * message = 0); + _UCXXEXPORT void __throw_overflow_error(const char * message = 0); + _UCXXEXPORT void __throw_length_error(const char * message = 0); + _UCXXEXPORT void __throw_invalid_argument(const char * message = 0); +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/string_iostream =================================================================== --- branches/slice/i386/modules/uClibc++/include/string_iostream (revision 0) +++ branches/slice/i386/modules/uClibc++/include/string_iostream (revision 727) @@ -0,0 +1,146 @@ +/* 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 + +#ifdef __UCLIBCXX_HAS_WCHAR__ +#include +#include +#endif + +#ifndef __HEADER_STD_STRING_IOSTREAM +#define __HEADER_STD_STRING_IOSTREAM 1 + +#pragma GCC visibility push(default) + +namespace std{ + + + +template _UCXXEXPORT basic_ostream& + operator<<(basic_ostream& os, const basic_string& str) +{ + return os.write(str.data(), str.length()); +} + +template _UCXXEXPORT basic_istream& + operator>>(basic_istream& is, basic_string& str) +{ + + typename basic_istream::sentry s(is); + if(s == false){ + return is; + } + + str.clear(); + + typename basic_istream::int_type c; + typename Allocator::size_type n = is.width(); + bool exitnow = false; + if(n == 0){ + n = str.max_size(); + } + +// //Clear out preliminary spaces first +// c = is.get(); +// while(isspace(c)){ +// c = is.get(); +// } +// +// is.putback(c); + + do{ + c = is.get(); + if(c == traits::eof() || isspace(c) || n == 0){ + is.putback(c); + exitnow = true; + }else{ + str.append(1, traits::to_char_type(c) ); + --n; + } + }while(exitnow == false); + return is; +} + +template _UCXXEXPORT basic_istream& + getline(basic_istream& is, basic_string& str, charT delim) +{ + typename basic_istream::sentry s(is); + if(s == false){ + return is; + } + + str.erase(); + + streamsize i = 0; + typename basic_istream::int_type c_i; + charT c; + unsigned int n = str.max_size(); + for(i=0;i _UCXXEXPORT basic_istream& + getline(basic_istream& is, basic_string& str) +{ + return getline(is, str, '\n'); +} + + +#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__ +#ifndef __UCLIBCXX_COMPILE_STRING__ + + +#ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ +template<> _UCXXEXPORT basic_istream >& operator>>( + basic_istream >& is, + basic_string, allocator >& str); +#endif + + +#ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ +template<> _UCXXEXPORT basic_ostream >& + operator<<(basic_ostream >& os, + const basic_string, std::allocator >& str); + +#endif + + +#endif +#endif + + +} + +#pragma GCC visibility pop + +#endif + Index: branches/slice/i386/modules/uClibc++/include/support =================================================================== --- branches/slice/i386/modules/uClibc++/include/support (revision 0) +++ branches/slice/i386/modules/uClibc++/include/support (revision 727) @@ -0,0 +1,167 @@ +/* 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 + +#ifndef HEADER_ULC_SUPPORT +#define HEADER_ULC_SUPPORT 1 + +using namespace std; + +//From C++ ABI spec +typedef enum { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 +} _Unwind_Reason_Code; + + +typedef void (*_Unwind_Exception_Cleanup_Fn) + (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc); + +//The following definitions were grabbed from the gcc implementation +typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); +typedef unsigned _Unwind_Word __attribute__((__mode__(__word__))); +typedef signed _Unwind_Sword __attribute__((__mode__(__word__))); +typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); +typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, struct _Unwind_Exception *); + +typedef int _Unwind_Action; +static const _Unwind_Action _UA_SEARCH_PHASE = 1; +static const _Unwind_Action _UA_CLEANUP_PHASE = 2; +static const _Unwind_Action _UA_HANDLER_FRAME = 4; +static const _Unwind_Action _UA_FORCE_UNWIND = 8; + +const _Unwind_Exception_Class __uclibcxx_exception_class = (((((((( + _Unwind_Exception_Class) 'u' << 8 | (_Unwind_Exception_Class) 'l') << 8 + | (_Unwind_Exception_Class) 'i') << 8 | (_Unwind_Exception_Class) 'b') << 8 + | (_Unwind_Exception_Class) 'C')<< 8 | (_Unwind_Exception_Class) '+') << 8 + | (_Unwind_Exception_Class) '+') << 8 | (_Unwind_Exception_Class) '\0'); + + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 +#define _UA_END_OF_STACK 16 + +struct _Unwind_Exception{ + _Unwind_Exception_Class exception_class; //Type of exception, eg ulibC++\0 + _Unwind_Exception_Cleanup_Fn exception_cleanup; //Destructor if from diff runtime + _Unwind_Word private_1; //Don't touch at all! + _Unwind_Word private_2; //Don't touch at all! +} __attribute__((__aligned__)); + + +//The following structure is system-dependent and defined by the compiler +//Thus it's definition was copied from the gcc 3.4.0 header files +struct _Unwind_Context; +//{ +// void *reg[DWARF_FRAME_REGISTERS+1]; +// void *cfa; +// void *ra; +// void *lsda; +// struct dwarf_eh_bases bases; +// _Unwind_Word args_size; +//}; + + + +_Unwind_Reason_Code _Unwind_RaiseException ( struct _Unwind_Exception *exception_object ); + +//_Unwind_ForcedUnwind + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) + (int version, _Unwind_Action actions, _Unwind_Exception_Class exceptionClass, + struct _Unwind_Exception *exceptionObject, + struct _Unwind_Context *context, void *stop_parameter ); + +_Unwind_Reason_Code _Unwind_ForcedUnwind ( + struct _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, + void *stop_parameter ); + +void _Unwind_Resume (struct _Unwind_Exception *exception_object); +void _Unwind_DeleteException (struct _Unwind_Exception *exception_object); + +_Unwind_Word _Unwind_GetGR (struct _Unwind_Context *context, int index); +void _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word); + +_Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *context); +void _Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr new_value); + +_Unwind_Ptr _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context); +_Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *context); + +_Unwind_Reason_Code (*__personality_routine) + (int version, //Should be 1 + _Unwind_Action actions, //Actions the routine will perform (bitmask) + _Unwind_Exception_Class exceptionClass, //Type of exception - vendor is high 4 bytes + struct _Unwind_Exception *exceptionObject, //Points to exception header + struct _Unwind_Context *context); //Unwinder state information + + +/*The following part is the Level II ABI which is required for compatability*/ +//This might be the only stuff that *I* need to implement + +struct __cxa_exception { + std::type_info *exceptionType; //Type of thrown exception + void (*exceptionDestructor) (void *); //Pointer to the destructor + unexpected_handler unexpectedHandler; //Unexpected handler to use + terminate_handler terminateHandler; //Terminate handle to use + __cxa_exception *nextException; //per thread linked list + + int handlerCount; //How many handlers have caught this + int handlerSwitchValue; + const char *actionRecord; + const char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; + + _Unwind_Exception unwindHeader; +}; + +struct __cxa_eh_globals { + __cxa_exception *caughtExceptions; + unsigned int uncaughtExceptions; +}; + +extern "C" __cxa_eh_globals *__cxa_get_globals(void); //Return ptr to the eh_globals object for current thread +extern "C" __cxa_eh_globals *__cxa_get_globals_fast(void); //Same as above, assumes that above called at least once + +extern "C" void *__cxa_allocate_exception(size_t thrown_size); //Allocate space for exception plus header +extern "C" void __cxa_free_exception(void *thrown_exception); //Free space allocated from the above + +extern "C" void __cxa_throw (void *thrown_exception, //This is the actual throw call +// std::type_info *tinfo, //Type of object + void * tinfo, //Type of object + void (*dest) (void *) ); //Pointer to destructor destroy object + + +#endif + + + Index: branches/slice/i386/modules/KernelPatcher/a.out =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/slice/i386/modules/KernelPatcher/kernel_patcher.h =================================================================== --- branches/slice/i386/modules/KernelPatcher/kernel_patcher.h (revision 726) +++ branches/slice/i386/modules/KernelPatcher/kernel_patcher.h (revision 727) @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2009 Evan Lojewski. All rights reserved. - * - */ - -#include -#include - -#ifndef __BOOT2_KERNEL_PATCHER_H -#define __BOOT2_KERNEL_PATCHER_H - -#define CPUID_MODEL_ANY 0x00 -#define CPUID_MODEL_UNKNOWN 0x01 - -#define CPUID_MODEL_YONAH 14 -#define CPUID_MODEL_MEROM 15 -#define CPUID_MODEL_PENRYN 23 -#define CPUID_MODEL_NEHALEM 26 -#define CPUID_MODEL_ATOM 28 -#define CPUID_MODEL_FIELDS 30 /* Lynnfield, Clarksfield, Jasper */ -#define CPUID_MODEL_DALES 31 /* Havendale, Auburndale */ -#define CPUID_MODEL_NEHALEM_EX 46 - -#define KERNEL_ANY 0x00 -#define KERNEL_64 0x01 -#define KERNEL_32 0x02 -#define KERNEL_ERR 0xFF - -typedef struct patchRoutine_t -{ - void(*patchRoutine)(void*); - int validArchs; - int validCpu; - struct patchRoutine_t* next; -} patchRoutine_t; - - -typedef struct kernSymbols_t -{ - char* symbol; - UInt64 addr; - struct kernSymbols_t* next; -} kernSymbols_t; - -kernSymbols_t* lookup_kernel_symbol(const char* name); -void register_kernel_symbol(int kernelType, const char* name); - -long long symbol_handler(char* symbolName, long long addr, char is64); -void patch_kernel(void* kernelData, void* arg2, void* arg3, void *arg4); -void register_kernel_patch(void* patch, int arch, int cpus); - -int locate_symbols(void* kernelData); - -int determineKernelArchitecture(void* kernelData); - -/* - * Internal patches provided by this module. - */ -void patch_cpuid_set_info_all(void* kernelData); -void patch_cpuid_set_info_32(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel); -void patch_cpuid_set_info_64(void* kernelData, UInt32 impersonateFamily, UInt8 impersonateModel); - -void patch_pmCPUExitHaltToOff(void* kernelData); -void patch_lapic_init(void* kernelData); -void patch_commpage_stuff_routine(void* kernelData); -void patch_lapic_configure(void* kernelData); -void patch_lapic_interrupt(void* kernelData); - -#endif /* !__BOOT2_KERNEL_PATCHER_H */ Index: branches/slice/i386/modules/Resolution/a.out =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: branches/slice/i386/modules/Resolution/edid.h =================================================================== --- branches/slice/i386/modules/Resolution/edid.h (revision 726) +++ branches/slice/i386/modules/Resolution/edid.h (revision 727) @@ -1,172 +0,0 @@ -/* - * edid.h - * - * - * Created by Evan Lojewski on 12/1/09. - * Copyright 2009. All rights reserved. - * - * Slice 2010 - */ -//#ifndef __EDID_H__ -//#define __EDID_H__ - - -#include "libsaio.h" - -#define EDID_BLOCK_SIZE 128 -#define EDID_V1_BLOCKS_TO_GO_OFFSET 126 -//Slice - some more info about EDID -#define EDID_LENGTH 0x80 -#define EDID_HEADER 0x00 -#define EDID_HEADER_END 0x07 - -#define ID_MANUFACTURER_NAME 0x08 -#define ID_MANUFACTURER_NAME_END 0x09 -#define ID_MODEL 0x0a - -#define ID_SERIAL_NUMBER 0x0c - -#define MANUFACTURE_WEEK 0x10 -#define MANUFACTURE_YEAR 0x11 - -#define EDID_STRUCT_VERSION 0x12 -#define EDID_STRUCT_REVISION 0x13 - -#define EDID_STRUCT_DISPLAY 0x14 - -#define DPMS_FLAGS 0x18 -#define ESTABLISHED_TIMING_1 0x23 -#define ESTABLISHED_TIMING_2 0x24 -#define MANUFACTURERS_TIMINGS 0x25 - -/* standard timings supported */ -#define STD_TIMING 8 -#define STD_TIMING_DESCRIPTION_SIZE 2 -#define STD_TIMING_DESCRIPTIONS_START 0x26 - -#define DETAILED_TIMING_DESCRIPTIONS_START 0x36 -#define DETAILED_TIMING_DESCRIPTION_SIZE 18 -#define NO_DETAILED_TIMING_DESCRIPTIONS 4 - -#define DETAILED_TIMING_DESCRIPTION_1 0x36 -#define DETAILED_TIMING_DESCRIPTION_2 0x48 -#define DETAILED_TIMING_DESCRIPTION_3 0x5a -#define DETAILED_TIMING_DESCRIPTION_4 0x6c - -#define DESCRIPTOR_DATA 5 - -#define UPPER_NIBBLE( x ) \ -(((128|64|32|16) & (x)) >> 4) - -#define LOWER_NIBBLE( x ) \ -((1|2|4|8) & (x)) - -#define COMBINE_HI_8LO( hi, lo ) \ -( (((unsigned)hi) << 8) | (unsigned)lo ) - -#define COMBINE_HI_4LO( hi, lo ) \ -( (((unsigned)hi) << 4) | (unsigned)lo ) - -#define PIXEL_CLOCK_LO (unsigned)block[ 0 ] -#define PIXEL_CLOCK_HI (unsigned)block[ 1 ] -#define PIXEL_CLOCK (COMBINE_HI_8LO( PIXEL_CLOCK_HI,PIXEL_CLOCK_LO )*10000) -#define H_ACTIVE_LO (unsigned)block[ 2 ] -#define H_BLANKING_LO (unsigned)block[ 3 ] -#define H_ACTIVE_HI UPPER_NIBBLE( (unsigned)block[ 4 ] ) -#define H_ACTIVE COMBINE_HI_8LO( H_ACTIVE_HI, H_ACTIVE_LO ) -#define H_BLANKING_HI LOWER_NIBBLE( (unsigned)block[ 4 ] ) -#define H_BLANKING COMBINE_HI_8LO( H_BLANKING_HI, H_BLANKING_LO ) - -#define V_ACTIVE_LO (unsigned)block[ 5 ] -#define V_BLANKING_LO (unsigned)block[ 6 ] -#define V_ACTIVE_HI UPPER_NIBBLE( (unsigned)block[ 7 ] ) -#define V_ACTIVE COMBINE_HI_8LO( V_ACTIVE_HI, V_ACTIVE_LO ) -#define V_BLANKING_HI LOWER_NIBBLE( (unsigned)block[ 7 ] ) -#define V_BLANKING COMBINE_HI_8LO( V_BLANKING_HI, V_BLANKING_LO ) - -#define H_SYNC_OFFSET_LO (unsigned)block[ 8 ] -#define H_SYNC_WIDTH_LO (unsigned)block[ 9 ] - -#define V_SYNC_OFFSET_LO UPPER_NIBBLE( (unsigned)block[ 10 ] ) -#define V_SYNC_WIDTH_LO LOWER_NIBBLE( (unsigned)block[ 10 ] ) - -#define V_SYNC_WIDTH_HI ((unsigned)block[ 11 ] & (1|2)) -#define V_SYNC_OFFSET_HI (((unsigned)block[ 11 ] & (4|8)) >> 2) - -#define H_SYNC_WIDTH_HI (((unsigned)block[ 11 ] & (16|32)) >> 4) -#define H_SYNC_OFFSET_HI (((unsigned)block[ 11 ] & (64|128)) >> 6) - -#define V_SYNC_WIDTH COMBINE_HI_4LO( V_SYNC_WIDTH_HI, V_SYNC_WIDTH_LO ) -#define V_SYNC_OFFSET COMBINE_HI_4LO( V_SYNC_OFFSET_HI, V_SYNC_OFFSET_LO ) - -#define H_SYNC_WIDTH COMBINE_HI_4LO( H_SYNC_WIDTH_HI, H_SYNC_WIDTH_LO ) -#define H_SYNC_OFFSET COMBINE_HI_4LO( H_SYNC_OFFSET_HI, H_SYNC_OFFSET_LO ) - -#define H_SIZE_LO (unsigned)block[ 12 ] -#define V_SIZE_LO (unsigned)block[ 13 ] - -#define H_SIZE_HI UPPER_NIBBLE( (unsigned)block[ 14 ] ) -#define V_SIZE_HI LOWER_NIBBLE( (unsigned)block[ 14 ] ) - -#define H_SIZE COMBINE_HI_8LO( H_SIZE_HI, H_SIZE_LO ) -#define V_SIZE COMBINE_HI_8LO( V_SIZE_HI, V_SIZE_LO ) - -#define H_BORDER (unsigned)block[ 15 ] -#define V_BORDER (unsigned)block[ 16 ] - -#define FLAGS (unsigned)block[ 17 ] - -#define INTERLACED (FLAGS&128) -#define SYNC_TYPE (FLAGS&3<<3) /* bits 4,3 */ -#define SYNC_SEPARATE (3<<3) -#define HSYNC_POSITIVE (FLAGS & 4) -#define VSYNC_POSITIVE (FLAGS & 2) - -#define V_MIN_RATE block[ 5 ] -#define V_MAX_RATE block[ 6 ] -#define H_MIN_RATE block[ 7 ] -#define H_MAX_RATE block[ 8 ] -#define MAX_PIXEL_CLOCK (((int)block[ 9 ]) * 10) -#define GTF_SUPPORT block[10] - -#define DPMS_ACTIVE_OFF (1 << 5) -#define DPMS_SUSPEND (1 << 6) -#define DPMS_STANDBY (1 << 7) - -struct EDID -{ - UInt8 header[8]; //0 - UInt8 vendorProduct[4]; //8 - UInt8 serialNumber[4]; //12 - UInt8 weekOfManufacture; //16 - UInt8 yearOfManufacture; //17 - UInt8 version; //18 - UInt8 revision; //19 - UInt8 displayParams[5]; //20 - UInt8 colorCharacteristics[10]; //25 - UInt8 establishedTimings[3]; //35 - UInt16 standardTimings[8]; //38 - UInt8 detailedTimings[72]; //54 - UInt8 extension; //126 - UInt8 checksum; //127 -}; - - -typedef struct _edid_mode { - unsigned short pixel_clock; - unsigned short h_active; - unsigned short h_blanking; - unsigned short v_active; - unsigned short v_blanking; - unsigned short h_sync_offset; - unsigned short h_sync_width; - unsigned short v_sync_offset; - unsigned short v_sync_width; -} edid_mode; - - -char* readEDID(); -void getResolution(UInt32* x, UInt32* y, UInt32* bp); -int fb_parse_edid(struct EDID *edid, edid_mode* var); - -//#endif \ No newline at end of file Index: branches/slice/i386/util/bdmesg.c =================================================================== --- branches/slice/i386/util/bdmesg.c (revision 726) +++ branches/slice/i386/util/bdmesg.c (revision 727) @@ -18,7 +18,7 @@ io_registry_entry_t root = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); if (!root) { - printf("IORegistryEntry \"IOService:/\" not found.\n"); + printf("IORegistryEntry \"IOIOService:/\" not found.\n"); return 0; } Index: branches/slice/i386/util/Makefile.old =================================================================== --- branches/slice/i386/util/Makefile.old (revision 0) +++ branches/slice/i386/util/Makefile.old (revision 727) @@ -0,0 +1,41 @@ +# +# Until I can remove the dependency on the appkit, +# we'll just keep the generated files in this directory +# and install them directly, rather than generating them again. +# + +DIR = util +include ../MakePaths.dir + +VPATH = $(OBJROOT):$(SYMROOT) + +INSTALLDIR = $(DSTROOT)/usr/standalone/i386 +LOCALBIN = $(DSTROOT)/usr/local/bin + +OPTIM = -Os -Oz +CFLAGS = $(RC_CFLAGS) $(OPTIM) -Wmost -Werror -g +LDFLAGS = +CFILES = machOconv.c +ALLSRC = $(CFILES) $(MFILES) $(HFILES) $(EXPORT_HFILES) + +PROGRAMS = machOconv bdmesg + +OUTFILES = $(PROGRAMS) + +DIRS_NEEDED = $(OBJROOT) $(SYMROOT) $(LANGDIR) + +all embedtheme optionrom: $(DIRS_NEEDED) $(PROGRAMS) + +machOconv: machOconv.o + @echo "\t[LD] $@" + @$(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $(SYMROOT)/$(@F) machOconv.o + +bdmesg: bdmesg.o + @echo "\t[LD] $@" + @$(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -mmacosx-version-min=10.5 -o $(SYMROOT)/$(@F) bdmesg.o + +include ../MakeInc.dir + +#dependencies +-include $(OBJROOT)/Makedep + Index: branches/slice/revision =================================================================== --- branches/slice/revision (revision 726) +++ branches/slice/revision (revision 727) @@ -1 +1 @@ -676:714 \ No newline at end of file +676:726 \ No newline at end of file Index: branches/slice/ChamMek/ChamMek.xcodeproj/slice.pbxuser =================================================================== --- branches/slice/ChamMek/ChamMek.xcodeproj/slice.pbxuser (revision 726) +++ branches/slice/ChamMek/ChamMek.xcodeproj/slice.pbxuser (revision 727) @@ -81,7 +81,7 @@ 16, 200, 50, - 445.20849609375, + 514.20849609375, ); PBXFileTableDataSourceColumnsKey = ( PBXSymbolsDataSource_SymbolTypeIconID, @@ -98,7 +98,7 @@ 20, 550, 20, - 48.16259765625, + 48, 43, 43, 20, @@ -114,44 +114,53 @@ PBXFileDataSource_Target_ColumnID, ); }; - PBXPerProjectTemplateStateSaveDate = 317745263; - PBXWorkspaceStateSaveDate = 317745263; + PBXPerProjectTemplateStateSaveDate = 318239850; + PBXWorkspaceStateSaveDate = 318239850; }; perUserProjectItems = { + 120DC73B12F5C87900345D09 /* PBXTextBookmark */ = 120DC73B12F5C87900345D09 /* PBXTextBookmark */; 120DFB1712BA3A4D00C7EAC8 /* PBXTextBookmark */ = 120DFB1712BA3A4D00C7EAC8 /* PBXTextBookmark */; 120DFB1812BA3A4D00C7EAC8 /* PBXTextBookmark */ = 120DFB1812BA3A4D00C7EAC8 /* PBXTextBookmark */; 120DFF6B12BA3BF500C7EAC8 /* PBXTextBookmark */ = 120DFF6B12BA3BF500C7EAC8 /* PBXTextBookmark */; - 12121ED112B261EA00207E55 /* PBXTextBookmark */ = 12121ED112B261EA00207E55 /* PBXTextBookmark */; + 12106C2B12F480E2008BA484 /* PBXTextBookmark */ = 12106C2B12F480E2008BA484 /* PBXTextBookmark */; + 121114BE12F591340029B6FC /* PBXTextBookmark */ = 121114BE12F591340029B6FC /* PBXTextBookmark */; 1216139E12B65BB50019961E /* PBXTextBookmark */ = 1216139E12B65BB50019961E /* PBXTextBookmark */; 121613FF12B65D970019961E /* PBXTextBookmark */ = 121613FF12B65D970019961E /* PBXTextBookmark */; + 1218381312F2EA3F007D1704 /* PBXTextBookmark */ = 1218381312F2EA3F007D1704 /* PBXTextBookmark */; + 1218381412F2EA3F007D1704 /* PBXTextBookmark */ = 1218381412F2EA3F007D1704 /* PBXTextBookmark */; + 1218381612F2EA3F007D1704 /* PBXTextBookmark */ = 1218381612F2EA3F007D1704 /* PBXTextBookmark */; + 1218381812F2EA3F007D1704 /* PBXTextBookmark */ = 1218381812F2EA3F007D1704 /* PBXTextBookmark */; + 1218381A12F2EA3F007D1704 /* PBXTextBookmark */ = 1218381A12F2EA3F007D1704 /* PBXTextBookmark */; 121FAA3512F051A200385F21 /* PBXTextBookmark */ = 121FAA3512F051A200385F21 /* PBXTextBookmark */; - 1223EF9012E5D63A0019EC66 /* PBXTextBookmark */ = 1223EF9012E5D63A0019EC66 /* PBXTextBookmark */; + 1220CE4112F2BFBF0045986D /* PBXTextBookmark */ = 1220CE4112F2BFBF0045986D /* PBXTextBookmark */; + 1220CE4212F2BFBF0045986D /* PBXTextBookmark */ = 1220CE4212F2BFBF0045986D /* PBXTextBookmark */; 122A869712EC5429004312F4 /* PBXTextBookmark */ = 122A869712EC5429004312F4 /* PBXTextBookmark */; 122A869812EC5429004312F4 /* PBXTextBookmark */ = 122A869812EC5429004312F4 /* PBXTextBookmark */; 122A86C612ECA817004312F4 /* PBXTextBookmark */ = 122A86C612ECA817004312F4 /* PBXTextBookmark */; - 12350DAB12F0697200F57D12 /* PBXTextBookmark */ = 12350DAB12F0697200F57D12 /* PBXTextBookmark */; - 12350DB012F0697600F57D12 /* PBXTextBookmark */ = 12350DB012F0697600F57D12 /* PBXTextBookmark */; - 12437EC112F059750081C569 /* PBXTextBookmark */ = 12437EC112F059750081C569 /* PBXTextBookmark */; - 1245162812F05DAA00E31980 /* PBXTextBookmark */ = 1245162812F05DAA00E31980 /* PBXTextBookmark */; + 122C56E012F2CB51005FE786 /* PBXTextBookmark */ = 122C56E012F2CB51005FE786 /* PBXTextBookmark */; + 122DBE3512F47E30003C7482 /* PBXTextBookmark */ = 122DBE3512F47E30003C7482 /* PBXTextBookmark */; + 12306DBE12F4AAEE000AAE98 /* PBXTextBookmark */ = 12306DBE12F4AAEE000AAE98 /* PBXTextBookmark */; 124C493212B8D846005AA276 /* PBXTextBookmark */ = 124C493212B8D846005AA276 /* PBXTextBookmark */; 124C493712B8D846005AA276 /* PBXTextBookmark */ = 124C493712B8D846005AA276 /* PBXTextBookmark */; 124C494212B8E8C2005AA276 /* PBXTextBookmark */ = 124C494212B8E8C2005AA276 /* PBXTextBookmark */; 124C494312B8E8C2005AA276 /* PBXTextBookmark */ = 124C494312B8E8C2005AA276 /* PBXTextBookmark */; 124C494512B8E8C2005AA276 /* PBXTextBookmark */ = 124C494512B8E8C2005AA276 /* PBXTextBookmark */; 124C494B12B8EA5D005AA276 /* PBXTextBookmark */ = 124C494B12B8EA5D005AA276 /* PBXTextBookmark */; - 1253557A12F066F8009BC838 /* PBXTextBookmark */ = 1253557A12F066F8009BC838 /* PBXTextBookmark */; 125437C812EF1E99007175C8 /* PBXTextBookmark */ = 125437C812EF1E99007175C8 /* PBXTextBookmark */; - 125437CA12EF1E99007175C8 /* PBXTextBookmark */ = 125437CA12EF1E99007175C8 /* PBXTextBookmark */; 125437CB12EF1E99007175C8 /* PBXTextBookmark */ = 125437CB12EF1E99007175C8 /* PBXTextBookmark */; 12569C8612F0115B005A9113 /* PBXTextBookmark */ = 12569C8612F0115B005A9113 /* PBXTextBookmark */; - 1265C97712C7554E0050D02E /* PBXTextBookmark */ = 1265C97712C7554E0050D02E /* PBXTextBookmark */; + 125A6C2512F53BCD00535D65 /* PBXTextBookmark */ = 125A6C2512F53BCD00535D65 /* PBXTextBookmark */; 1267813012B7B13E00A25CED /* PBXTextBookmark */ = 1267813012B7B13E00A25CED /* PBXTextBookmark */; 12679BA312BE822E00E3637F /* PBXTextBookmark */ = 12679BA312BE822E00E3637F /* PBXTextBookmark */; + 1267A85B12F5771100751FC6 /* PBXTextBookmark */ = 1267A85B12F5771100751FC6 /* PBXTextBookmark */; + 1267A85C12F5771100751FC6 /* PBXTextBookmark */ = 1267A85C12F5771100751FC6 /* PBXTextBookmark */; 126C766312EEF67F00BDB81E /* PBXTextBookmark */ = 126C766312EEF67F00BDB81E /* PBXTextBookmark */; + 126D84C612F7FA6E000AB776 /* PBXTextBookmark */ = 126D84C612F7FA6E000AB776 /* PBXTextBookmark */; + 126D84C712F7FA6E000AB776 /* PBXTextBookmark */ = 126D84C712F7FA6E000AB776 /* PBXTextBookmark */; + 126D84C912F7FA6E000AB776 /* PBXTextBookmark */ = 126D84C912F7FA6E000AB776 /* PBXTextBookmark */; 12715CDF12EA253100E3013B /* PBXTextBookmark */ = 12715CDF12EA253100E3013B /* PBXTextBookmark */; 12715CE012EA253100E3013B /* PBXTextBookmark */ = 12715CE012EA253100E3013B /* PBXTextBookmark */; 1288318212C3608100EA4CB2 /* PBXTextBookmark */ = 1288318212C3608100EA4CB2 /* PBXTextBookmark */; - 128A97B812C2336000600556 /* PBXTextBookmark */ = 128A97B812C2336000600556 /* PBXTextBookmark */; 128A9AF412C233CE00600556 /* PBXTextBookmark */ = 128A9AF412C233CE00600556 /* PBXTextBookmark */; 1299A51F12B3C328007ED516 /* PBXTextBookmark */ = 1299A51F12B3C328007ED516 /* PBXTextBookmark */; 1299A55612B3C4DF007ED516 /* PBXTextBookmark */ = 1299A55612B3C4DF007ED516 /* PBXTextBookmark */; @@ -187,9 +196,13 @@ 12D6232512BA5F380032F367 /* PBXTextBookmark */ = 12D6232512BA5F380032F367 /* PBXTextBookmark */; 12D6232612BA5F380032F367 /* PBXTextBookmark */ = 12D6232612BA5F380032F367 /* PBXTextBookmark */; 12D64B9F12D8EA0A00A1FE07 /* PBXTextBookmark */ = 12D64B9F12D8EA0A00A1FE07 /* PBXTextBookmark */; - 12D7EC0512C8C5EA0021414C /* PBXTextBookmark */ = 12D7EC0512C8C5EA0021414C /* PBXTextBookmark */; 12DA422F12C52DAC009281B3 /* PBXTextBookmark */ = 12DA422F12C52DAC009281B3 /* PBXTextBookmark */; 12DCD38E12BBA5D600A20635 /* PBXTextBookmark */ = 12DCD38E12BBA5D600A20635 /* PBXTextBookmark */; + 12DFBB1C12F6E9A500E2DA49 /* PBXTextBookmark */ = 12DFBB1C12F6E9A500E2DA49 /* PBXTextBookmark */; + 12DFBB1D12F6E9A500E2DA49 /* PBXTextBookmark */ = 12DFBB1D12F6E9A500E2DA49 /* PBXTextBookmark */; + 12DFBB1F12F6E9A500E2DA49 /* PBXTextBookmark */ = 12DFBB1F12F6E9A500E2DA49 /* PBXTextBookmark */; + 12DFBB2112F6E9A500E2DA49 /* PBXTextBookmark */ = 12DFBB2112F6E9A500E2DA49 /* PBXTextBookmark */; + 12DFBFDA12F7066500E2DA49 /* PBXTextBookmark */ = 12DFBFDA12F7066500E2DA49 /* PBXTextBookmark */; 12E17AE612B2BA9B00607D8E /* PBXTextBookmark */ = 12E17AE612B2BA9B00607D8E /* PBXTextBookmark */; 12E6FB5712BB458400C2A021 /* PBXTextBookmark */ = 12E6FB5712BB458400C2A021 /* PBXTextBookmark */; 12E8842612D8F833004C76C8 /* PBXTextBookmark */ = 12E8842612D8F833004C76C8 /* PBXTextBookmark */; @@ -197,7 +210,6 @@ 12EFE2FD12B51ED5002A1712 /* PBXTextBookmark */ = 12EFE2FD12B51ED5002A1712 /* PBXTextBookmark */; 12EFE65A12B547A7002A1712 /* PBXTextBookmark */ = 12EFE65A12B547A7002A1712 /* PBXTextBookmark */; 12EFE95E12B549B6002A1712 /* PBXTextBookmark */ = 12EFE95E12B549B6002A1712 /* PBXTextBookmark */; - 12F1147112C7A41D0064D7EE /* PBXTextBookmark */ = 12F1147112C7A41D0064D7EE /* PBXTextBookmark */; 12F7FF0012BB9F3200949DEC /* PBXTextBookmark */ = 12F7FF0012BB9F3200949DEC /* PBXTextBookmark */; 12FC0E7512BB4B5200E9CFA8 /* PBXTextBookmark */ = 12FC0E7512BB4B5200E9CFA8 /* PBXTextBookmark */; 12FC0E9412BB65A800E9CFA8 /* PBXTextBookmark */ = 12FC0E9412BB65A800E9CFA8 /* PBXTextBookmark */; @@ -212,7 +224,7 @@ }; 08FB7796FE84155DC02AAC07 /* main.c */ = { uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {903, 304}}"; + sepNavIntBoundsRect = "{{0, 0}, {752, 331}}"; sepNavSelRange = "{192, 7}"; sepNavVisRange = "{0, 235}"; }; @@ -238,6 +250,16 @@ path = /Users/slice/Projects/fakesmc/Chameleon/RC5m/i386/boot2/boot.c; sourceTree = ""; }; + 120DC73B12F5C87900345D09 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 12164AF212F5C31400CB43B3 /* Makefile */; + name = "Makefile: 4"; + rLen = 6; + rLoc = 105; + rType = 0; + vrLen = 798; + vrLoc = 0; + }; 120DFB0A12BA3A3900C7EAC8 /* Localizable.strings */ = { isa = PBXFileReference; lastKnownFileType = text.plist.strings; @@ -289,6 +311,26 @@ path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/CHANGES; sourceTree = ""; }; + 12106C2B12F480E2008BA484 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 122DBE3A12F47E30003C7482 /* stringTable.c */; + name = "stringTable.c: 602"; + rLen = 12; + rLoc = 11991; + rType = 0; + vrLen = 470; + vrLoc = 11606; + }; + 121114BE12F591340029B6FC /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1267A85F12F5771100751FC6 /* GUI_module.c */; + name = "GUI_module.c: 150"; + rLen = 6; + rLoc = 3652; + rType = 0; + vrLen = 747; + vrLoc = 3433; + }; 121217CC12EEF2550055AF66 /* options.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; @@ -296,16 +338,6 @@ path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/options.c; sourceTree = ""; }; - 12121ED112B261EA00207E55 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 12C26F9A12B0E98200AF7F4B /* kernel_patcher.h */; - name = "kernel_patcher.h: 19"; - rLen = 4; - rLoc = 393; - rType = 0; - vrLen = 468; - vrLoc = 0; - }; 1216139E12B65BB50019961E /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12CF89A712B6410100B7BC73 /* pci_setup.c */; @@ -333,6 +365,98 @@ vrLen = 895; vrLoc = 563; }; + 12164AF212F5C31400CB43B3 /* Makefile */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.make; + name = Makefile; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/Makefile; + sourceTree = ""; + }; + 1218381312F2EA3F007D1704 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 122C56E412F2CB51005FE786 /* Memory.c */; + name = "Memory.c: 61"; + rLen = 13; + rLoc = 1338; + rType = 0; + vrLen = 758; + vrLoc = 1080; + }; + 1218381412F2EA3F007D1704 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1218381512F2EA3F007D1704 /* __udivsi3.c */; + name = "__udivsi3.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 234; + vrLoc = 0; + }; + 1218381512F2EA3F007D1704 /* __udivsi3.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = __udivsi3.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/klibc/__udivsi3.c; + sourceTree = ""; + }; + 1218381612F2EA3F007D1704 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1218381712F2EA3F007D1704 /* __udivmodsi4.c */; + name = "__udivmodsi4.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 485; + vrLoc = 0; + }; + 1218381712F2EA3F007D1704 /* __udivmodsi4.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = __udivmodsi4.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/klibc/__udivmodsi4.c; + sourceTree = ""; + }; + 1218381812F2EA3F007D1704 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1218381912F2EA3F007D1704 /* uClibc++.c */; + name = "uClibc++.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 97; + vrLoc = 0; + }; + 1218381912F2EA3F007D1704 /* uClibc++.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = "uClibc++.c"; + path = "/Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/uClibc++/uClibc++.c"; + sourceTree = ""; + }; + 1218381A12F2EA3F007D1704 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1218381B12F2EA3F007D1704 /* Makefile */; + name = "Makefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1158; + vrLoc = 0; + }; + 1218381B12F2EA3F007D1704 /* Makefile */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.make; + name = Makefile; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/klibc/Makefile; + sourceTree = ""; + }; + 121B17F412F2C5DF00259614 /* platform.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = platform.h; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/libsaio/platform.h; + sourceTree = ""; + }; 121E3B3D12F04EB9007B7E08 /* gui.h */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; @@ -364,28 +488,38 @@ vrLen = 887; vrLoc = 2270; }; - 121FAA3B12F051A200385F21 /* graphics.c */ = { + 1220CE3912F2BF1C0045986D /* dram_controllers.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; - name = graphics.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/graphics.c; + name = dram_controllers.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/Memory/dram_controllers.c; sourceTree = ""; }; - 1223EF9012E5D63A0019EC66 /* PBXTextBookmark */ = { + 1220CE4112F2BFBF0045986D /* PBXTextBookmark */ = { isa = PBXTextBookmark; - fRef = 1223EF9112E5D63A0019EC66 /* stringTable.c */; - name = "stringTable.c: 199"; - rLen = 14; - rLoc = 3922; + fRef = 1220CE3912F2BF1C0045986D /* dram_controllers.c */; + name = "dram_controllers.c: 162"; + rLen = 13; + rLoc = 3575; rType = 0; - vrLen = 594; - vrLoc = 3596; + vrLen = 629; + vrLoc = 3268; }; - 1223EF9112E5D63A0019EC66 /* stringTable.c */ = { + 1220CE4212F2BFBF0045986D /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1220CE4312F2BFBF0045986D /* mem.c */; + name = "mem.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 508; + vrLoc = 0; + }; + 1220CE4312F2BFBF0045986D /* mem.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; - name = stringTable.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/libsaio/stringTable.c; + name = mem.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/Memory/mem.c; sourceTree = ""; }; 122A869012EC534F004312F4 /* ext2fs.c */ = { @@ -439,77 +573,64 @@ vrLen = 528; vrLoc = 4718; }; - 12350DAB12F0697200F57D12 /* PBXTextBookmark */ = { + 122C56E012F2CB51005FE786 /* PBXTextBookmark */ = { isa = PBXTextBookmark; - fRef = 12350DAC12F0697200F57D12 /* gui.c */; - rLen = 6; - rLoc = 22021; + fRef = 121B17F412F2C5DF00259614 /* platform.h */; + name = "platform.h: 89"; + rLen = 0; + rLoc = 2826; rType = 0; + vrLen = 902; + vrLoc = 2408; }; - 12350DAC12F0697200F57D12 /* gui.c */ = { + 122C56E412F2CB51005FE786 /* Memory.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; - name = gui.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/gui.c; + name = Memory.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/Memory/Memory.c; sourceTree = ""; }; - 12350DB012F0697600F57D12 /* PBXTextBookmark */ = { + 122DBE3512F47E30003C7482 /* PBXTextBookmark */ = { isa = PBXTextBookmark; - fRef = 12350DB112F0697600F57D12 /* gui.c */; - name = "gui.c: 731"; - rLen = 6; - rLoc = 22021; + fRef = 125332B012F4563000937C5D /* usb.c */; + name = "usb.c: 379"; + rLen = 0; + rLoc = 10512; rType = 0; - vrLen = 872; - vrLoc = 21569; + vrLen = 860; + vrLoc = 9952; }; - 12350DB112F0697600F57D12 /* gui.c */ = { + 122DBE3A12F47E30003C7482 /* stringTable.c */ = { isa = PBXFileReference; - name = gui.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/gui.c; + lastKnownFileType = sourcecode.c.c; + name = stringTable.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/libsaio/stringTable.c; sourceTree = ""; }; - 123C5F9112C8AB2C00DFC2D4 /* edid.h */ = { + 12306DB512F4A734000AAE98 /* Symbols.h */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; - name = edid.h; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/Resolution/edid.h; + name = Symbols.h; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/sym/i386/Symbols.h; sourceTree = ""; }; - 12437EC112F059750081C569 /* PBXTextBookmark */ = { + 12306DBE12F4AAEE000AAE98 /* PBXTextBookmark */ = { isa = PBXTextBookmark; - fRef = 121FAA3B12F051A200385F21 /* graphics.c */; - name = "graphics.c: 633"; - rLen = 10; - rLoc = 17982; + fRef = 12306DB512F4A734000AAE98 /* Symbols.h */; + name = "Symbols.h: 698"; + rLen = 8; + rLoc = 38634; rType = 0; - vrLen = 958; - vrLoc = 17553; + vrLen = 1295; + vrLoc = 37954; }; - 12437EC412F059750081C569 /* boot.c */ = { + 1230722412F4BC2E000AAE98 /* bootstruct.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; - name = boot.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/boot.c; + name = bootstruct.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/libsaio/bootstruct.c; sourceTree = ""; }; - 1245162812F05DAA00E31980 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 12437EC412F059750081C569 /* boot.c */; - name = "boot.c: 66"; - rLen = 0; - rLoc = 2077; - rType = 0; - vrLen = 551; - vrLoc = 1826; - }; - 1245162C12F05DAA00E31980 /* GUI_module.c */ = { - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - name = GUI_module.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/GUI_module.c; - sourceTree = ""; - }; 124C492812B8C915005AA276 /* Memory.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; @@ -612,15 +733,12 @@ vrLen = 554; vrLoc = 5486; }; - 1253557A12F066F8009BC838 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 1245162C12F05DAA00E31980 /* GUI_module.c */; - name = "GUI_module.c: 125"; - rLen = 7; - rLoc = 2921; - rType = 0; - vrLen = 834; - vrLoc = 2699; + 125332B012F4563000937C5D /* usb.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = usb.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/USBFix/usb.c; + sourceTree = ""; }; 125437C812EF1E99007175C8 /* PBXTextBookmark */ = { isa = PBXTextBookmark; @@ -639,16 +757,6 @@ path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/HPET/HPET.c; sourceTree = ""; }; - 125437CA12EF1E99007175C8 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 126C766512EEF67F00BDB81E /* Memory.c */; - name = "Memory.c: 37"; - rLen = 11; - rLoc = 726; - rType = 0; - vrLen = 835; - vrLoc = 393; - }; 125437CB12EF1E99007175C8 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 125437CC12EF1E99007175C8 /* modules.h */; @@ -676,30 +784,16 @@ vrLen = 1670; vrLoc = 0; }; - 1265C97712C7554E0050D02E /* PBXTextBookmark */ = { + 125A6C2512F53BCD00535D65 /* PBXTextBookmark */ = { isa = PBXTextBookmark; - fRef = 1265C97812C7554E0050D02E /* basic_definitions */; - name = "basic_definitions: 1"; - rLen = 0; - rLoc = 0; + fRef = 1230722412F4BC2E000AAE98 /* bootstruct.c */; + name = "bootstruct.c: 38"; + rLen = 29; + rLoc = 1346; rType = 0; - vrLen = 366; - vrLoc = 1283; + vrLen = 750; + vrLoc = 1047; }; - 1265C97812C7554E0050D02E /* basic_definitions */ = { - isa = PBXFileReference; - lastKnownFileType = text; - name = basic_definitions; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/include/basic_definitions; - sourceTree = ""; - }; - 1265D11B12C778D90050D02E /* bitset */ = { - isa = PBXFileReference; - lastKnownFileType = text; - name = bitset; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/include/bitset; - sourceTree = ""; - }; 1267813012B7B13E00A25CED /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12B46E6D12B75631006C2B9C /* smbios_patcher.h */; @@ -720,6 +814,47 @@ vrLen = 894; vrLoc = 14871; }; + 1267A85112F574E500751FC6 /* modules.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = modules.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/modules.c; + sourceTree = ""; + }; + 1267A85612F576AA00751FC6 /* ATIEnabler.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = ATIEnabler.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/ATI5000Enabler/ATIEnabler.c; + sourceTree = ""; + }; + 1267A85B12F5771100751FC6 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1267A85612F576AA00751FC6 /* ATIEnabler.c */; + name = "ATIEnabler.c: 22"; + rLen = 5; + rLoc = 428; + rType = 0; + vrLen = 597; + vrLoc = 0; + }; + 1267A85C12F5771100751FC6 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 1267A85112F574E500751FC6 /* modules.c */; + name = "modules.c: 80"; + rLen = 15; + rLoc = 1931; + rType = 0; + vrLen = 804; + vrLoc = 1636; + }; + 1267A85F12F5771100751FC6 /* GUI_module.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = GUI_module.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/GUI_module.c; + sourceTree = ""; + }; 126C766312EEF67F00BDB81E /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 121217CC12EEF2550055AF66 /* options.c */; @@ -730,13 +865,46 @@ vrLen = 1190; vrLoc = 24206; }; - 126C766512EEF67F00BDB81E /* Memory.c */ = { + 126D84C612F7FA6E000AB776 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 12DFBFDE12F7066500E2DA49 /* boot0.s */; + name = "boot0.s: 784"; + rLen = 0; + rLoc = 22464; + rType = 0; + vrLen = 761; + vrLoc = 22651; + }; + 126D84C712F7FA6E000AB776 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 126D84C812F7FA6E000AB776 /* gui.c */; + rLen = 13; + rLoc = 22523; + rType = 0; + }; + 126D84C812F7FA6E000AB776 /* gui.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; - name = Memory.c; - path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/Memory/Memory.c; + name = gui.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/gui.c; sourceTree = ""; }; + 126D84C912F7FA6E000AB776 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 126D84CA12F7FA6E000AB776 /* gui.c */; + name = "gui.c: 745"; + rLen = 13; + rLoc = 22523; + rType = 0; + vrLen = 1319; + vrLoc = 21985; + }; + 126D84CA12F7FA6E000AB776 /* gui.c */ = { + isa = PBXFileReference; + name = gui.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/GUI/gui.c; + sourceTree = ""; + }; 1271587B12EA1C6400E3013B /* ntfs.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; @@ -774,16 +942,6 @@ vrLen = 858; vrLoc = 0; }; - 128A97B812C2336000600556 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 08FB7796FE84155DC02AAC07 /* main.c */; - name = "main.c: 10"; - rLen = 7; - rLoc = 192; - rType = 0; - vrLen = 235; - vrLoc = 0; - }; 128A97BC12C2336000600556 /* USBFix.c */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; @@ -1159,13 +1317,6 @@ isa = PBXCodeSenseManager; indexTemplatePath = ""; }; - 12C26F9A12B0E98200AF7F4B /* kernel_patcher.h */ = { - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.h; - name = kernel_patcher.h; - path = /Users/slice/Projects/Chameleons/chameleon/branches/meklort/i386/modules/KernelPatcher/kernel_patcher.h; - sourceTree = ""; - }; 12C5020712D8B82400EDCC4E /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12D52EA712D7377E00A23AEF /* resume.c */; @@ -1436,16 +1587,6 @@ vrLen = 1864; vrLoc = 8297; }; - 12D7EC0512C8C5EA0021414C /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 123C5F9112C8AB2C00DFC2D4 /* edid.h */; - name = "edid.h: 170"; - rLen = 13; - rLoc = 5294; - rType = 0; - vrLen = 691; - vrLoc = 4662; - }; 12D928BE12C7C8EB00269820 /* Makefile */ = { isa = PBXFileReference; lastKnownFileType = sourcecode.make; @@ -1487,6 +1628,96 @@ vrLen = 1189; vrLoc = 0; }; + 12DFBB1C12F6E9A500E2DA49 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 08FB7796FE84155DC02AAC07 /* main.c */; + name = "main.c: 10"; + rLen = 7; + rLoc = 192; + rType = 0; + vrLen = 235; + vrLoc = 0; + }; + 12DFBB1D12F6E9A500E2DA49 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 12DFBB1E12F6E9A500E2DA49 /* acpi.h */; + name = "acpi.h: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 634; + vrLoc = 0; + }; + 12DFBB1E12F6E9A500E2DA49 /* acpi.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = acpi.h; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/libsaio/acpi.h; + sourceTree = ""; + }; + 12DFBB1F12F6E9A500E2DA49 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 12DFBB2012F6E9A500E2DA49 /* kext_patcher.c */; + name = "kext_patcher.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 831; + vrLoc = 4232; + }; + 12DFBB2012F6E9A500E2DA49 /* kext_patcher.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = kext_patcher.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/KextPatcher/kext_patcher.c; + sourceTree = ""; + }; + 12DFBB2112F6E9A500E2DA49 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 12DFBB2212F6E9A500E2DA49 /* boot.h */; + name = "boot.h: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 617; + vrLoc = 7802; + }; + 12DFBB2212F6E9A500E2DA49 /* boot.h */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = boot.h; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/boot.h; + sourceTree = ""; + }; + 12DFBFD412F7016200E2DA49 /* boot.c */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = boot.c; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot2/boot.c; + sourceTree = ""; + }; + 12DFBFDA12F7066500E2DA49 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 12DFBFD412F7016200E2DA49 /* boot.c */; + name = "boot.c: 327"; + rLen = 9; + rLoc = 9603; + rType = 0; + vrLen = 772; + vrLoc = 9218; + }; + 12DFBFDE12F7066500E2DA49 /* boot0.s */ = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.asm; + name = boot0.s; + path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/boot0/boot0.s; + sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {752, 11219}}"; + sepNavSelRange = "{22464, 0}"; + sepNavVisRange = "{22651, 761}"; + }; + }; 12E17AE612B2BA9B00607D8E /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12B90A5712B2AE1300FE287A /* 915resolution.h */; @@ -1613,16 +1844,6 @@ path = /Users/slice/Projects/fakesmc/Chameleon/RC5m/i386/libsaio/pci_root.c; sourceTree = ""; }; - 12F1147112C7A41D0064D7EE /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 1265D11B12C778D90050D02E /* bitset */; - name = "bitset: 1"; - rLen = 0; - rLoc = 0; - rType = 0; - vrLen = 991; - vrLoc = 0; - }; 12F7FF0012BB9F3200949DEC /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12FC25E812BB825300E9CFA8 /* drivers.c */; @@ -1707,13 +1928,18 @@ name = 915resolution.c; path = /Users/slice/Projects/Chameleons/chameleon/branches/slice/i386/modules/Resolution/915resolution.c; sourceTree = ""; + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1048, 10751}}"; + sepNavSelRange = "{13812, 8}"; + sepNavVisRange = "{20341, 1044}"; + }; }; 12FE987912C7E281001B1702 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = 12FE985E12C7E1F7001B1702 /* 915resolution.c */; name = "915resolution.c: 419"; rLen = 0; - rLoc = 8937; + rLoc = 8936; rType = 0; vrLen = 670; vrLoc = 2670; Index: branches/slice/ChamMek/ChamMek.xcodeproj/slice.mode1v3 =================================================================== --- branches/slice/ChamMek/ChamMek.xcodeproj/slice.mode1v3 (revision 726) +++ branches/slice/ChamMek/ChamMek.xcodeproj/slice.mode1v3 (revision 727) @@ -269,12 +269,16 @@ 08FB7794FE84155DC02AAC07 08FB7795FE84155DC02AAC07 12C26D3912B0DE0A00AF7F4B + 126D803012F7F46A000AB776 1C37FABC05509CD000000102 PBXSmartGroupTreeModuleOutlineStateSelectionKey - 28 + 33 + 2 + 1 + 0 PBXSmartGroupTreeModuleOutlineStateVisibleRectKey @@ -299,7 +303,7 @@ 164 RubberWindowFrame - 257 172 1021 706 0 0 1440 878 + 364 171 1021 706 0 0 1440 878 Module PBXSmartGroupTreeModule @@ -329,10 +333,9 @@ _historyCapacity 0 bookmark - 12350DB012F0697600F57D12 + 126D84C912F7FA6E000AB776 history - 12121ED112B261EA00207E55 12B9F42612B29A4A00FE287A 12B90A2012B2A7E200FE287A 12B90A2B12B2A86B00FE287A @@ -381,7 +384,6 @@ 12F7FF0012BB9F3200949DEC 12DCD38E12BBA5D600A20635 12679BA312BE822E00E3637F - 128A97B812C2336000600556 128A9AF412C233CE00600556 1288318212C3608100EA4CB2 12DA422F12C52DAC009281B3 @@ -391,18 +393,14 @@ 12D3329E12C669090093EEDB 12D332A512C669090093EEDB 12D332AA12C669090093EEDB - 1265C97712C7554E0050D02E - 12F1147112C7A41D0064D7EE 12FE983612C7CEEB001B1702 12FE984A12C7E11C001B1702 12FE987912C7E281001B1702 12FE987A12C7E281001B1702 12C246F412C87C7C007E8339 - 12D7EC0512C8C5EA0021414C 12C5020712D8B82400EDCC4E 12D64B9F12D8EA0A00A1FE07 12E8842612D8F833004C76C8 - 1223EF9012E5D63A0019EC66 12715CDF12EA253100E3013B 12715CE012EA253100E3013B 122A869712EC5429004312F4 @@ -410,14 +408,32 @@ 122A86C612ECA817004312F4 126C766312EEF67F00BDB81E 125437C812EF1E99007175C8 - 125437CA12EF1E99007175C8 125437CB12EF1E99007175C8 12569C8612F0115B005A9113 121FAA3512F051A200385F21 - 12437EC112F059750081C569 - 1245162812F05DAA00E31980 - 1253557A12F066F8009BC838 - 12350DAB12F0697200F57D12 + 1220CE4112F2BFBF0045986D + 1220CE4212F2BFBF0045986D + 122C56E012F2CB51005FE786 + 1218381312F2EA3F007D1704 + 1218381412F2EA3F007D1704 + 1218381612F2EA3F007D1704 + 1218381812F2EA3F007D1704 + 1218381A12F2EA3F007D1704 + 122DBE3512F47E30003C7482 + 12106C2B12F480E2008BA484 + 12306DBE12F4AAEE000AAE98 + 125A6C2512F53BCD00535D65 + 1267A85B12F5771100751FC6 + 1267A85C12F5771100751FC6 + 121114BE12F591340029B6FC + 120DC73B12F5C87900345D09 + 12DFBB1C12F6E9A500E2DA49 + 12DFBB1D12F6E9A500E2DA49 + 12DFBB1F12F6E9A500E2DA49 + 12DFBB2112F6E9A500E2DA49 + 12DFBFDA12F7066500E2DA49 + 126D84C612F7FA6E000AB776 + 126D84C712F7FA6E000AB776 SplitCount @@ -429,14 +445,14 @@ GeometryConfiguration Frame - {{0, 0}, {813, 386}} + {{0, 0}, {813, 502}} RubberWindowFrame - 257 172 1021 706 0 0 1440 878 + 364 171 1021 706 0 0 1440 878 Module PBXNavigatorGroup Proportion - 386pt + 502pt ContentConfiguration @@ -449,14 +465,14 @@ GeometryConfiguration Frame - {{0, 391}, {813, 274}} + {{0, 507}, {813, 158}} RubberWindowFrame - 257 172 1021 706 0 0 1440 878 + 364 171 1021 706 0 0 1440 878 Module XCDetailModule Proportion - 274pt + 158pt Proportion @@ -475,9 +491,9 @@ TableOfContents - 12350DB212F0697600F57D12 + 126D84CB12F7FA6E000AB776 1CE0B1FE06471DED0097A5F4 - 12350DB312F0697600F57D12 + 126D84CC12F7FA6E000AB776 1CE0B20306471E060097A5F4 1CE0B20506471E060097A5F4 @@ -616,12 +632,11 @@ WindowOrderList 1C530D57069F1CE1000CFCEE - 1CD10A99069EF8BA00B06720 12C26D3512B0DDFC00AF7F4B /Users/slice/Projects/Chameleons/chameleon/branches/slice/ChamMek/ChamMek.xcodeproj WindowString - 257 172 1021 706 0 0 1440 878 + 364 171 1021 706 0 0 1440 878 WindowToolsV3 @@ -698,7 +713,7 @@ TableOfContents 12C26D3512B0DDFC00AF7F4B - 12350DA312F0697200F57D12 + 126D84BE12F7FA66000AB776 1CD0528F0623707200166675 XCMainBuildResultsModuleGUID @@ -820,13 +835,13 @@ TableOfContents 1CD10A99069EF8BA00B06720 - 12350DA412F0697200F57D12 + 12DFBFDF12F7066500E2DA49 1C162984064C10D400B95A72 - 12350DA512F0697200F57D12 - 12350DA612F0697200F57D12 - 12350DA712F0697200F57D12 - 12350DA812F0697200F57D12 - 12350DA912F0697200F57D12 + 12DFBFE012F7066500E2DA49 + 12DFBFE112F7066500E2DA49 + 12DFBFE212F7066500E2DA49 + 12DFBFE312F7066500E2DA49 + 12DFBFE412F7066500E2DA49 ToolbarConfiguration xcode.toolbar.config.debugV3 @@ -858,7 +873,7 @@ PBXProjectModuleGUID 1CDD528C0622207200134675 PBXProjectModuleLabel - gui.c + 915resolution.c StatusBarVisibility @@ -867,7 +882,7 @@ Frame {{0, 0}, {1109, 510}} RubberWindowFrame - 238 61 1109 816 0 0 1440 878 + 273 62 1109 816 0 0 1440 878 Module PBXNavigatorGroup @@ -893,7 +908,7 @@ Frame {{0, 515}, {1109, 260}} RubberWindowFrame - 238 61 1109 816 0 0 1440 878 + 273 62 1109 816 0 0 1440 878 Module PBXProjectFindModule @@ -916,13 +931,13 @@ TableOfContents 1C530D57069F1CE1000CFCEE - 12350DAE12F0697200F57D12 - 12350DAF12F0697200F57D12 + 126D84C412F7FA66000AB776 + 126D84C512F7FA66000AB776 1CDD528C0622207200134675 1CD0528E0623707200166675 WindowString - 238 61 1109 816 0 0 1440 878 + 273 62 1109 816 0 0 1440 878 WindowToolGUID 1C530D57069F1CE1000CFCEE WindowToolIsVisible Index: branches/slice/TODO =================================================================== --- branches/slice/TODO (revision 726) +++ branches/slice/TODO (revision 727) @@ -1,10 +1,14 @@ TODO List for Chameleon Boot Loader ==================================== +31.01.2011 Slice +- linux detection +- proper bootArgs when starting from CD + 27.12.2010 Slice - numerous errors, mistakes, reservation, non-finished codes... Spaghetti sources! -- kernelcache never used (adler32 is wrong?) +- kernelcache never used (adler32 is wrong?) -- resolved - more careful CPU detection -- readNVRAM is wrong +- readNVRAM is wrong -- resolved - graphicsEnabler for X3100 is not good - ATI Radeon enabler is not perfect