/programs/develop/libraries/newlib/crt/chkstk.S |
---|
0,0 → 1,29 |
.global ___chkstk |
.global __alloca |
.section .text |
.align 4 |
___chkstk: |
__alloca: |
pushl %ecx /* save temp */ |
leal 8(%esp), %ecx /* point past return addr */ |
subl %eax, %ecx |
cmpl %fs:4, %ecx # check low stack limit |
jb 1f |
movl %esp, %eax /* save old stack pointer */ |
movl %ecx, %esp /* decrement stack */ |
movl (%eax), %ecx /* recover saved temp */ |
movl 4(%eax), %eax /* recover return address */ |
/* Push the return value back. Doing this instead of just |
jumping to %eax preserves the cached call-return stack |
used by most modern processors. */ |
pushl %eax |
ret |
1: |
int3 #trap to debugger |
.ascii "Stack overflow" |
/programs/develop/libraries/newlib/crt/cpu_features.c |
---|
0,0 → 1,72 |
#include "cpu_features.h" |
/* level 1 edx bits */ |
#define EDX_CX8 (1 << 8) /* CMPXCHG8B */ |
#define EDX_CMOV (1 << 15) |
#define EDX_MMX (1 << 23) |
#define EDX_FXSR (1 << 24) /* FXSAVE and FXRSTOR */ |
#define EDX_SSE (1 << 25) |
#define EDX_SSE2 (1 << 26) |
/* level 1 ecx bits */ |
#define ECX_SSE3 (1 << 0) |
#define ECX_CX16 (1 << 13) /* CMPXCHG16B */ |
/* extended level 0x80000001 edx bits */ |
#define EDX_3DNOW (1 << 31) |
#define EDX_3DNOWP (1 << 30) |
#define EDX_LM (1 << 29) /*LONG MODE */ |
#define __cpuid(level,a,b,c,d) \ |
__asm__ __volatile__ ("cpuid;" \ |
: "=a" (a), "=b" (b), "=c" (c), "=d" (d)\ |
: "0" (level)) |
/* Combine the different cpuid flags into a single bitmap. */ |
unsigned int __cpu_features = 0; |
void __cpu_features_init (void) |
{ |
unsigned int eax, ebx, ecx, edx; |
__cpuid (0, eax, ebx, ecx, edx); |
if (eax == 0) |
return; |
__cpuid (1, eax, ebx, ecx, edx); |
if (edx & EDX_CX8) |
__cpu_features |= _CRT_CMPXCHG8B; |
if (edx & EDX_CMOV) |
__cpu_features |= _CRT_CMOV; |
if (edx & EDX_MMX) |
__cpu_features |= _CRT_MMX; |
if (edx & EDX_FXSR) |
__cpu_features |= _CRT_FXSR; |
if (edx & EDX_SSE) |
__cpu_features |= _CRT_SSE; |
if (edx & EDX_SSE2) |
__cpu_features |= _CRT_SSE2; |
if (ecx & ECX_SSE3) |
__cpu_features |= _CRT_SSE3; |
if (ecx & ECX_CX16) |
__cpu_features |= _CRT_CMPXCHG16B; |
__cpuid (0x80000000, eax, ebx, ecx, edx); |
if (eax < 0x80000001) |
return; |
__cpuid (0x80000001, eax, ebx, ecx, edx); |
if (edx & EDX_3DNOW) |
__cpu_features |= _CRT_3DNOW; |
if (edx & EDX_3DNOWP) |
__cpu_features |= _CRT_3DNOWP; |
return; |
} |
/programs/develop/libraries/newlib/crt/cpu_features.h |
---|
0,0 → 1,21 |
#ifndef _CPU_FEATURES_H |
#define _CPU_FEATURES_H |
#define _CRT_CMPXCHG8B 0x0001 |
#define _CRT_CMOV 0x0002 |
#define _CRT_MMX 0x0004 |
#define _CRT_FXSR 0x0008 |
#define _CRT_SSE 0x0010 |
#define _CRT_SSE2 0x0020 |
#define _CRT_SSE3 0x0040 |
#define _CRT_CMPXCHG16B 0x0080 |
#define _CRT_3DNOW 0x0100 |
#define _CRT_3DNOWP 0x0200 |
extern unsigned int __cpu_features; |
/* Currently we use this in fpenv functions */ |
#define __HAS_SSE __cpu_features & _CRT_SSE |
#endif |
/programs/develop/libraries/newlib/crt/crt1.c |
---|
0,0 → 1,126 |
/* |
* crt1.c |
* This file has no copyright assigned and is placed in the Public Domain. |
* This file is a part of the mingw-runtime package. |
* No warranty is given; refer to the file DISCLAIMER within the package. |
* |
* Source code for the startup proceedures used by all programs. This code |
* is compiled to make crt1.o, which should be located in the library path. |
* |
*/ |
/* Hide the declaration of _fmode with dllimport attribute in stdlib.h to |
avoid problems with older GCC. */ |
#include <newlib.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <string.h> |
#include "cpu_features.h" |
/* NOTE: The code for initializing the _argv, _argc, and environ variables |
* has been moved to a separate .c file which is included in both |
* crt1.c and dllcrt1.c. This means changes in the code don't have to |
* be manually synchronized, but it does lead to this not-generally- |
* a-good-idea use of include. */ |
extern char __cmdline; |
extern char __pgmname; |
extern int main (int, char **, char **); |
int _errno; |
int _fmode; |
char __appcwd[1024]; |
int __appcwdlen; |
int _argc; |
char **_argv; |
static char *arg[2]; |
void _exit(int __status) __attribute__((noreturn)); |
char * __libc_getenv(const char *name) |
{ |
return NULL; |
} |
void __main (){}; |
void init_reent(); |
void __attribute__((noreturn)) |
__thread_startup (int (*entry)(void*), void *param, |
void *stacklow, void *stackhigh) |
{ |
int retval; |
__asm__ __volatile__( // save stack limits |
"movl %0, %%fs:4 \n\t" // use TLS |
"movl %1, %%fs:8 \n\t" |
::"r"(stacklow), "r"(stackhigh)); |
init_reent(); // initialize thread reentry structure |
retval = entry(param); // call user thread function |
_exit(retval); |
}; |
void __attribute__((noreturn)) |
__crt_startup (void) |
{ |
int nRet; |
init_reent(); |
/* |
* Initialize floating point unit. |
*/ |
__cpu_features_init (); /* Do we have SSE, etc.*/ |
// _fpreset (); /* Supplied by the runtime library. */ |
__initPOSIXHandles(); |
__appcwdlen = strrchr(&__pgmname, '/') - &__pgmname + 1; |
__appcwdlen = __appcwdlen > 1023 ? 1023 : __appcwdlen; |
strncpy(__appcwd, &__pgmname, __appcwdlen); |
__appcwd[__appcwdlen] = 0; |
arg[0] = &__pgmname; |
if( __cmdline != 0) |
{ |
_argc = 2; |
arg[1] = &__cmdline; |
} else _argc = 1; |
_argv = arg; |
/* |
* Sets the default file mode. |
* If _CRT_fmode is set, also set mode for stdin, stdout |
* and stderr, as well |
* NOTE: DLLs don't do this because that would be rude! |
*/ |
// _mingw32_init_fmode (); |
nRet = main (_argc, _argv, NULL); |
/* |
* Perform exit processing for the C library. This means |
* flushing output and calling 'atexit' registered functions. |
*/ |
_exit (nRet); |
} |
/programs/develop/libraries/newlib/crt/start.S |
---|
0,0 → 1,40 |
.section .init |
.global __start |
.global __exit |
.global __Exit |
.align 4 |
__start: |
movl $68, %eax |
movl $12, %ebx |
lea __size_of_stack_reserve__, %ecx |
addl $4095, %ecx #load stack size |
andl $-4096, %ecx #align to page granularity |
int $0x40 #and allocate |
testl %eax, %eax |
jz 1f |
addl %eax, %ecx |
movl %eax, %fs:4 |
movl %ecx, %fs:8 #save stack base - low limit |
#save stack top - high limit |
movl %ecx, %esp |
jmp ___crt_startup #reload stack |
1: |
int3 #trap to debugger |
.ascii "No enough memory for stack allocation" |
.align 4 |
__exit: |
__Exit: |
movl 4(%esp), %edx #store exit code |
movl $68, %eax |
movl $13, %ebx |
movl %fs:4, %ecx |
int $0x40 #destroy stack |
movl $-1, %eax |
int $0x40 #terminate thread |
/programs/develop/libraries/newlib/crt/thread.S |
---|
0,0 → 1,46 |
.global _create_thread |
.global ___thread_startup |
.section .text |
.align 4 |
_create_thread: |
#.thr_proc equ esp+8 |
#.param equ esp+12 |
#.stack_size equ esp+16 |
pushl %ebx |
movl $68, %eax |
movl $12, %ebx |
movl 16(%esp), %ecx #[.stack_size] |
addl $4095, %ecx |
andl $-4096, %ecx |
movl %ecx, 16(%esp) #save stack size |
int $0x40 |
testl %eax, %eax |
jz 1f |
leal -20(%eax,%ecx), %edx |
movl 8(%esp), %ebx #[.thr_proc] |
mov %ebx, 4(%edx) |
movl 12(%esp), %ebx #[.param] |
movl %ebx, 8(%edx) |
addl %eax, %ecx |
movl %eax, 12(%edx) #stack low limit |
movl %ecx, 16(%edx) #stack high limit |
movl $51, %eax |
movl $1, %ebx |
lea ___thread_startup , %ecx |
int $0x40 |
popl %ebx |
ret |
1: |
notl %eax |
popl %ebx |
ret |
/programs/develop/libraries/newlib/crt |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/ctype/ctype_.c |
---|
0,0 → 1,223 |
/* |
* Copyright (c) 1989 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "@(#)ctype_.c 5.6 (Berkeley) 6/1/90"; |
#endif /* LIBC_SCCS and not lint */ |
#include <ctype.h> |
#define _CTYPE_DATA_0_127 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_N, _N, _N, _N, _N, _N, _N, _N, \ |
_N, _N, _P, _P, _P, _P, _P, _P, \ |
_P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _P, _P, _P, _P, _P, \ |
_P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _P, _P, _P, _P, _C |
#define _CTYPE_DATA_128_255 \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0 |
#if (defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)) || defined (__CYGWIN__) |
#define ALLOW_NEGATIVE_CTYPE_INDEX |
#endif |
#if defined(_MB_CAPABLE) |
#if defined(_MB_EXTENDED_CHARSETS_ISO) |
#include "ctype_iso.h" |
#endif |
#if defined(_MB_EXTENDED_CHARSETS_WINDOWS) |
#include "ctype_cp.h" |
#endif |
#endif |
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
/* No static const on Cygwin since it's referenced and potentially overwritten |
for compatibility with older applications. */ |
#ifndef __CYGWIN__ |
static _CONST |
#endif |
char _ctype_b[128 + 256] = { |
_CTYPE_DATA_128_255, |
_CTYPE_DATA_0_127, |
_CTYPE_DATA_128_255 |
}; |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char __EXPORT *__ctype_ptr = (char *) _ctype_b + 128; |
#endif |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char __EXPORT *__ctype_ptr__ = (char *) _ctype_b + 127; |
# ifdef __CYGWIN__ |
__asm__ (" \n\ |
.data \n\ |
.globl __ctype_ \n\ |
.set __ctype_,__ctype_b+127 \n\ |
.text \n\ |
"); |
# else /* !__CYGWIN__ */ |
_CONST char _ctype_[1 + 256] = { |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_DATA_128_255 |
}; |
# endif /* !__CYGWIN__ */ |
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ |
_CONST char _ctype_[1 + 256] = { |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_DATA_128_255 |
}; |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char *__ctype_ptr = (char *) _ctype_ + 1; |
#endif |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char *__ctype_ptr__ = (char *) _ctype_; |
#endif |
#if defined(_MB_CAPABLE) |
/* Cygwin has its own implementation which additionally maintains backward |
compatibility with applications built under older Cygwin releases. */ |
#ifndef __CYGWIN__ |
void |
__set_ctype (const char *charset) |
{ |
#if defined(_MB_EXTENDED_CHARSETS_ISO) || defined(_MB_EXTENDED_CHARSETS_WINDOWS) |
int idx; |
#endif |
switch (*charset) |
{ |
#if defined(_MB_EXTENDED_CHARSETS_ISO) |
case 'I': |
idx = __iso_8859_index (charset + 9); |
/* The ctype table has a leading ISO-8859-1 element so we have to add |
1 to the index returned by __iso_8859_index. If __iso_8859_index |
returns < 0, it's ISO-8859-1. */ |
if (idx < 0) |
idx = 0; |
else |
++idx; |
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) (__ctype_iso[idx] + 128); |
#endif |
__ctype_ptr__ = (char *) (__ctype_iso[idx] + 127); |
# else |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) __ctype_iso[idx] + 1; |
#endif |
__ctype_ptr__ = (char *) __ctype_iso[idx]; |
# endif |
return; |
#endif |
#if defined(_MB_EXTENDED_CHARSETS_WINDOWS) |
case 'C': |
idx = __cp_index (charset + 2); |
if (idx < 0) |
break; |
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) (__ctype_cp[idx] + 128); |
#endif |
__ctype_ptr__ = (char *) (__ctype_cp[idx] + 127); |
# else |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) __ctype_cp[idx] + 1; |
#endif |
__ctype_ptr__ = (char *) __ctype_cp[idx]; |
# endif |
return; |
#endif |
default: |
break; |
} |
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) _ctype_b + 128; |
#endif |
__ctype_ptr__ = (char *) _ctype_b + 127; |
# else |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) _ctype_ + 1; |
#endif |
__ctype_ptr__ = (char *) _ctype_; |
# endif |
} |
#endif /* !__CYGWIN__ */ |
#endif /* _MB_CAPABLE */ |
/programs/develop/libraries/newlib/ctype/ctype_cp.h |
---|
0,0 → 1,775 |
/* ctype table definitions for Windows codepage charsets. |
Included by ctype_.c. */ |
#define _CTYPE_CP437_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_L, _U, _U, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _U, _L, _U, _L, _P, _L, \ |
_U, _U, _U, _L, _P, _L, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP437_255 _S|_B |
#define _CTYPE_CP720_128_254 \ |
0, 0, _L, _L, 0, _L, 0, _L, \ |
_L, _L, _L, _L, _L, 0, 0, 0, \ |
0, _P, _P, _L, _P, _P, _L, _L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _P, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP720_255 _S|_B |
#define _CTYPE_CP737_128_254 \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _U, _U, _U, _U, _U, _U, \ |
_U, _P, _P, _P, _U, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP737_255 _S|_B |
#define _CTYPE_CP775_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _U, _L, _L, _U, _U, _U, \ |
_U, _L, _U, _L, _L, _U, _P, _U, \ |
_L, _U, _U, _L, _P, _U, _P, _P, \ |
_U, _U, _L, _U, _L, _L, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_U, _P, _P, _P, _P, _U, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _U, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _L, _U, _U, _L, _U, _P, _L, \ |
_U, _L, _U, _L, _L, _U, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP775_255 _S|_B |
#define _CTYPE_CP850_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_L, _U, _U, _L, _P, _U, _P, _L, \ |
_L, _L, _L, _L, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _U, _U, _U, _L, _U, _U, \ |
_U, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _L, _U, _U, _L, _U, _P, _L, \ |
_U, _U, _U, _U, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP850_255 _S|_B |
#define _CTYPE_CP852_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _U, _L, _L, _U, _U, _U, \ |
_U, _U, _L, _L, _L, _U, _L, _U, \ |
_L, _U, _U, _U, _L, _U, _P, _L, \ |
_L, _L, _L, _L, _U, _L, _U, _L, \ |
_U, _L, _P, _L, _U, _L, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_U, _P, _P, _P, _P, _U, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _U, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _U, _U, _L, _U, _U, _U, \ |
_L, _P, _P, _P, _P, _U, _U, _P, \ |
_U, _L, _U, _U, _L, _L, _U, _L, \ |
_U, _U, _L, _U, _L, _U, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _L, _U, _L, _P |
#define _CTYPE_CP852_255 _S|_B |
#define _CTYPE_CP855_128_254 \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _L, _U, _L, \ |
_U, _P, _P, _P, _P, _L, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _P, _P, _P, _P, _U, _L, _P, \ |
_U, _L, _U, _L, _U, _L, _U, _L, \ |
_U, _L, _U, _L, _U, _L, _U, _P, \ |
_P, _L, _U, _L, _U, _L, _U, _L, \ |
_U, _L, _U, _L, _U, _P, _P |
#define _CTYPE_CP855_255 _S|_B |
#define _CTYPE_CP857_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_U, _U, _U, _L, _P, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _U, _U, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _U, _U, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _U, _U, _U, 0, _U, _U, \ |
_U, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _L, _U, _U, _L, _U, _P, 0, \ |
_P, _U, _U, _U, _L, _L, _P, _P, \ |
_P, _P, 0, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP857_255 _S|_B |
#define _CTYPE_CP858_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_L, _U, _U, _L, _P, _U, _P, _L, \ |
_L, _L, _L, _L, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _U, _U, _U, _P, _U, _U, \ |
_U, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _L, _U, _U, _L, _U, _P, _L, \ |
_U, _U, _U, _U, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP858_255 _S|_B |
#define _CTYPE_CP862_128_254 \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _P, _P, _P, _P, _L, \ |
_L, _L, _L, _L, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _U, _L, _U, _L, _P, _L, \ |
_U, _U, _U, _L, _P, _L, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP862_255 _S|_B |
#define _CTYPE_CP866_128_254 \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _L, _U, _L, _U, _L, _U, _L, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP866_255 _S|_B |
#define _CTYPE_CP874_128_254 \ |
_P, 0, 0, 0, 0, _P, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
_S|_B, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, 0, 0, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _U|_L, _U|_L, 0, 0, 0 |
#define _CTYPE_CP874_255 0 |
#define _CTYPE_CP1125_128_254 \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _L, _U, _L, _U, _L, _U, _L, \ |
_U, _L, _P, _P, _P, _P, _P |
#define _CTYPE_CP1125_255 _S|_B |
#define _CTYPE_CP1250_128_254 \ |
_P, 0, _P, 0, _P, _P, _P, _P, \ |
0, _P, _U, _P, _U, _U, _U, _U, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, _L, _P, _L, _L, _L, _L, \ |
_S|_B, _P, _P, _U, _P, _U, _P, _P, \ |
_P, _P, _U, _P, _P, _P, _P, _U, \ |
_P, _P, _P, _L, _P, _P, _P, _P, \ |
_P, _L, _L, _P, _U, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1250_255 _P |
#define _CTYPE_CP1251_128_254 \ |
_U, _U, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, _U, _U, _U, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, _L, _P, _L, _L, _L, _L, \ |
_S|_B, _U, _L, _U, _P, _U, _P, _P, \ |
_U, _P, _U, _P, _P, _P, _P, _U, \ |
_P, _P, _U, _L, _L, _P, _P, _P, \ |
_L, _P, _L, _P, _L, _U, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1251_255 _L |
#define _CTYPE_CP1252_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, _U, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _L, _P, _L, 0, _L, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1252_255 _L |
#define _CTYPE_CP1253_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, 0, 0, 0, \ |
_S|_B, _P, _U, _P, _P, _P, _P, _P, \ |
_P, _P, 0, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _P, _U, _P, _U, _U, \ |
_L, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1253_255 _L |
#define _CTYPE_CP1254_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _L, _P, _L, 0, 0, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1254_255 _L |
#define _CTYPE_CP1255_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, 0, _P, 0, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, 0, _P, 0, 0, 0, 0, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _U|_L, _U|_L, _U|_L, _P, \ |
_P, 0, 0, 0, 0, 0, 0, 0, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, _P, _P |
#define _CTYPE_CP1255_255 0 |
#define _CTYPE_CP1256_128_254 \ |
_P, _U|_L, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U|_L, _P, _U, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _P, _U|_L, _P, _L, _P, _P, _U|_L, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _U|_L, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _P, _U|_L, _U|_L, _U|_L, \ |
_L, _U|_L, _L, _U|_L, _U|_L, _U|_L, _U|_L, _L, \ |
_L, _L, _L, _L, _U|_L, _U|_L, _L, _L, \ |
_P, _P, _P, _P, _L, _P, _P, _P, \ |
_P, _L, _P, _L, _L, _P, _P |
#define _CTYPE_CP1256_255 _U|_L |
#define _CTYPE_CP1257_128_254 \ |
_P, 0, _P, 0, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, _P, _P, _P, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, _P, _P, 0, \ |
_S|_B, 0, _P, _P, _P, 0, _P, _P, \ |
_U, _P, _U, _P, _P, _P, _P, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _P, _L, _P, _P, _P, _P, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1257_255 _P |
#define _CTYPE_CP1258_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, 0, _P, _U, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, 0, _P, _L, 0, 0, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _P, _U, _U, _U, \ |
_U, _U, _P, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _P, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _P, _L, _L, _L, \ |
_L, _L, _P, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _P |
#define _CTYPE_CP1258_255 _L |
#define _CTYPE_CP20866_128_254 \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _S|_B, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _U, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U |
#define _CTYPE_CP20866_255 _U |
#define _CTYPE_CP21866_128_254 \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _S|_B, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _L, _L, _P, _L, _L, \ |
_P, _P, _P, _P, _P, _L, _P, _P, \ |
_P, _P, _P, _U, _U, _P, _U, _U, \ |
_P, _P, _P, _P, _P, _U, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U |
#define _CTYPE_CP21866_255 _U |
#define _CTYPE_GEORGIAN_PS_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, _U, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _L, _P, _L, 0, _L, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_GEORGIAN_PS_255 _L |
#define _CTYPE_PT154_128_254 \ |
_U, _U, _U, _L, _P, _P, _U, _U, \ |
_U, _L, _U, _U, _U, _U, _U, _U, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_S|_B, _U, _L, _U, _U, _U, _U, _P, \ |
_U, _P, _U, _P, _P, _L, _P, _U, \ |
_P, _L, _U, _L, _L, _L, _P, _P, \ |
_L, _P, _L, _P, _L, _U, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_PT154_255 _L |
extern int __cp_index (const char *charset_ext); |
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifndef __CYGWIN__ |
static _CONST |
#endif |
char __ctype_cp[26][128 + 256] = { |
{ _CTYPE_CP437_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP437_128_254, |
_CTYPE_CP437_255 |
}, |
{ _CTYPE_CP720_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP720_128_254, |
_CTYPE_CP720_255 |
}, |
{ _CTYPE_CP737_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP737_128_254, |
_CTYPE_CP737_255 |
}, |
{ _CTYPE_CP775_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP775_128_254, |
_CTYPE_CP775_255 |
}, |
{ _CTYPE_CP850_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP850_128_254, |
_CTYPE_CP850_255 |
}, |
{ _CTYPE_CP852_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP852_128_254, |
_CTYPE_CP852_255 |
}, |
{ _CTYPE_CP855_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP855_128_254, |
_CTYPE_CP855_255 |
}, |
{ _CTYPE_CP857_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP857_128_254, |
_CTYPE_CP857_255 |
}, |
{ _CTYPE_CP858_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP858_128_254, |
_CTYPE_CP858_255 |
}, |
{ _CTYPE_CP862_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP862_128_254, |
_CTYPE_CP862_255 |
}, |
{ _CTYPE_CP866_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP866_128_254, |
_CTYPE_CP866_255 |
}, |
{ _CTYPE_CP874_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP874_128_254, |
_CTYPE_CP874_255 |
}, |
{ _CTYPE_CP1125_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1125_128_254, |
_CTYPE_CP1125_255 |
}, |
{ _CTYPE_CP1250_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1250_128_254, |
_CTYPE_CP1250_255 |
}, |
{ _CTYPE_CP1251_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1251_128_254, |
_CTYPE_CP1251_255 |
}, |
{ _CTYPE_CP1252_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1252_128_254, |
_CTYPE_CP1252_255 |
}, |
{ _CTYPE_CP1253_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1253_128_254, |
_CTYPE_CP1253_255 |
}, |
{ _CTYPE_CP1254_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1254_128_254, |
_CTYPE_CP1254_255 |
}, |
{ _CTYPE_CP1255_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1255_128_254, |
_CTYPE_CP1255_255 |
}, |
{ _CTYPE_CP1256_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1256_128_254, |
_CTYPE_CP1256_255 |
}, |
{ _CTYPE_CP1257_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1257_128_254, |
_CTYPE_CP1257_255 |
}, |
{ _CTYPE_CP1258_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1258_128_254, |
_CTYPE_CP1258_255 |
}, |
{ _CTYPE_CP20866_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP20866_128_254, |
_CTYPE_CP20866_255 |
}, |
{ _CTYPE_CP21866_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP21866_128_254, |
_CTYPE_CP21866_255 |
}, |
{ _CTYPE_GEORGIAN_PS_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_GEORGIAN_PS_128_254, |
_CTYPE_GEORGIAN_PS_255 |
}, |
{ _CTYPE_PT154_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_PT154_128_254, |
_CTYPE_PT154_255 |
}, |
}; |
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ |
static _CONST char __ctype_cp[26][1 + 256] = { |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP437_128_254, |
_CTYPE_CP437_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP720_128_254, |
_CTYPE_CP720_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP737_128_254, |
_CTYPE_CP737_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP775_128_254, |
_CTYPE_CP775_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP850_128_254, |
_CTYPE_CP850_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP852_128_254, |
_CTYPE_CP852_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP855_128_254, |
_CTYPE_CP855_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP857_128_254, |
_CTYPE_CP857_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP858_128_254, |
_CTYPE_CP858_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP862_128_254, |
_CTYPE_CP862_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP866_128_254, |
_CTYPE_CP866_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP874_128_254, |
_CTYPE_CP874_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1125_128_254, |
_CTYPE_CP1125_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1250_128_254, |
_CTYPE_CP1250_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1251_128_254, |
_CTYPE_CP1251_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1252_128_254, |
_CTYPE_CP1252_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1253_128_254, |
_CTYPE_CP1253_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1254_128_254, |
_CTYPE_CP1254_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1255_128_254, |
_CTYPE_CP1255_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1256_128_254, |
_CTYPE_CP1256_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1257_128_254, |
_CTYPE_CP1257_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1258_128_254, |
_CTYPE_CP1258_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP20866_128_254, |
_CTYPE_CP20866_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP21866_128_254, |
_CTYPE_CP21866_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_GEORGIAN_PS_128_254, |
_CTYPE_GEORGIAN_PS_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_PT154_128_254, |
_CTYPE_PT154_255 |
}, |
}; |
#endif /* ALLOW_NEGATIVE_CTYPE_INDEX */ |
/programs/develop/libraries/newlib/ctype/ctype_iso.h |
---|
0,0 → 1,455 |
/* ctype table definitions for ISO-8859-x charsets. |
Included by ctype_.c. */ |
#define _CTYPE_ISO_8859_1_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_1_255 _L |
#define _CTYPE_ISO_8859_2_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _P, _U, _P, _U, _U, _P, \ |
_P, _U, _U, _U, _U, _P, _U, _U, \ |
_P, _L, _P, _L, _P, _L, _L, _P, \ |
_P, _L, _L, _L, _L, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_2_255 _P |
#define _CTYPE_ISO_8859_3_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _P, _P, _P, 0, _U, _P, \ |
_P, _U, _U, _U, _U, _P, 0, _U, \ |
_P, _L, _P, _P, _P, _P, _L, _P, \ |
_P, _L, _L, _L, _L, _P, 0, _L, \ |
_U, _U, _U, 0, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
0, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, 0, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
0, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_3_255 _P |
#define _CTYPE_ISO_8859_4_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _L, _U, _P, _U, _U, _P, \ |
_P, _U, _U, _U, _U, _P, _U, _P, \ |
_P, _L, _P, _L, _P, _L, _L, _P, \ |
_P, _L, _L, _L, _L, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_4_255 _L |
#define _CTYPE_ISO_8859_5_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _P, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _P, _L |
#define _CTYPE_ISO_8859_5_255 _L |
#define _CTYPE_ISO_8859_6_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, 0, 0, 0, _P, 0, 0, 0, \ |
0, 0, 0, 0, _P, _P, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, _P, 0, 0, 0, _P, \ |
0, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, 0, 0, 0, \ |
_P, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _P, _P, _P, _P, _P, \ |
_P, _P, _P, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0 |
#define _CTYPE_ISO_8859_6_255 0 |
#define _CTYPE_ISO_8859_7_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, 0, _P, \ |
_P, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _U, _U, _P, _U, _P, _U, _U, \ |
_L, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_7_255 0 |
#define _CTYPE_ISO_8859_8_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, 0, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, _P, _P |
#define _CTYPE_ISO_8859_8_255 0 |
#define _CTYPE_ISO_8859_9_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_9_255 _L |
#define _CTYPE_ISO_8859_10_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _P, _U, _U, \ |
_P, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_10_255 _L |
#define _CTYPE_ISO_8859_11_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _P, _U|_L, _U|_L, _P, _P, _P, _P, \ |
_P, _P, _P, 0, 0, 0, 0, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, 0, 0, 0 |
#define _CTYPE_ISO_8859_11_255 0 |
#define _CTYPE_ISO_8859_13_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _P, _U, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _P, _L, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_13_255 _P |
#define _CTYPE_ISO_8859_14_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _L, _P, _U, _L, _U, _P, \ |
_U, _P, _U, _L, _U, _P, _P, _U, \ |
_U, _L, _U, _L, _U, _L, _P, _U, \ |
_L, _L, _L, _U, _L, _U, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_14_255 _L |
#define _CTYPE_ISO_8859_15_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _U, _P, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _U, _P, _P, _P, \ |
_L, _P, _P, _P, _U, _L, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_15_255 _L |
#define _CTYPE_ISO_8859_16_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _L, _U, _P, _P, _U, _P, \ |
_L, _P, _U, _P, _U, _P, _L, _U, \ |
_P, _P, _U, _U, _U, _P, _P, _P, \ |
_L, _L, _L, _P, _U, _L, _U, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_16_255 _L |
extern int __iso_8859_index (const char *charset_ext); |
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifndef __CYGWIN__ |
static _CONST |
#endif |
char __ctype_iso[15][128 + 256] = { |
{ _CTYPE_ISO_8859_1_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_1_128_254, |
_CTYPE_ISO_8859_1_255 |
}, |
{ _CTYPE_ISO_8859_2_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_2_128_254, |
_CTYPE_ISO_8859_2_255 |
}, |
{ _CTYPE_ISO_8859_3_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_3_128_254, |
_CTYPE_ISO_8859_3_255 |
}, |
{ _CTYPE_ISO_8859_4_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_4_128_254, |
_CTYPE_ISO_8859_4_255 |
}, |
{ _CTYPE_ISO_8859_5_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_5_128_254, |
_CTYPE_ISO_8859_5_255 |
}, |
{ _CTYPE_ISO_8859_6_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_6_128_254, |
_CTYPE_ISO_8859_6_255 |
}, |
{ _CTYPE_ISO_8859_7_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_7_128_254, |
_CTYPE_ISO_8859_7_255 |
}, |
{ _CTYPE_ISO_8859_8_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_8_128_254, |
_CTYPE_ISO_8859_8_255 |
}, |
{ _CTYPE_ISO_8859_9_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_9_128_254, |
_CTYPE_ISO_8859_9_255 |
}, |
{ _CTYPE_ISO_8859_10_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_10_128_254, |
_CTYPE_ISO_8859_10_255 |
}, |
{ _CTYPE_ISO_8859_11_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_11_128_254, |
_CTYPE_ISO_8859_11_255 |
}, |
{ _CTYPE_ISO_8859_13_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_13_128_254, |
_CTYPE_ISO_8859_13_255 |
}, |
{ _CTYPE_ISO_8859_14_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_14_128_254, |
_CTYPE_ISO_8859_14_255 |
}, |
{ _CTYPE_ISO_8859_15_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_15_128_254, |
_CTYPE_ISO_8859_15_255 |
}, |
{ _CTYPE_ISO_8859_16_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_16_128_254, |
_CTYPE_ISO_8859_16_255 |
}, |
}; |
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ |
static _CONST char __ctype_iso[15][1 + 256] = { |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_1_128_254, |
_CTYPE_ISO_8859_1_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_2_128_254, |
_CTYPE_ISO_8859_2_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_3_128_254, |
_CTYPE_ISO_8859_3_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_4_128_254, |
_CTYPE_ISO_8859_4_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_5_128_254, |
_CTYPE_ISO_8859_5_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_6_128_254, |
_CTYPE_ISO_8859_6_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_7_128_254, |
_CTYPE_ISO_8859_7_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_8_128_254, |
_CTYPE_ISO_8859_8_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_9_128_254, |
_CTYPE_ISO_8859_9_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_10_128_254, |
_CTYPE_ISO_8859_10_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_11_128_254, |
_CTYPE_ISO_8859_11_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_13_128_254, |
_CTYPE_ISO_8859_13_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_14_128_254, |
_CTYPE_ISO_8859_14_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_15_128_254, |
_CTYPE_ISO_8859_15_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_16_128_254, |
_CTYPE_ISO_8859_16_255 |
}, |
}; |
#endif /* ALLOW_NEGATIVE_CTYPE_INDEX */ |
/programs/develop/libraries/newlib/ctype/isalnum.c |
---|
0,0 → 1,46 |
/* |
FUNCTION |
<<isalnum>>---alphanumeric character predicate |
INDEX |
isalnum |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isalnum(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isalnum(<[c]>); |
DESCRIPTION |
<<isalnum>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for alphabetic or |
numeric ASCII characters, and <<0>> for other arguments. It is defined |
for all integer values. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isalnum>>'. |
RETURNS |
<<isalnum>> returns non-zero if <[c]> is a letter (<<a>>--<<z>> or |
<<A>>--<<Z>>) or a digit (<<0>>--<<9>>). |
PORTABILITY |
<<isalnum>> is ANSI C. |
No OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isalnum |
int |
_DEFUN(isalnum,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_U|_L|_N)); |
} |
/programs/develop/libraries/newlib/ctype/isalpha.c |
---|
0,0 → 1,44 |
/* |
FUNCTION |
<<isalpha>>---alphabetic character predicate |
INDEX |
isalpha |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isalpha(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isalpha(<[c]>); |
DESCRIPTION |
<<isalpha>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero when <[c]> represents an |
alphabetic ASCII character, and 0 otherwise. It is defined only when |
<<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isalpha>>'. |
RETURNS |
<<isalpha>> returns non-zero if <[c]> is a letter (<<A>>--<<Z>> or |
<<a>>--<<z>>). |
PORTABILITY |
<<isalpha>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isalpha |
int |
_DEFUN(isalpha,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_U|_L)); |
} |
/programs/develop/libraries/newlib/ctype/iscntrl.c |
---|
0,0 → 1,48 |
/* |
FUNCTION |
<<iscntrl>>---control character predicate |
INDEX |
iscntrl |
ANSI_SYNOPSIS |
#include <ctype.h> |
int iscntrl(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int iscntrl(<[c]>); |
DESCRIPTION |
<<iscntrl>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for control characters, and 0 |
for other characters. It is defined only when <<isascii>>(<[c]>) is |
true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef iscntrl>>'. |
RETURNS |
<<iscntrl>> returns non-zero if <[c]> is a delete character or ordinary |
control character (<<0x7F>> or <<0x00>>--<<0x1F>>). |
PORTABILITY |
<<iscntrl>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef iscntrl |
int |
_DEFUN(iscntrl,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _C); |
} |
/programs/develop/libraries/newlib/ctype/isdigit.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<isdigit>>---decimal digit predicate |
INDEX |
isdigit |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isdigit(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isdigit(<[c]>); |
DESCRIPTION |
<<isdigit>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for decimal digits, and 0 for |
other characters. It is defined only when <<isascii>>(<[c]>) is true |
or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isdigit>>'. |
RETURNS |
<<isdigit>> returns non-zero if <[c]> is a decimal digit (<<0>>--<<9>>). |
PORTABILITY |
<<isdigit>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isdigit |
int |
_DEFUN(isdigit,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _N); |
} |
/programs/develop/libraries/newlib/ctype/islower.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<islower>>---lowercase character predicate |
INDEX |
islower |
ANSI_SYNOPSIS |
#include <ctype.h> |
int islower(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int islower(<[c]>); |
DESCRIPTION |
<<islower>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for minuscules |
(lowercase alphabetic characters), and 0 for other characters. |
It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef islower>>'. |
RETURNS |
<<islower>> returns non-zero if <[c]> is a lowercase letter (<<a>>--<<z>>). |
PORTABILITY |
<<islower>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef islower |
int |
_DEFUN(islower,(c),int c) |
{ |
return ((__ctype_ptr__[c+1] & (_U|_L)) == _L); |
} |
/programs/develop/libraries/newlib/ctype/isprint.c |
---|
0,0 → 1,60 |
/* |
FUNCTION |
<<isprint>>, <<isgraph>>---printable character predicates |
INDEX |
isprint |
INDEX |
isgraph |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isprint(int <[c]>); |
int isgraph(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isprint(<[c]>); |
int isgraph(<[c]>); |
DESCRIPTION |
<<isprint>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for printable |
characters, and 0 for other character arguments. |
It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining either macro using `<<#undef isprint>>' or `<<#undef isgraph>>'. |
RETURNS |
<<isprint>> returns non-zero if <[c]> is a printing character, |
(<<0x20>>--<<0x7E>>). |
<<isgraph>> behaves identically to <<isprint>>, except that the space |
character (<<0x20>>) is excluded. |
PORTABILITY |
<<isprint>> and <<isgraph>> are ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isgraph |
int |
_DEFUN(isgraph,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_P|_U|_L|_N)); |
} |
#undef isprint |
int |
_DEFUN(isprint,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_P|_U|_L|_N|_B)); |
} |
/programs/develop/libraries/newlib/ctype/ispunct.c |
---|
0,0 → 1,46 |
/* |
FUNCTION |
<<ispunct>>---punctuation character predicate |
INDEX |
ispunct |
ANSI_SYNOPSIS |
#include <ctype.h> |
int ispunct(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int ispunct(<[c]>); |
DESCRIPTION |
<<ispunct>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for printable |
punctuation characters, and 0 for other characters. It is defined |
only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef ispunct>>'. |
RETURNS |
<<ispunct>> returns non-zero if <[c]> is a printable punctuation character |
(<<isgraph(<[c]>) && !isalnum(<[c]>)>>). |
PORTABILITY |
<<ispunct>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef ispunct |
int |
_DEFUN(ispunct,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _P); |
} |
/programs/develop/libraries/newlib/ctype/isspace.c |
---|
0,0 → 1,44 |
/* |
FUNCTION |
<<isspace>>---whitespace character predicate |
INDEX |
isspace |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isspace(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isspace(<[c]>); |
DESCRIPTION |
<<isspace>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for whitespace |
characters, and 0 for other characters. It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isspace>>'. |
RETURNS |
<<isspace>> returns non-zero if <[c]> is a space, tab, carriage return, new |
line, vertical tab, or formfeed (<<0x09>>--<<0x0D>>, <<0x20>>). |
PORTABILITY |
<<isspace>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isspace |
int |
_DEFUN(isspace,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _S); |
} |
/programs/develop/libraries/newlib/ctype/isupper.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<isupper>>---uppercase character predicate |
INDEX |
isupper |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isupper(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isupper(<[c]>); |
DESCRIPTION |
<<isupper>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for uppercase letters |
(<<A>>--<<Z>>), and 0 for other characters. It is defined only when |
<<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isupper>>'. |
RETURNS |
<<isupper>> returns non-zero if <[c]> is a uppercase letter (A-Z). |
PORTABILITY |
<<isupper>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isupper |
int |
_DEFUN(isupper,(c),int c) |
{ |
return ((__ctype_ptr__[c+1] & (_U|_L)) == _U); |
} |
/programs/develop/libraries/newlib/ctype/iswalnum.c |
---|
0,0 → 1,37 |
/* |
FUNCTION |
<<iswalnum>>---alphanumeric wide character test |
INDEX |
iswalnum |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswalnum(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswalnum(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswalnum>> is a function which classifies wide-character values that |
are alphanumeric. |
RETURNS |
<<iswalnum>> returns non-zero if <[c]> is a alphanumeric wide character. |
PORTABILITY |
<<iswalnum>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswalnum,(c),wint_t c) |
{ |
return (iswalpha (c) || iswdigit (c)); |
} |
/programs/develop/libraries/newlib/ctype/iswalpha.c |
---|
0,0 → 1,433 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswalpha>>---alphabetic wide character test |
INDEX |
iswalpha |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswalpha(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswalpha(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswalpha>> is a function which classifies wide-character values that |
are alphabetic. |
RETURNS |
<<iswalpha>> returns non-zero if <[c]> is an alphabetic wide character. |
PORTABILITY |
<<iswalpha>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <string.h> |
#include <ctype.h> |
#include "local.h" |
#ifdef _MB_CAPABLE |
#include "utf8alpha.h" |
#endif /* _MB_CAPABLE */ |
int |
_DEFUN(iswalpha,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
unsigned const char *table; |
unsigned char *ptr; |
unsigned char ctmp; |
int size; |
wint_t x; |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 |
See utf8alpha.h for a description how to fetch the data. */ |
x = (c >> 8); |
/* for some large sections, all characters are alphabetic so handle them here */ |
if ((x >= 0x34 && x <= 0x4c) || |
(x >= 0x4e && x <= 0x9e) || |
(x >= 0xac && x <= 0xd6) || |
(x >= 0x120 && x <= 0x122) || |
(x >= 0x130 && x <= 0x133) || |
(x >= 0x200 && x <= 0x2a5) || |
(x >= 0x2a7 && x <= 0x2b6)) |
return 1; |
switch (x) |
{ |
case 0x00: |
table = u0; |
size = sizeof(u0); |
break; |
case 0x01: |
case 0x11: |
case 0x15: |
case 0x1e: |
case 0xa0: |
case 0xa1: |
case 0xa2: |
case 0xa3: |
case 0xa5: |
case 0xf9: |
case 0xfc: |
case 0x2f8: |
case 0x2f9: |
return 1; |
case 0x02: |
table = u2; |
size = sizeof(u2); |
break; |
case 0x03: |
table = u3; |
size = sizeof(u3); |
break; |
case 0x04: |
table = u4; |
size = sizeof(u4); |
break; |
case 0x05: |
table = u5; |
size = sizeof(u5); |
break; |
case 0x06: |
table = u6; |
size = sizeof(u6); |
break; |
case 0x07: |
table = u7; |
size = sizeof(u7); |
break; |
case 0x08: |
table = u8; |
size = sizeof(u8); |
break; |
case 0x09: |
table = u9; |
size = sizeof(u9); |
break; |
case 0x0a: |
table = ua; |
size = sizeof(ua); |
break; |
case 0x0b: |
table = ub; |
size = sizeof(ub); |
break; |
case 0x0c: |
table = uc; |
size = sizeof(uc); |
break; |
case 0x0d: |
table = ud; |
size = sizeof(ud); |
break; |
case 0x0e: |
table = ue; |
size = sizeof(ue); |
break; |
case 0x0f: |
table = uf; |
size = sizeof(uf); |
break; |
case 0x10: |
table = u10; |
size = sizeof(u10); |
break; |
case 0x12: |
table = u12; |
size = sizeof(u12); |
break; |
case 0x13: |
table = u13; |
size = sizeof(u13); |
break; |
case 0x14: |
table = u14; |
size = sizeof(u14); |
break; |
case 0x16: |
table = u16; |
size = sizeof(u16); |
break; |
case 0x17: |
table = u17; |
size = sizeof(u17); |
break; |
case 0x18: |
table = u18; |
size = sizeof(u18); |
break; |
case 0x19: |
table = u19; |
size = sizeof(u19); |
break; |
case 0x1a: |
table = u1a; |
size = sizeof(u1a); |
break; |
case 0x1b: |
table = u1b; |
size = sizeof(u1b); |
break; |
case 0x1c: |
table = u1c; |
size = sizeof(u1c); |
break; |
case 0x1d: |
table = u1d; |
size = sizeof(u1d); |
break; |
case 0x1f: |
table = u1f; |
size = sizeof(u1f); |
break; |
case 0x20: |
table = u20; |
size = sizeof(u20); |
break; |
case 0x21: |
table = u21; |
size = sizeof(u21); |
break; |
case 0x24: |
table = u24; |
size = sizeof(u24); |
break; |
case 0x2c: |
table = u2c; |
size = sizeof(u2c); |
break; |
case 0x2d: |
table = u2d; |
size = sizeof(u2d); |
break; |
case 0x2e: |
table = u2e; |
size = sizeof(u2e); |
break; |
case 0x30: |
table = u30; |
size = sizeof(u30); |
break; |
case 0x31: |
table = u31; |
size = sizeof(u31); |
break; |
case 0x4d: |
table = u4d; |
size = sizeof(u4d); |
break; |
case 0x9f: |
table = u9f; |
size = sizeof(u9f); |
break; |
case 0xa4: |
table = ua4; |
size = sizeof(ua4); |
break; |
case 0xa6: |
table = ua6; |
size = sizeof(ua6); |
break; |
case 0xa7: |
table = ua7; |
size = sizeof(ua7); |
break; |
case 0xa8: |
table = ua8; |
size = sizeof(ua8); |
break; |
case 0xa9: |
table = ua9; |
size = sizeof(ua9); |
break; |
case 0xaa: |
table = uaa; |
size = sizeof(uaa); |
break; |
case 0xab: |
table = uab; |
size = sizeof(uab); |
break; |
case 0xd7: |
table = ud7; |
size = sizeof(ud7); |
break; |
case 0xfa: |
table = ufa; |
size = sizeof(ufa); |
break; |
case 0xfb: |
table = ufb; |
size = sizeof(ufb); |
break; |
case 0xfd: |
table = ufd; |
size = sizeof(ufd); |
break; |
case 0xfe: |
table = ufe; |
size = sizeof(ufe); |
break; |
case 0xff: |
table = uff; |
size = sizeof(uff); |
break; |
case 0x100: |
table = u100; |
size = sizeof(u100); |
break; |
case 0x101: |
table = u101; |
size = sizeof(u101); |
break; |
case 0x102: |
table = u102; |
size = sizeof(u102); |
break; |
case 0x103: |
table = u103; |
size = sizeof(u103); |
break; |
case 0x104: |
table = u104; |
size = sizeof(u104); |
break; |
case 0x108: |
table = u108; |
size = sizeof(u108); |
break; |
case 0x109: |
table = u109; |
size = sizeof(u109); |
break; |
case 0x10a: |
table = u10a; |
size = sizeof(u10a); |
break; |
case 0x10b: |
table = u10b; |
size = sizeof(u10b); |
break; |
case 0x10c: |
table = u10c; |
size = sizeof(u10c); |
break; |
case 0x110: |
table = u110; |
size = sizeof(u110); |
break; |
case 0x123: |
table = u123; |
size = sizeof(u123); |
break; |
case 0x124: |
table = u124; |
size = sizeof(u124); |
break; |
case 0x134: |
table = u134; |
size = sizeof(u134); |
break; |
case 0x1d4: |
table = u1d4; |
size = sizeof(u1d4); |
break; |
case 0x1d5: |
table = u1d5; |
size = sizeof(u1d5); |
break; |
case 0x1d6: |
table = u1d6; |
size = sizeof(u1d6); |
break; |
case 0x1d7: |
table = u1d7; |
size = sizeof(u1d7); |
break; |
case 0x1f1: |
table = u1f1; |
size = sizeof(u1f1); |
break; |
case 0x2a6: |
table = u2a6; |
size = sizeof(u2a6); |
break; |
case 0x2b7: |
table = u2b7; |
size = sizeof(u2b7); |
break; |
case 0x2fa: |
table = u2fa; |
size = sizeof(u2fa); |
break; |
default: |
return 0; |
} |
/* we have narrowed down to a section of 256 characters to check */ |
/* now check if c matches the alphabetic wide-chars within that section */ |
ptr = (unsigned char *)table; |
ctmp = (unsigned char)c; |
while (ptr < table + size) |
{ |
if (ctmp == *ptr) |
return 1; |
if (ctmp < *ptr) |
return 0; |
/* otherwise c > *ptr */ |
/* look for 0x0 as next element which indicates a range */ |
++ptr; |
if (*ptr == 0x0) |
{ |
/* we have a range..see if c falls within range */ |
++ptr; |
if (ctmp <= *ptr) |
return 1; |
++ptr; |
} |
} |
/* not in table */ |
return 0; |
#else |
return (c < (wint_t)0x100 ? isalpha (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/programs/develop/libraries/newlib/ctype/iswblank.c |
---|
0,0 → 1,82 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswblank>>---blank wide character test |
INDEX |
iswblank |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswblank(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswblank(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswblank>> is a function which classifies wide-character values that |
are categorized as blank. |
RETURNS |
<<iswblank>> returns non-zero if <[c]> is a blank wide character. |
PORTABILITY |
<<iswblank>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <ctype.h> |
#include <string.h> |
#include "local.h" |
int |
_DEFUN(iswblank,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on Unicode 5.2. Control char 09, plus all characters |
from general category "Zs", which are not marked as decomposition |
type "noBreak". */ |
return (c == 0x0009 || c == 0x0020 || |
c == 0x1680 || c == 0x180e || |
(c >= 0x2000 && c <= 0x2006) || |
(c >= 0x2008 && c <= 0x200a) || |
c == 0x205f || c == 0x3000); |
#else |
return (c < 0x100 ? isblank (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/programs/develop/libraries/newlib/ctype/iswcntrl.c |
---|
0,0 → 1,80 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswcntrl>>---control wide character test |
INDEX |
iswcntrl |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswcntrl(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswcntrl(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswcntrl>> is a function which classifies wide-character values that |
are categorized as control characters. |
RETURNS |
<<iswcntrl>> returns non-zero if <[c]> is a control wide character. |
PORTABILITY |
<<iswcntrl>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <ctype.h> |
#include <string.h> |
#include "local.h" |
int |
_DEFUN(iswcntrl,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on Unicode 5.2. All characters from general category "Cc", "Zl", |
and "Zp". */ |
return ((c >= 0x0000 && c <= 0x001f) || |
(c >= 0x007f && c <= 0x009f) || |
c == 0x2028 || c == 0x2029); |
#else |
return (c < 0x100 ? iscntrl (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/programs/develop/libraries/newlib/ctype/iswctype.c |
---|
0,0 → 1,71 |
/* |
FUNCTION |
<<iswctype>>---extensible wide-character test |
INDEX |
iswctype |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswctype(wint_t <[c]>, wctype_t <[desc]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswctype(<[c]>, <[desc]>) |
wint_t <[c]>; |
wctype_t <[desc]>; |
DESCRIPTION |
<<iswctype>> is a function which classifies wide-character values using the |
wide-character test specified by <[desc]>. |
RETURNS |
<<iswctype>> returns non-zero if and only if <[c]> matches the test specified by <[desc]>. |
If <[desc]> is unknown, zero is returned. |
PORTABILITY |
<<iswctype>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
#include "local.h" |
int |
_DEFUN(iswctype,(c, desc), wint_t c _AND wctype_t desc) |
{ |
switch (desc) |
{ |
case WC_ALNUM: |
return iswalnum (c); |
case WC_ALPHA: |
return iswalpha (c); |
case WC_BLANK: |
return iswblank (c); |
case WC_CNTRL: |
return iswcntrl (c); |
case WC_DIGIT: |
return iswdigit (c); |
case WC_GRAPH: |
return iswgraph (c); |
case WC_LOWER: |
return iswlower (c); |
case WC_PRINT: |
return iswprint (c); |
case WC_PUNCT: |
return iswpunct (c); |
case WC_SPACE: |
return iswspace (c); |
case WC_UPPER: |
return iswupper (c); |
case WC_XDIGIT: |
return iswxdigit (c); |
default: |
return 0; /* eliminate warning */ |
} |
/* otherwise unknown */ |
return 0; |
} |
/programs/develop/libraries/newlib/ctype/iswdigit.c |
---|
0,0 → 1,37 |
/* |
FUNCTION |
<<iswdigit>>---decimal digit wide character test |
INDEX |
iswdigit |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswdigit(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswdigit(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswdigit>> is a function which classifies wide-character values that |
are decimal digits. |
RETURNS |
<<iswdigit>> returns non-zero if <[c]> is a decimal digit wide character. |
PORTABILITY |
<<iswdigit>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswdigit,(c), wint_t c) |
{ |
return (c >= (wint_t)'0' && c <= (wint_t)'9'); |
} |
/programs/develop/libraries/newlib/ctype/iswgraph.c |
---|
0,0 → 1,66 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswgraph>>---graphic wide character test |
INDEX |
iswgraph |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswgraph(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswgraph(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswgraph>> is a function which classifies wide-character values that |
are graphic. |
RETURNS |
<<iswgraph>> returns non-zero if <[c]> is a graphic wide character. |
PORTABILITY |
<<iswgraph>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswgraph,(c),wint_t c) |
{ |
return (iswprint (c) && !iswspace (c)); |
} |
/programs/develop/libraries/newlib/ctype/iswlower.c |
---|
0,0 → 1,38 |
/* |
FUNCTION |
<<iswlower>>---lowercase wide character test |
INDEX |
iswlower |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswlower(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswlower(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswlower>> is a function which classifies wide-character values that |
have uppercase translations. |
RETURNS |
<<iswlower>> returns non-zero if <[c]> is a lowercase wide character. |
PORTABILITY |
<<iswlower>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswlower,(c),wint_t c) |
{ |
return (towupper (c) != c); |
} |
/programs/develop/libraries/newlib/ctype/iswprint.c |
---|
0,0 → 1,496 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswprint>>---printable wide character test |
INDEX |
iswprint |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswprint(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswprint(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswprint>> is a function which classifies wide-character values that |
are printable. |
RETURNS |
<<iswprint>> returns non-zero if <[c]> is a printable wide character. |
PORTABILITY |
<<iswprint>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <string.h> |
#include <ctype.h> |
#include "local.h" |
#ifdef _MB_CAPABLE |
#include "utf8print.h" |
#endif /* _MB_CAPABLE */ |
int |
_DEFUN(iswprint,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
unsigned const char *table; |
unsigned char *ptr; |
unsigned char ctmp; |
int size; |
wint_t x; |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 |
See utf8print.h for a description how to fetch the data. */ |
x = (c >> 8); |
/* for some large sections, all characters are printuation so handle them here */ |
if ((x >= 0x33 && x <= 0x4c) || |
(x >= 0x4e && x <= 0x9e) || |
(x >= 0xa0 && x <= 0xa3) || |
(x >= 0xac && x <= 0xd6) || |
(x >= 0xe0 && x <= 0xf9) || |
(x >= 0x120 && x <= 0x122) || |
(x >= 0x130 && x <= 0x133) || |
(x >= 0x200 && x <= 0x2a5) || |
(x >= 0x2a7 && x <= 0x2b6) || |
(x >= 0xf00 && x <= 0xffe) || |
(x >= 0x1000 && x <= 0x10fe)) |
return 1; |
switch (x) |
{ |
case 0x01: |
case 0x02: |
case 0x04: |
case 0x11: |
case 0x14: |
case 0x15: |
case 0x1e: |
case 0x22: |
case 0x25: |
case 0x28: |
case 0x29: |
case 0x2a: |
case 0xa5: |
case 0xfc: |
case 0x2f8: |
case 0x2f9: |
return 1; |
case 0x00: |
table = u0; |
size = sizeof(u0); |
break; |
case 0x03: |
table = u3; |
size = sizeof(u3); |
break; |
case 0x05: |
table = u5; |
size = sizeof(u5); |
break; |
case 0x06: |
table = u6; |
size = sizeof(u6); |
break; |
case 0x07: |
table = u7; |
size = sizeof(u7); |
break; |
case 0x08: |
table = u8; |
size = sizeof(u8); |
break; |
case 0x09: |
table = u9; |
size = sizeof(u9); |
break; |
case 0x0a: |
table = ua; |
size = sizeof(ua); |
break; |
case 0x0b: |
table = ub; |
size = sizeof(ub); |
break; |
case 0x0c: |
table = uc; |
size = sizeof(uc); |
break; |
case 0x0d: |
table = ud; |
size = sizeof(ud); |
break; |
case 0x0e: |
table = ue; |
size = sizeof(ue); |
break; |
case 0x0f: |
table = uf; |
size = sizeof(uf); |
break; |
case 0x10: |
table = u10; |
size = sizeof(u10); |
break; |
case 0x12: |
table = u12; |
size = sizeof(u12); |
break; |
case 0x13: |
table = u13; |
size = sizeof(u13); |
break; |
case 0x16: |
table = u16; |
size = sizeof(u16); |
break; |
case 0x17: |
table = u17; |
size = sizeof(u17); |
break; |
case 0x18: |
table = u18; |
size = sizeof(u18); |
break; |
case 0x19: |
table = u19; |
size = sizeof(u19); |
break; |
case 0x1a: |
table = u1a; |
size = sizeof(u1a); |
break; |
case 0x1b: |
table = u1b; |
size = sizeof(u1b); |
break; |
case 0x1c: |
table = u1c; |
size = sizeof(u1c); |
break; |
case 0x1d: |
table = u1d; |
size = sizeof(u1d); |
break; |
case 0x1f: |
table = u1f; |
size = sizeof(u1f); |
break; |
case 0x20: |
table = u20; |
size = sizeof(u20); |
break; |
case 0x21: |
table = u21; |
size = sizeof(u21); |
break; |
case 0x23: |
table = u23; |
size = sizeof(u23); |
break; |
case 0x24: |
table = u24; |
size = sizeof(u24); |
break; |
case 0x26: |
table = u26; |
size = sizeof(u26); |
break; |
case 0x27: |
table = u27; |
size = sizeof(u27); |
break; |
case 0x2b: |
table = u2b; |
size = sizeof(u2b); |
break; |
case 0x2c: |
table = u2c; |
size = sizeof(u2c); |
break; |
case 0x2d: |
table = u2d; |
size = sizeof(u2d); |
break; |
case 0x2e: |
table = u2e; |
size = sizeof(u2e); |
break; |
case 0x2f: |
table = u2f; |
size = sizeof(u2f); |
break; |
case 0x30: |
table = u30; |
size = sizeof(u30); |
break; |
case 0x31: |
table = u31; |
size = sizeof(u31); |
break; |
case 0x32: |
table = u32; |
size = sizeof(u32); |
break; |
case 0x4d: |
table = u4d; |
size = sizeof(u4d); |
break; |
case 0x9f: |
table = u9f; |
size = sizeof(u9f); |
break; |
case 0xa4: |
table = ua4; |
size = sizeof(ua4); |
break; |
case 0xa6: |
table = ua6; |
size = sizeof(ua6); |
break; |
case 0xa7: |
table = ua7; |
size = sizeof(ua7); |
break; |
case 0xa8: |
table = ua8; |
size = sizeof(ua8); |
break; |
case 0xa9: |
table = ua9; |
size = sizeof(ua9); |
break; |
case 0xaa: |
table = uaa; |
size = sizeof(uaa); |
break; |
case 0xab: |
table = uab; |
size = sizeof(uab); |
break; |
case 0xd7: |
table = ud7; |
size = sizeof(ud7); |
break; |
case 0xfa: |
table = ufa; |
size = sizeof(ufa); |
break; |
case 0xfb: |
table = ufb; |
size = sizeof(ufb); |
break; |
case 0xfd: |
table = ufd; |
size = sizeof(ufd); |
break; |
case 0xfe: |
table = ufe; |
size = sizeof(ufe); |
break; |
case 0xff: |
table = uff; |
size = sizeof(uff); |
break; |
case 0x100: |
table = u100; |
size = sizeof(u100); |
break; |
case 0x101: |
table = u101; |
size = sizeof(u101); |
break; |
case 0x102: |
table = u102; |
size = sizeof(u102); |
break; |
case 0x103: |
table = u103; |
size = sizeof(u103); |
break; |
case 0x104: |
table = u104; |
size = sizeof(u104); |
break; |
case 0x108: |
table = u108; |
size = sizeof(u108); |
break; |
case 0x109: |
table = u109; |
size = sizeof(u109); |
break; |
case 0x10a: |
table = u10a; |
size = sizeof(u10a); |
break; |
case 0x10b: |
table = u10b; |
size = sizeof(u10b); |
break; |
case 0x10c: |
table = u10c; |
size = sizeof(u10c); |
break; |
case 0x10e: |
table = u10e; |
size = sizeof(u10e); |
break; |
case 0x110: |
table = u110; |
size = sizeof(u110); |
break; |
case 0x123: |
table = u123; |
size = sizeof(u123); |
break; |
case 0x124: |
table = u124; |
size = sizeof(u124); |
break; |
case 0x134: |
table = u134; |
size = sizeof(u134); |
break; |
case 0x1d0: |
table = u1d0; |
size = sizeof(u1d0); |
break; |
case 0x1d1: |
table = u1d1; |
size = sizeof(u1d1); |
break; |
case 0x1d2: |
table = u1d2; |
size = sizeof(u1d2); |
break; |
case 0x1d3: |
table = u1d3; |
size = sizeof(u1d3); |
break; |
case 0x1d4: |
table = u1d4; |
size = sizeof(u1d4); |
break; |
case 0x1d5: |
table = u1d5; |
size = sizeof(u1d5); |
break; |
case 0x1d6: |
table = u1d6; |
size = sizeof(u1d6); |
break; |
case 0x1d7: |
table = u1d7; |
size = sizeof(u1d7); |
break; |
case 0x1f0: |
table = u1f0; |
size = sizeof(u1f0); |
break; |
case 0x1f1: |
table = u1f1; |
size = sizeof(u1f1); |
break; |
case 0x1f2: |
table = u1f2; |
size = sizeof(u1f2); |
break; |
case 0x2a6: |
table = u2a6; |
size = sizeof(u2a6); |
break; |
case 0x2b7: |
table = u2b7; |
size = sizeof(u2b7); |
break; |
case 0x2fa: |
table = u2fa; |
size = sizeof(u2fa); |
break; |
case 0xe00: |
table = ue00; |
size = sizeof(ue00); |
break; |
case 0xe01: |
table = ue01; |
size = sizeof(ue01); |
break; |
case 0xfff: |
table = ufff; |
size = sizeof(ufff); |
break; |
case 0x10ff: |
table = u10ff; |
size = sizeof(u10ff); |
break; |
default: |
return 0; |
} |
/* we have narrowed down to a section of 256 characters to check */ |
/* now check if c matches the printuation wide-chars within that section */ |
ptr = (unsigned char *)table; |
ctmp = (unsigned char)c; |
while (ptr < table + size) |
{ |
if (ctmp == *ptr) |
return 1; |
if (ctmp < *ptr) |
return 0; |
/* otherwise c > *ptr */ |
/* look for 0x0 as next element which indicates a range */ |
++ptr; |
if (*ptr == 0x0) |
{ |
/* we have a range..see if c falls within range */ |
++ptr; |
if (ctmp <= *ptr) |
return 1; |
++ptr; |
} |
} |
/* not in table */ |
return 0; |
#else |
return (c < (wint_t)0x100 ? isprint (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/programs/develop/libraries/newlib/ctype/iswpunct.c |
---|
0,0 → 1,70 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswpunct>>---punctuation wide character test |
INDEX |
iswpunct |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswpunct(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswpunct(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswpunct>> is a function which classifies wide-character values that |
are punctuation. |
RETURNS |
<<iswpunct>> returns non-zero if <[c]> is a punctuation wide character. |
PORTABILITY |
<<iswpunct>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <string.h> |
#include <ctype.h> |
#include "local.h" |
int |
_DEFUN(iswpunct,(c), wint_t c) |
{ |
return (!iswalnum (c) && iswgraph (c)); |
} |
/programs/develop/libraries/newlib/ctype/iswspace.c |
---|
0,0 → 1,83 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswspace>>---whitespace wide character test |
INDEX |
iswspace |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswspace(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswspace(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswspace>> is a function which classifies wide-character values that |
are categorized as whitespace. |
RETURNS |
<<iswspace>> returns non-zero if <[c]> is a whitespace wide character. |
PORTABILITY |
<<iswspace>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <ctype.h> |
#include <string.h> |
#include "local.h" |
int |
_DEFUN(iswspace,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on Unicode 5.2. Control chars 09-0D, plus all characters |
from general category "Zs", which are not marked as decomposition |
type "noBreak". */ |
return ((c >= 0x0009 && c <= 0x000d) || c == 0x0020 || |
c == 0x1680 || c == 0x180e || |
(c >= 0x2000 && c <= 0x2006) || |
(c >= 0x2008 && c <= 0x200a) || |
c == 0x2028 || c == 0x2029 || |
c == 0x205f || c == 0x3000); |
#else |
return (c < 0x100 ? isspace (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/programs/develop/libraries/newlib/ctype/iswupper.c |
---|
0,0 → 1,38 |
/* |
FUNCTION |
<<iswupper>>---uppercase wide character test |
INDEX |
iswupper |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswupper(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswupper(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswupper>> is a function which classifies wide-character values that |
have uppercase translations. |
RETURNS |
<<iswupper>> returns non-zero if <[c]> is a uppercase wide character. |
PORTABILITY |
<<iswupper>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswupper,(c),wint_t c) |
{ |
return (towlower (c) != c); |
} |
/programs/develop/libraries/newlib/ctype/iswxdigit.c |
---|
0,0 → 1,39 |
/* |
FUNCTION |
<<iswxdigit>>---hexadecimal digit wide character test |
INDEX |
iswxdigit |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswxdigit(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswxdigit(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswxdigit>> is a function which classifies wide character values that |
are hexadecimal digits. |
RETURNS |
<<iswxdigit>> returns non-zero if <[c]> is a hexadecimal digit wide character. |
PORTABILITY |
<<iswxdigit>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswxdigit,(c), wint_t c) |
{ |
return ((c >= (wint_t)'0' && c <= (wint_t)'9') || |
(c >= (wint_t)'a' && c <= (wint_t)'f') || |
(c >= (wint_t)'A' && c <= (wint_t)'F')); |
} |
/programs/develop/libraries/newlib/ctype/isxdigit.c |
---|
0,0 → 1,45 |
/* |
FUNCTION |
<<isxdigit>>---hexadecimal digit predicate |
INDEX |
isxdigit |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isxdigit(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isxdigit(int <[c]>); |
DESCRIPTION |
<<isxdigit>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for hexadecimal digits, |
and <<0>> for other characters. It is defined only when |
<<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isxdigit>>'. |
RETURNS |
<<isxdigit>> returns non-zero if <[c]> is a hexadecimal digit |
(<<0>>--<<9>>, <<a>>--<<f>>, or <<A>>--<<F>>). |
PORTABILITY |
<<isxdigit>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isxdigit |
int |
_DEFUN(isxdigit,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & ((_X)|(_N))); |
} |
/programs/develop/libraries/newlib/ctype/jp2uc.h |
---|
0,0 → 1,6849 |
/* based on eucjp-208A.txt */ |
/* a1 is contiguous from a1a1 to a1fe */ |
static unsigned short a1[] = { |
0x3000, |
0x3001, |
0x3002, |
0xFF0C, |
0xFF0E, |
0x30FB, |
0xFF1A, |
0xFF1B, |
0xFF1F, |
0xFF01, |
0x309B, |
0x309C, |
0x00B4, |
0xFF40, |
0x00A8, |
0xFF3E, |
0x203E, |
0xFF3F, |
0x30FD, |
0x30FE, |
0x309D, |
0x309E, |
0x3003, |
0x4EDD, |
0x3005, |
0x3006, |
0x3007, |
0x30FC, |
0x2014, |
0x2010, |
0xFF0F, |
0xFF3C, |
0x301C, |
0x2016, |
0xFF5C, |
0x2026, |
0x2025, |
0x2018, |
0x2019, |
0x201C, |
0x201D, |
0xFF08, |
0xFF09, |
0x3014, |
0x3015, |
0xFF3B, |
0xFF3D, |
0xFF5B, |
0xFF5D, |
0x3008, |
0x3009, |
0x300A, |
0x300B, |
0x300C, |
0x300D, |
0x300E, |
0x300F, |
0x3010, |
0x3011, |
0xFF0B, |
0x2212, |
0x00B1, |
0x00D7, |
0x00F7, |
0xFF1D, |
0x2260, |
0xFF1C, |
0xFF1E, |
0x2266, |
0x2267, |
0x221E, |
0x2234, |
0x2642, |
0x2640, |
0x00B0, |
0x2032, |
0x2033, |
0x2103, |
0x00A5, |
0xFF04, |
0x00A2, |
0x00A3, |
0xFF05, |
0xFF03, |
0xFF06, |
0xFF0A, |
0xFF20, |
0x00A7, |
0x2606, |
0x2605, |
0x25CB, |
0x25CF, |
0x25CE, |
0x25C7 |
}; |
/* a2 has a number of holes between a2a1 and a2fe which we fill with 0x0000 */ |
static unsigned short a2[] = { |
0x25C6, |
0x25A1, |
0x25A0, |
0x25B3, |
0x25B2, |
0x25BD, |
0x25BC, |
0x203B, |
0x3012, |
0x2192, |
0x2190, |
0x2191, |
0x2193, |
0x3013, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x2208, |
0x220B, |
0x2286, |
0x2287, |
0x2282, |
0x2283, |
0x222A, |
0x2229, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x2227, |
0x2228, |
0x00AC, |
0x21D2, |
0x21D4, |
0x2200, |
0x2203, |
0x2229, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x2220, |
0x22A5, |
0x2312, |
0x2202, |
0x2207, |
0x2261, |
0x2252, |
0x226A, |
0x226B, |
0x221A, |
0x223D, |
0x221D, |
0x2235, |
0x222B, |
0x222C, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x212B, |
0x2030, |
0x266F, |
0x266D, |
0x266A, |
0x2020, |
0x2021, |
0x00B6, |
0x222C, |
0x0000, |
0x0000, |
0x0000, |
0x25EF |
}; |
/* a3a1 to a3fe is mostly contiguous. Conversion output values are |
of the form 0xFFxx where xx is (yy - 0xA0) where the input is 0xA3yy */ |
static unsigned char a3[] = { |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1 |
}; |
/* a4 is contiguous from a4a1 to a4f3 */ |
/* transform = 0x30xx where xx = last byte - 0x60 */ |
/* a5 is contiguous from a5a1 to a5f6 */ |
/* transform = 0x30xx where xx = last byte */ |
/* a6 is mostly contiguous from a6a1 to a6d8 */ |
static unsigned short a6[] = { |
0x0391, |
0x0392, |
0x0393, |
0x0394, |
0x0395, |
0x0396, |
0x0397, |
0x0398, |
0x0399, |
0x039A, |
0x039B, |
0x039C, |
0x039D, |
0x039E, |
0x039F, |
0x03A0, |
0x03A1, |
0x03A3, |
0x03A4, |
0x03A5, |
0x03A6, |
0x03A7, |
0x03A8, |
0x03A9, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x03B1, |
0x03B2, |
0x03B3, |
0x03B4, |
0x03B5, |
0x03B6, |
0x03B7, |
0x03B8, |
0x03B9, |
0x03BA, |
0x03BB, |
0x03BC, |
0x03BD, |
0x03BE, |
0x03BF, |
0x03C0, |
0x03C1, |
0x03C3, |
0x03C4, |
0x03C5, |
0x03C6, |
0x03C7, |
0x03C8, |
0x03C9 |
}; |
/* a7 is mostly contiguous from a7a1 to a7f1 */ |
static unsigned short a7[] = { |
0x0410, |
0x0411, |
0x0412, |
0x0413, |
0x0414, |
0x0415, |
0x0401, |
0x0416, |
0x0417, |
0x0418, |
0x0419, |
0x041A, |
0x041B, |
0x041C, |
0x041D, |
0x041E, |
0x041F, |
0x0420, |
0x0421, |
0x0422, |
0x0423, |
0x0424, |
0x0425, |
0x0426, |
0x0427, |
0x0428, |
0x0429, |
0x042A, |
0x042B, |
0x042C, |
0x042D, |
0x042E, |
0x042F, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0430, |
0x0431, |
0x0432, |
0x0433, |
0x0434, |
0x0435, |
0x0451, |
0x0436, |
0x0437, |
0x0438, |
0x0439, |
0x043A, |
0x043B, |
0x043C, |
0x043D, |
0x043E, |
0x043F, |
0x0440, |
0x0441, |
0x0442, |
0x0443, |
0x0444, |
0x0445, |
0x0446, |
0x0447, |
0x0448, |
0x0449, |
0x044A, |
0x044B, |
0x044C, |
0x044D, |
0x044E, |
0x044F |
}; |
/* a8 is contiguous from a8a1 to a8c0 */ |
static unsigned short a8[] = { |
0x2500, |
0x2502, |
0x250C, |
0x2510, |
0x2518, |
0x2514, |
0x251C, |
0x252C, |
0x2524, |
0x2534, |
0x253C, |
0x2501, |
0x2503, |
0x250F, |
0x2513, |
0x251B, |
0x2517, |
0x2523, |
0x2533, |
0x252B, |
0x253B, |
0x254B, |
0x2520, |
0x252F, |
0x2528, |
0x2537, |
0x253F, |
0x251D, |
0x2530, |
0x2525, |
0x2538, |
0x2542 |
}; |
/* no conversion a9 to af */ |
/* b0a1 to cfd3 is contiguous except for illegal sequences with 0xfe */ |
static unsigned short b02cf[] = { |
0x4E9C, |
0x5516, |
0x5A03, |
0x963F, |
0x54C0, |
0x611B, |
0x6328, |
0x59F6, |
0x9022, |
0x8475, |
0x831C, |
0x7A50, |
0x60AA, |
0x63E1, |
0x6E25, |
0x65ED, |
0x8466, |
0x82A6, |
0x9BF5, |
0x6893, |
0x5727, |
0x65A1, |
0x6271, |
0x5B9B, |
0x59D0, |
0x867B, |
0x98F4, |
0x7D62, |
0x7DBE, |
0x9B8E, |
0x6216, |
0x7C9F, |
0x88B7, |
0x5B89, |
0x5EB5, |
0x6309, |
0x6697, |
0x6848, |
0x95C7, |
0x978D, |
0x674F, |
0x4EE5, |
0x4F0A, |
0x4F4D, |
0x4F9D, |
0x5049, |
0x56F2, |
0x5937, |
0x59D4, |
0x5A01, |
0x5C09, |
0x60DF, |
0x610F, |
0x6170, |
0x6613, |
0x6905, |
0x70BA, |
0x754F, |
0x7570, |
0x79FB, |
0x7DAD, |
0x7DEF, |
0x80C3, |
0x840E, |
0x8863, |
0x8B02, |
0x9055, |
0x907A, |
0x533B, |
0x4E95, |
0x4EA5, |
0x57DF, |
0x80B2, |
0x90C1, |
0x78EF, |
0x4E00, |
0x58F1, |
0x6EA2, |
0x9038, |
0x7A32, |
0x8328, |
0x828B, |
0x9C2F, |
0x5141, |
0x5370, |
0x54BD, |
0x54E1, |
0x56E0, |
0x59FB, |
0x5F15, |
0x98F2, |
0x6DEB, |
0x80E4, |
0x852D, |
0x9662, |
0x9670, |
0x96A0, |
0x97FB, |
0x540B, |
0x53F3, |
0x5B87, |
0x70CF, |
0x7FBD, |
0x8FC2, |
0x96E8, |
0x536F, |
0x9D5C, |
0x7ABA, |
0x4E11, |
0x7893, |
0x81FC, |
0x6E26, |
0x5618, |
0x5504, |
0x6B1D, |
0x851A, |
0x9C3B, |
0x59E5, |
0x53A9, |
0x6D66, |
0x74DC, |
0x958F, |
0x5642, |
0x4E91, |
0x904B, |
0x96F2, |
0x834F, |
0x990C, |
0x53E1, |
0x55B6, |
0x5B30, |
0x5F71, |
0x6620, |
0x66F3, |
0x6804, |
0x6C38, |
0x6CF3, |
0x6D29, |
0x745B, |
0x76C8, |
0x7A4E, |
0x9834, |
0x82F1, |
0x885B, |
0x8A60, |
0x92ED, |
0x6DB2, |
0x75AB, |
0x76CA, |
0x99C5, |
0x60A6, |
0x8B01, |
0x8D8A, |
0x95B2, |
0x698E, |
0x53AD, |
0x5186, |
0x5712, |
0x5830, |
0x5944, |
0x5BB4, |
0x5EF6, |
0x6028, |
0x63A9, |
0x63F4, |
0x6CBF, |
0x6F14, |
0x708E, |
0x7114, |
0x7159, |
0x71D5, |
0x733F, |
0x7E01, |
0x8276, |
0x82D1, |
0x8597, |
0x9060, |
0x925B, |
0x9D1B, |
0x5869, |
0x65BC, |
0x6C5A, |
0x7525, |
0x51F9, |
0x592E, |
0x5965, |
0x5F80, |
0x5FDC, |
0x62BC, |
0x65FA, |
0x6A2A, |
0x6B27, |
0x6BB4, |
0x738B, |
0x7FC1, |
0x8956, |
0x9D2C, |
0x9D0E, |
0x9EC4, |
0x5CA1, |
0x6C96, |
0x837B, |
0x5104, |
0x5C4B, |
0x61B6, |
0x81C6, |
0x6876, |
0x7261, |
0x4E59, |
0x4FFA, |
0x5378, |
0x6069, |
0x6E29, |
0x7A4F, |
0x97F3, |
0x4E0B, |
0x5316, |
0x4EEE, |
0x4F55, |
0x4F3D, |
0x4FA1, |
0x4F73, |
0x52A0, |
0x53EF, |
0x5609, |
0x590F, |
0x5AC1, |
0x5BB6, |
0x5BE1, |
0x79D1, |
0x6687, |
0x679C, |
0x67B6, |
0x6B4C, |
0x6CB3, |
0x706B, |
0x73C2, |
0x798D, |
0x79BE, |
0x7A3C, |
0x7B87, |
0x82B1, |
0x82DB, |
0x8304, |
0x8377, |
0x83EF, |
0x83D3, |
0x8766, |
0x8AB2, |
0x5629, |
0x8CA8, |
0x8FE6, |
0x904E, |
0x971E, |
0x868A, |
0x4FC4, |
0x5CE8, |
0x6211, |
0x7259, |
0x753B, |
0x81E5, |
0x82BD, |
0x86FE, |
0x8CC0, |
0x96C5, |
0x9913, |
0x99D5, |
0x4ECB, |
0x4F1A, |
0x89E3, |
0x56DE, |
0x584A, |
0x58CA, |
0x5EFB, |
0x5FEB, |
0x602A, |
0x6094, |
0x6062, |
0x61D0, |
0x6212, |
0x62D0, |
0x6539, |
0x9B41, |
0x6666, |
0x68B0, |
0x6D77, |
0x7070, |
0x754C, |
0x7686, |
0x7D75, |
0x82A5, |
0x87F9, |
0x958B, |
0x968E, |
0x8C9D, |
0x51F1, |
0x52BE, |
0x5916, |
0x54B3, |
0x5BB3, |
0x5D16, |
0x6168, |
0x6982, |
0x6DAF, |
0x788D, |
0x84CB, |
0x8857, |
0x8A72, |
0x93A7, |
0x9AB8, |
0x6D6C, |
0x99A8, |
0x86D9, |
0x57A3, |
0x67FF, |
0x86CE, |
0x920E, |
0x5283, |
0x5687, |
0x5404, |
0x5ED3, |
0x62E1, |
0x64B9, |
0x683C, |
0x6838, |
0x6BBB, |
0x7372, |
0x78BA, |
0x7A6B, |
0x899A, |
0x89D2, |
0x8D6B, |
0x8F03, |
0x90ED, |
0x95A3, |
0x9694, |
0x9769, |
0x5B66, |
0x5CB3, |
0x697D, |
0x984D, |
0x984E, |
0x639B, |
0x7B20, |
0x6A2B, |
0x6A7F, |
0x68B6, |
0x9C0D, |
0x6F5F, |
0x5272, |
0x559D, |
0x6070, |
0x62EC, |
0x6D3B, |
0x6E07, |
0x6ED1, |
0x845B, |
0x8910, |
0x8F44, |
0x4E14, |
0x9C39, |
0x53F6, |
0x691B, |
0x6A3A, |
0x9784, |
0x682A, |
0x515C, |
0x7AC3, |
0x84B2, |
0x91DC, |
0x938C, |
0x565B, |
0x9D28, |
0x6822, |
0x8305, |
0x8431, |
0x7CA5, |
0x5208, |
0x82C5, |
0x74E6, |
0x4E7E, |
0x4F83, |
0x51A0, |
0x5BD2, |
0x520A, |
0x52D8, |
0x52E7, |
0x5DFB, |
0x559A, |
0x582A, |
0x59E6, |
0x5B8C, |
0x5B98, |
0x5BDB, |
0x5E72, |
0x5E79, |
0x60A3, |
0x611F, |
0x6163, |
0x61BE, |
0x63DB, |
0x6562, |
0x67D1, |
0x6853, |
0x68FA, |
0x6B3E, |
0x6B53, |
0x6C57, |
0x6F22, |
0x6F97, |
0x6F45, |
0x74B0, |
0x7518, |
0x76E3, |
0x770B, |
0x7AFF, |
0x7BA1, |
0x7C21, |
0x7DE9, |
0x7F36, |
0x7FF0, |
0x809D, |
0x8266, |
0x839E, |
0x89B3, |
0x8ACC, |
0x8CAB, |
0x9084, |
0x9451, |
0x9593, |
0x9591, |
0x95A2, |
0x9665, |
0x97D3, |
0x9928, |
0x8218, |
0x4E38, |
0x542B, |
0x5CB8, |
0x5DCC, |
0x73A9, |
0x764C, |
0x773C, |
0x5CA9, |
0x7FEB, |
0x8D0B, |
0x96C1, |
0x9811, |
0x9854, |
0x9858, |
0x4F01, |
0x4F0E, |
0x5371, |
0x559C, |
0x5668, |
0x57FA, |
0x5947, |
0x5B09, |
0x5BC4, |
0x5C90, |
0x5E0C, |
0x5E7E, |
0x5FCC, |
0x63EE, |
0x673A, |
0x65D7, |
0x65E2, |
0x671F, |
0x68CB, |
0x68C4, |
0x6A5F, |
0x5E30, |
0x6BC5, |
0x6C17, |
0x6C7D, |
0x757F, |
0x7948, |
0x5B63, |
0x7A00, |
0x7D00, |
0x5FBD, |
0x898F, |
0x8A18, |
0x8CB4, |
0x8D77, |
0x8ECC, |
0x8F1D, |
0x98E2, |
0x9A0E, |
0x9B3C, |
0x4E80, |
0x507D, |
0x5100, |
0x5993, |
0x5B9C, |
0x622F, |
0x6280, |
0x64EC, |
0x6B3A, |
0x72A0, |
0x7591, |
0x7947, |
0x7FA9, |
0x87FB, |
0x8ABC, |
0x8B70, |
0x63AC, |
0x83CA, |
0x97A0, |
0x5409, |
0x5403, |
0x55AB, |
0x6854, |
0x6A58, |
0x8A70, |
0x7827, |
0x6775, |
0x9ECD, |
0x5374, |
0x5BA2, |
0x811A, |
0x8650, |
0x9006, |
0x4E18, |
0x4E45, |
0x4EC7, |
0x4F11, |
0x53CA, |
0x5438, |
0x5BAE, |
0x5F13, |
0x6025, |
0x6551, |
0x673D, |
0x6C42, |
0x6C72, |
0x6CE3, |
0x7078, |
0x7403, |
0x7A76, |
0x7AAE, |
0x7B08, |
0x7D1A, |
0x7CFE, |
0x7D66, |
0x65E7, |
0x725B, |
0x53BB, |
0x5C45, |
0x5DE8, |
0x62D2, |
0x62E0, |
0x6319, |
0x6E20, |
0x865A, |
0x8A31, |
0x8DDD, |
0x92F8, |
0x6F01, |
0x79A6, |
0x9B5A, |
0x4EA8, |
0x4EAB, |
0x4EAC, |
0x4F9B, |
0x4FA0, |
0x50D1, |
0x5147, |
0x7AF6, |
0x5171, |
0x51F6, |
0x5354, |
0x5321, |
0x537F, |
0x53EB, |
0x55AC, |
0x5883, |
0x5CE1, |
0x5F37, |
0x5F4A, |
0x602F, |
0x6050, |
0x606D, |
0x631F, |
0x6559, |
0x6A4B, |
0x6CC1, |
0x72C2, |
0x72ED, |
0x77EF, |
0x80F8, |
0x8105, |
0x8208, |
0x854E, |
0x90F7, |
0x93E1, |
0x97FF, |
0x9957, |
0x9A5A, |
0x4EF0, |
0x51DD, |
0x5C2D, |
0x6681, |
0x696D, |
0x5C40, |
0x66F2, |
0x6975, |
0x7389, |
0x6850, |
0x7C81, |
0x50C5, |
0x52E4, |
0x5747, |
0x5DFE, |
0x9326, |
0x65A4, |
0x6B23, |
0x6B3D, |
0x7434, |
0x7981, |
0x79BD, |
0x7B4B, |
0x7DCA, |
0x82B9, |
0x83CC, |
0x887F, |
0x895F, |
0x8B39, |
0x8FD1, |
0x91D1, |
0x541F, |
0x9280, |
0x4E5D, |
0x5036, |
0x53E5, |
0x533A, |
0x72D7, |
0x7396, |
0x77E9, |
0x82E6, |
0x8EAF, |
0x99C6, |
0x99C8, |
0x99D2, |
0x5177, |
0x611A, |
0x865E, |
0x55B0, |
0x7A7A, |
0x5076, |
0x5BD3, |
0x9047, |
0x9685, |
0x4E32, |
0x6ADB, |
0x91E7, |
0x5C51, |
0x5C48, |
0x6398, |
0x7A9F, |
0x6C93, |
0x9774, |
0x8F61, |
0x7AAA, |
0x718A, |
0x9688, |
0x7C82, |
0x6817, |
0x7E70, |
0x6851, |
0x936C, |
0x52F2, |
0x541B, |
0x85AB, |
0x8A13, |
0x7FA4, |
0x8ECD, |
0x90E1, |
0x5366, |
0x8888, |
0x7941, |
0x4FC2, |
0x50BE, |
0x5211, |
0x5144, |
0x5553, |
0x572D, |
0x73EA, |
0x578B, |
0x5951, |
0x5F62, |
0x5F84, |
0x6075, |
0x6176, |
0x6167, |
0x61A9, |
0x63B2, |
0x643A, |
0x656C, |
0x666F, |
0x6842, |
0x6E13, |
0x7566, |
0x7A3D, |
0x7CFB, |
0x7D4C, |
0x7D99, |
0x7E4B, |
0x7F6B, |
0x830E, |
0x834A, |
0x86CD, |
0x8A08, |
0x8A63, |
0x8B66, |
0x8EFD, |
0x981A, |
0x9D8F, |
0x82B8, |
0x8FCE, |
0x9BE8, |
0x5287, |
0x621F, |
0x6483, |
0x6FC0, |
0x9699, |
0x6841, |
0x5091, |
0x6B20, |
0x6C7A, |
0x6F54, |
0x7A74, |
0x7D50, |
0x8840, |
0x8A23, |
0x6708, |
0x4EF6, |
0x5039, |
0x5026, |
0x5065, |
0x517C, |
0x5238, |
0x5263, |
0x55A7, |
0x570F, |
0x5805, |
0x5ACC, |
0x5EFA, |
0x61B2, |
0x61F8, |
0x62F3, |
0x6372, |
0x691C, |
0x6A29, |
0x727D, |
0x72AC, |
0x732E, |
0x7814, |
0x786F, |
0x7D79, |
0x770C, |
0x80A9, |
0x898B, |
0x8B19, |
0x8CE2, |
0x8ED2, |
0x9063, |
0x9375, |
0x967A, |
0x9855, |
0x9A13, |
0x9E78, |
0x5143, |
0x539F, |
0x53B3, |
0x5E7B, |
0x5F26, |
0x6E1B, |
0x6E90, |
0x7384, |
0x73FE, |
0x7D43, |
0x8237, |
0x8A00, |
0x8AFA, |
0x9650, |
0x4E4E, |
0x500B, |
0x53E4, |
0x547C, |
0x56FA, |
0x59D1, |
0x5B64, |
0x5DF1, |
0x5EAB, |
0x5F27, |
0x6238, |
0x6545, |
0x67AF, |
0x6E56, |
0x72D0, |
0x7CCA, |
0x88B4, |
0x80A1, |
0x80E1, |
0x83F0, |
0x864E, |
0x8A87, |
0x8DE8, |
0x9237, |
0x96C7, |
0x9867, |
0x9F13, |
0x4E94, |
0x4E92, |
0x4F0D, |
0x5348, |
0x5449, |
0x543E, |
0x5A2F, |
0x5F8C, |
0x5FA1, |
0x609F, |
0x68A7, |
0x6A8E, |
0x745A, |
0x7881, |
0x8A9E, |
0x8AA4, |
0x8B77, |
0x9190, |
0x4E5E, |
0x9BC9, |
0x4EA4, |
0x4F7C, |
0x4FAF, |
0x5019, |
0x5016, |
0x5149, |
0x516C, |
0x529F, |
0x52B9, |
0x52FE, |
0x539A, |
0x53E3, |
0x5411, |
0x540E, |
0x5589, |
0x5751, |
0x57A2, |
0x597D, |
0x5B54, |
0x5B5D, |
0x5B8F, |
0x5DE5, |
0x5DE7, |
0x5DF7, |
0x5E78, |
0x5E83, |
0x5E9A, |
0x5EB7, |
0x5F18, |
0x6052, |
0x614C, |
0x6297, |
0x62D8, |
0x63A7, |
0x653B, |
0x6602, |
0x6643, |
0x66F4, |
0x676D, |
0x6821, |
0x6897, |
0x69CB, |
0x6C5F, |
0x6D2A, |
0x6D69, |
0x6E2F, |
0x6E9D, |
0x7532, |
0x7687, |
0x786C, |
0x7A3F, |
0x7CE0, |
0x7D05, |
0x7D18, |
0x7D5E, |
0x7DB1, |
0x8015, |
0x8003, |
0x80AF, |
0x80B1, |
0x8154, |
0x818F, |
0x822A, |
0x8352, |
0x884C, |
0x8861, |
0x8B1B, |
0x8CA2, |
0x8CFC, |
0x90CA, |
0x9175, |
0x9271, |
0x783F, |
0x92FC, |
0x95A4, |
0x964D, |
0x9805, |
0x9999, |
0x9AD8, |
0x9D3B, |
0x525B, |
0x52AB, |
0x53F7, |
0x5408, |
0x58D5, |
0x62F7, |
0x6FE0, |
0x8C6A, |
0x8F5F, |
0x9EB9, |
0x514B, |
0x523B, |
0x544A, |
0x56FD, |
0x7A40, |
0x9177, |
0x9D60, |
0x9ED2, |
0x7344, |
0x6F09, |
0x8170, |
0x7511, |
0x5FFD, |
0x60DA, |
0x9AA8, |
0x72DB, |
0x8FBC, |
0x6B64, |
0x9803, |
0x4ECA, |
0x56F0, |
0x5764, |
0x58BE, |
0x5A5A, |
0x6068, |
0x61C7, |
0x660F, |
0x6606, |
0x6839, |
0x68B1, |
0x6DF7, |
0x75D5, |
0x7D3A, |
0x826E, |
0x9B42, |
0x4E9B, |
0x4F50, |
0x53C9, |
0x5506, |
0x5D6F, |
0x5DE6, |
0x5DEE, |
0x67FB, |
0x6C99, |
0x7473, |
0x7802, |
0x8A50, |
0x9396, |
0x88DF, |
0x5750, |
0x5EA7, |
0x632B, |
0x50B5, |
0x50AC, |
0x518D, |
0x6700, |
0x54C9, |
0x585E, |
0x59BB, |
0x5BB0, |
0x5F69, |
0x624D, |
0x63A1, |
0x683D, |
0x6B73, |
0x6E08, |
0x707D, |
0x91C7, |
0x7280, |
0x7815, |
0x7826, |
0x796D, |
0x658E, |
0x7D30, |
0x83DC, |
0x88C1, |
0x8F09, |
0x969B, |
0x5264, |
0x5728, |
0x6750, |
0x7F6A, |
0x8CA1, |
0x51B4, |
0x5742, |
0x962A, |
0x583A, |
0x698A, |
0x80B4, |
0x54B2, |
0x5D0E, |
0x57FC, |
0x7895, |
0x9DFA, |
0x4F5C, |
0x524A, |
0x548B, |
0x643E, |
0x6628, |
0x6714, |
0x67F5, |
0x7A84, |
0x7B56, |
0x7D22, |
0x932F, |
0x685C, |
0x9BAD, |
0x7B39, |
0x5319, |
0x518A, |
0x5237, |
0x5BDF, |
0x62F6, |
0x64AE, |
0x64E6, |
0x672D, |
0x6BBA, |
0x85A9, |
0x96D1, |
0x7690, |
0x9BD6, |
0x634C, |
0x9306, |
0x9BAB, |
0x76BF, |
0x6652, |
0x4E09, |
0x5098, |
0x53C2, |
0x5C71, |
0x60E8, |
0x6492, |
0x6563, |
0x685F, |
0x71E6, |
0x73CA, |
0x7523, |
0x7B97, |
0x7E82, |
0x8695, |
0x8B83, |
0x8CDB, |
0x9178, |
0x9910, |
0x65AC, |
0x66AB, |
0x6B8B, |
0x4ED5, |
0x4ED4, |
0x4F3A, |
0x4F7F, |
0x523A, |
0x53F8, |
0x53F2, |
0x55E3, |
0x56DB, |
0x58EB, |
0x59CB, |
0x59C9, |
0x59FF, |
0x5B50, |
0x5C4D, |
0x5E02, |
0x5E2B, |
0x5FD7, |
0x601D, |
0x6307, |
0x652F, |
0x5B5C, |
0x65AF, |
0x65BD, |
0x65E8, |
0x679D, |
0x6B62, |
0x6B7B, |
0x6C0F, |
0x7345, |
0x7949, |
0x79C1, |
0x7CF8, |
0x7D19, |
0x7D2B, |
0x80A2, |
0x8102, |
0x81F3, |
0x8996, |
0x8A5E, |
0x8A69, |
0x8A66, |
0x8A8C, |
0x8AEE, |
0x8CC7, |
0x8CDC, |
0x96CC, |
0x98FC, |
0x6B6F, |
0x4E8B, |
0x4F3C, |
0x4F8D, |
0x5150, |
0x5B57, |
0x5BFA, |
0x6148, |
0x6301, |
0x6642, |
0x6B21, |
0x6ECB, |
0x6CBB, |
0x723E, |
0x74BD, |
0x75D4, |
0x78C1, |
0x793A, |
0x800C, |
0x8033, |
0x81EA, |
0x8494, |
0x8F9E, |
0x6C50, |
0x9E7F, |
0x5F0F, |
0x8B58, |
0x9D2B, |
0x7AFA, |
0x8EF8, |
0x5B8D, |
0x96EB, |
0x4E03, |
0x53F1, |
0x57F7, |
0x5931, |
0x5AC9, |
0x5BA4, |
0x6089, |
0x6E7F, |
0x6F06, |
0x75BE, |
0x8CEA, |
0x5B9F, |
0x8500, |
0x7BE0, |
0x5072, |
0x67F4, |
0x829D, |
0x5C61, |
0x854A, |
0x7E1E, |
0x820E, |
0x5199, |
0x5C04, |
0x6368, |
0x8D66, |
0x659C, |
0x716E, |
0x793E, |
0x7D17, |
0x8005, |
0x8B1D, |
0x8ECA, |
0x906E, |
0x86C7, |
0x90AA, |
0x501F, |
0x52FA, |
0x5C3A, |
0x6753, |
0x707C, |
0x7235, |
0x914C, |
0x91C8, |
0x932B, |
0x82E5, |
0x5BC2, |
0x5F31, |
0x60F9, |
0x4E3B, |
0x53D6, |
0x5B88, |
0x624B, |
0x6731, |
0x6B8A, |
0x72E9, |
0x73E0, |
0x7A2E, |
0x816B, |
0x8DA3, |
0x9152, |
0x9996, |
0x5112, |
0x53D7, |
0x546A, |
0x5BFF, |
0x6388, |
0x6A39, |
0x7DAC, |
0x9700, |
0x56DA, |
0x53CE, |
0x5468, |
0x5B97, |
0x5C31, |
0x5DDE, |
0x4FEE, |
0x6101, |
0x62FE, |
0x6D32, |
0x79C0, |
0x79CB, |
0x7D42, |
0x7E4D, |
0x7FD2, |
0x81ED, |
0x821F, |
0x8490, |
0x8846, |
0x8972, |
0x8B90, |
0x8E74, |
0x8F2F, |
0x9031, |
0x914B, |
0x916C, |
0x96C6, |
0x919C, |
0x4EC0, |
0x4F4F, |
0x5145, |
0x5341, |
0x5F93, |
0x620E, |
0x67D4, |
0x6C41, |
0x6E0B, |
0x7363, |
0x7E26, |
0x91CD, |
0x9283, |
0x53D4, |
0x5919, |
0x5BBF, |
0x6DD1, |
0x795D, |
0x7E2E, |
0x7C9B, |
0x587E, |
0x719F, |
0x51FA, |
0x8853, |
0x8FF0, |
0x4FCA, |
0x5CFB, |
0x6625, |
0x77AC, |
0x7AE3, |
0x821C, |
0x99FF, |
0x51C6, |
0x5FAA, |
0x65EC, |
0x696F, |
0x6B89, |
0x6DF3, |
0x6E96, |
0x6F64, |
0x76FE, |
0x7D14, |
0x5DE1, |
0x9075, |
0x9187, |
0x9806, |
0x51E6, |
0x521D, |
0x6240, |
0x6691, |
0x66D9, |
0x6E1A, |
0x5EB6, |
0x7DD2, |
0x7F72, |
0x66F8, |
0x85AF, |
0x85F7, |
0x8AF8, |
0x52A9, |
0x53D9, |
0x5973, |
0x5E8F, |
0x5F90, |
0x6055, |
0x92E4, |
0x9664, |
0x50B7, |
0x511F, |
0x52DD, |
0x5320, |
0x5347, |
0x53EC, |
0x54E8, |
0x5546, |
0x5531, |
0x5617, |
0x5968, |
0x59BE, |
0x5A3C, |
0x5BB5, |
0x5C06, |
0x5C0F, |
0x5C11, |
0x5C1A, |
0x5E84, |
0x5E8A, |
0x5EE0, |
0x5F70, |
0x627F, |
0x6284, |
0x62DB, |
0x638C, |
0x6377, |
0x6607, |
0x660C, |
0x662D, |
0x6676, |
0x677E, |
0x68A2, |
0x6A1F, |
0x6A35, |
0x6CBC, |
0x6D88, |
0x6E09, |
0x6E58, |
0x713C, |
0x7126, |
0x7167, |
0x75C7, |
0x7701, |
0x785D, |
0x7901, |
0x7965, |
0x79F0, |
0x7AE0, |
0x7B11, |
0x7CA7, |
0x7D39, |
0x8096, |
0x83D6, |
0x848B, |
0x8549, |
0x885D, |
0x88F3, |
0x8A1F, |
0x8A3C, |
0x8A54, |
0x8A73, |
0x8C61, |
0x8CDE, |
0x91A4, |
0x9266, |
0x937E, |
0x9418, |
0x969C, |
0x9798, |
0x4E0A, |
0x4E08, |
0x4E1E, |
0x4E57, |
0x5197, |
0x5270, |
0x57CE, |
0x5834, |
0x58CC, |
0x5B22, |
0x5E38, |
0x60C5, |
0x64FE, |
0x6761, |
0x6756, |
0x6D44, |
0x72B6, |
0x7573, |
0x7A63, |
0x84B8, |
0x8B72, |
0x91B8, |
0x9320, |
0x5631, |
0x57F4, |
0x98FE, |
0x62ED, |
0x690D, |
0x6B96, |
0x71ED, |
0x7E54, |
0x8077, |
0x8272, |
0x89E6, |
0x98DF, |
0x8755, |
0x8FB1, |
0x5C3B, |
0x4F38, |
0x4FE1, |
0x4FB5, |
0x5507, |
0x5A20, |
0x5BDD, |
0x5BE9, |
0x5FC3, |
0x614E, |
0x632F, |
0x65B0, |
0x664B, |
0x68EE, |
0x699B, |
0x6D78, |
0x6DF1, |
0x7533, |
0x75B9, |
0x771F, |
0x795E, |
0x79E6, |
0x7D33, |
0x81E3, |
0x82AF, |
0x85AA, |
0x89AA, |
0x8A3A, |
0x8EAB, |
0x8F9B, |
0x9032, |
0x91DD, |
0x9707, |
0x4EBA, |
0x4EC1, |
0x5203, |
0x5875, |
0x58EC, |
0x5C0B, |
0x751A, |
0x5C3D, |
0x814E, |
0x8A0A, |
0x8FC5, |
0x9663, |
0x976D, |
0x7B25, |
0x8ACF, |
0x9808, |
0x9162, |
0x56F3, |
0x53A8, |
0x9017, |
0x5439, |
0x5782, |
0x5E25, |
0x63A8, |
0x6C34, |
0x708A, |
0x7761, |
0x7C8B, |
0x7FE0, |
0x8870, |
0x9042, |
0x9154, |
0x9310, |
0x9318, |
0x968F, |
0x745E, |
0x9AC4, |
0x5D07, |
0x5D69, |
0x6570, |
0x67A2, |
0x8DA8, |
0x96DB, |
0x636E, |
0x6749, |
0x6919, |
0x83C5, |
0x9817, |
0x96C0, |
0x88FE, |
0x6F84, |
0x647A, |
0x5BF8, |
0x4E16, |
0x702C, |
0x755D, |
0x662F, |
0x51C4, |
0x5236, |
0x52E2, |
0x59D3, |
0x5F81, |
0x6027, |
0x6210, |
0x653F, |
0x6574, |
0x661F, |
0x6674, |
0x68F2, |
0x6816, |
0x6B63, |
0x6E05, |
0x7272, |
0x751F, |
0x76DB, |
0x7CBE, |
0x8056, |
0x58F0, |
0x88FD, |
0x897F, |
0x8AA0, |
0x8A93, |
0x8ACB, |
0x901D, |
0x9192, |
0x9752, |
0x9759, |
0x6589, |
0x7A0E, |
0x8106, |
0x96BB, |
0x5E2D, |
0x60DC, |
0x621A, |
0x65A5, |
0x6614, |
0x6790, |
0x77F3, |
0x7A4D, |
0x7C4D, |
0x7E3E, |
0x810A, |
0x8CAC, |
0x8D64, |
0x8DE1, |
0x8E5F, |
0x78A9, |
0x5207, |
0x62D9, |
0x63A5, |
0x6442, |
0x6298, |
0x8A2D, |
0x7A83, |
0x7BC0, |
0x8AAC, |
0x96EA, |
0x7D76, |
0x820C, |
0x8749, |
0x4ED9, |
0x5148, |
0x5343, |
0x5360, |
0x5BA3, |
0x5C02, |
0x5C16, |
0x5DDD, |
0x6226, |
0x6247, |
0x64B0, |
0x6813, |
0x6834, |
0x6CC9, |
0x6D45, |
0x6D17, |
0x67D3, |
0x6F5C, |
0x714E, |
0x717D, |
0x65CB, |
0x7A7F, |
0x7BAD, |
0x7DDA, |
0x7E4A, |
0x7FA8, |
0x817A, |
0x821B, |
0x8239, |
0x85A6, |
0x8A6E, |
0x8CCE, |
0x8DF5, |
0x9078, |
0x9077, |
0x92AD, |
0x9291, |
0x9583, |
0x9BAE, |
0x524D, |
0x5584, |
0x6F38, |
0x7136, |
0x5168, |
0x7985, |
0x7E55, |
0x81B3, |
0x7CCE, |
0x564C, |
0x5851, |
0x5CA8, |
0x63AA, |
0x66FE, |
0x66FD, |
0x695A, |
0x72D9, |
0x758F, |
0x758E, |
0x790E, |
0x7956, |
0x79DF, |
0x7C97, |
0x7D20, |
0x7D44, |
0x8607, |
0x8A34, |
0x963B, |
0x9061, |
0x9F20, |
0x50E7, |
0x5275, |
0x53CC, |
0x53E2, |
0x5009, |
0x55AA, |
0x58EE, |
0x594F, |
0x723D, |
0x5B8B, |
0x5C64, |
0x531D, |
0x60E3, |
0x60F3, |
0x635C, |
0x6383, |
0x633F, |
0x63BB, |
0x64CD, |
0x65E9, |
0x66F9, |
0x5DE3, |
0x69CD, |
0x69FD, |
0x6F15, |
0x71E5, |
0x4E89, |
0x75E9, |
0x76F8, |
0x7A93, |
0x7CDF, |
0x7DCF, |
0x7D9C, |
0x8061, |
0x8349, |
0x8358, |
0x846C, |
0x84BC, |
0x85FB, |
0x88C5, |
0x8D70, |
0x9001, |
0x906D, |
0x9397, |
0x971C, |
0x9A12, |
0x50CF, |
0x5897, |
0x618E, |
0x81D3, |
0x8535, |
0x8D08, |
0x9020, |
0x4FC3, |
0x5074, |
0x5247, |
0x5373, |
0x606F, |
0x6349, |
0x675F, |
0x6E2C, |
0x8DB3, |
0x901F, |
0x4FD7, |
0x5C5E, |
0x8CCA, |
0x65CF, |
0x7D9A, |
0x5352, |
0x8896, |
0x5176, |
0x63C3, |
0x5B58, |
0x5B6B, |
0x5C0A, |
0x640D, |
0x6751, |
0x905C, |
0x4ED6, |
0x591A, |
0x592A, |
0x6C70, |
0x8A51, |
0x553E, |
0x5815, |
0x59A5, |
0x60F0, |
0x6253, |
0x67C1, |
0x8235, |
0x6955, |
0x9640, |
0x99C4, |
0x9A28, |
0x4F53, |
0x5806, |
0x5BFE, |
0x8010, |
0x5CB1, |
0x5E2F, |
0x5F85, |
0x6020, |
0x614B, |
0x6234, |
0x66FF, |
0x6CF0, |
0x6EDE, |
0x80CE, |
0x817F, |
0x82D4, |
0x888B, |
0x8CB8, |
0x9000, |
0x902E, |
0x968A, |
0x9EDB, |
0x9BDB, |
0x4EE3, |
0x53F0, |
0x5927, |
0x7B2C, |
0x918D, |
0x984C, |
0x9DF9, |
0x6EDD, |
0x7027, |
0x5353, |
0x5544, |
0x5B85, |
0x6258, |
0x629E, |
0x62D3, |
0x6CA2, |
0x6FEF, |
0x7422, |
0x8A17, |
0x9438, |
0x6FC1, |
0x8AFE, |
0x8338, |
0x51E7, |
0x86F8, |
0x53EA, |
0x53E9, |
0x4F46, |
0x9054, |
0x8FB0, |
0x596A, |
0x8131, |
0x5DFD, |
0x7AEA, |
0x8FBF, |
0x68DA, |
0x8C37, |
0x72F8, |
0x9C48, |
0x6A3D, |
0x8AB0, |
0x4E39, |
0x5358, |
0x5606, |
0x5766, |
0x62C5, |
0x63A2, |
0x65E6, |
0x6B4E, |
0x6DE1, |
0x6E5B, |
0x70AD, |
0x77ED, |
0x7AEF, |
0x7BAA, |
0x7DBB, |
0x803D, |
0x80C6, |
0x86CB, |
0x8A95, |
0x935B, |
0x56E3, |
0x58C7, |
0x5F3E, |
0x65AD, |
0x6696, |
0x6A80, |
0x6BB5, |
0x7537, |
0x8AC7, |
0x5024, |
0x77E5, |
0x5730, |
0x5F1B, |
0x6065, |
0x667A, |
0x6C60, |
0x75F4, |
0x7A1A, |
0x7F6E, |
0x81F4, |
0x8718, |
0x9045, |
0x99B3, |
0x7BC9, |
0x755C, |
0x7AF9, |
0x7B51, |
0x84C4, |
0x9010, |
0x79E9, |
0x7A92, |
0x8336, |
0x5AE1, |
0x7740, |
0x4E2D, |
0x4EF2, |
0x5B99, |
0x5FE0, |
0x62BD, |
0x663C, |
0x67F1, |
0x6CE8, |
0x866B, |
0x8877, |
0x8A3B, |
0x914E, |
0x92F3, |
0x99D0, |
0x6A17, |
0x7026, |
0x732A, |
0x82E7, |
0x8457, |
0x8CAF, |
0x4E01, |
0x5146, |
0x51CB, |
0x558B, |
0x5BF5, |
0x5E16, |
0x5E33, |
0x5E81, |
0x5F14, |
0x5F35, |
0x5F6B, |
0x5FB4, |
0x61F2, |
0x6311, |
0x66A2, |
0x671D, |
0x6F6E, |
0x7252, |
0x753A, |
0x773A, |
0x8074, |
0x8139, |
0x8178, |
0x8776, |
0x8ABF, |
0x8ADC, |
0x8D85, |
0x8DF3, |
0x929A, |
0x9577, |
0x9802, |
0x9CE5, |
0x52C5, |
0x6357, |
0x76F4, |
0x6715, |
0x6C88, |
0x73CD, |
0x8CC3, |
0x93AE, |
0x9673, |
0x6D25, |
0x589C, |
0x690E, |
0x69CC, |
0x8FFD, |
0x939A, |
0x75DB, |
0x901A, |
0x585A, |
0x6802, |
0x63B4, |
0x69FB, |
0x4F43, |
0x6F2C, |
0x67D8, |
0x8FBB, |
0x8526, |
0x7DB4, |
0x9354, |
0x693F, |
0x6F70, |
0x576A, |
0x58F7, |
0x5B2C, |
0x7D2C, |
0x722A, |
0x540A, |
0x91E3, |
0x9DB4, |
0x4EAD, |
0x4F4E, |
0x505C, |
0x5075, |
0x5243, |
0x8C9E, |
0x5448, |
0x5824, |
0x5B9A, |
0x5E1D, |
0x5E95, |
0x5EAD, |
0x5EF7, |
0x5F1F, |
0x608C, |
0x62B5, |
0x633A, |
0x63D0, |
0x68AF, |
0x6C40, |
0x7887, |
0x798E, |
0x7A0B, |
0x7DE0, |
0x8247, |
0x8A02, |
0x8AE6, |
0x8E44, |
0x9013, |
0x90B8, |
0x912D, |
0x91D8, |
0x9F0E, |
0x6CE5, |
0x6458, |
0x64E2, |
0x6575, |
0x6EF4, |
0x7684, |
0x7B1B, |
0x9069, |
0x93D1, |
0x6EBA, |
0x54F2, |
0x5FB9, |
0x64A4, |
0x8F4D, |
0x8FED, |
0x9244, |
0x5178, |
0x586B, |
0x5929, |
0x5C55, |
0x5E97, |
0x6DFB, |
0x7E8F, |
0x751C, |
0x8CBC, |
0x8EE2, |
0x985B, |
0x70B9, |
0x4F1D, |
0x6BBF, |
0x6FB1, |
0x7530, |
0x96FB, |
0x514E, |
0x5410, |
0x5835, |
0x5857, |
0x59AC, |
0x5C60, |
0x5F92, |
0x6597, |
0x675C, |
0x6E21, |
0x767B, |
0x83DF, |
0x8CED, |
0x9014, |
0x90FD, |
0x934D, |
0x7825, |
0x783A, |
0x52AA, |
0x5EA6, |
0x571F, |
0x5974, |
0x6012, |
0x5012, |
0x515A, |
0x51AC, |
0x51CD, |
0x5200, |
0x5510, |
0x5854, |
0x5858, |
0x5957, |
0x5B95, |
0x5CF6, |
0x5D8B, |
0x60BC, |
0x6295, |
0x642D, |
0x6771, |
0x6843, |
0x68BC, |
0x68DF, |
0x76D7, |
0x6DD8, |
0x6E6F, |
0x6D9B, |
0x706F, |
0x71C8, |
0x5F53, |
0x75D8, |
0x7977, |
0x7B49, |
0x7B54, |
0x7B52, |
0x7CD6, |
0x7D71, |
0x5230, |
0x8463, |
0x8569, |
0x85E4, |
0x8A0E, |
0x8B04, |
0x8C46, |
0x8E0F, |
0x9003, |
0x900F, |
0x9419, |
0x9676, |
0x982D, |
0x9A30, |
0x95D8, |
0x50CD, |
0x52D5, |
0x540C, |
0x5802, |
0x5C0E, |
0x61A7, |
0x649E, |
0x6D1E, |
0x77B3, |
0x7AE5, |
0x80F4, |
0x8404, |
0x9053, |
0x9285, |
0x5CE0, |
0x9D07, |
0x533F, |
0x5F97, |
0x5FB3, |
0x6D9C, |
0x7279, |
0x7763, |
0x79BF, |
0x7BE4, |
0x6BD2, |
0x72EC, |
0x8AAD, |
0x6803, |
0x6A61, |
0x51F8, |
0x7A81, |
0x6934, |
0x5C4A, |
0x9CF6, |
0x82EB, |
0x5BC5, |
0x9149, |
0x701E, |
0x5678, |
0x5C6F, |
0x60C7, |
0x6566, |
0x6C8C, |
0x8C5A, |
0x9041, |
0x9813, |
0x5451, |
0x66C7, |
0x920D, |
0x5948, |
0x90A3, |
0x5185, |
0x4E4D, |
0x51EA, |
0x8599, |
0x8B0E, |
0x7058, |
0x637A, |
0x934B, |
0x6962, |
0x99B4, |
0x7E04, |
0x7577, |
0x5357, |
0x6960, |
0x8EDF, |
0x96E3, |
0x6C5D, |
0x4E8C, |
0x5C3C, |
0x5F10, |
0x8FE9, |
0x5302, |
0x8CD1, |
0x8089, |
0x8679, |
0x5EFF, |
0x65E5, |
0x4E73, |
0x5165, |
0x5982, |
0x5C3F, |
0x97EE, |
0x4EFB, |
0x598A, |
0x5FCD, |
0x8A8D, |
0x6FE1, |
0x79B0, |
0x7962, |
0x5BE7, |
0x8471, |
0x732B, |
0x71B1, |
0x5E74, |
0x5FF5, |
0x637B, |
0x649A, |
0x71C3, |
0x7C98, |
0x4E43, |
0x5EFC, |
0x4E4B, |
0x57DC, |
0x56A2, |
0x60A9, |
0x6FC3, |
0x7D0D, |
0x80FD, |
0x8133, |
0x81BF, |
0x8FB2, |
0x8997, |
0x86A4, |
0x5DF4, |
0x628A, |
0x64AD, |
0x8987, |
0x6777, |
0x6CE2, |
0x6D3E, |
0x7436, |
0x7834, |
0x5A46, |
0x7F75, |
0x82AD, |
0x99AC, |
0x4FF3, |
0x5EC3, |
0x62DD, |
0x6392, |
0x6557, |
0x676F, |
0x76C3, |
0x724C, |
0x80CC, |
0x80BA, |
0x8F29, |
0x914D, |
0x500D, |
0x57F9, |
0x5A92, |
0x6885, |
0x6973, |
0x7164, |
0x72FD, |
0x8CB7, |
0x58F2, |
0x8CE0, |
0x966A, |
0x9019, |
0x877F, |
0x79E4, |
0x77E7, |
0x8429, |
0x4F2F, |
0x5265, |
0x535A, |
0x62CD, |
0x67CF, |
0x6CCA, |
0x767D, |
0x7B94, |
0x7C95, |
0x8236, |
0x8584, |
0x8FEB, |
0x66DD, |
0x6F20, |
0x7206, |
0x7E1B, |
0x83AB, |
0x99C1, |
0x9EA6, |
0x51FD, |
0x7BB1, |
0x7872, |
0x7BB8, |
0x8087, |
0x7B48, |
0x6AE8, |
0x5E61, |
0x808C, |
0x7551, |
0x7560, |
0x516B, |
0x9262, |
0x6E8C, |
0x767A, |
0x9197, |
0x9AEA, |
0x4F10, |
0x7F70, |
0x629C, |
0x7B4F, |
0x95A5, |
0x9CE9, |
0x567A, |
0x5859, |
0x86E4, |
0x96BC, |
0x4F34, |
0x5224, |
0x534A, |
0x53CD, |
0x53DB, |
0x5E06, |
0x642C, |
0x6591, |
0x677F, |
0x6C3E, |
0x6C4E, |
0x7248, |
0x72AF, |
0x73ED, |
0x7554, |
0x7E41, |
0x822C, |
0x85E9, |
0x8CA9, |
0x7BC4, |
0x91C6, |
0x7169, |
0x9812, |
0x98EF, |
0x633D, |
0x6669, |
0x756A, |
0x76E4, |
0x78D0, |
0x8543, |
0x86EE, |
0x532A, |
0x5351, |
0x5426, |
0x5983, |
0x5E87, |
0x5F7C, |
0x60B2, |
0x6249, |
0x6279, |
0x62AB, |
0x6590, |
0x6BD4, |
0x6CCC, |
0x75B2, |
0x76AE, |
0x7891, |
0x79D8, |
0x7DCB, |
0x7F77, |
0x80A5, |
0x88AB, |
0x8AB9, |
0x8CBB, |
0x907F, |
0x975E, |
0x98DB, |
0x6A0B, |
0x7C38, |
0x5099, |
0x5C3E, |
0x5FAE, |
0x6787, |
0x6BD8, |
0x7435, |
0x7709, |
0x7F8E, |
0x9F3B, |
0x67CA, |
0x7A17, |
0x5339, |
0x758B, |
0x9AED, |
0x5F66, |
0x819D, |
0x83F1, |
0x8098, |
0x5F3C, |
0x5FC5, |
0x7562, |
0x7B46, |
0x903C, |
0x6867, |
0x59EB, |
0x5A9B, |
0x7D10, |
0x767E, |
0x8B2C, |
0x4FF5, |
0x5F6A, |
0x6A19, |
0x6C37, |
0x6F02, |
0x74E2, |
0x7968, |
0x8868, |
0x8A55, |
0x8C79, |
0x5EDF, |
0x63CF, |
0x75C5, |
0x79D2, |
0x82D7, |
0x9328, |
0x92F2, |
0x849C, |
0x86ED, |
0x9C2D, |
0x54C1, |
0x5F6C, |
0x658C, |
0x6D5C, |
0x7015, |
0x8CA7, |
0x8CD3, |
0x983B, |
0x654F, |
0x74F6, |
0x4E0D, |
0x4ED8, |
0x57E0, |
0x592B, |
0x5A66, |
0x5BCC, |
0x51A8, |
0x5E03, |
0x5E9C, |
0x6016, |
0x6276, |
0x6577, |
0x65A7, |
0x666E, |
0x6D6E, |
0x7236, |
0x7B26, |
0x8150, |
0x819A, |
0x8299, |
0x8B5C, |
0x8CA0, |
0x8CE6, |
0x8D74, |
0x961C, |
0x9644, |
0x4FAE, |
0x64AB, |
0x6B66, |
0x821E, |
0x8461, |
0x856A, |
0x90E8, |
0x5C01, |
0x6953, |
0x98A8, |
0x847A, |
0x8557, |
0x4F0F, |
0x526F, |
0x5FA9, |
0x5E45, |
0x670D, |
0x798F, |
0x8179, |
0x8907, |
0x8986, |
0x6DF5, |
0x5F17, |
0x6255, |
0x6CB8, |
0x4ECF, |
0x7269, |
0x9B92, |
0x5206, |
0x543B, |
0x5674, |
0x58B3, |
0x61A4, |
0x626E, |
0x711A, |
0x596E, |
0x7C89, |
0x7CDE, |
0x7D1B, |
0x96F0, |
0x6587, |
0x805E, |
0x4E19, |
0x4F75, |
0x5175, |
0x5840, |
0x5E63, |
0x5E73, |
0x5F0A, |
0x67C4, |
0x4E26, |
0x853D, |
0x9589, |
0x965B, |
0x7C73, |
0x9801, |
0x50FB, |
0x58C1, |
0x7656, |
0x78A7, |
0x5225, |
0x77A5, |
0x8511, |
0x7B86, |
0x504F, |
0x5909, |
0x7247, |
0x7BC7, |
0x7DE8, |
0x8FBA, |
0x8FD4, |
0x904D, |
0x4FBF, |
0x52C9, |
0x5A29, |
0x5F01, |
0x97AD, |
0x4FDD, |
0x8217, |
0x92EA, |
0x5703, |
0x6355, |
0x6B69, |
0x752B, |
0x88DC, |
0x8F14, |
0x7A42, |
0x52DF, |
0x5893, |
0x6155, |
0x620A, |
0x66AE, |
0x6BCD, |
0x7C3F, |
0x83E9, |
0x5023, |
0x4FF8, |
0x5305, |
0x5446, |
0x5831, |
0x5949, |
0x5B9D, |
0x5CF0, |
0x5CEF, |
0x5D29, |
0x5E96, |
0x62B1, |
0x6367, |
0x653E, |
0x65B9, |
0x670B, |
0x6CD5, |
0x6CE1, |
0x70F9, |
0x7832, |
0x7E2B, |
0x80DE, |
0x82B3, |
0x840C, |
0x84EC, |
0x8702, |
0x8912, |
0x8A2A, |
0x8C4A, |
0x90A6, |
0x92D2, |
0x98FD, |
0x9CF3, |
0x9D6C, |
0x4E4F, |
0x4EA1, |
0x508D, |
0x5256, |
0x574A, |
0x59A8, |
0x5E3D, |
0x5FD8, |
0x5FD9, |
0x623F, |
0x66B4, |
0x671B, |
0x67D0, |
0x68D2, |
0x5192, |
0x7D21, |
0x80AA, |
0x81A8, |
0x8B00, |
0x8C8C, |
0x8CBF, |
0x927E, |
0x9632, |
0x5420, |
0x982C, |
0x5317, |
0x50D5, |
0x535C, |
0x58A8, |
0x64B2, |
0x6734, |
0x7267, |
0x7766, |
0x7A46, |
0x91E6, |
0x52C3, |
0x6CA1, |
0x6B86, |
0x5800, |
0x5E4C, |
0x5954, |
0x672C, |
0x7FFB, |
0x51E1, |
0x76C6, |
0x6469, |
0x78E8, |
0x9B54, |
0x9EBB, |
0x57CB, |
0x59B9, |
0x6627, |
0x679A, |
0x6BCE, |
0x54E9, |
0x69D9, |
0x5E55, |
0x819C, |
0x6795, |
0x9BAA, |
0x67FE, |
0x9C52, |
0x685D, |
0x4EA6, |
0x4FE3, |
0x53C8, |
0x62B9, |
0x672B, |
0x6CAB, |
0x8FC4, |
0x4FAD, |
0x7E6D, |
0x9EBF, |
0x4E07, |
0x6162, |
0x6E80, |
0x6F2B, |
0x8513, |
0x5473, |
0x672A, |
0x9B45, |
0x5DF3, |
0x7B95, |
0x5CAC, |
0x5BC6, |
0x871C, |
0x6E4A, |
0x84D1, |
0x7A14, |
0x8108, |
0x5999, |
0x7C8D, |
0x6C11, |
0x7720, |
0x52D9, |
0x5922, |
0x7121, |
0x725F, |
0x77DB, |
0x9727, |
0x9D61, |
0x690B, |
0x5A7F, |
0x5A18, |
0x51A5, |
0x540D, |
0x547D, |
0x660E, |
0x76DF, |
0x8FF7, |
0x9298, |
0x9CF4, |
0x59EA, |
0x725D, |
0x6EC5, |
0x514D, |
0x68C9, |
0x7DBF, |
0x7DEC, |
0x9762, |
0x9EBA, |
0x6478, |
0x6A21, |
0x8302, |
0x5984, |
0x5B5F, |
0x6BDB, |
0x731B, |
0x76F2, |
0x7DB2, |
0x8017, |
0x8499, |
0x5132, |
0x6728, |
0x9ED9, |
0x76EE, |
0x6762, |
0x52FF, |
0x9905, |
0x5C24, |
0x623B, |
0x7C7E, |
0x8CB0, |
0x554F, |
0x60B6, |
0x7D0B, |
0x9580, |
0x5301, |
0x4E5F, |
0x51B6, |
0x591C, |
0x723A, |
0x8036, |
0x91CE, |
0x5F25, |
0x77E2, |
0x5384, |
0x5F79, |
0x7D04, |
0x85AC, |
0x8A33, |
0x8E8D, |
0x9756, |
0x67F3, |
0x85AE, |
0x9453, |
0x6109, |
0x6108, |
0x6CB9, |
0x7652, |
0x8AED, |
0x8F38, |
0x552F, |
0x4F51, |
0x512A, |
0x52C7, |
0x53CB, |
0x5BA5, |
0x5E7D, |
0x60A0, |
0x6182, |
0x63D6, |
0x6709, |
0x67DA, |
0x6E67, |
0x6D8C, |
0x7336, |
0x7337, |
0x7531, |
0x7950, |
0x88D5, |
0x8A98, |
0x904A, |
0x9091, |
0x90F5, |
0x96C4, |
0x878D, |
0x5915, |
0x4E88, |
0x4F59, |
0x4E0E, |
0x8A89, |
0x8F3F, |
0x9810, |
0x50AD, |
0x5E7C, |
0x5996, |
0x5BB9, |
0x5EB8, |
0x63DA, |
0x63FA, |
0x64C1, |
0x66DC, |
0x694A, |
0x69D8, |
0x6D0B, |
0x6EB6, |
0x7194, |
0x7528, |
0x7AAF, |
0x7F8A, |
0x8000, |
0x8449, |
0x84C9, |
0x8981, |
0x8B21, |
0x8E0A, |
0x9065, |
0x967D, |
0x990A, |
0x617E, |
0x6291, |
0x6B32, |
0x6C83, |
0x6D74, |
0x7FCC, |
0x7FFC, |
0x6DC0, |
0x7F85, |
0x87BA, |
0x88F8, |
0x6765, |
0x83B1, |
0x983C, |
0x96F7, |
0x6D1B, |
0x7D61, |
0x843D, |
0x916A, |
0x4E71, |
0x5375, |
0x5D50, |
0x6B04, |
0x6FEB, |
0x85CD, |
0x862D, |
0x89A7, |
0x5229, |
0x540F, |
0x5C65, |
0x674E, |
0x68A8, |
0x7406, |
0x7483, |
0x75E2, |
0x88CF, |
0x88E1, |
0x91CC, |
0x96E2, |
0x9678, |
0x5F8B, |
0x7387, |
0x7ACB, |
0x844E, |
0x63A0, |
0x7565, |
0x5289, |
0x6D41, |
0x6E9C, |
0x7409, |
0x7559, |
0x786B, |
0x7C92, |
0x9686, |
0x7ADC, |
0x9F8D, |
0x4FB6, |
0x616E, |
0x65C5, |
0x865C, |
0x4E86, |
0x4EAE, |
0x50DA, |
0x4E21, |
0x51CC, |
0x5BEE, |
0x6599, |
0x6881, |
0x6DBC, |
0x731F, |
0x7642, |
0x77AD, |
0x7A1C, |
0x7CE7, |
0x826F, |
0x8AD2, |
0x907C, |
0x91CF, |
0x9675, |
0x9818, |
0x529B, |
0x7DD1, |
0x502B, |
0x5398, |
0x6797, |
0x6DCB, |
0x71D0, |
0x7433, |
0x81E8, |
0x8F2A, |
0x96A3, |
0x9C57, |
0x9E9F, |
0x7460, |
0x5841, |
0x6D99, |
0x7D2F, |
0x985E, |
0x4EE4, |
0x4F36, |
0x4F8B, |
0x51B7, |
0x52B1, |
0x5DBA, |
0x601C, |
0x73B2, |
0x793C, |
0x82D3, |
0x9234, |
0x96B7, |
0x96F6, |
0x970A, |
0x9E97, |
0x9F62, |
0x66A6, |
0x6B74, |
0x5217, |
0x52A3, |
0x70C8, |
0x88C2, |
0x5EC9, |
0x604B, |
0x6190, |
0x6F23, |
0x7149, |
0x7C3E, |
0x7DF4, |
0x806F, |
0x84EE, |
0x9023, |
0x932C, |
0x5442, |
0x9B6F, |
0x6AD3, |
0x7089, |
0x8CC2, |
0x8DEF, |
0x9732, |
0x52B4, |
0x5A41, |
0x5ECA, |
0x5F04, |
0x6717, |
0x697C, |
0x6994, |
0x6D6A, |
0x6F0F, |
0x7262, |
0x72FC, |
0x7BED, |
0x8001, |
0x807E, |
0x874B, |
0x90CE, |
0x516D, |
0x9E93, |
0x7984, |
0x808B, |
0x9332, |
0x8AD6, |
0x502D, |
0x548C, |
0x8A71, |
0x6B6A, |
0x8CC4, |
0x8107, |
0x60D1, |
0x67A0, |
0x9DF2, |
0x4E99, |
0x4E98, |
0x9C10, |
0x8A6B, |
0x85C1, |
0x8568, |
0x6900, |
0x6E7E, |
0x7897, |
0x8155 |
}; |
/* d0a1 to f4a6 is contiguous */ |
static unsigned short d02f4[] = { |
0x5F0C, |
0x4E10, |
0x4E15, |
0x4E2A, |
0x4E31, |
0x4E36, |
0x4E3C, |
0x4E3F, |
0x4E42, |
0x4E56, |
0x4E58, |
0x4E82, |
0x4E85, |
0x8C6B, |
0x4E8A, |
0x8212, |
0x5F0D, |
0x4E8E, |
0x4E9E, |
0x4E9F, |
0x4EA0, |
0x4EA2, |
0x4EB0, |
0x4EB3, |
0x4EB6, |
0x4ECE, |
0x4ECD, |
0x4EC4, |
0x4EC6, |
0x4EC2, |
0x4ED7, |
0x4EDE, |
0x4EED, |
0x4EDF, |
0x4EF7, |
0x4F09, |
0x4F5A, |
0x4F30, |
0x4F5B, |
0x4F5D, |
0x4F57, |
0x4F47, |
0x4F76, |
0x4F88, |
0x4F8F, |
0x4F98, |
0x4F7B, |
0x4F69, |
0x4F70, |
0x4F91, |
0x4F6F, |
0x4F86, |
0x4F96, |
0x5118, |
0x4FD4, |
0x4FDF, |
0x4FCE, |
0x4FD8, |
0x4FDB, |
0x4FD1, |
0x4FDA, |
0x4FD0, |
0x4FE4, |
0x4FE5, |
0x501A, |
0x5028, |
0x5014, |
0x502A, |
0x5025, |
0x5005, |
0x4F1C, |
0x4FF6, |
0x5021, |
0x5029, |
0x502C, |
0x4FFE, |
0x4FEF, |
0x5011, |
0x5006, |
0x5043, |
0x5047, |
0x6703, |
0x5055, |
0x5050, |
0x5048, |
0x505A, |
0x5056, |
0x506C, |
0x5078, |
0x5080, |
0x509A, |
0x5085, |
0x50B4, |
0x50B2, |
0x50C9, |
0x50CA, |
0x50B3, |
0x50C2, |
0x50D6, |
0x50DE, |
0x50E5, |
0x50ED, |
0x50E3, |
0x50EE, |
0x50F9, |
0x50F5, |
0x5109, |
0x5101, |
0x5102, |
0x5116, |
0x5115, |
0x5114, |
0x511A, |
0x5121, |
0x513A, |
0x5137, |
0x513C, |
0x513B, |
0x513F, |
0x5140, |
0x5152, |
0x514C, |
0x5154, |
0x5162, |
0x7AF8, |
0x5169, |
0x516A, |
0x516E, |
0x5180, |
0x5182, |
0x56D8, |
0x518C, |
0x5189, |
0x518F, |
0x5191, |
0x5193, |
0x5195, |
0x5196, |
0x51A4, |
0x51A6, |
0x51A2, |
0x51A9, |
0x51AA, |
0x51AB, |
0x51B3, |
0x51B1, |
0x51B2, |
0x51B0, |
0x51B5, |
0x51BD, |
0x51C5, |
0x51C9, |
0x51DB, |
0x51E0, |
0x8655, |
0x51E9, |
0x51ED, |
0x51F0, |
0x51F5, |
0x51FE, |
0x5204, |
0x520B, |
0x5214, |
0x520E, |
0x5227, |
0x522A, |
0x522E, |
0x5233, |
0x5239, |
0x524F, |
0x5244, |
0x524B, |
0x524C, |
0x525E, |
0x5254, |
0x526A, |
0x5274, |
0x5269, |
0x5273, |
0x527F, |
0x527D, |
0x528D, |
0x5294, |
0x5292, |
0x5271, |
0x5288, |
0x5291, |
0x8FA8, |
0x8FA7, |
0x52AC, |
0x52AD, |
0x52BC, |
0x52B5, |
0x52C1, |
0x52CD, |
0x52D7, |
0x52DE, |
0x52E3, |
0x52E6, |
0x98ED, |
0x52E0, |
0x52F3, |
0x52F5, |
0x52F8, |
0x52F9, |
0x5306, |
0x5308, |
0x7538, |
0x530D, |
0x5310, |
0x530F, |
0x5315, |
0x531A, |
0x5323, |
0x532F, |
0x5331, |
0x5333, |
0x5338, |
0x5340, |
0x5346, |
0x5345, |
0x4E17, |
0x5349, |
0x534D, |
0x51D6, |
0x535E, |
0x5369, |
0x536E, |
0x5918, |
0x537B, |
0x5377, |
0x5382, |
0x5396, |
0x53A0, |
0x53A6, |
0x53A5, |
0x53AE, |
0x53B0, |
0x53B6, |
0x53C3, |
0x7C12, |
0x96D9, |
0x53DF, |
0x66FC, |
0x71EE, |
0x53EE, |
0x53E8, |
0x53ED, |
0x53FA, |
0x5401, |
0x543D, |
0x5440, |
0x542C, |
0x542D, |
0x543C, |
0x542E, |
0x5436, |
0x5429, |
0x541D, |
0x544E, |
0x548F, |
0x5475, |
0x548E, |
0x545F, |
0x5471, |
0x5477, |
0x5470, |
0x5492, |
0x547B, |
0x5480, |
0x5476, |
0x5484, |
0x5490, |
0x5486, |
0x54C7, |
0x54A2, |
0x54B8, |
0x54A5, |
0x54AC, |
0x54C4, |
0x54C8, |
0x54A8, |
0x54AB, |
0x54C2, |
0x54A4, |
0x54BE, |
0x54BC, |
0x54D8, |
0x54E5, |
0x54E6, |
0x550F, |
0x5514, |
0x54FD, |
0x54EE, |
0x54ED, |
0x54FA, |
0x54E2, |
0x5539, |
0x5540, |
0x5563, |
0x554C, |
0x552E, |
0x555C, |
0x5545, |
0x5556, |
0x5557, |
0x5538, |
0x5533, |
0x555D, |
0x5599, |
0x5580, |
0x54AF, |
0x558A, |
0x559F, |
0x557B, |
0x557E, |
0x5598, |
0x559E, |
0x55AE, |
0x557C, |
0x5583, |
0x55A9, |
0x5587, |
0x55A8, |
0x55DA, |
0x55C5, |
0x55DF, |
0x55C4, |
0x55DC, |
0x55E4, |
0x55D4, |
0x5614, |
0x55F7, |
0x5616, |
0x55FE, |
0x55FD, |
0x561B, |
0x55F9, |
0x564E, |
0x5650, |
0x71DF, |
0x5634, |
0x5636, |
0x5632, |
0x5638, |
0x566B, |
0x5664, |
0x562F, |
0x566C, |
0x566A, |
0x5686, |
0x5680, |
0x568A, |
0x56A0, |
0x5694, |
0x568F, |
0x56A5, |
0x56AE, |
0x56B6, |
0x56B4, |
0x56C2, |
0x56BC, |
0x56C1, |
0x56C3, |
0x56C0, |
0x56C8, |
0x56CE, |
0x56D1, |
0x56D3, |
0x56D7, |
0x56EE, |
0x56F9, |
0x5700, |
0x56FF, |
0x5704, |
0x5709, |
0x5708, |
0x570B, |
0x570D, |
0x5713, |
0x5718, |
0x5716, |
0x55C7, |
0x571C, |
0x5726, |
0x5737, |
0x5738, |
0x574E, |
0x573B, |
0x5740, |
0x574F, |
0x5769, |
0x57C0, |
0x5788, |
0x5761, |
0x577F, |
0x5789, |
0x5793, |
0x57A0, |
0x57B3, |
0x57A4, |
0x57AA, |
0x57B0, |
0x57C3, |
0x57C6, |
0x57D4, |
0x57D2, |
0x57D3, |
0x580A, |
0x57D6, |
0x57E3, |
0x580B, |
0x5819, |
0x581D, |
0x5872, |
0x5821, |
0x5862, |
0x584B, |
0x5870, |
0x6BC0, |
0x5852, |
0x583D, |
0x5879, |
0x5885, |
0x58B9, |
0x589F, |
0x58AB, |
0x58BA, |
0x58DE, |
0x58BB, |
0x58B8, |
0x58AE, |
0x58C5, |
0x58D3, |
0x58D1, |
0x58D7, |
0x58D9, |
0x58D8, |
0x58E5, |
0x58DC, |
0x58E4, |
0x58DF, |
0x58EF, |
0x58FA, |
0x58F9, |
0x58FB, |
0x58FC, |
0x58FD, |
0x5902, |
0x590A, |
0x5910, |
0x591B, |
0x68A6, |
0x5925, |
0x592C, |
0x592D, |
0x5932, |
0x5938, |
0x593E, |
0x7AD2, |
0x5955, |
0x5950, |
0x594E, |
0x595A, |
0x5958, |
0x5962, |
0x5960, |
0x5967, |
0x596C, |
0x5969, |
0x5978, |
0x5981, |
0x599D, |
0x4F5E, |
0x4FAB, |
0x59A3, |
0x59B2, |
0x59C6, |
0x59E8, |
0x59DC, |
0x598D, |
0x59D9, |
0x59DA, |
0x5A25, |
0x5A1F, |
0x5A11, |
0x5A1C, |
0x5A09, |
0x5A1A, |
0x5A40, |
0x5A6C, |
0x5A49, |
0x5A35, |
0x5A36, |
0x5A62, |
0x5A6A, |
0x5A9A, |
0x5ABC, |
0x5ABE, |
0x5ACB, |
0x5AC2, |
0x5ABD, |
0x5AE3, |
0x5AD7, |
0x5AE6, |
0x5AE9, |
0x5AD6, |
0x5AFA, |
0x5AFB, |
0x5B0C, |
0x5B0B, |
0x5B16, |
0x5B32, |
0x5AD0, |
0x5B2A, |
0x5B36, |
0x5B3E, |
0x5B43, |
0x5B45, |
0x5B40, |
0x5B51, |
0x5B55, |
0x5B5A, |
0x5B5B, |
0x5B65, |
0x5B69, |
0x5B70, |
0x5B73, |
0x5B75, |
0x5B78, |
0x6588, |
0x5B7A, |
0x5B80, |
0x5B83, |
0x5BA6, |
0x5BB8, |
0x5BC3, |
0x5BC7, |
0x5BC9, |
0x5BD4, |
0x5BD0, |
0x5BE4, |
0x5BE6, |
0x5BE2, |
0x5BDE, |
0x5BE5, |
0x5BEB, |
0x5BF0, |
0x5BF6, |
0x5BF3, |
0x5C05, |
0x5C07, |
0x5C08, |
0x5C0D, |
0x5C13, |
0x5C20, |
0x5C22, |
0x5C28, |
0x5C38, |
0x5C39, |
0x5C41, |
0x5C46, |
0x5C4E, |
0x5C53, |
0x5C50, |
0x5C4F, |
0x5B71, |
0x5C6C, |
0x5C6E, |
0x4E62, |
0x5C76, |
0x5C79, |
0x5C8C, |
0x5C91, |
0x5C94, |
0x599B, |
0x5CAB, |
0x5CBB, |
0x5CB6, |
0x5CBC, |
0x5CB7, |
0x5CC5, |
0x5CBE, |
0x5CC7, |
0x5CD9, |
0x5CE9, |
0x5CFD, |
0x5CFA, |
0x5CED, |
0x5D8C, |
0x5CEA, |
0x5D0B, |
0x5D15, |
0x5D17, |
0x5D5C, |
0x5D1F, |
0x5D1B, |
0x5D11, |
0x5D14, |
0x5D22, |
0x5D1A, |
0x5D19, |
0x5D18, |
0x5D4C, |
0x5D52, |
0x5D4E, |
0x5D4B, |
0x5D6C, |
0x5D73, |
0x5D76, |
0x5D87, |
0x5D84, |
0x5D82, |
0x5DA2, |
0x5D9D, |
0x5DAC, |
0x5DAE, |
0x5DBD, |
0x5D90, |
0x5DB7, |
0x5DBC, |
0x5DC9, |
0x5DCD, |
0x5DD3, |
0x5DD2, |
0x5DD6, |
0x5DDB, |
0x5DEB, |
0x5DF2, |
0x5DF5, |
0x5E0B, |
0x5E1A, |
0x5E19, |
0x5E11, |
0x5E1B, |
0x5E36, |
0x5E37, |
0x5E44, |
0x5E43, |
0x5E40, |
0x5E4E, |
0x5E57, |
0x5E54, |
0x5E5F, |
0x5E62, |
0x5E64, |
0x5E47, |
0x5E75, |
0x5E76, |
0x5E7A, |
0x9EBC, |
0x5E7F, |
0x5EA0, |
0x5EC1, |
0x5EC2, |
0x5EC8, |
0x5ED0, |
0x5ECF, |
0x5ED6, |
0x5EE3, |
0x5EDD, |
0x5EDA, |
0x5EDB, |
0x5EE2, |
0x5EE1, |
0x5EE8, |
0x5EE9, |
0x5EEC, |
0x5EF1, |
0x5EF3, |
0x5EF0, |
0x5EF4, |
0x5EF8, |
0x5EFE, |
0x5F03, |
0x5F09, |
0x5F5D, |
0x5F5C, |
0x5F0B, |
0x5F11, |
0x5F16, |
0x5F29, |
0x5F2D, |
0x5F38, |
0x5F41, |
0x5F48, |
0x5F4C, |
0x5F4E, |
0x5F2F, |
0x5F51, |
0x5F56, |
0x5F57, |
0x5F59, |
0x5F61, |
0x5F6D, |
0x5F73, |
0x5F77, |
0x5F83, |
0x5F82, |
0x5F7F, |
0x5F8A, |
0x5F88, |
0x5F91, |
0x5F87, |
0x5F9E, |
0x5F99, |
0x5F98, |
0x5FA0, |
0x5FA8, |
0x5FAD, |
0x5FBC, |
0x5FD6, |
0x5FFB, |
0x5FE4, |
0x5FF8, |
0x5FF1, |
0x5FDD, |
0x60B3, |
0x5FFF, |
0x6021, |
0x6060, |
0x6019, |
0x6010, |
0x6029, |
0x600E, |
0x6031, |
0x601B, |
0x6015, |
0x602B, |
0x6026, |
0x600F, |
0x603A, |
0x605A, |
0x6041, |
0x606A, |
0x6077, |
0x605F, |
0x604A, |
0x6046, |
0x604D, |
0x6063, |
0x6043, |
0x6064, |
0x6042, |
0x606C, |
0x606B, |
0x6059, |
0x6081, |
0x608D, |
0x60E7, |
0x6083, |
0x609A, |
0x6084, |
0x609B, |
0x6096, |
0x6097, |
0x6092, |
0x60A7, |
0x608B, |
0x60E1, |
0x60B8, |
0x60E0, |
0x60D3, |
0x60B4, |
0x5FF0, |
0x60BD, |
0x60C6, |
0x60B5, |
0x60D8, |
0x614D, |
0x6115, |
0x6106, |
0x60F6, |
0x60F7, |
0x6100, |
0x60F4, |
0x60FA, |
0x6103, |
0x6121, |
0x60FB, |
0x60F1, |
0x610D, |
0x610E, |
0x6147, |
0x613E, |
0x6128, |
0x6127, |
0x614A, |
0x613F, |
0x613C, |
0x612C, |
0x6134, |
0x613D, |
0x6142, |
0x6144, |
0x6173, |
0x6177, |
0x6158, |
0x6159, |
0x615A, |
0x616B, |
0x6174, |
0x616F, |
0x6165, |
0x6171, |
0x615F, |
0x615D, |
0x6153, |
0x6175, |
0x6199, |
0x6196, |
0x6187, |
0x61AC, |
0x6194, |
0x619A, |
0x618A, |
0x6191, |
0x61AB, |
0x61AE, |
0x61CC, |
0x61CA, |
0x61C9, |
0x61F7, |
0x61C8, |
0x61C3, |
0x61C6, |
0x61BA, |
0x61CB, |
0x7F79, |
0x61CD, |
0x61E6, |
0x61E3, |
0x61F6, |
0x61FA, |
0x61F4, |
0x61FF, |
0x61FD, |
0x61FC, |
0x61FE, |
0x6200, |
0x6208, |
0x6209, |
0x620D, |
0x620C, |
0x6214, |
0x621B, |
0x621E, |
0x6221, |
0x622A, |
0x622E, |
0x6230, |
0x6232, |
0x6233, |
0x6241, |
0x624E, |
0x625E, |
0x6263, |
0x625B, |
0x6260, |
0x6268, |
0x627C, |
0x6282, |
0x6289, |
0x627E, |
0x6292, |
0x6293, |
0x6296, |
0x62D4, |
0x6283, |
0x6294, |
0x62D7, |
0x62D1, |
0x62BB, |
0x62CF, |
0x62FF, |
0x62C6, |
0x64D4, |
0x62C8, |
0x62DC, |
0x62CC, |
0x62CA, |
0x62C2, |
0x62C7, |
0x629B, |
0x62C9, |
0x630C, |
0x62EE, |
0x62F1, |
0x6327, |
0x6302, |
0x6308, |
0x62EF, |
0x62F5, |
0x6350, |
0x633E, |
0x634D, |
0x641C, |
0x634F, |
0x6396, |
0x638E, |
0x6380, |
0x63AB, |
0x6376, |
0x63A3, |
0x638F, |
0x6389, |
0x639F, |
0x63B5, |
0x636B, |
0x6369, |
0x63BE, |
0x63E9, |
0x63C0, |
0x63C6, |
0x63E3, |
0x63C9, |
0x63D2, |
0x63F6, |
0x63C4, |
0x6416, |
0x6434, |
0x6406, |
0x6413, |
0x6426, |
0x6436, |
0x651D, |
0x6417, |
0x6428, |
0x640F, |
0x6467, |
0x646F, |
0x6476, |
0x644E, |
0x652A, |
0x6495, |
0x6493, |
0x64A5, |
0x64A9, |
0x6488, |
0x64BC, |
0x64DA, |
0x64D2, |
0x64C5, |
0x64C7, |
0x64BB, |
0x64D8, |
0x64C2, |
0x64F1, |
0x64E7, |
0x8209, |
0x64E0, |
0x64E1, |
0x62AC, |
0x64E3, |
0x64EF, |
0x652C, |
0x64F6, |
0x64F4, |
0x64F2, |
0x64FA, |
0x6500, |
0x64FD, |
0x6518, |
0x651C, |
0x6505, |
0x6524, |
0x6523, |
0x652B, |
0x6534, |
0x6535, |
0x6537, |
0x6536, |
0x6538, |
0x754B, |
0x6548, |
0x6556, |
0x6555, |
0x654D, |
0x6558, |
0x655E, |
0x655D, |
0x6572, |
0x6578, |
0x6582, |
0x6583, |
0x8B8A, |
0x659B, |
0x659F, |
0x65AB, |
0x65B7, |
0x65C3, |
0x65C6, |
0x65C1, |
0x65C4, |
0x65CC, |
0x65D2, |
0x65DB, |
0x65D9, |
0x65E0, |
0x65E1, |
0x65F1, |
0x6772, |
0x660A, |
0x6603, |
0x65FB, |
0x6773, |
0x6635, |
0x6636, |
0x6634, |
0x661C, |
0x664F, |
0x6644, |
0x6649, |
0x6641, |
0x665E, |
0x665D, |
0x6664, |
0x6667, |
0x6668, |
0x665F, |
0x6662, |
0x6670, |
0x6683, |
0x6688, |
0x668E, |
0x6689, |
0x6684, |
0x6698, |
0x669D, |
0x66C1, |
0x66B9, |
0x66C9, |
0x66BE, |
0x66BC, |
0x66C4, |
0x66B8, |
0x66D6, |
0x66DA, |
0x66E0, |
0x663F, |
0x66E6, |
0x66E9, |
0x66F0, |
0x66F5, |
0x66F7, |
0x670F, |
0x6716, |
0x671E, |
0x6726, |
0x6727, |
0x9738, |
0x672E, |
0x673F, |
0x6736, |
0x6741, |
0x6738, |
0x6737, |
0x6746, |
0x675E, |
0x6760, |
0x6759, |
0x6763, |
0x6764, |
0x6789, |
0x6770, |
0x67A9, |
0x677C, |
0x676A, |
0x678C, |
0x678B, |
0x67A6, |
0x67A1, |
0x6785, |
0x67B7, |
0x67EF, |
0x67B4, |
0x67EC, |
0x67B3, |
0x67E9, |
0x67B8, |
0x67E4, |
0x67DE, |
0x67DD, |
0x67E2, |
0x67EE, |
0x67B9, |
0x67CE, |
0x67C6, |
0x67E7, |
0x6A9C, |
0x681E, |
0x6846, |
0x6829, |
0x6840, |
0x684D, |
0x6832, |
0x684E, |
0x68B3, |
0x682B, |
0x6859, |
0x6863, |
0x6877, |
0x687F, |
0x689F, |
0x688F, |
0x68AD, |
0x6894, |
0x689D, |
0x689B, |
0x6883, |
0x6AAE, |
0x68B9, |
0x6874, |
0x68B5, |
0x68A0, |
0x68BA, |
0x690F, |
0x688D, |
0x687E, |
0x6901, |
0x68CA, |
0x6908, |
0x68D8, |
0x6922, |
0x6926, |
0x68E1, |
0x690C, |
0x68CD, |
0x68D4, |
0x68E7, |
0x68D5, |
0x6936, |
0x6912, |
0x6904, |
0x68D7, |
0x68E3, |
0x6925, |
0x68F9, |
0x68E0, |
0x68EF, |
0x6928, |
0x692A, |
0x691A, |
0x6923, |
0x6921, |
0x68C6, |
0x6979, |
0x6977, |
0x695C, |
0x6978, |
0x696B, |
0x6954, |
0x697E, |
0x696E, |
0x6939, |
0x6974, |
0x693D, |
0x6959, |
0x6930, |
0x6961, |
0x695E, |
0x695D, |
0x6981, |
0x696A, |
0x69B2, |
0x69AE, |
0x69D0, |
0x69BF, |
0x69C1, |
0x69D3, |
0x69BE, |
0x69CE, |
0x5BE8, |
0x69CA, |
0x69DD, |
0x69BB, |
0x69C3, |
0x69A7, |
0x6A2E, |
0x6991, |
0x69A0, |
0x699C, |
0x6995, |
0x69B4, |
0x69DE, |
0x69E8, |
0x6A02, |
0x6A1B, |
0x69FF, |
0x6B0A, |
0x69F9, |
0x69F2, |
0x69E7, |
0x6A05, |
0x69B1, |
0x6A1E, |
0x69ED, |
0x6A14, |
0x69EB, |
0x6A0A, |
0x6A12, |
0x6AC1, |
0x6A23, |
0x6A13, |
0x6A44, |
0x6A0C, |
0x6A72, |
0x6A36, |
0x6A78, |
0x6A47, |
0x6A62, |
0x6A59, |
0x6A66, |
0x6A48, |
0x6A38, |
0x6A22, |
0x6A90, |
0x6A8D, |
0x6AA0, |
0x6A84, |
0x6AA2, |
0x6AA3, |
0x6A97, |
0x8617, |
0x6ABB, |
0x6AC3, |
0x6AC2, |
0x6AB8, |
0x6AB3, |
0x6AAC, |
0x6ADE, |
0x6AD1, |
0x6ADF, |
0x6AAA, |
0x6ADA, |
0x6AEA, |
0x6AFB, |
0x6B05, |
0x8616, |
0x6AFA, |
0x6B12, |
0x6B16, |
0x9B31, |
0x6B1F, |
0x6B38, |
0x6B37, |
0x76DC, |
0x6B39, |
0x98EE, |
0x6B47, |
0x6B43, |
0x6B49, |
0x6B50, |
0x6B59, |
0x6B54, |
0x6B5B, |
0x6B5F, |
0x6B61, |
0x6B78, |
0x6B79, |
0x6B7F, |
0x6B80, |
0x6B84, |
0x6B83, |
0x6B8D, |
0x6B98, |
0x6B95, |
0x6B9E, |
0x6BA4, |
0x6BAA, |
0x6BAB, |
0x6BAF, |
0x6BB2, |
0x6BB1, |
0x6BB3, |
0x6BB7, |
0x6BBC, |
0x6BC6, |
0x6BCB, |
0x6BD3, |
0x6BDF, |
0x6BEC, |
0x6BEB, |
0x6BF3, |
0x6BEF, |
0x9EBE, |
0x6C08, |
0x6C13, |
0x6C14, |
0x6C1B, |
0x6C24, |
0x6C23, |
0x6C5E, |
0x6C55, |
0x6C62, |
0x6C6A, |
0x6C82, |
0x6C8D, |
0x6C9A, |
0x6C81, |
0x6C9B, |
0x6C7E, |
0x6C68, |
0x6C73, |
0x6C92, |
0x6C90, |
0x6CC4, |
0x6CF1, |
0x6CD3, |
0x6CBD, |
0x6CD7, |
0x6CC5, |
0x6CDD, |
0x6CAE, |
0x6CB1, |
0x6CBE, |
0x6CBA, |
0x6CDB, |
0x6CEF, |
0x6CD9, |
0x6CEA, |
0x6D1F, |
0x884D, |
0x6D36, |
0x6D2B, |
0x6D3D, |
0x6D38, |
0x6D19, |
0x6D35, |
0x6D33, |
0x6D12, |
0x6D0C, |
0x6D63, |
0x6D93, |
0x6D64, |
0x6D5A, |
0x6D79, |
0x6D59, |
0x6D8E, |
0x6D95, |
0x6FE4, |
0x6D85, |
0x6DF9, |
0x6E15, |
0x6E0A, |
0x6DB5, |
0x6DC7, |
0x6DE6, |
0x6DB8, |
0x6DC6, |
0x6DEC, |
0x6DDE, |
0x6DCC, |
0x6DE8, |
0x6DD2, |
0x6DC5, |
0x6DFA, |
0x6DD9, |
0x6DE4, |
0x6DD5, |
0x6DEA, |
0x6DEE, |
0x6E2D, |
0x6E6E, |
0x6E2E, |
0x6E19, |
0x6E72, |
0x6E5F, |
0x6E3E, |
0x6E23, |
0x6E6B, |
0x6E2B, |
0x6E76, |
0x6E4D, |
0x6E1F, |
0x6E43, |
0x6E3A, |
0x6E4E, |
0x6E24, |
0x6EFF, |
0x6E1D, |
0x6E38, |
0x6E82, |
0x6EAA, |
0x6E98, |
0x6EC9, |
0x6EB7, |
0x6ED3, |
0x6EBD, |
0x6EAF, |
0x6EC4, |
0x6EB2, |
0x6ED4, |
0x6ED5, |
0x6E8F, |
0x6EA5, |
0x6EC2, |
0x6E9F, |
0x6F41, |
0x6F11, |
0x704C, |
0x6EEC, |
0x6EF8, |
0x6EFE, |
0x6F3F, |
0x6EF2, |
0x6F31, |
0x6EEF, |
0x6F32, |
0x6ECC, |
0x6F3E, |
0x6F13, |
0x6EF7, |
0x6F86, |
0x6F7A, |
0x6F78, |
0x6F81, |
0x6F80, |
0x6F6F, |
0x6F5B, |
0x6FF3, |
0x6F6D, |
0x6F82, |
0x6F7C, |
0x6F58, |
0x6F8E, |
0x6F91, |
0x6FC2, |
0x6F66, |
0x6FB3, |
0x6FA3, |
0x6FA1, |
0x6FA4, |
0x6FB9, |
0x6FC6, |
0x6FAA, |
0x6FDF, |
0x6FD5, |
0x6FEC, |
0x6FD4, |
0x6FD8, |
0x6FF1, |
0x6FEE, |
0x6FDB, |
0x7009, |
0x700B, |
0x6FFA, |
0x7011, |
0x7001, |
0x700F, |
0x6FFE, |
0x701B, |
0x701A, |
0x6F74, |
0x701D, |
0x7018, |
0x701F, |
0x7030, |
0x703E, |
0x7032, |
0x7051, |
0x7063, |
0x7099, |
0x7092, |
0x70AF, |
0x70F1, |
0x70AC, |
0x70B8, |
0x70B3, |
0x70AE, |
0x70DF, |
0x70CB, |
0x70DD, |
0x70D9, |
0x7109, |
0x70FD, |
0x711C, |
0x7119, |
0x7165, |
0x7155, |
0x7188, |
0x7166, |
0x7162, |
0x714C, |
0x7156, |
0x716C, |
0x718F, |
0x71FB, |
0x7184, |
0x7195, |
0x71A8, |
0x71AC, |
0x71D7, |
0x71B9, |
0x71BE, |
0x71D2, |
0x71C9, |
0x71D4, |
0x71CE, |
0x71E0, |
0x71EC, |
0x71E7, |
0x71F5, |
0x71FC, |
0x71F9, |
0x71FF, |
0x720D, |
0x7210, |
0x721B, |
0x7228, |
0x722D, |
0x722C, |
0x7230, |
0x7232, |
0x723B, |
0x723C, |
0x723F, |
0x7240, |
0x7246, |
0x724B, |
0x7258, |
0x7274, |
0x727E, |
0x7282, |
0x7281, |
0x7287, |
0x7292, |
0x7296, |
0x72A2, |
0x72A7, |
0x72B9, |
0x72B2, |
0x72C3, |
0x72C6, |
0x72C4, |
0x72CE, |
0x72D2, |
0x72E2, |
0x72E0, |
0x72E1, |
0x72F9, |
0x72F7, |
0x500F, |
0x7317, |
0x730A, |
0x731C, |
0x7316, |
0x731D, |
0x7334, |
0x732F, |
0x7329, |
0x7325, |
0x733E, |
0x734E, |
0x734F, |
0x9ED8, |
0x7357, |
0x736A, |
0x7368, |
0x7370, |
0x7378, |
0x7375, |
0x737B, |
0x737A, |
0x73C8, |
0x73B3, |
0x73CE, |
0x73BB, |
0x73C0, |
0x73E5, |
0x73EE, |
0x73DE, |
0x74A2, |
0x7405, |
0x746F, |
0x7425, |
0x73F8, |
0x7432, |
0x743A, |
0x7455, |
0x743F, |
0x745F, |
0x7459, |
0x7441, |
0x745C, |
0x7469, |
0x7470, |
0x7463, |
0x746A, |
0x7476, |
0x747E, |
0x748B, |
0x749E, |
0x74A7, |
0x74CA, |
0x74CF, |
0x74D4, |
0x73F1, |
0x74E0, |
0x74E3, |
0x74E7, |
0x74E9, |
0x74EE, |
0x74F2, |
0x74F0, |
0x74F1, |
0x74F8, |
0x74F7, |
0x7504, |
0x7503, |
0x7505, |
0x750C, |
0x750E, |
0x750D, |
0x7515, |
0x7513, |
0x751E, |
0x7526, |
0x752C, |
0x753C, |
0x7544, |
0x754D, |
0x754A, |
0x7549, |
0x755B, |
0x7546, |
0x755A, |
0x7569, |
0x7564, |
0x7567, |
0x756B, |
0x756D, |
0x7578, |
0x7576, |
0x7586, |
0x7587, |
0x7574, |
0x758A, |
0x7589, |
0x7582, |
0x7594, |
0x759A, |
0x759D, |
0x75A5, |
0x75A3, |
0x75C2, |
0x75B3, |
0x75C3, |
0x75B5, |
0x75BD, |
0x75B8, |
0x75BC, |
0x75B1, |
0x75CD, |
0x75CA, |
0x75D2, |
0x75D9, |
0x75E3, |
0x75DE, |
0x75FE, |
0x75FF, |
0x75FC, |
0x7601, |
0x75F0, |
0x75FA, |
0x75F2, |
0x75F3, |
0x760B, |
0x760D, |
0x7609, |
0x761F, |
0x7627, |
0x7620, |
0x7621, |
0x7622, |
0x7624, |
0x7634, |
0x7630, |
0x763B, |
0x7647, |
0x7648, |
0x7646, |
0x765C, |
0x7658, |
0x7661, |
0x7662, |
0x7668, |
0x7669, |
0x766A, |
0x7667, |
0x766C, |
0x7670, |
0x7672, |
0x7676, |
0x7678, |
0x767C, |
0x7680, |
0x7683, |
0x7688, |
0x768B, |
0x768E, |
0x7696, |
0x7693, |
0x7699, |
0x769A, |
0x76B0, |
0x76B4, |
0x76B8, |
0x76B9, |
0x76BA, |
0x76C2, |
0x76CD, |
0x76D6, |
0x76D2, |
0x76DE, |
0x76E1, |
0x76E5, |
0x76E7, |
0x76EA, |
0x862F, |
0x76FB, |
0x7708, |
0x7707, |
0x7704, |
0x7729, |
0x7724, |
0x771E, |
0x7725, |
0x7726, |
0x771B, |
0x7737, |
0x7738, |
0x7747, |
0x775A, |
0x7768, |
0x776B, |
0x775B, |
0x7765, |
0x777F, |
0x777E, |
0x7779, |
0x778E, |
0x778B, |
0x7791, |
0x77A0, |
0x779E, |
0x77B0, |
0x77B6, |
0x77B9, |
0x77BF, |
0x77BC, |
0x77BD, |
0x77BB, |
0x77C7, |
0x77CD, |
0x77D7, |
0x77DA, |
0x77DC, |
0x77E3, |
0x77EE, |
0x77FC, |
0x780C, |
0x7812, |
0x7926, |
0x7820, |
0x792A, |
0x7845, |
0x788E, |
0x7874, |
0x7886, |
0x787C, |
0x789A, |
0x788C, |
0x78A3, |
0x78B5, |
0x78AA, |
0x78AF, |
0x78D1, |
0x78C6, |
0x78CB, |
0x78D4, |
0x78BE, |
0x78BC, |
0x78C5, |
0x78CA, |
0x78EC, |
0x78E7, |
0x78DA, |
0x78FD, |
0x78F4, |
0x7907, |
0x7912, |
0x7911, |
0x7919, |
0x792C, |
0x792B, |
0x7940, |
0x7960, |
0x7957, |
0x795F, |
0x795A, |
0x7955, |
0x7953, |
0x797A, |
0x797F, |
0x798A, |
0x799D, |
0x79A7, |
0x9F4B, |
0x79AA, |
0x79AE, |
0x79B3, |
0x79B9, |
0x79BA, |
0x79C9, |
0x79D5, |
0x79E7, |
0x79EC, |
0x79E1, |
0x79E3, |
0x7A08, |
0x7A0D, |
0x7A18, |
0x7A19, |
0x7A20, |
0x7A1F, |
0x7980, |
0x7A31, |
0x7A3B, |
0x7A3E, |
0x7A37, |
0x7A43, |
0x7A57, |
0x7A49, |
0x7A61, |
0x7A62, |
0x7A69, |
0x9F9D, |
0x7A70, |
0x7A79, |
0x7A7D, |
0x7A88, |
0x7A97, |
0x7A95, |
0x7A98, |
0x7A96, |
0x7AA9, |
0x7AC8, |
0x7AB0, |
0x7AB6, |
0x7AC5, |
0x7AC4, |
0x7ABF, |
0x9083, |
0x7AC7, |
0x7ACA, |
0x7ACD, |
0x7ACF, |
0x7AD5, |
0x7AD3, |
0x7AD9, |
0x7ADA, |
0x7ADD, |
0x7AE1, |
0x7AE2, |
0x7AE6, |
0x7AED, |
0x7AF0, |
0x7B02, |
0x7B0F, |
0x7B0A, |
0x7B06, |
0x7B33, |
0x7B18, |
0x7B19, |
0x7B1E, |
0x7B35, |
0x7B28, |
0x7B36, |
0x7B50, |
0x7B7A, |
0x7B04, |
0x7B4D, |
0x7B0B, |
0x7B4C, |
0x7B45, |
0x7B75, |
0x7B65, |
0x7B74, |
0x7B67, |
0x7B70, |
0x7B71, |
0x7B6C, |
0x7B6E, |
0x7B9D, |
0x7B98, |
0x7B9F, |
0x7B8D, |
0x7B9C, |
0x7B9A, |
0x7B8B, |
0x7B92, |
0x7B8F, |
0x7B5D, |
0x7B99, |
0x7BCB, |
0x7BC1, |
0x7BCC, |
0x7BCF, |
0x7BB4, |
0x7BC6, |
0x7BDD, |
0x7BE9, |
0x7C11, |
0x7C14, |
0x7BE6, |
0x7BE5, |
0x7C60, |
0x7C00, |
0x7C07, |
0x7C13, |
0x7BF3, |
0x7BF7, |
0x7C17, |
0x7C0D, |
0x7BF6, |
0x7C23, |
0x7C27, |
0x7C2A, |
0x7C1F, |
0x7C37, |
0x7C2B, |
0x7C3D, |
0x7C4C, |
0x7C43, |
0x7C54, |
0x7C4F, |
0x7C40, |
0x7C50, |
0x7C58, |
0x7C5F, |
0x7C64, |
0x7C56, |
0x7C65, |
0x7C6C, |
0x7C75, |
0x7C83, |
0x7C90, |
0x7CA4, |
0x7CAD, |
0x7CA2, |
0x7CAB, |
0x7CA1, |
0x7CA8, |
0x7CB3, |
0x7CB2, |
0x7CB1, |
0x7CAE, |
0x7CB9, |
0x7CBD, |
0x7CC0, |
0x7CC5, |
0x7CC2, |
0x7CD8, |
0x7CD2, |
0x7CDC, |
0x7CE2, |
0x9B3B, |
0x7CEF, |
0x7CF2, |
0x7CF4, |
0x7CF6, |
0x7CFA, |
0x7D06, |
0x7D02, |
0x7D1C, |
0x7D15, |
0x7D0A, |
0x7D45, |
0x7D4B, |
0x7D2E, |
0x7D32, |
0x7D3F, |
0x7D35, |
0x7D46, |
0x7D73, |
0x7D56, |
0x7D4E, |
0x7D72, |
0x7D68, |
0x7D6E, |
0x7D4F, |
0x7D63, |
0x7D93, |
0x7D89, |
0x7D5B, |
0x7D8F, |
0x7D7D, |
0x7D9B, |
0x7DBA, |
0x7DAE, |
0x7DA3, |
0x7DB5, |
0x7DC7, |
0x7DBD, |
0x7DAB, |
0x7E3D, |
0x7DA2, |
0x7DAF, |
0x7DDC, |
0x7DB8, |
0x7D9F, |
0x7DB0, |
0x7DD8, |
0x7DDD, |
0x7DE4, |
0x7DDE, |
0x7DFB, |
0x7DF2, |
0x7DE1, |
0x7E05, |
0x7E0A, |
0x7E23, |
0x7E21, |
0x7E12, |
0x7E31, |
0x7E1F, |
0x7E09, |
0x7E0B, |
0x7E22, |
0x7E46, |
0x7E66, |
0x7E3B, |
0x7E35, |
0x7E39, |
0x7E43, |
0x7E37, |
0x7E32, |
0x7E3A, |
0x7E67, |
0x7E5D, |
0x7E56, |
0x7E5E, |
0x7E59, |
0x7E5A, |
0x7E79, |
0x7E6A, |
0x7E69, |
0x7E7C, |
0x7E7B, |
0x7E83, |
0x7DD5, |
0x7E7D, |
0x8FAE, |
0x7E7F, |
0x7E88, |
0x7E89, |
0x7E8C, |
0x7E92, |
0x7E90, |
0x7E93, |
0x7E94, |
0x7E96, |
0x7E8E, |
0x7E9B, |
0x7E9C, |
0x7F38, |
0x7F3A, |
0x7F45, |
0x7F4C, |
0x7F4D, |
0x7F4E, |
0x7F50, |
0x7F51, |
0x7F55, |
0x7F54, |
0x7F58, |
0x7F5F, |
0x7F60, |
0x7F68, |
0x7F69, |
0x7F67, |
0x7F78, |
0x7F82, |
0x7F86, |
0x7F83, |
0x7F88, |
0x7F87, |
0x7F8C, |
0x7F94, |
0x7F9E, |
0x7F9D, |
0x7F9A, |
0x7FA3, |
0x7FAF, |
0x7FB2, |
0x7FB9, |
0x7FAE, |
0x7FB6, |
0x7FB8, |
0x8B71, |
0x7FC5, |
0x7FC6, |
0x7FCA, |
0x7FD5, |
0x7FD4, |
0x7FE1, |
0x7FE6, |
0x7FE9, |
0x7FF3, |
0x7FF9, |
0x98DC, |
0x8006, |
0x8004, |
0x800B, |
0x8012, |
0x8018, |
0x8019, |
0x801C, |
0x8021, |
0x8028, |
0x803F, |
0x803B, |
0x804A, |
0x8046, |
0x8052, |
0x8058, |
0x805A, |
0x805F, |
0x8062, |
0x8068, |
0x8073, |
0x8072, |
0x8070, |
0x8076, |
0x8079, |
0x807D, |
0x807F, |
0x8084, |
0x8086, |
0x8085, |
0x809B, |
0x8093, |
0x809A, |
0x80AD, |
0x5190, |
0x80AC, |
0x80DB, |
0x80E5, |
0x80D9, |
0x80DD, |
0x80C4, |
0x80DA, |
0x80D6, |
0x8109, |
0x80EF, |
0x80F1, |
0x811B, |
0x8129, |
0x8123, |
0x812F, |
0x814B, |
0x968B, |
0x8146, |
0x813E, |
0x8153, |
0x8151, |
0x80FC, |
0x8171, |
0x816E, |
0x8165, |
0x8166, |
0x8174, |
0x8183, |
0x8188, |
0x818A, |
0x8180, |
0x8182, |
0x81A0, |
0x8195, |
0x81A4, |
0x81A3, |
0x815F, |
0x8193, |
0x81A9, |
0x81B0, |
0x81B5, |
0x81BE, |
0x81B8, |
0x81BD, |
0x81C0, |
0x81C2, |
0x81BA, |
0x81C9, |
0x81CD, |
0x81D1, |
0x81D9, |
0x81D8, |
0x81C8, |
0x81DA, |
0x81DF, |
0x81E0, |
0x81E7, |
0x81FA, |
0x81FB, |
0x81FE, |
0x8201, |
0x8202, |
0x8205, |
0x8207, |
0x820A, |
0x820D, |
0x8210, |
0x8216, |
0x8229, |
0x822B, |
0x8238, |
0x8233, |
0x8240, |
0x8259, |
0x8258, |
0x825D, |
0x825A, |
0x825F, |
0x8264, |
0x8262, |
0x8268, |
0x826A, |
0x826B, |
0x822E, |
0x8271, |
0x8277, |
0x8278, |
0x827E, |
0x828D, |
0x8292, |
0x82AB, |
0x829F, |
0x82BB, |
0x82AC, |
0x82E1, |
0x82E3, |
0x82DF, |
0x82D2, |
0x82F4, |
0x82F3, |
0x82FA, |
0x8393, |
0x8303, |
0x82FB, |
0x82F9, |
0x82DE, |
0x8306, |
0x82DC, |
0x8309, |
0x82D9, |
0x8335, |
0x8334, |
0x8316, |
0x8332, |
0x8331, |
0x8340, |
0x8339, |
0x8350, |
0x8345, |
0x832F, |
0x832B, |
0x8317, |
0x8318, |
0x8385, |
0x839A, |
0x83AA, |
0x839F, |
0x83A2, |
0x8396, |
0x8323, |
0x838E, |
0x8387, |
0x838A, |
0x837C, |
0x83B5, |
0x8373, |
0x8375, |
0x83A0, |
0x8389, |
0x83A8, |
0x83F4, |
0x8413, |
0x83EB, |
0x83CE, |
0x83FD, |
0x8403, |
0x83D8, |
0x840B, |
0x83C1, |
0x83F7, |
0x8407, |
0x83E0, |
0x83F2, |
0x840D, |
0x8422, |
0x8420, |
0x83BD, |
0x8438, |
0x8506, |
0x83FB, |
0x846D, |
0x842A, |
0x843C, |
0x855A, |
0x8484, |
0x8477, |
0x846B, |
0x84AD, |
0x846E, |
0x8482, |
0x8469, |
0x8446, |
0x842C, |
0x846F, |
0x8479, |
0x8435, |
0x84CA, |
0x8462, |
0x84B9, |
0x84BF, |
0x849F, |
0x84D9, |
0x84CD, |
0x84BB, |
0x84DA, |
0x84D0, |
0x84C1, |
0x84C6, |
0x84D6, |
0x84A1, |
0x8521, |
0x84FF, |
0x84F4, |
0x8517, |
0x8518, |
0x852C, |
0x851F, |
0x8515, |
0x8514, |
0x84FC, |
0x8540, |
0x8563, |
0x8558, |
0x8548, |
0x8541, |
0x8602, |
0x854B, |
0x8555, |
0x8580, |
0x85A4, |
0x8588, |
0x8591, |
0x858A, |
0x85A8, |
0x856D, |
0x8594, |
0x859B, |
0x85EA, |
0x8587, |
0x859C, |
0x8577, |
0x857E, |
0x8590, |
0x85C9, |
0x85BA, |
0x85CF, |
0x85B9, |
0x85D0, |
0x85D5, |
0x85DD, |
0x85E5, |
0x85DC, |
0x85F9, |
0x860A, |
0x8613, |
0x860B, |
0x85FE, |
0x85FA, |
0x8606, |
0x8622, |
0x861A, |
0x8630, |
0x863F, |
0x864D, |
0x4E55, |
0x8654, |
0x865F, |
0x8667, |
0x8671, |
0x8693, |
0x86A3, |
0x86A9, |
0x86AA, |
0x868B, |
0x868C, |
0x86B6, |
0x86AF, |
0x86C4, |
0x86C6, |
0x86B0, |
0x86C9, |
0x8823, |
0x86AB, |
0x86D4, |
0x86DE, |
0x86E9, |
0x86EC, |
0x86DF, |
0x86DB, |
0x86EF, |
0x8712, |
0x8706, |
0x8708, |
0x8700, |
0x8703, |
0x86FB, |
0x8711, |
0x8709, |
0x870D, |
0x86F9, |
0x870A, |
0x8734, |
0x873F, |
0x8737, |
0x873B, |
0x8725, |
0x8729, |
0x871A, |
0x8760, |
0x875F, |
0x8778, |
0x874C, |
0x874E, |
0x8774, |
0x8757, |
0x8768, |
0x876E, |
0x8759, |
0x8753, |
0x8763, |
0x876A, |
0x8805, |
0x87A2, |
0x879F, |
0x8782, |
0x87AF, |
0x87CB, |
0x87BD, |
0x87C0, |
0x87D0, |
0x96D6, |
0x87AB, |
0x87C4, |
0x87B3, |
0x87C7, |
0x87C6, |
0x87BB, |
0x87EF, |
0x87F2, |
0x87E0, |
0x880F, |
0x880D, |
0x87FE, |
0x87F6, |
0x87F7, |
0x880E, |
0x87D2, |
0x8811, |
0x8816, |
0x8815, |
0x8822, |
0x8821, |
0x8831, |
0x8836, |
0x8839, |
0x8827, |
0x883B, |
0x8844, |
0x8842, |
0x8852, |
0x8859, |
0x885E, |
0x8862, |
0x886B, |
0x8881, |
0x887E, |
0x889E, |
0x8875, |
0x887D, |
0x88B5, |
0x8872, |
0x8882, |
0x8897, |
0x8892, |
0x88AE, |
0x8899, |
0x88A2, |
0x888D, |
0x88A4, |
0x88B0, |
0x88BF, |
0x88B1, |
0x88C3, |
0x88C4, |
0x88D4, |
0x88D8, |
0x88D9, |
0x88DD, |
0x88F9, |
0x8902, |
0x88FC, |
0x88F4, |
0x88E8, |
0x88F2, |
0x8904, |
0x890C, |
0x890A, |
0x8913, |
0x8943, |
0x891E, |
0x8925, |
0x892A, |
0x892B, |
0x8941, |
0x8944, |
0x893B, |
0x8936, |
0x8938, |
0x894C, |
0x891D, |
0x8960, |
0x895E, |
0x8966, |
0x8964, |
0x896D, |
0x896A, |
0x896F, |
0x8974, |
0x8977, |
0x897E, |
0x8983, |
0x8988, |
0x898A, |
0x8993, |
0x8998, |
0x89A1, |
0x89A9, |
0x89A6, |
0x89AC, |
0x89AF, |
0x89B2, |
0x89BA, |
0x89BD, |
0x89BF, |
0x89C0, |
0x89DA, |
0x89DC, |
0x89DD, |
0x89E7, |
0x89F4, |
0x89F8, |
0x8A03, |
0x8A16, |
0x8A10, |
0x8A0C, |
0x8A1B, |
0x8A1D, |
0x8A25, |
0x8A36, |
0x8A41, |
0x8A5B, |
0x8A52, |
0x8A46, |
0x8A48, |
0x8A7C, |
0x8A6D, |
0x8A6C, |
0x8A62, |
0x8A85, |
0x8A82, |
0x8A84, |
0x8AA8, |
0x8AA1, |
0x8A91, |
0x8AA5, |
0x8AA6, |
0x8A9A, |
0x8AA3, |
0x8AC4, |
0x8ACD, |
0x8AC2, |
0x8ADA, |
0x8AEB, |
0x8AF3, |
0x8AE7, |
0x8AE4, |
0x8AF1, |
0x8B14, |
0x8AE0, |
0x8AE2, |
0x8AF7, |
0x8ADE, |
0x8ADB, |
0x8B0C, |
0x8B07, |
0x8B1A, |
0x8AE1, |
0x8B16, |
0x8B10, |
0x8B17, |
0x8B20, |
0x8B33, |
0x97AB, |
0x8B26, |
0x8B2B, |
0x8B3E, |
0x8B28, |
0x8B41, |
0x8B4C, |
0x8B4F, |
0x8B4E, |
0x8B49, |
0x8B56, |
0x8B5B, |
0x8B5A, |
0x8B6B, |
0x8B5F, |
0x8B6C, |
0x8B6F, |
0x8B74, |
0x8B7D, |
0x8B80, |
0x8B8C, |
0x8B8E, |
0x8B92, |
0x8B93, |
0x8B96, |
0x8B99, |
0x8B9A, |
0x8C3A, |
0x8C41, |
0x8C3F, |
0x8C48, |
0x8C4C, |
0x8C4E, |
0x8C50, |
0x8C55, |
0x8C62, |
0x8C6C, |
0x8C78, |
0x8C7A, |
0x8C82, |
0x8C89, |
0x8C85, |
0x8C8A, |
0x8C8D, |
0x8C8E, |
0x8C94, |
0x8C7C, |
0x8C98, |
0x621D, |
0x8CAD, |
0x8CAA, |
0x8CBD, |
0x8CB2, |
0x8CB3, |
0x8CAE, |
0x8CB6, |
0x8CC8, |
0x8CC1, |
0x8CE4, |
0x8CE3, |
0x8CDA, |
0x8CFD, |
0x8CFA, |
0x8CFB, |
0x8D04, |
0x8D05, |
0x8D0A, |
0x8D07, |
0x8D0F, |
0x8D0D, |
0x8D10, |
0x9F4E, |
0x8D13, |
0x8CCD, |
0x8D14, |
0x8D16, |
0x8D67, |
0x8D6D, |
0x8D71, |
0x8D73, |
0x8D81, |
0x8D99, |
0x8DC2, |
0x8DBE, |
0x8DBA, |
0x8DCF, |
0x8DDA, |
0x8DD6, |
0x8DCC, |
0x8DDB, |
0x8DCB, |
0x8DEA, |
0x8DEB, |
0x8DDF, |
0x8DE3, |
0x8DFC, |
0x8E08, |
0x8E09, |
0x8DFF, |
0x8E1D, |
0x8E1E, |
0x8E10, |
0x8E1F, |
0x8E42, |
0x8E35, |
0x8E30, |
0x8E34, |
0x8E4A, |
0x8E47, |
0x8E49, |
0x8E4C, |
0x8E50, |
0x8E48, |
0x8E59, |
0x8E64, |
0x8E60, |
0x8E2A, |
0x8E63, |
0x8E55, |
0x8E76, |
0x8E72, |
0x8E7C, |
0x8E81, |
0x8E87, |
0x8E85, |
0x8E84, |
0x8E8B, |
0x8E8A, |
0x8E93, |
0x8E91, |
0x8E94, |
0x8E99, |
0x8EAA, |
0x8EA1, |
0x8EAC, |
0x8EB0, |
0x8EC6, |
0x8EB1, |
0x8EBE, |
0x8EC5, |
0x8EC8, |
0x8ECB, |
0x8EDB, |
0x8EE3, |
0x8EFC, |
0x8EFB, |
0x8EEB, |
0x8EFE, |
0x8F0A, |
0x8F05, |
0x8F15, |
0x8F12, |
0x8F19, |
0x8F13, |
0x8F1C, |
0x8F1F, |
0x8F1B, |
0x8F0C, |
0x8F26, |
0x8F33, |
0x8F3B, |
0x8F39, |
0x8F45, |
0x8F42, |
0x8F3E, |
0x8F4C, |
0x8F49, |
0x8F46, |
0x8F4E, |
0x8F57, |
0x8F5C, |
0x8F62, |
0x8F63, |
0x8F64, |
0x8F9C, |
0x8F9F, |
0x8FA3, |
0x8FAD, |
0x8FAF, |
0x8FB7, |
0x8FDA, |
0x8FE5, |
0x8FE2, |
0x8FEA, |
0x8FEF, |
0x9087, |
0x8FF4, |
0x9005, |
0x8FF9, |
0x8FFA, |
0x9011, |
0x9015, |
0x9021, |
0x900D, |
0x901E, |
0x9016, |
0x900B, |
0x9027, |
0x9036, |
0x9035, |
0x9039, |
0x8FF8, |
0x904F, |
0x9050, |
0x9051, |
0x9052, |
0x900E, |
0x9049, |
0x903E, |
0x9056, |
0x9058, |
0x905E, |
0x9068, |
0x906F, |
0x9076, |
0x96A8, |
0x9072, |
0x9082, |
0x907D, |
0x9081, |
0x9080, |
0x908A, |
0x9089, |
0x908F, |
0x90A8, |
0x90AF, |
0x90B1, |
0x90B5, |
0x90E2, |
0x90E4, |
0x6248, |
0x90DB, |
0x9102, |
0x9112, |
0x9119, |
0x9132, |
0x9130, |
0x914A, |
0x9156, |
0x9158, |
0x9163, |
0x9165, |
0x9169, |
0x9173, |
0x9172, |
0x918B, |
0x9189, |
0x9182, |
0x91A2, |
0x91AB, |
0x91AF, |
0x91AA, |
0x91B5, |
0x91B4, |
0x91BA, |
0x91C0, |
0x91C1, |
0x91C9, |
0x91CB, |
0x91D0, |
0x91D6, |
0x91DF, |
0x91E1, |
0x91DB, |
0x91FC, |
0x91F5, |
0x91F6, |
0x921E, |
0x91FF, |
0x9214, |
0x922C, |
0x9215, |
0x9211, |
0x925E, |
0x9257, |
0x9245, |
0x9249, |
0x9264, |
0x9248, |
0x9295, |
0x923F, |
0x924B, |
0x9250, |
0x929C, |
0x9296, |
0x9293, |
0x929B, |
0x925A, |
0x92CF, |
0x92B9, |
0x92B7, |
0x92E9, |
0x930F, |
0x92FA, |
0x9344, |
0x932E, |
0x9319, |
0x9322, |
0x931A, |
0x9323, |
0x933A, |
0x9335, |
0x933B, |
0x935C, |
0x9360, |
0x937C, |
0x936E, |
0x9356, |
0x93B0, |
0x93AC, |
0x93AD, |
0x9394, |
0x93B9, |
0x93D6, |
0x93D7, |
0x93E8, |
0x93E5, |
0x93D8, |
0x93C3, |
0x93DD, |
0x93D0, |
0x93C8, |
0x93E4, |
0x941A, |
0x9414, |
0x9413, |
0x9403, |
0x9407, |
0x9410, |
0x9436, |
0x942B, |
0x9435, |
0x9421, |
0x943A, |
0x9441, |
0x9452, |
0x9444, |
0x945B, |
0x9460, |
0x9462, |
0x945E, |
0x946A, |
0x9229, |
0x9470, |
0x9475, |
0x9477, |
0x947D, |
0x945A, |
0x947C, |
0x947E, |
0x9481, |
0x947F, |
0x9582, |
0x9587, |
0x958A, |
0x9594, |
0x9596, |
0x9598, |
0x9599, |
0x95A0, |
0x95A8, |
0x95A7, |
0x95AD, |
0x95BC, |
0x95BB, |
0x95B9, |
0x95BE, |
0x95CA, |
0x6FF6, |
0x95C3, |
0x95CD, |
0x95CC, |
0x95D5, |
0x95D4, |
0x95D6, |
0x95DC, |
0x95E1, |
0x95E5, |
0x95E2, |
0x9621, |
0x9628, |
0x962E, |
0x962F, |
0x9642, |
0x964C, |
0x964F, |
0x964B, |
0x9677, |
0x965C, |
0x965E, |
0x965D, |
0x965F, |
0x9666, |
0x9672, |
0x966C, |
0x968D, |
0x9698, |
0x9695, |
0x9697, |
0x96AA, |
0x96A7, |
0x96B1, |
0x96B2, |
0x96B0, |
0x96B4, |
0x96B6, |
0x96B8, |
0x96B9, |
0x96CE, |
0x96CB, |
0x96C9, |
0x96CD, |
0x894D, |
0x96DC, |
0x970D, |
0x96D5, |
0x96F9, |
0x9704, |
0x9706, |
0x9708, |
0x9713, |
0x970E, |
0x9711, |
0x970F, |
0x9716, |
0x9719, |
0x9724, |
0x972A, |
0x9730, |
0x9739, |
0x973D, |
0x973E, |
0x9744, |
0x9746, |
0x9748, |
0x9742, |
0x9749, |
0x975C, |
0x9760, |
0x9764, |
0x9766, |
0x9768, |
0x52D2, |
0x976B, |
0x9771, |
0x9779, |
0x9785, |
0x977C, |
0x9781, |
0x977A, |
0x9786, |
0x978B, |
0x978F, |
0x9790, |
0x979C, |
0x97A8, |
0x97A6, |
0x97A3, |
0x97B3, |
0x97B4, |
0x97C3, |
0x97C6, |
0x97C8, |
0x97CB, |
0x97DC, |
0x97ED, |
0x9F4F, |
0x97F2, |
0x7ADF, |
0x97F6, |
0x97F5, |
0x980F, |
0x980C, |
0x9838, |
0x9824, |
0x9821, |
0x9837, |
0x983D, |
0x9846, |
0x984F, |
0x984B, |
0x986B, |
0x986F, |
0x9870, |
0x9871, |
0x9874, |
0x9873, |
0x98AA, |
0x98AF, |
0x98B1, |
0x98B6, |
0x98C4, |
0x98C3, |
0x98C6, |
0x98E9, |
0x98EB, |
0x9903, |
0x9909, |
0x9912, |
0x9914, |
0x9918, |
0x9921, |
0x991D, |
0x991E, |
0x9924, |
0x9920, |
0x992C, |
0x992E, |
0x993D, |
0x993E, |
0x9942, |
0x9949, |
0x9945, |
0x9950, |
0x994B, |
0x9951, |
0x9952, |
0x994C, |
0x9955, |
0x9997, |
0x9998, |
0x99A5, |
0x99AD, |
0x99AE, |
0x99BC, |
0x99DF, |
0x99DB, |
0x99DD, |
0x99D8, |
0x99D1, |
0x99ED, |
0x99EE, |
0x99F1, |
0x99F2, |
0x99FB, |
0x99F8, |
0x9A01, |
0x9A0F, |
0x9A05, |
0x99E2, |
0x9A19, |
0x9A2B, |
0x9A37, |
0x9A45, |
0x9A42, |
0x9A40, |
0x9A43, |
0x9A3E, |
0x9A55, |
0x9A4D, |
0x9A5B, |
0x9A57, |
0x9A5F, |
0x9A62, |
0x9A65, |
0x9A64, |
0x9A69, |
0x9A6B, |
0x9A6A, |
0x9AAD, |
0x9AB0, |
0x9ABC, |
0x9AC0, |
0x9ACF, |
0x9AD1, |
0x9AD3, |
0x9AD4, |
0x9ADE, |
0x9ADF, |
0x9AE2, |
0x9AE3, |
0x9AE6, |
0x9AEF, |
0x9AEB, |
0x9AEE, |
0x9AF4, |
0x9AF1, |
0x9AF7, |
0x9AFB, |
0x9B06, |
0x9B18, |
0x9B1A, |
0x9B1F, |
0x9B22, |
0x9B23, |
0x9B25, |
0x9B27, |
0x9B28, |
0x9B29, |
0x9B2A, |
0x9B2E, |
0x9B2F, |
0x9B32, |
0x9B44, |
0x9B43, |
0x9B4F, |
0x9B4D, |
0x9B4E, |
0x9B51, |
0x9B58, |
0x9B74, |
0x9B93, |
0x9B83, |
0x9B91, |
0x9B96, |
0x9B97, |
0x9B9F, |
0x9BA0, |
0x9BA8, |
0x9BB4, |
0x9BC0, |
0x9BCA, |
0x9BB9, |
0x9BC6, |
0x9BCF, |
0x9BD1, |
0x9BD2, |
0x9BE3, |
0x9BE2, |
0x9BE4, |
0x9BD4, |
0x9BE1, |
0x9C3A, |
0x9BF2, |
0x9BF1, |
0x9BF0, |
0x9C15, |
0x9C14, |
0x9C09, |
0x9C13, |
0x9C0C, |
0x9C06, |
0x9C08, |
0x9C12, |
0x9C0A, |
0x9C04, |
0x9C2E, |
0x9C1B, |
0x9C25, |
0x9C24, |
0x9C21, |
0x9C30, |
0x9C47, |
0x9C32, |
0x9C46, |
0x9C3E, |
0x9C5A, |
0x9C60, |
0x9C67, |
0x9C76, |
0x9C78, |
0x9CE7, |
0x9CEC, |
0x9CF0, |
0x9D09, |
0x9D08, |
0x9CEB, |
0x9D03, |
0x9D06, |
0x9D2A, |
0x9D26, |
0x9DAF, |
0x9D23, |
0x9D1F, |
0x9D44, |
0x9D15, |
0x9D12, |
0x9D41, |
0x9D3F, |
0x9D3E, |
0x9D46, |
0x9D48, |
0x9D5D, |
0x9D5E, |
0x9D64, |
0x9D51, |
0x9D50, |
0x9D59, |
0x9D72, |
0x9D89, |
0x9D87, |
0x9DAB, |
0x9D6F, |
0x9D7A, |
0x9D9A, |
0x9DA4, |
0x9DA9, |
0x9DB2, |
0x9DC4, |
0x9DC1, |
0x9DBB, |
0x9DB8, |
0x9DBA, |
0x9DC6, |
0x9DCF, |
0x9DC2, |
0x9DD9, |
0x9DD3, |
0x9DF8, |
0x9DE6, |
0x9DED, |
0x9DEF, |
0x9DFD, |
0x9E1A, |
0x9E1B, |
0x9E1E, |
0x9E75, |
0x9E79, |
0x9E7D, |
0x9E81, |
0x9E88, |
0x9E8B, |
0x9E8C, |
0x9E92, |
0x9E95, |
0x9E91, |
0x9E9D, |
0x9EA5, |
0x9EA9, |
0x9EB8, |
0x9EAA, |
0x9EAD, |
0x9761, |
0x9ECC, |
0x9ECE, |
0x9ECF, |
0x9ED0, |
0x9ED4, |
0x9EDC, |
0x9EDE, |
0x9EDD, |
0x9EE0, |
0x9EE5, |
0x9EE8, |
0x9EEF, |
0x9EF4, |
0x9EF6, |
0x9EF7, |
0x9EF9, |
0x9EFB, |
0x9EFC, |
0x9EFD, |
0x9F07, |
0x9F08, |
0x76B7, |
0x9F15, |
0x9F21, |
0x9F2C, |
0x9F3E, |
0x9F4A, |
0x9F52, |
0x9F54, |
0x9F63, |
0x9F5F, |
0x9F60, |
0x9F61, |
0x9F66, |
0x9F67, |
0x9F6C, |
0x9F6A, |
0x9F77, |
0x9F72, |
0x9F76, |
0x9F95, |
0x9F9C, |
0x9FA0, |
0x582F, |
0x69C7, |
0x9059, |
0x7464, |
0x51DC, |
0x7199 |
}; |
/* f5 to fe is non-existent */ |
/programs/develop/libraries/newlib/ctype/local.h |
---|
0,0 → 1,32 |
/* wctrans constants */ |
#include <_ansi.h> |
/* valid values for wctrans_t */ |
#define WCT_TOLOWER 1 |
#define WCT_TOUPPER 2 |
/* valid values for wctype_t */ |
#define WC_ALNUM 1 |
#define WC_ALPHA 2 |
#define WC_BLANK 3 |
#define WC_CNTRL 4 |
#define WC_DIGIT 5 |
#define WC_GRAPH 6 |
#define WC_LOWER 7 |
#define WC_PRINT 8 |
#define WC_PUNCT 9 |
#define WC_SPACE 10 |
#define WC_UPPER 11 |
#define WC_XDIGIT 12 |
extern char *__locale_charset(_NOARGS); |
/* internal function to translate JP to Unicode */ |
#ifdef __CYGWIN__ |
/* Under Cygwin, the incoming wide character is already given in UTF due |
to the requirements of the underlying OS. */ |
#define _jp2uc(c) (c) |
#else |
wint_t _EXFUN (_jp2uc, (wint_t)); |
#endif |
/programs/develop/libraries/newlib/ctype/tolower.c |
---|
0,0 → 1,76 |
/* |
FUNCTION |
<<tolower>>---translate characters to lowercase |
INDEX |
tolower |
INDEX |
_tolower |
ANSI_SYNOPSIS |
#include <ctype.h> |
int tolower(int <[c]>); |
int _tolower(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int tolower(<[c]>); |
int _tolower(<[c]>); |
DESCRIPTION |
<<tolower>> is a macro which converts uppercase characters to lowercase, |
leaving all other characters unchanged. It is only defined when |
<[c]> is an integer in the range <<EOF>> to <<255>>. |
You can use a compiled subroutine instead of the macro definition by |
undefining this macro using `<<#undef tolower>>'. |
<<_tolower>> performs the same conversion as <<tolower>>, but should |
only be used when <[c]> is known to be an uppercase character (<<A>>--<<Z>>). |
RETURNS |
<<tolower>> returns the lowercase equivalent of <[c]> when it is a |
character between <<A>> and <<Z>>, and <[c]> otherwise. |
<<_tolower>> returns the lowercase equivalent of <[c]> when it is a |
character between <<A>> and <<Z>>. If <[c]> is not one of these |
characters, the behaviour of <<_tolower>> is undefined. |
PORTABILITY |
<<tolower>> is ANSI C. <<_tolower>> is not recommended for portable |
programs. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
#include <limits.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <wctype.h> |
#include <wchar.h> |
#endif |
#undef tolower |
int |
_DEFUN(tolower,(c),int c) |
{ |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
if ((unsigned char) c <= 0x7f) |
return isupper (c) ? c - 'A' + 'a' : c; |
else if (c != EOF && MB_CUR_MAX == 1 && isupper (c)) |
{ |
char s[MB_LEN_MAX] = { c, '\0' }; |
wchar_t wc; |
if (mbtowc (&wc, s, 1) >= 0 |
&& wctomb (s, (wchar_t) towlower ((wint_t) wc)) == 1) |
c = (unsigned char) s[0]; |
} |
return c; |
#else |
return isupper(c) ? (c) - 'A' + 'a' : c; |
#endif |
} |
/programs/develop/libraries/newlib/ctype/toupper.c |
---|
0,0 → 1,75 |
/* |
FUNCTION |
<<toupper>>---translate characters to uppercase |
INDEX |
toupper |
INDEX |
_toupper |
ANSI_SYNOPSIS |
#include <ctype.h> |
int toupper(int <[c]>); |
int _toupper(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int toupper(<[c]>); |
int _toupper(<[c]>); |
DESCRIPTION |
<<toupper>> is a macro which converts lowercase characters to uppercase, |
leaving all other characters unchanged. It is only defined when |
<[c]> is an integer in the range <<EOF>> to <<255>>. |
You can use a compiled subroutine instead of the macro definition by |
undefining this macro using `<<#undef toupper>>'. |
<<_toupper>> performs the same conversion as <<toupper>>, but should |
only be used when <[c]> is known to be a lowercase character (<<a>>--<<z>>). |
RETURNS |
<<toupper>> returns the uppercase equivalent of <[c]> when it is a |
character between <<a>> and <<z>>, and <[c]> otherwise. |
<<_toupper>> returns the uppercase equivalent of <[c]> when it is a |
character between <<a>> and <<z>>. If <[c]> is not one of these |
characters, the behaviour of <<_toupper>> is undefined. |
PORTABILITY |
<<toupper>> is ANSI C. <<_toupper>> is not recommended for portable programs. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
#include <limits.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <wctype.h> |
#include <wchar.h> |
#endif |
#undef toupper |
int |
_DEFUN(toupper,(c),int c) |
{ |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
if ((unsigned char) c <= 0x7f) |
return islower (c) ? c - 'a' + 'A' : c; |
else if (c != EOF && MB_CUR_MAX == 1 && islower (c)) |
{ |
char s[MB_LEN_MAX] = { c, '\0' }; |
wchar_t wc; |
if (mbtowc (&wc, s, 1) >= 0 |
&& wctomb (s, (wchar_t) towupper ((wint_t) wc)) == 1) |
c = (unsigned char) s[0]; |
} |
return c; |
#else |
return islower (c) ? c - 'a' + 'A' : c; |
#endif |
} |
/programs/develop/libraries/newlib/ctype/towlower.c |
---|
0,0 → 1,569 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<towlower>>---translate wide characters to lowercase |
INDEX |
towlower |
ANSI_SYNOPSIS |
#include <wctype.h> |
wint_t towlower(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
wint_t towlower(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<towlower>> is a function which converts uppercase wide characters to |
lowercase, leaving all other characters unchanged. |
RETURNS |
<<towlower>> returns the lowercase equivalent of <[c]> when it is a |
uppercase wide character; otherwise, it returns the input character. |
PORTABILITY |
<<towlower>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <string.h> |
#include <reent.h> |
#include <ctype.h> |
#include <wctype.h> |
#include "local.h" |
wint_t |
_DEFUN(towlower,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 */ |
/* Expression used to filter out the characters for the below code: |
awk -F\; '{ if ( $14 != "" ) print $1; }' UnicodeData.txt |
*/ |
if (c < 0x100) |
{ |
if ((c >= 0x0041 && c <= 0x005a) || |
(c >= 0x00c0 && c <= 0x00d6) || |
(c >= 0x00d8 && c <= 0x00de)) |
return (c + 0x20); |
return c; |
} |
else if (c < 0x300) |
{ |
if ((c >= 0x0100 && c <= 0x012e) || |
(c >= 0x0132 && c <= 0x0136) || |
(c >= 0x014a && c <= 0x0176) || |
(c >= 0x01de && c <= 0x01ee) || |
(c >= 0x01f8 && c <= 0x021e) || |
(c >= 0x0222 && c <= 0x0232)) |
{ |
if (!(c & 0x01)) |
return (c + 1); |
return c; |
} |
if (c == 0x0130) |
return 0x0069; |
if ((c >= 0x0139 && c <= 0x0147) || |
(c >= 0x01cd && c <= 0x01db)) |
{ |
if (c & 0x01) |
return (c + 1); |
return c; |
} |
if (c >= 0x178 && c <= 0x01f7) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x0178: |
k = 0x00ff; |
break; |
case 0x0179: |
case 0x017b: |
case 0x017d: |
case 0x0182: |
case 0x0184: |
case 0x0187: |
case 0x018b: |
case 0x0191: |
case 0x0198: |
case 0x01a0: |
case 0x01a2: |
case 0x01a4: |
case 0x01a7: |
case 0x01ac: |
case 0x01af: |
case 0x01b3: |
case 0x01b5: |
case 0x01b8: |
case 0x01bc: |
case 0x01c5: |
case 0x01c8: |
case 0x01cb: |
case 0x01cd: |
case 0x01cf: |
case 0x01d1: |
case 0x01d3: |
case 0x01d5: |
case 0x01d7: |
case 0x01d9: |
case 0x01db: |
case 0x01f2: |
case 0x01f4: |
k = c + 1; |
break; |
case 0x0181: |
k = 0x0253; |
break; |
case 0x0186: |
k = 0x0254; |
break; |
case 0x0189: |
k = 0x0256; |
break; |
case 0x018a: |
k = 0x0257; |
break; |
case 0x018e: |
k = 0x01dd; |
break; |
case 0x018f: |
k = 0x0259; |
break; |
case 0x0190: |
k = 0x025b; |
break; |
case 0x0193: |
k = 0x0260; |
break; |
case 0x0194: |
k = 0x0263; |
break; |
case 0x0196: |
k = 0x0269; |
break; |
case 0x0197: |
k = 0x0268; |
break; |
case 0x019c: |
k = 0x026f; |
break; |
case 0x019d: |
k = 0x0272; |
break; |
case 0x019f: |
k = 0x0275; |
break; |
case 0x01a6: |
k = 0x0280; |
break; |
case 0x01a9: |
k = 0x0283; |
break; |
case 0x01ae: |
k = 0x0288; |
break; |
case 0x01b1: |
k = 0x028a; |
break; |
case 0x01b2: |
k = 0x028b; |
break; |
case 0x01b7: |
k = 0x0292; |
break; |
case 0x01c4: |
case 0x01c7: |
case 0x01ca: |
case 0x01f1: |
k = c + 2; |
break; |
case 0x01f6: |
k = 0x0195; |
break; |
case 0x01f7: |
k = 0x01bf; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
else if (c == 0x0220) |
return 0x019e; |
else if (c >= 0x023a && c <= 0x024e) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x023a: |
k = 0x2c65; |
break; |
case 0x023b: |
case 0x0241: |
case 0x0246: |
case 0x0248: |
case 0x024a: |
case 0x024c: |
case 0x024e: |
k = c + 1; |
break; |
case 0x023d: |
k = 0x019a; |
break; |
case 0x023e: |
k = 0x2c66; |
break; |
case 0x0243: |
k = 0x0180; |
break; |
case 0x0244: |
k = 0x0289; |
break; |
case 0x0245: |
k = 0x028c; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x0400) |
{ |
if (c == 0x0370 || c == 0x0372 || c == 0x0376) |
return (c + 1); |
if (c >= 0x0391 && c <= 0x03ab && c != 0x03a2) |
return (c + 0x20); |
if (c >= 0x03d8 && c <= 0x03ee && !(c & 0x01)) |
return (c + 1); |
if (c >= 0x0386 && c <= 0x03ff) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x0386: |
k = 0x03ac; |
break; |
case 0x0388: |
k = 0x03ad; |
break; |
case 0x0389: |
k = 0x03ae; |
break; |
case 0x038a: |
k = 0x03af; |
break; |
case 0x038c: |
k = 0x03cc; |
break; |
case 0x038e: |
k = 0x03cd; |
break; |
case 0x038f: |
k = 0x03ce; |
break; |
case 0x03cf: |
k = 0x03d7; |
break; |
case 0x03f4: |
k = 0x03b8; |
break; |
case 0x03f7: |
k = 0x03f8; |
break; |
case 0x03f9: |
k = 0x03f2; |
break; |
case 0x03fa: |
k = 0x03fb; |
break; |
case 0x03fd: |
k = 0x037b; |
break; |
case 0x03fe: |
k = 0x037c; |
break; |
case 0x03ff: |
k = 0x037d; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x500) |
{ |
if (c >= 0x0400 && c <= 0x040f) |
return (c + 0x50); |
if (c >= 0x0410 && c <= 0x042f) |
return (c + 0x20); |
if ((c >= 0x0460 && c <= 0x0480) || |
(c >= 0x048a && c <= 0x04be) || |
(c >= 0x04d0 && c <= 0x04fe)) |
{ |
if (!(c & 0x01)) |
return (c + 1); |
return c; |
} |
if (c == 0x04c0) |
return 0x04cf; |
if (c >= 0x04c1 && c <= 0x04cd) |
{ |
if (c & 0x01) |
return (c + 1); |
return c; |
} |
} |
else if (c < 0x1f00) |
{ |
if ((c >= 0x0500 && c <= 0x050e) || |
(c >= 0x0510 && c <= 0x0524) || |
(c >= 0x1e00 && c <= 0x1e94) || |
(c >= 0x1ea0 && c <= 0x1ef8)) |
{ |
if (!(c & 0x01)) |
return (c + 1); |
return c; |
} |
if (c >= 0x0531 && c <= 0x0556) |
return (c + 0x30); |
if (c >= 0x10a0 && c <= 0x10c5) |
return (c + 0x1c60); |
if (c == 0x1e9e) |
return 0x00df; |
if (c >= 0x1efa && c <= 0x1efe && !(c & 0x01)) |
return (c + 1); |
} |
else if (c < 0x2000) |
{ |
if ((c >= 0x1f08 && c <= 0x1f0f) || |
(c >= 0x1f18 && c <= 0x1f1d) || |
(c >= 0x1f28 && c <= 0x1f2f) || |
(c >= 0x1f38 && c <= 0x1f3f) || |
(c >= 0x1f48 && c <= 0x1f4d) || |
(c >= 0x1f68 && c <= 0x1f6f) || |
(c >= 0x1f88 && c <= 0x1f8f) || |
(c >= 0x1f98 && c <= 0x1f9f) || |
(c >= 0x1fa8 && c <= 0x1faf)) |
return (c - 0x08); |
if (c >= 0x1f59 && c <= 0x1f5f) |
{ |
if (c & 0x01) |
return (c - 0x08); |
return c; |
} |
if (c >= 0x1fb8 && c <= 0x1ffc) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x1fb8: |
case 0x1fb9: |
case 0x1fd8: |
case 0x1fd9: |
case 0x1fe8: |
case 0x1fe9: |
k = c - 0x08; |
break; |
case 0x1fba: |
case 0x1fbb: |
k = c - 0x4a; |
break; |
case 0x1fbc: |
k = 0x1fb3; |
break; |
case 0x1fc8: |
case 0x1fc9: |
case 0x1fca: |
case 0x1fcb: |
k = c - 0x56; |
break; |
case 0x1fcc: |
k = 0x1fc3; |
break; |
case 0x1fda: |
case 0x1fdb: |
k = c - 0x64; |
break; |
case 0x1fea: |
case 0x1feb: |
k = c - 0x70; |
break; |
case 0x1fec: |
k = 0x1fe5; |
break; |
case 0x1ff8: |
case 0x1ff9: |
k = c - 0x80; |
break; |
case 0x1ffa: |
case 0x1ffb: |
k = c - 0x7e; |
break; |
case 0x1ffc: |
k = 0x1ff3; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x2c00) |
{ |
if (c >= 0x2160 && c <= 0x216f) |
return (c + 0x10); |
if (c >= 0x24b6 && c <= 0x24cf) |
return (c + 0x1a); |
switch (c) |
{ |
case 0x2126: |
return 0x03c9; |
case 0x212a: |
return 0x006b; |
case 0x212b: |
return 0x00e5; |
case 0x2132: |
return 0x214e; |
case 0x2183: |
return 0x2184; |
} |
} |
else if (c < 0x2d00) |
{ |
if (c >= 0x2c00 && c <= 0x2c2e) |
return (c + 0x30); |
if (c >= 0x2c80 && c <= 0x2ce2 && !(c & 0x01)) |
return (c + 1); |
switch (c) |
{ |
case 0x2c60: |
return 0x2c61; |
case 0x2c62: |
return 0x026b; |
case 0x2c63: |
return 0x1d7d; |
case 0x2c64: |
return 0x027d; |
case 0x2c67: |
case 0x2c69: |
case 0x2c6b: |
case 0x2c72: |
case 0x2c75: |
case 0x2ceb: |
case 0x2ced: |
return c + 1; |
case 0x2c6d: |
return 0x0251; |
case 0x2c6e: |
return 0x0271; |
case 0x2c6f: |
return 0x0250; |
case 0x2c70: |
return 0x0252; |
case 0x2c7e: |
return 0x023f; |
case 0x2c7f: |
return 0x0240; |
} |
} |
else if (c >= 0xa600 && c < 0xa800) |
{ |
if ((c >= 0xa640 && c <= 0xa65e) || |
(c >= 0xa662 && c <= 0xa66c) || |
(c >= 0xa680 && c <= 0xa696) || |
(c >= 0xa722 && c <= 0xa72e) || |
(c >= 0xa732 && c <= 0xa76e) || |
(c >= 0xa77f && c <= 0xa786)) |
{ |
if (!(c & 1)) |
return (c + 1); |
return c; |
} |
switch (c) |
{ |
case 0xa779: |
case 0xa77b: |
case 0xa77e: |
case 0xa78b: |
return (c + 1); |
case 0xa77d: |
return 0x1d79; |
} |
} |
else |
{ |
if (c >= 0xff21 && c <= 0xff3a) |
return (c + 0x20); |
if (c >= 0x10400 && c <= 0x10427) |
return (c + 0x28); |
} |
return c; |
#else |
return (c < 0x00ff ? (wint_t)(tolower ((int)c)) : c); |
#endif /* _MB_CAPABLE */ |
} |
/programs/develop/libraries/newlib/ctype/towupper.c |
---|
0,0 → 1,590 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<towupper>>---translate wide characters to uppercase |
INDEX |
towupper |
ANSI_SYNOPSIS |
#include <wctype.h> |
wint_t towupper(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
wint_t towupper(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<towupper>> is a function which converts lowercase wide characters to |
uppercase, leaving all other characters unchanged. |
RETURNS |
<<towupper>> returns the uppercase equivalent of <[c]> when it is a |
lowercase wide character, otherwise, it returns the input character. |
PORTABILITY |
<<towupper>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <string.h> |
#include <reent.h> |
#include <ctype.h> |
#include <wctype.h> |
#include "local.h" |
wint_t |
_DEFUN(towupper,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 */ |
/* Expression used to filter out the characters for the below code: |
awk -F\; '{ if ( $13 != "" ) print $1; }' UnicodeData.txt |
*/ |
if (c < 0x100) |
{ |
if (c == 0x00b5) |
return 0x039c; |
if ((c >= 0x00e0 && c <= 0x00fe && c != 0x00f7) || |
(c >= 0x0061 && c <= 0x007a)) |
return (c - 0x20); |
if (c == 0xff) |
return 0x0178; |
return c; |
} |
else if (c < 0x300) |
{ |
if ((c >= 0x0101 && c <= 0x012f) || |
(c >= 0x0133 && c <= 0x0137) || |
(c >= 0x014b && c <= 0x0177) || |
(c >= 0x01df && c <= 0x01ef) || |
(c >= 0x01f9 && c <= 0x021f) || |
(c >= 0x0223 && c <= 0x0233) || |
(c >= 0x0247 && c <= 0x024f)) |
{ |
if (c & 0x01) |
return (c - 1); |
return c; |
} |
if ((c >= 0x013a && c <= 0x0148) || |
(c >= 0x01ce && c <= 0x01dc) || |
c == 0x023c || c == 0x0242) |
{ |
if (!(c & 0x01)) |
return (c - 1); |
return c; |
} |
if (c == 0x0131) |
return 0x0049; |
if (c == 0x017a || c == 0x017c || c == 0x017e) |
return (c - 1); |
if (c >= 0x017f && c <= 0x0292) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x017f: |
k = 0x0053; |
break; |
case 0x0180: |
k = 0x0243; |
break; |
case 0x0183: |
k = 0x0182; |
break; |
case 0x0185: |
k = 0x0184; |
break; |
case 0x0188: |
k = 0x0187; |
break; |
case 0x018c: |
k = 0x018b; |
break; |
case 0x0192: |
k = 0x0191; |
break; |
case 0x0195: |
k = 0x01f6; |
break; |
case 0x0199: |
k = 0x0198; |
break; |
case 0x019a: |
k = 0x023d; |
break; |
case 0x019e: |
k = 0x0220; |
break; |
case 0x01a1: |
case 0x01a3: |
case 0x01a5: |
case 0x01a8: |
case 0x01ad: |
case 0x01b0: |
case 0x01b4: |
case 0x01b6: |
case 0x01b9: |
case 0x01bd: |
case 0x01c5: |
case 0x01c8: |
case 0x01cb: |
case 0x01f2: |
case 0x01f5: |
k = c - 1; |
break; |
case 0x01bf: |
k = 0x01f7; |
break; |
case 0x01c6: |
case 0x01c9: |
case 0x01cc: |
k = c - 2; |
break; |
case 0x01dd: |
k = 0x018e; |
break; |
case 0x01f3: |
k = 0x01f1; |
break; |
case 0x023f: |
k = 0x2c7e; |
break; |
case 0x0240: |
k = 0x2c7f; |
break; |
case 0x0250: |
k = 0x2c6f; |
break; |
case 0x0251: |
k = 0x2c6d; |
break; |
case 0x0252: |
k = 0x2c70; |
break; |
case 0x0253: |
k = 0x0181; |
break; |
case 0x0254: |
k = 0x0186; |
break; |
case 0x0256: |
k = 0x0189; |
break; |
case 0x0257: |
k = 0x018a; |
break; |
case 0x0259: |
k = 0x018f; |
break; |
case 0x025b: |
k = 0x0190; |
break; |
case 0x0260: |
k = 0x0193; |
break; |
case 0x0263: |
k = 0x0194; |
break; |
case 0x0268: |
k = 0x0197; |
break; |
case 0x0269: |
k = 0x0196; |
break; |
case 0x026b: |
k = 0x2c62; |
break; |
case 0x026f: |
k = 0x019c; |
break; |
case 0x0271: |
k = 0x2c6e; |
break; |
case 0x0272: |
k = 0x019d; |
break; |
case 0x0275: |
k = 0x019f; |
break; |
case 0x027d: |
k = 0x2c64; |
break; |
case 0x0280: |
k = 0x01a6; |
break; |
case 0x0283: |
k = 0x01a9; |
break; |
case 0x0288: |
k = 0x01ae; |
break; |
case 0x0289: |
k = 0x0244; |
break; |
case 0x028a: |
k = 0x01b1; |
break; |
case 0x028b: |
k = 0x01b2; |
break; |
case 0x028c: |
k = 0x0245; |
break; |
case 0x0292: |
k = 0x01b7; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x0400) |
{ |
wint_t k; |
if (c >= 0x03ad && c <= 0x03af) |
return (c - 0x25); |
if (c >= 0x03b1 && c <= 0x03cb && c != 0x03c2) |
return (c - 0x20); |
if (c >= 0x03d9 && c <= 0x03ef && (c & 1)) |
return (c - 1); |
switch (c) |
{ |
case 0x0345: |
k = 0x0399; |
break; |
case 0x0371: |
case 0x0373: |
case 0x0377: |
case 0x03f8: |
case 0x03fb: |
k = c - 1; |
break; |
case 0x037b: |
case 0x037c: |
case 0x037d: |
k = c + 0x82; |
break; |
case 0x03ac: |
k = 0x0386; |
break; |
case 0x03c2: |
k = 0x03a3; |
break; |
case 0x03cc: |
k = 0x038c; |
break; |
case 0x03cd: |
case 0x03ce: |
k = c - 0x3f; |
break; |
case 0x03d0: |
k = 0x0392; |
break; |
case 0x03d1: |
k = 0x0398; |
break; |
case 0x03d5: |
k = 0x03a6; |
break; |
case 0x03d6: |
k = 0x03a0; |
break; |
case 0x03d7: |
k = 0x03cf; |
break; |
case 0x03f0: |
k = 0x039a; |
break; |
case 0x03f1: |
k = 0x03a1; |
break; |
case 0x03f2: |
k = 0x03f9; |
break; |
case 0x03f5: |
k = 0x0395; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
else if (c < 0x500) |
{ |
if (c >= 0x0430 && c <= 0x044f) |
return (c - 0x20); |
if (c >= 0x0450 && c <= 0x045f) |
return (c - 0x50); |
if ((c >= 0x0461 && c <= 0x0481) || |
(c >= 0x048b && c <= 0x04bf) || |
(c >= 0x04d1 && c <= 0x04ff)) |
{ |
if (c & 0x01) |
return (c - 1); |
return c; |
} |
if (c >= 0x04c2 && c <= 0x04ce) |
{ |
if (!(c & 0x01)) |
return (c - 1); |
return c; |
} |
if (c == 0x04cf) |
return 0x04c0; |
if (c >= 0x04f7 && c <= 0x04f9) |
return (c - 1); |
} |
else if (c < 0x0600) |
{ |
if (c >= 0x0501 && c <= 0x0525 && (c & 1)) |
return c - 1; |
if (c >= 0x0561 && c <= 0x0586) |
return (c - 0x30); |
} |
else if (c < 0x1f00) |
{ |
if (c == 0x1d79) |
return 0xa77d; |
if (c == 0x1d7d) |
return 0x2c63; |
if ((c >= 0x1e01 && c <= 0x1e95) || |
(c >= 0x1ea1 && c <= 0x1eff)) |
{ |
if (c & 0x01) |
return (c - 1); |
return c; |
} |
if (c == 0x1e9b) |
return 0x1e60; |
} |
else if (c < 0x2000) |
{ |
if ((c >= 0x1f00 && c <= 0x1f07) || |
(c >= 0x1f10 && c <= 0x1f15) || |
(c >= 0x1f20 && c <= 0x1f27) || |
(c >= 0x1f30 && c <= 0x1f37) || |
(c >= 0x1f40 && c <= 0x1f45) || |
(c >= 0x1f60 && c <= 0x1f67) || |
(c >= 0x1f80 && c <= 0x1f87) || |
(c >= 0x1f90 && c <= 0x1f97) || |
(c >= 0x1fa0 && c <= 0x1fa7)) |
return (c + 0x08); |
if (c >= 0x1f51 && c <= 0x1f57 && (c & 0x01)) |
return (c + 0x08); |
if (c >= 0x1f70 && c <= 0x1ff3) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x1fb0: |
k = 0x1fb8; |
break; |
case 0x1fb1: |
k = 0x1fb9; |
break; |
case 0x1f70: |
k = 0x1fba; |
break; |
case 0x1f71: |
k = 0x1fbb; |
break; |
case 0x1fb3: |
k = 0x1fbc; |
break; |
case 0x1fbe: |
k = 0x0399; |
break; |
case 0x1f72: |
k = 0x1fc8; |
break; |
case 0x1f73: |
k = 0x1fc9; |
break; |
case 0x1f74: |
k = 0x1fca; |
break; |
case 0x1f75: |
k = 0x1fcb; |
break; |
case 0x1fc3: |
k = 0x1fcc; |
break; |
case 0x1fd0: |
k = 0x1fd8; |
break; |
case 0x1fd1: |
k = 0x1fd9; |
break; |
case 0x1f76: |
k = 0x1fda; |
break; |
case 0x1f77: |
k = 0x1fdb; |
break; |
case 0x1fe0: |
k = 0x1fe8; |
break; |
case 0x1fe1: |
k = 0x1fe9; |
break; |
case 0x1f7a: |
k = 0x1fea; |
break; |
case 0x1f7b: |
k = 0x1feb; |
break; |
case 0x1fe5: |
k = 0x1fec; |
break; |
case 0x1f78: |
k = 0x1ff8; |
break; |
case 0x1f79: |
k = 0x1ff9; |
break; |
case 0x1f7c: |
k = 0x1ffa; |
break; |
case 0x1f7d: |
k = 0x1ffb; |
break; |
case 0x1ff3: |
k = 0x1ffc; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x3000) |
{ |
if (c == 0x214e) |
return 0x2132; |
if (c == 0x2184) |
return 0x2183; |
if (c >= 0x2170 && c <= 0x217f) |
return (c - 0x10); |
if (c >= 0x24d0 && c <= 0x24e9) |
return (c - 0x1a); |
if (c >= 0x2c30 && c <= 0x2c5e) |
return (c - 0x30); |
if ((c >= 0x2c68 && c <= 0x2c6c && !(c & 1)) || |
(c >= 0x2c81 && c <= 0x2ce3 && (c & 1)) || |
c == 0x2c73 || c == 0x2c76 || |
c == 0x2cec || c == 0x2cee) |
return (c - 1); |
if (c >= 0x2c81 && c <= 0x2ce3 && (c & 1)) |
return (c - 1); |
if (c >= 0x2d00 && c <= 0x2d25) |
return (c - 0x1c60); |
switch (c) |
{ |
case 0x2c61: |
return 0x2c60; |
case 0x2c65: |
return 0x023a; |
case 0x2c66: |
return 0x023e; |
} |
} |
else if (c >= 0xa000 && c < 0xb000) |
{ |
if (((c >= 0xa641 && c <= 0xa65f) || |
(c >= 0xa663 && c <= 0xa66d) || |
(c >= 0xa681 && c <= 0xa697) || |
(c >= 0xa723 && c <= 0xa72f) || |
(c >= 0xa733 && c <= 0xa76f) || |
(c >= 0xa77f && c <= 0xa787)) && |
(c & 1)) |
return (c - 1); |
if (c == 0xa77a || c == 0xa77c || c == 0xa78c) |
return (c - 1); |
} |
else |
{ |
if (c >= 0xff41 && c <= 0xff5a) |
return (c - 0x20); |
if (c >= 0x10428 && c <= 0x1044f) |
return (c - 0x28); |
} |
return c; |
#else |
return (c < 0x00ff ? (wint_t)(toupper ((int)c)) : c); |
#endif /* _MB_CAPABLE */ |
} |
/programs/develop/libraries/newlib/ctype/utf8alpha.h |
---|
0,0 → 1,355 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* Generated using UnicodeData.txt 5.2 */ |
/* Expression used to filter out the characters for the below tables: |
awk -F\; \ |
'{ \ |
VAL = strtonum (sprintf("0x%s", $1)); \ |
# All of general category "L", except for two Thai characters which \ |
# are actually punctuation characters. Old Unicode weirdness. \ |
# The character "COMBINING GREEK YPOGEGRAMMENI", as well as all Thai \ |
# characters which are in "Mn" category. Old Unicode weirdness. \ |
# All numerical digit or letter characters, except the ASCII variants. \ |
# This is necessary due to the unfortunate ISO C definition for the \ |
# iswdigit class, otherwise these characters are missing in iswalnum. \ |
# All "Other Symbols" which are named as "LETTER" characters. \ |
# \ |
# Before running this test, make sure to expand all Unicode blocks \ |
# which are just marked by their first and last character! \ |
# \ |
if ( (match($3, "^L") && VAL != 0x0e2f && VAL != 0x0e46) \ |
|| (match($3, "^Mn") && (VAL == 0x0345 || match($2, "\\<CHARACTER\\>"))) \ |
|| (match($3, "^N[dl]") && VAL >= 0x100) \ |
|| (match($3, "^So") && match($2, "\\<LETTER\\>"))) \ |
print $1; \ |
}' UnicodeData.txt |
*/ |
static const unsigned char u0[] = { |
0x41, 0x0, 0x5a, 0x61, 0x0, 0x7a, 0xaa, 0xb5, |
0xba, 0xc0, 0x0, 0xd6, 0xd8, 0x0, 0xf6, 0xf8, |
0x0, 0xff }; |
/* u1 all alphabetic */ |
static const unsigned char u2[] = { |
0x00, 0x0, 0xc1, 0xc6, 0x0, 0xd1, |
0xe0, 0x0, 0xe4, 0xec, 0xee }; |
static const unsigned char u3[] = { |
0x45, 0x70, 0x0, 0x74, 0x76, 0x77, |
0x7a, 0x0, 0x7d, 0x86, 0x88, 0x0, 0x8a, 0x8c, |
0x8e, 0x0, 0xa1, 0xa3, 0x0, 0xf5, |
0xf7, 0x0, 0xff }; |
static const unsigned char u4[] = { |
0x00, 0x0, 0x81, 0x8a, 0x0, 0xff }; |
static const unsigned char u5[] = { |
0x00, 0x0, 0x25, 0x31, 0x0, 0x56, 0x59, |
0x61, 0x0, 0x87, 0xd0, 0x0, 0xea, |
0xf0, 0x0, 0xf2 }; |
static const unsigned char u6[] = { |
0x21, 0x0, 0x4a, 0x60, 0x0, 0x69, |
0x6e, 0x0, 0x6f, 0x71, 0x0, 0xd3, |
0xd5, 0xe5, 0x0, 0xe6, 0xee, 0x0, 0xfc, 0xff }; |
static const unsigned char u7[] = { |
0x10, 0x12, 0x0, 0x2f, 0x4d, 0x0, 0xa5, 0xb1, |
0xc0, 0x0, 0xea, 0xf4, 0xf5, 0xfa }; |
static const unsigned char u8[] = { |
0x00, 0x0, 0x15, 0x1a, 0x24, 0x28 }; |
static const unsigned char u9[] = { |
0x04, 0x0, 0x39, 0x3d, 0x50, 0x58, 0x0, 0x61, |
0x66, 0x0, 0x6f, 0x71, 0x72, 0x79, 0x0, 0x7f, |
0x85, 0x0, 0x8c, 0x8f, 0x0, 0x90, |
0x93, 0x0, 0xa8, 0xaa, 0x0, 0xb0, 0xb2, |
0xb6, 0x0, 0xb9, 0xbd, 0xce, 0xdc, 0x0, 0xdd, |
0xdf, 0x0, 0xe1, 0xe6, 0x0, 0xf1 }; |
static const unsigned char ua[] = { |
0x05, 0x0, 0x0a, 0x0f, 0x0, 0x10, |
0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, |
0x32, 0x0, 0x33, 0x35, 0x0, 0x36, |
0x38, 0x0, 0x39, 0x59, 0x0, 0x5c, |
0x5e, 0x66, 0x0, 0x6f, 0x72, 0x0, 0x74, |
0x85, 0x0, 0x8d, 0x8f, 0x0, 0x91, |
0x93, 0x0, 0xa8, 0xaa, 0x0, 0xb0, |
0xb2, 0x0, 0xb3, 0xb5, 0x0, 0xb9, |
0xbd, 0xd0, 0xe0, 0xe1, 0xe6, 0x0, 0xef }; |
static const unsigned char ub[] = { |
0x05, 0x0, 0x0c, 0x0f, 0x0, 0x10, |
0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, |
0x32, 0x0, 0x33, 0x35, 0x0, 0x39, 0x3d, |
0x5c, 0x0, 0x5d, 0x5f, 0x0, 0x61, |
0x66, 0x0, 0x6f, 0x71, 0x83, 0x85, 0x0, 0x8a, |
0x8e, 0x0, 0x90, 0x92, 0x0, 0x95, |
0x99, 0x0, 0x9a, 0x9c, 0x9e, 0x0, 0x9f, |
0xa3, 0x0, 0xa4, 0xa8, 0x0, 0xaa, |
0xae, 0x0, 0xb9, 0xd0, 0xe6, 0x0, 0xef }; |
static const unsigned char uc[] = { |
0x05, 0x0, 0x0c, 0x0e, 0x0, 0x10, |
0x12, 0x0, 0x28, 0x2a, 0x0, 0x33, |
0x35, 0x0, 0x39, 0x3d, 0x58, 0x59, |
0x60, 0x0, 0x61, 0x66, 0x0, 0x6f, |
0x85, 0x0, 0x8c, 0x8e, 0x0, 0x90, |
0x92, 0x0, 0xa8, 0xaa, 0x0, 0xb3, |
0xb5, 0x0, 0xb9, 0xbd, 0xde, 0xe0, 0x0, 0xe1, |
0xe6, 0x0, 0xef }; |
static const unsigned char ud[] = { |
0x05, 0x0, 0x0c, 0x0e, 0x0, 0x10, |
0x12, 0x0, 0x28, 0x2a, 0x0, 0x39, 0x3d, |
0x60, 0x0, 0x61, 0x66, 0x0, 0x6f, |
0x7a, 0x0, 0x7f, 0x85, 0x0, 0x96, 0x9a, |
0x0, 0xb1, 0xb3, 0x0, 0xbb, 0xbd, |
0xc0, 0x0, 0xc6 }; |
static const unsigned char ue[] = { |
0x01, 0x0, 0x2e, 0x30, 0x0, 0x3a, 0x40, |
0x0, 0x45, 0x47, 0x0, 0x4e, 0x50, 0x0, 0x59, |
0x81, 0x0, 0x82, 0x84, 0x87, 0x0, 0x88, 0x8a, |
0x8d, 0x94, 0x0, 0x97, 0x99, 0x0, 0x9f, 0xa1, |
0x0, 0xa3, 0xa5, 0xa7, 0xaa, 0x0, 0xab, 0xad, |
0x0, 0xb0, 0xb2, 0x0, 0xb3, 0xbd, 0xc0, 0x0, |
0xc4, 0xc6, 0xd0, 0x0, 0xd9, 0xdc, 0x0, 0xdd }; |
static const unsigned char uf[] = { |
0x00, 0x20, 0x0, 0x29, 0x40, 0x0, 0x47, 0x49, |
0x0, 0x6c, 0x88, 0x0, 0x8b }; |
static const unsigned char u10[] = { |
0x00, 0x0, 0x2a, 0x3f, 0x0, 0x49, |
0x50, 0x0, 0x55, 0x5a, 0x0, 0x5d, |
0x61, 0x65, 0x66, 0x6e, 0x0, 0x70, |
0x75, 0x0, 0x81, 0x8e, 0x90, 0x0, 0x99, |
0xa0, 0x0, 0xc5, 0xd0, 0x0, 0xfa, 0xfc }; |
/* u11 all alphabetic */ |
static const unsigned char u12[] = { |
0x00, 0x0, 0x48, 0x4a, 0x0, 0x4d, |
0x50, 0x0, 0x56, 0x58, 0x5a, 0x0, 0x5d, |
0x60, 0x0, 0x88, 0x8a, 0x0, 0x8d, |
0x90, 0x0, 0xb0, 0xb2, 0x0, 0xb5, |
0xb8, 0x0, 0xbe, 0xc0, 0xc2, 0x0, 0xc5, |
0xc8, 0x0, 0xd6, 0xd8, 0x0, 0xff }; |
static const unsigned char u13[] = { |
0x00, 0x0, 0x10, 0x12, 0x0, 0x15, |
0x18, 0x0, 0x5a, 0x80, 0x0, 0x8f, |
0xa0, 0x0, 0xf4 }; |
static const unsigned char u14[] = { |
0x01, 0x0, 0xff }; |
/* u15 all alphabetic */ |
static const unsigned char u16[] = { |
0x00, 0x0, 0x6c, 0x6f, 0x0, 0x7f, |
0x81, 0x0, 0x9a, 0xa0, 0x0, 0xea, |
0xee, 0x0, 0xf0 }; |
static const unsigned char u17[] = { |
0x00, 0x0, 0x0c, 0x0e, 0x0, 0x11, |
0x20, 0x0, 0x31, 0x40, 0x0, 0x51, |
0x60, 0x0, 0x6c, 0x6e, 0x0, 0x70, |
0x80, 0x0, 0xb3, 0xd7, 0xdc, 0xe0, 0x0, 0xe9 }; |
static const unsigned char u18[] = { |
0x10, 0x0, 0x19, 0x20, 0x0, 0x77, |
0x80, 0x0, 0xa8, 0xaa, 0xb0, 0x0, 0xf5 }; |
static const unsigned char u19[] = { |
0x00, 0x0, 0x1c, 0x46, 0x0, 0x6d, |
0x70, 0x0, 0x74, 0x80, 0x0, 0xab, |
0xc1, 0x0, 0xc7, 0xd0, 0x0, 0xda }; |
static const unsigned char u1a[] = { |
0x00, 0x0, 0x16, 0x20, 0x0, 0x54, |
0x80, 0x0, 0x89, 0x90, 0x0, 0x99, 0xa7 }; |
static const unsigned char u1b[] = { |
0x05, 0x0, 0x33, 0x45, 0x0, 0x4b, |
0x50, 0x0, 0x59, 0x83, 0x0, 0xa0, |
0xae, 0x0, 0xb9 }; |
static const unsigned char u1c[] = { |
0x00, 0x0, 0x23, 0x40, 0x0, 0x49, |
0x4d, 0x0, 0x7d, 0xe9, 0x0, 0xec, |
0xee, 0x0, 0xf1 }; |
static const unsigned char u1d[] = { |
0x00, 0x0, 0xbf }; |
/* u1e all alphabetic */ |
static const unsigned char u1f[] = { |
0x00, 0x0, 0x15, 0x18, 0x0, 0x1d, |
0x20, 0x0, 0x45, 0x48, 0x0, 0x4d, 0x50, 0x0, 0x57, 0x59, |
0x5b, 0x5d, 0x5f, 0x0, 0x7d, 0x80, 0x0, 0xb4, |
0xb6, 0x0, 0xbc, 0xbe, 0xc2, 0x0, 0xc4, 0xc6, |
0x0, 0xcc, 0xd0, 0x0, 0xd3, 0xd6, 0x0, 0xdb, |
0xe0, 0x0, 0xec, 0xf2, 0x0, 0xf4, 0xf6, 0x0, |
0xfc }; |
static const unsigned char u20[] = { |
0x71, 0x7f, 0x90, 0x0, 0x94 }; |
static const unsigned char u21[] = { |
0x02, 0x07, 0x0a, 0x0, 0x13, 0x15, |
0x19, 0x0, 0x1d, 0x24, 0x26, 0x28, 0x0, 0x2d, |
0x2f, 0x0, 0x39, 0x3c, 0x0, 0x3f, |
0x45, 0x0, 0x49, 0x4e, 0x60, 0x0, 0x88 }; |
static const unsigned char u24[] = { |
0x9c, 0x0, 0xe9 }; |
static const unsigned char u2c[] = { |
0x00, 0x0, 0x2e, 0x30, 0x0, 0x5e, |
0x60, 0x0, 0xe4, 0xeb, 0x0, 0xee }; |
static const unsigned char u2d[] = { |
0x00, 0x0, 0x25, 0x30, 0x0, 0x65, 0x6f, |
0x80, 0x0, 0x96, 0xa0, 0x0, 0xa6, |
0xa8, 0x0, 0xae, 0xb0, 0x0, 0xb6, |
0xb8, 0x0, 0xbe, 0xc0, 0x0, 0xc6, |
0xc8, 0x0, 0xce, 0xd0, 0x0, 0xd6, |
0xd8, 0x0, 0xde }; |
static const unsigned char u2e[] = { |
0x2f }; |
static const unsigned char u30[] = { |
0x05, 0x0, 0x07, 0x21, 0x0, |
0x29, 0x31, 0x0, 0x35, 0x38, 0x0, 0x3c, 0x41, |
0x0, 0x96, 0x9d, 0x0, 0x9f, 0xa1, 0x0, 0xfa, |
0xfc, 0x0, 0xff }; |
static const unsigned char u31[] = { |
0x05, 0x0, 0x2d, 0x31, 0x0, |
0x8e, 0xa0, 0x0, 0xb7, 0xf0, 0x0, 0xff }; |
/* u34 to u4c all alphabetic */ |
static const unsigned char u4d[] = { |
0x00, 0x0, 0xb5 }; |
/* u4e to u9e all alphabetic */ |
static const unsigned char u9f[] = { |
0x00, 0x0, 0xcb }; |
/* ua0 to ua3 all alphabetic */ |
static const unsigned char ua4[] = { |
0x00, 0x0, 0x8c, 0xd0, 0x0, 0xfd }; |
/* ua5 all alphabetic */ |
static const unsigned char ua6[] = { |
0x00, 0x0, 0x0c, 0x10, 0x0, 0x2b, |
0x40, 0x0, 0x5f, 0x62, 0x0, 0x6e, |
0x7f, 0x0, 0x97, 0xa0, 0x0, 0xef }; |
static const unsigned char ua7[] = { |
0x17, 0x0, 0x1f, 0x22, 0x0, 0x88, |
0x8b, 0x8c, |
0xfb, 0x0, 0xff }; |
static const unsigned char ua8[] = { |
0x00, 0x01, 0x03, 0x0, 0x05, 0x07, 0x0, 0x0a, |
0x0c, 0x0, 0x22, 0x40, 0x0, 0x73, |
0x82, 0x0, 0xb3, 0xd0, 0x0, 0xd9, |
0xf2, 0x0, 0xf7, 0xfb }; |
static const unsigned char ua9[] = { |
0x00, 0x0, 0x25, 0x30, 0x0, 0x46, |
0x60, 0x0, 0x7c, 0x84, 0x0, 0xb2, |
0xcf, 0x0, 0xd9 }; |
static const unsigned char uaa[] = { |
0x00, 0x0, 0x28, 0x40, 0x0, 0x42, |
0x44, 0x0, 0x4b, 0x50, 0x0, 0x59, |
0x60, 0x0, 0x76, 0x7a, 0x80, 0x0, 0xaf, |
0xb1, 0xb5, 0xb6, 0xb9, 0x0, 0xbd, |
0xc0, 0xc2, 0xdb, 0x0, 0xdd }; |
static const unsigned char uab[] = { |
0xc0, 0x0, 0xe2, 0xf0, 0x0, 0xf9 }; |
/* uac to ud6 all alphabetic */ |
static const unsigned char ud7[] = { |
0x00, 0x0, 0xa3, 0xb0, 0x0, 0xc6, |
0xcb, 0x0, 0xfb }; |
/* uf9 all alphabetic */ |
static const unsigned char ufa[] = { |
0x00, 0x0, 0x2d, 0x30, 0x0, 0x6d, |
0x70, 0x0, 0xd9 }; |
static const unsigned char ufb[] = { |
0x00, 0x0, 0x06, 0x13, 0x0, 0x17, 0x1d, |
0x1f, 0x0, 0x28, 0x2a, 0x0, 0x36, 0x38, 0x0, |
0x3c, 0x3e, 0x40, 0x0, 0x41, 0x43, 0x0, 0x44, |
0x46, 0x0, 0xb1, 0xd3, 0x0, 0xff }; |
/* ufc all alphabetic */ |
static const unsigned char ufd[] = { |
0x00, 0x0, 0x3d, 0x50, 0x0, |
0x8f, 0x92, 0x0, 0xc7, 0xf0, 0x0, 0xfb }; |
static const unsigned char ufe[] = { |
0x70, |
0x0, 0x74, 0x76, 0x0, 0xfc }; |
static const unsigned char uff[] = { |
0x10, 0x0, 0x19, |
0x21, 0x0, 0x3a, 0x41, 0x0, 0x5a, 0x66, 0x0, |
0xbe, 0xc2, 0x0, 0xc7, 0xca, 0x0, 0xcf, 0xd2, |
0x0, 0xd7, 0xda, 0x0, 0xdc }; |
static const unsigned char u100[] = { |
0x00, 0x0, 0x0b, 0x0d, 0x0, 0x26, |
0x28, 0x0, 0x3a, 0x3c, 0x3d, 0x3f, 0x0, 0x4d, |
0x50, 0x0, 0x5d, 0x80, 0x0, 0xfa }; |
static const unsigned char u101[] = { |
0x40, 0x0, 0x74 }; |
static const unsigned char u102[] = { |
0x80, 0x0, 0x9c, 0xa0, 0x0, 0xd0 }; |
static const unsigned char u103[] = { |
0x00, 0x0, 0x1e, 0x30, 0x0, 0x4a, |
0x80, 0x0, 0x9d, 0xa0, 0x0, 0xc3, |
0xc8, 0x0, 0xcf, 0xd1, 0x0, 0xd5 }; |
static const unsigned char u104[] = { |
0x00, 0x0, 0x9d, 0xa0, 0x0, 0xa9 }; |
static const unsigned char u108[] = { |
0x00, 0x0, 0x05, 0x08, 0x0a, 0x0, 0x35, |
0x37, 0x38, 0x3c, 0x3f, 0x0, 0x55 }; |
static const unsigned char u109[] = { |
0x00, 0x0, 0x15, 0x20, 0x0, 0x39 }; |
static const unsigned char u10a[] = { |
0x00, 0x10, 0x0, 0x13, 0x15, 0x0, 0x17, |
0x19, 0x0, 0x33, 0x60, 0x0, 0x7c }; |
static const unsigned char u10b[] = { |
0x00, 0x0, 0x35, 0x40, 0x0, 0x55, |
0x60, 0x0, 0x72 }; |
static const unsigned char u10c[] = { |
0x00, 0x0, 0x48 }; |
static const unsigned char u110[] = { |
0x83, 0x0, 0xaf }; |
/* u120 to u122 all alphabetic */ |
static const unsigned char u123[] = { |
0x00, 0x0, 0x6e }; |
static const unsigned char u124[] = { |
0x00, 0x0, 0x62 }; |
/* u130 to u133 all alphabetic */ |
static const unsigned char u134[] = { |
0x00, 0x0, 0x2e }; |
static const unsigned char u1d4[] = { |
0x00, 0x0, 0x54, 0x56, 0x0, 0x9c, |
0x9e, 0x0, 0x9f, 0xa2, 0xa5, 0x0, 0xa6, |
0xa9, 0x0, 0xac, 0xae, 0x0, 0xb9, 0xbb, |
0xbd, 0x0, 0xc3, 0xc5, 0x0, 0xff }; |
static const unsigned char u1d5[] = { |
0x00, 0x0, 0x05, 0x07, 0x0, |
0x0a, 0x0d, 0x0, 0x14, 0x16, 0x0, 0x1c, 0x1e, |
0x0, 0x39, 0x3b, 0x0, 0x3e, 0x40, 0x0, 0x44, |
0x46, 0x4a, 0x0, 0x50, 0x52, 0x0, 0xff }; |
static const unsigned char u1d6[] = { |
0x00, 0x0, 0xa5, 0xa8, 0x0, 0xc0, |
0xc2, 0x0, 0xda, 0xdc, 0x0, 0xfa, |
0xfc, 0x0, 0xff }; |
static const unsigned char u1d7[] = { |
0x00, 0x0, 0x14, 0x16, 0x0, 0x34, |
0x36, 0x0, 0x4e, 0x50, 0x0, 0x6e, |
0x70, 0x0, 0x88, 0x8a, 0x0, 0xa8, |
0xaa, 0x0, 0xc2, 0xc4, 0x0, 0xcb, |
0xce, 0x0, 0xff }; |
static const unsigned char u1f1[] = { |
0x10, 0x0, 0x2c, 0x31, 0x3d, 0x3f, 0x42, 0x46, |
0x57, 0x5f, 0x79, 0x7b, 0x7c, 0x7f, 0x8a }; |
/* u200 to u2a5 all alphabetic */ |
static const unsigned char u2a6[] = { |
0x00, 0x0, 0xd6 }; |
/* u2a7 to u2b6 all alphabetic */ |
static const unsigned char u2b7[] = { |
0x00, 0x0, 0x34 }; |
/* u2f8 to u2f9 all alphabetic */ |
static const unsigned char u2fa[] = { |
0x00, 0x0, 0x1d }; |
/programs/develop/libraries/newlib/ctype/utf8print.h |
---|
0,0 → 1,389 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* Generated using UnicodeData.txt 5.2 */ |
/* Expression used to filter out the characters for the below tables: |
awk -F\; \ |
'{ \ |
VAL = strtonum (sprintf("0x%s", $1)); \ |
# All valid characters except from categories Cc (C0 or C1 control code), \ |
# Cs (Surrogates), Zl (Line separator), and Zp (Paragraph separator).\ |
# \ |
# Before running this test, make sure to expand all Unicode blocks \ |
# which are just marked by their first and last character! \ |
# \ |
if (!match($3, "^C[cs]") && !match($3, "^Z[lp]")) \ |
print $1; \ |
}' UnicodeData.txt |
*/ |
static const unsigned char u0[] = { |
0x20, 0x0, 0x7e, 0xa0, 0x0, 0xff }; |
/* u1 is all-print */ |
/* u2 is all-print */ |
static const unsigned char u3[] = { |
0x00, 0x0, 0x77, 0x7a, 0x0, 0x7e, |
0x84, 0x0, 0x8a, 0x8c, 0x8e, 0x0, |
0xa1, 0xa3, 0x0, 0xff }; |
/* u4 is all-print */ |
static const unsigned char u5[] = { |
0x00, 0x0, 0x25, 0x31, 0x0, |
0x56, 0x59, 0x0, 0x5f, 0x61, 0x0, 0x87, 0x89, |
0x0, 0x8a, 0x91, 0x0, 0xc7, 0xd0, 0x0, 0xea, |
0xf0, 0x0, 0xf4 }; |
static const unsigned char u6[] = { |
0x00, 0x0, 0x03, 0x06, 0x0, 0x1b, 0x1e, 0x1f, |
0x21, 0x0, 0x5e, 0x60, 0x0, 0xff }; |
static const unsigned char u7[] = { |
0x00, 0x0, 0x0d, 0x0f, 0x0, 0x4a, 0x4d, 0x0, 0xb1, |
0xc0, 0x0, 0xfa }; |
static const unsigned char u8[] = { |
0x00, 0x0, 0x2d, 0x30, 0x0, 0x3e, }; |
static const unsigned char u9[] = { |
0x00, 0x0, 0x39, 0x3c, 0x0, 0x4e, 0x50, 0x0, 0x55, |
0x58, 0x0, 0x72, 0x79, 0x0, 0x7f, 0x81, 0x0, 0x83, |
0x85, 0x0, 0x8c, 0x8f, 0x0, 0x90, 0x93, 0x0, 0xa8, |
0xaa, 0x0, 0xb0, 0xb2, 0xb6, 0x0, 0xb9, 0xbc, |
0x0, 0xc4, 0xc7, 0xc8, 0xcb, 0x0, 0xce, |
0xd7, 0xdc, 0x0, 0xdd, 0xdf, 0x0, 0xe3, 0xe6, |
0x0, 0xfb }; |
static const unsigned char ua[] = { |
0x01, 0x0, 0x03, 0x05, 0x0, 0x0a, 0x0f, 0x0, |
0x10, 0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, 0x32, |
0x0, 0x33, 0x35, 0x0, 0x36, 0x38, 0x0, 0x39, |
0x3c, 0x3e, 0x0, 0x42, 0x47, 0x0, 0x48, 0x4b, |
0x0, 0x4d, 0x51, 0x59, 0x0, 0x5c, 0x5e, 0x66, 0x0, |
0x75, 0x81, 0x0, 0x83, 0x85, 0x0, 0x8d, |
0x8f, 0x0, 0x91, 0x93, 0x0, 0xa8, 0xaa, 0x0, |
0xb0, 0xb2, 0x0, 0xb3, 0xb5, 0x0, 0xb9, 0xbc, |
0x0, 0xc5, 0xc7, 0x0, 0xc9, 0xcb, 0x0, 0xcd, |
0xd0, 0xe0, 0x0, 0xe3, 0xe6, 0x0, 0xef, 0xf1 }; |
static const unsigned char ub[] = { |
0x01, 0x0, 0x03, |
0x05, 0x0, 0x0c, 0x0f, 0x0, 0x10, 0x13, 0x0, |
0x28, 0x2a, 0x0, 0x30, 0x32, 0x0, 0x33, 0x35, |
0x0, 0x39, 0x3c, 0x0, 0x44, 0x47, 0x0, 0x48, |
0x4b, 0x0, 0x4d, 0x56, 0x0, 0x57, 0x5c, 0x0, |
0x5d, 0x5f, 0x0, 0x63, 0x66, 0x0, 0x71, 0x82, |
0x0, 0x83, 0x85, 0x0, 0x8a, 0x8e, 0x0, 0x90, |
0x92, 0x0, 0x95, 0x99, 0x0, 0x9a, 0x9c, 0x9e, |
0x0, 0x9f, 0xa3, 0x0, 0xa4, 0xa8, 0x0, 0xaa, |
0xae, 0x0, 0xb9, 0xbe, 0x0, |
0xc2, 0xc6, 0x0, 0xc8, 0xca, 0x0, 0xcd, 0xd0, |
0xd7, 0xe6, 0xe7, 0x0, 0xfa }; |
static const unsigned char uc[] = { |
0x01, 0x0, 0x03, 0x05, 0x0, |
0x0c, 0x0e, 0x0, 0x10, 0x12, 0x0, 0x28, 0x2a, |
0x0, 0x33, 0x35, 0x0, 0x39, 0x3d, 0x0, 0x44, |
0x46, 0x0, 0x48, 0x4a, 0x0, 0x4d, 0x55, 0x0, |
0x56, 0x58, 0x59, 0x60, 0x0, 0x63, 0x66, 0x0, 0x6f, |
0x78, 0x0, 0x7f, 0x82, 0x83, 0x85, 0x0, 0x8c, |
0x8e, 0x0, 0x90, 0x92, 0x0, 0xa8, 0xaa, 0x0, 0xb3, |
0xb5, 0x0, 0xb9, 0xbc, 0x0, 0xc4, 0xc6, 0x0, 0xc8, |
0xca, 0x0, 0xcd, 0xd5, 0x0, 0xd6, 0xde, 0xe0, 0x0, |
0xe3, 0xe6, 0x0, 0xef, 0xf1, 0xf2 }; |
static const unsigned char ud[] = { |
0x02, 0x0, 0x03, 0x05, |
0x0, 0x0c, 0x0e, 0x0, 0x10, 0x12, 0x0, 0x28, |
0x2a, 0x0, 0x39, 0x3d, 0x0, 0x44, 0x46, 0x0, |
0x48, 0x4a, 0x0, 0x4d, 0x57, 0x60, 0x0, 0x63, |
0x66, 0x0, 0x75, 0x79, 0x0, 0x7f, 0x82, 0x0, 0x83, |
0x85, 0x0, 0x96, 0x9a, 0x0, 0xb1, 0xb3, 0x0, 0xbb, |
0xbd, 0xc0, 0x0, 0xc6, 0xca, 0xcf, 0x0, 0xd4, 0xd6, |
0xd8, 0x0, 0xdf, 0xf2, 0x0, 0xf4 }; |
static const unsigned char ue[] = { |
0x01, 0x0, |
0x3a, 0x3f, 0x0, 0x5b, 0x81, 0x0, 0x82, 0x84, |
0x87, 0x0, 0x88, 0x8a, 0x8d, 0x94, 0x0, 0x97, |
0x99, 0x0, 0x9f, 0xa1, 0x0, 0xa3, 0xa5, 0xa7, |
0xaa, 0x0, 0xab, 0xad, 0x0, 0xb9, 0xbb, 0x0, |
0xbd, 0xc0, 0x0, 0xc4, 0xc6, 0xc8, 0x0, 0xcd, |
0xd0, 0x0, 0xd9, 0xdc, 0x0, 0xdd }; |
static const unsigned char uf[] = { |
0x00, 0x0, 0x47, 0x49, 0x0, 0x6c, |
0x71, 0x0, 0x8b, 0x90, 0x0, 0x97, |
0x99, 0x0, 0xbc, 0xbe, 0x0, 0xcc, |
0xce, 0x0, 0xd8 }; |
static const unsigned char u10[] = { |
0x00, 0x0, 0xc5, 0xd0, 0x0, 0xfc }; |
/* u11 is all-print */ |
static const unsigned char u12[] = { |
0x00, 0x0, 0x48, 0x4a, 0x0, 0x4d, 0x50, 0x0, 0x56, |
0x58, 0x5a, 0x0, 0x5d, 0x60, 0x0, 0x88, |
0x8a, 0x0, 0x8d, 0x90, 0x0, 0xb0, 0xb2, |
0x0, 0xb5, 0xb8, 0x0, 0xbe, 0xc0, 0xc2, 0x0, |
0xc5, 0xc8, 0x0, 0xd6, 0xd8, 0x0, 0xff }; |
static const unsigned char u13[] = { |
0x00, 0x0, 0x10, 0x12, 0x0, 0x15, |
0x18, 0x0, 0x5a, 0x5f, 0x0, 0x7c, |
0x80, 0x0, 0x99, 0xa0, 0x0, 0xf4 }; |
/* u14 is all-print */ |
/* u15 is all-print */ |
static const unsigned char u16[] = { |
0x00, 0x0, 0x9c, 0xa0, 0x0, 0xf0 }; |
static const unsigned char u17[] = { |
0x00, 0x0, 0x0c, 0x0e, 0x0, 0x14, 0x20, |
0x0, 0x36, 0x40, 0x0, 0x53, 0x60, 0x0, 0x6c, |
0x6e, 0x0, 0x70, 0x72, 0x0, 0x73, 0x80, 0x0, |
0xdd, 0xe0, 0x0, 0xe9, 0xf0, 0x0, 0xf9 }; |
static const unsigned char u18[] = { |
0x00, 0x0, 0x0e, 0x10, |
0x0, 0x19, 0x20, 0x0, 0x77, 0x80, 0x0, 0xaa, |
0xb0, 0x0, 0xf5 }; |
static const unsigned char u19[] = { |
0x00, 0x0, 0x1c, 0x20, 0x0, 0x2b, |
0x30, 0x0, 0x3b, 0x40, 0x44, 0x0, 0x6d, |
0x70, 0x0, 0x74, 0x80, 0x0, 0xab, |
0xb0, 0x0, 0xc9, 0xd0, 0x0, 0xda, |
0xde, 0x0, 0xff }; |
static const unsigned char u1a[] = { |
0x00, 0x0, 0x1b, 0x1e, 0x0, 0x5e, |
0x60, 0x0, 0x7c, 0x7f, 0x0, 0x89, |
0x90, 0x0, 0x99, 0xa0, 0x0, 0xad }; |
static const unsigned char u1b[] = { |
0x00, 0x0, 0x4b, 0x50, 0x0, 0x7c, |
0x80, 0x0, 0xaa, 0xae, 0x0, 0xb9 }; |
static const unsigned char u1c[] = { |
0x00, 0x0, 0x37, 0x3b, 0x0, 0x49, |
0x4d, 0x0, 0x7f, 0xd0, 0x0, 0xf2 }; |
static const unsigned char u1d[] = { |
0x00, 0x0, 0xe6, 0xfd, 0x0, 0xff }; |
/* u1e is all-print */ |
static const unsigned char u1f[] = { |
0x00, 0x0, |
0x15, 0x18, 0x0, 0x1d, 0x20, 0x0, 0x45, 0x48, |
0x0, 0x4d, 0x50, 0x0, 0x57, 0x59, 0x5b, 0x5d, |
0x5f, 0x0, 0x7d, 0x80, 0x0, 0xb4, 0xb6, 0x0, |
0xc4, 0xc6, 0x0, 0xd3, 0xd6, 0x0, 0xdb, 0xdd, |
0x0, 0xef, 0xf2, 0x0, 0xf4, 0xf6, 0x0, 0xfe }; |
static const unsigned char u20[] = { |
0x00, 0x0, 0x27, 0x2a, 0x0, 0x64, |
0x6a, 0x0, 0x71, 0x74, 0x0, 0x8e, |
0x90, 0x0, 0x94, 0xa0, 0x0, 0xb8, |
0xd0, 0x0, 0xf0 }; |
static const unsigned char u21[] = { |
0x00, 0x0, 0x89, 0x90, 0x0, 0xff }; |
/* u22 is all-print */ |
static const unsigned char u23[] = { |
0x00, 0x0, 0xe8 }; |
static const unsigned char u24[] = { |
0x00, 0x0, 0x26, 0x40, 0x0, 0x4a, |
0x60, 0x0, 0xff }; |
/* u25 is all-print */ |
static const unsigned char u26[] = { |
0x00, 0x0, 0xcd, 0xcf, 0x0, 0xe1, |
0xe3, 0xe8, 0x0, 0xff }; |
static const unsigned char u27[] = { |
0x01, 0x0, 0x04, 0x06, 0x0, 0x09, |
0x0c, 0x0, 0x27, 0x29, 0x0, 0x4b, 0x4d, |
0x4f, 0x0, 0x52, 0x56, 0x0, 0x5e, |
0x61, 0x0, 0x94, 0x98, 0x0, 0xaf, |
0xb1, 0x0, 0xbe, 0xc0, 0x0, 0xca, 0xcc, |
0xd0, 0x0, 0xff }; |
/* u28 to u2a are all-print */ |
static const unsigned char u2b[] = { |
0x00, 0x0, 0x4c, 0x50, 0x0, 0x59 }; |
static const unsigned char u2c[] = { |
0x00, 0x0, 0x2e, 0x30, 0x0, 0x5e, |
0x60, 0x0, 0xf1, 0xf9, 0x0, 0xff }; |
static const unsigned char u2d[] = { |
0x00, 0x0, 0x25, 0x30, 0x0, 0x65, 0x6f, |
0x80, 0x0, 0x96, 0xa0, 0x0, 0xa6, |
0xa8, 0x0, 0xae, 0xb0, 0x0, 0xb6, |
0xb8, 0x0, 0xbe, 0xc0, 0x0, 0xc6, |
0xc8, 0x0, 0xce, 0xd0, 0x0, 0xd6, |
0xd8, 0x0, 0xde, 0xe0, 0x0, 0xff }; |
static const unsigned char u2e[] = { |
0x00, 0x0, 0x31, 0x80, 0x0, 0x99, |
0x9b, 0x0, 0xf3 }; |
static const unsigned char u2f[] = { |
0x00, 0x0, 0xd5, 0xf0, 0x0, 0xfb }; |
static const unsigned char u30[] = { |
0x00, 0x0, |
0x3f, 0x41, 0x0, 0x96, 0x99, 0x0, 0xff }; |
static const unsigned char u31[] = { |
0x05, 0x0, 0x2d, 0x31, 0x0, 0x8e, |
0x90, 0x0, 0xb7, 0xc0, 0x0, 0xe3, |
0xf0, 0x0, 0xff }; |
static const unsigned char u32[] = { |
0x00, 0x0, 0x1e, 0x20, 0x0, 0xfe }; |
/* u33 to u4c is all-print */ |
static const unsigned char u4d[] = { |
0x00, 0x0, 0xb5, 0xc0, 0x0, 0xff }; |
/* u4e to u9e is all-print */ |
static const unsigned char u9f[] = { |
0x00, 0x0, 0xcb }; |
/* ua0 to ua3 is all-print */ |
static const unsigned char ua4[] = { |
0x00, 0x0, 0x8c, 0x90, 0x0, 0xc6, |
0xd0, 0x0, 0xff }; |
/* ua5 is all-print */ |
static const unsigned char ua6[] = { |
0x00, 0x0, 0x2b, 0x40, 0x0, 0x5f, |
0x62, 0x0, 0x73, 0x7c, 0x0, 0x97, |
0xa0, 0x0, 0xf7 }; |
static const unsigned char ua7[] = { |
0x00, 0x0, 0x8c, 0xfb, 0x0, 0xff }; |
static const unsigned char ua8[] = { |
0x00, 0x0, 0x2b, 0x30, 0x0, 0x39, |
0x40, 0x0, 0x77, 0x80, 0x0, 0xc4, |
0xce, 0x0, 0xd9, 0xe0, 0x0, 0xfb }; |
static const unsigned char ua9[] = { |
0x00, 0x0, 0x53, 0x5f, 0x0, 0x7c, |
0x80, 0x0, 0xcd, 0xcf, 0x0, 0xd9, |
0xde, 0xdf }; |
static const unsigned char uaa[] = { |
0x00, 0x0, 0x36, 0x40, 0x0, 0x4d, |
0x50, 0x0, 0x59, 0x5c, 0x0, 0x7b, |
0x80, 0x0, 0xc2, 0xdb, 0x0, 0xdf }; |
static const unsigned char uab[] = { |
0xc0, 0x0, 0xed, 0xf0, 0x0, 0xf9 }; |
/* uac to ud6 is all-print */ |
static const unsigned char ud7[] = { |
0x00, 0x0, 0xa3, 0xb0, 0x0, 0xc6, |
0xcb, 0x0, 0xfb }; |
/* ud8 to udf are UTF-16 surrogates, non-printable */ |
/* ue0 to uf9 is all-print */ |
static const unsigned char ufa[] = { |
0x00, 0x0, 0x2d, 0x30, 0x0, 0x6d, |
0x70, 0x0, 0xd9 }; |
static const unsigned char ufb[] = { |
0x00, 0x0, 0x06, 0x13, 0x0, 0x17, |
0x1d, 0x0, 0x36, 0x38, 0x0, 0x3c, |
0x3e, 0x40, 0x41, 0x43, 0x44, |
0x46, 0x0, 0xb1, 0xd3, 0x0, 0xff }; |
/* ufc is all-print */ |
static const unsigned char ufd[] = { |
0x00, 0x0, 0x3f, 0x50, 0x0, 0x8f, |
0x92, 0x0, 0xc7, 0xf0, 0x0, 0xfd }; |
static const unsigned char ufe[] = { |
0x00, 0x0, 0x19, 0x20, 0x0, 0x26, |
0x30, 0x0, 0x52, 0x54, 0x0, 0x66, |
0x68, 0x0, 0x6b, 0x70, 0x0, 0x74, |
0x76, 0x0, 0xfc, 0xff }; |
static const unsigned char uff[] = { |
0x01, 0x0, 0xbe, 0xc2, 0x0, 0xc7, 0xca, 0x0, |
0xcf, 0xd2, 0x0, 0xd7, 0xda, 0x0, 0xdc, 0xe0, |
0x0, 0xe6, 0xe8, 0x0, 0xee, 0xf9, 0x0, 0xfd }; |
static const unsigned char u100[] = { |
0x00, 0x0, 0x0b, 0x0d, 0x0, 0x26, |
0x28, 0x0, 0x3a, 0x3c, 0x3d, 0x3f, 0x0, 0x4d, |
0x50, 0x0, 0x5d, 0x80, 0x0, 0xfa }; |
static const unsigned char u101[] = { |
0x00, 0x0, 0x02, 0x07, 0x0, 0x33, |
0x37, 0x0, 0x8a, 0x90, 0x0, 0x9b, |
0xd0, 0x0, 0xfd }; |
static const unsigned char u102[] = { |
0x80, 0x0, 0x9c, 0xa0, 0x0, 0xd0 }; |
static const unsigned char u103[] = { |
0x00, 0x0, 0x1e, 0x20, 0x0, 0x23, |
0x30, 0x0, 0x4a, 0x80, 0x0, 0x9d, |
0x9f, 0x0, 0xc3, 0xc8, 0x0, 0xd5 }; |
static const unsigned char u104[] = { |
0x00, 0x0, 0x9d, 0xa0, 0x0, 0xa9 }; |
static const unsigned char u108[] = { |
0x00, 0x0, 0x05, 0x08, 0x0a, 0x0, 0x35, |
0x37, 0x38, 0x3c, 0x3f, 0x0, 0x55, |
0x57, 0x0, 0x5f }; |
static const unsigned char u109[] = { |
0x00, 0x0, 0x1b, 0x1f, 0x0, 0x39, 0x3f }; |
static const unsigned char u10a[] = { |
0x00, 0x0, 0x03, 0x05, 0x06, 0x0c, 0x0, 0x13, |
0x15, 0x0, 0x17, 0x19, 0x0, 0x33, |
0x38, 0x0, 0x3a, 0x3f, 0x0, 0x47, |
0x50, 0x0, 0x58, 0x60, 0x0, 0x7f }; |
static const unsigned char u10b[] = { |
0x00, 0x0, 0x35, 0x39, 0x0, 0x55, |
0x58, 0x0, 0x72, 0x78, 0x0, 0x7f }; |
static const unsigned char u10c[] = { |
0x00, 0x0, 0x48 }; |
static const unsigned char u10e[] = { |
0x60, 0x0, 0x7e }; |
static const unsigned char u110[] = { |
0x80, 0x0, 0xc1 }; |
/* u120 to u122 is all-print */ |
static const unsigned char u123[] = { |
0x00, 0x0, 0x6e }; |
static const unsigned char u124[] = { |
0x00, 0x0, 0x62, 0x70, 0x0, 0x73 }; |
/* u130 to u133 is all-print */ |
static const unsigned char u134[] = { |
0x00, 0x0, 0x2e }; |
static const unsigned char u1d0[] = { |
0x00, 0x0, 0xf5 }; |
static const unsigned char u1d1[] = { |
0x00, 0x0, 0x26, 0x29, 0x0, 0xdd }; |
static const unsigned char u1d2[] = { |
0x00, 0x0, 0x45 }; |
static const unsigned char u1d3[] = { |
0x00, 0x0, 0x56, 0x60, 0x0, 0x71 }; |
static const unsigned char u1d4[] = { |
0x00, 0x0, 0x54, 0x56, 0x0, 0x9c, 0x9e, 0x0, |
0x9f, 0xa2, 0xa5, 0x0, 0xa6, 0xa9, 0x0, 0xac, |
0xae, 0x0, 0xb9, 0xbb, 0xbd, 0x0, 0xc3, |
0xc5, 0x0, 0xff }; |
static const unsigned char u1d5[] = { |
0x00, 0x0, 0x05, 0x07, 0x0, 0x0a, |
0x0d, 0x0, 0x14, 0x16, 0x0, 0x1c, 0x1e, 0x0, |
0x39, 0x3b, 0x0, 0x3e, 0x40, 0x0, 0x44, 0x46, |
0x4a, 0x0, 0x50, 0x52, 0x0, 0xff }; |
static const unsigned char u1d6[] = { |
0x00, 0x0, 0xa5, 0xa8, 0x0, 0xff }; |
static const unsigned char u1d7[] = { |
0x00, 0x0, 0xcb, 0xce, 0x0, 0xff }; |
static const unsigned char u1f0[] = { |
0x00, 0x0, 0x2b, 0x30, 0x0, 0x93 }; |
static const unsigned char u1f1[] = { |
0x00, 0x0, 0x0a, 0x10, 0x0, 0x2e, |
0x31, 0x3d, 0x3f, 0x42, 0x46, 0x4a, 0x0, 0x4e, |
0x57, 0x5f, 0x79, 0x7b, 0x7c, 0x7f, 0x8a, 0x0, |
0x8c, 0x8d, 0x90 }; |
static const unsigned char u1f2[] = { |
0x00, 0x10, 0x0, 0x31, 0x40, 0x0, 0x48 }; |
/* u200 to u2a5 is all-print */ |
static const unsigned char u2a6[] = { |
0x00, 0x0, 0xd6 }; |
/* u2a7 to u2b6 is all-print */ |
static const unsigned char u2b7[] = { |
0x00, 0x0, 0x34 }; |
/* u2f8 to u2f9 is all-print */ |
static const unsigned char u2fa[] = { |
0x00, |
0x0, 0x1d }; |
static const unsigned char ue00[] = { |
0x01, 0x20, 0x0, 0x7f }; |
static const unsigned char ue01[] = { |
0x00, 0x0, 0xef }; |
/* uf00 to uffe is all-print */ |
static const unsigned char ufff[] = { |
0x00, 0x0, 0xfd }; |
/* u1000 to u10fe is all-print */ |
static const unsigned char u10ff[] = { |
0x00, 0x0, 0xfd }; |
/programs/develop/libraries/newlib/ctype |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/errno/errno.c |
---|
0,0 → 1,16 |
/* The errno variable is stored in the reentrancy structure. This |
function returns its address for use by the macro errno defined in |
errno.h. */ |
#include <errno.h> |
#include <reent.h> |
#ifndef _REENT_ONLY |
int * |
__errno () |
{ |
return &_REENT->_errno; |
} |
#endif |
/programs/develop/libraries/newlib/errno |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/include/_ansi.h |
---|
0,0 → 1,133 |
/* Provide support for both ANSI and non-ANSI environments. */ |
/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be |
relied upon to have it's intended meaning. Therefore we must use our own |
concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib |
sources! |
To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will |
"comment out" the non-ANSI parts of the ANSI header files (non-ANSI header |
files aren't affected). */ |
#ifndef _ANSIDECL_H_ |
#define _ANSIDECL_H_ |
#include <newlib.h> |
#include <sys/config.h> |
/* First try to figure out whether we really are in an ANSI C environment. */ |
/* FIXME: This probably needs some work. Perhaps sys/config.h can be |
prevailed upon to give us a clue. */ |
#ifdef __STDC__ |
#define _HAVE_STDC |
#endif |
/* ISO C++. */ |
#ifdef __cplusplus |
#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) |
#ifdef _HAVE_STD_CXX |
#define _BEGIN_STD_C namespace std { extern "C" { |
#define _END_STD_C } } |
#else |
#define _BEGIN_STD_C extern "C" { |
#define _END_STD_C } |
#endif |
#if defined(__GNUC__) && \ |
( (__GNUC__ >= 4) || \ |
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) |
#define _NOTHROW __attribute__ ((nothrow)) |
#else |
#define _NOTHROW throw() |
#endif |
#endif |
#else |
#define _BEGIN_STD_C |
#define _END_STD_C |
#define _NOTHROW |
#endif |
#ifdef _HAVE_STDC |
#define _PTR void * |
#define _AND , |
#define _NOARGS void |
#define _CONST const |
#define _VOLATILE volatile |
#define _SIGNED signed |
#define _DOTS , ... |
#define _VOID void |
#ifdef __CYGWIN__ |
#define _EXFUN_NOTHROW(name, proto) __cdecl name proto _NOTHROW |
#define _EXFUN(name, proto) __cdecl name proto |
#define _EXPARM(name, proto) (* __cdecl name) proto |
#define _EXFNPTR(name, proto) (__cdecl * name) proto |
#else |
#define _EXFUN_NOTHROW(name, proto) name proto _NOTHROW |
#define _EXFUN(name, proto) name proto |
#define _EXPARM(name, proto) (* name) proto |
#define _EXFNPTR(name, proto) (* name) proto |
#endif |
#define _DEFUN(name, arglist, args) name(args) |
#define _DEFUN_VOID(name) name(_NOARGS) |
#define _CAST_VOID (void) |
#ifndef _LONG_DOUBLE |
#define _LONG_DOUBLE long double |
#endif |
#ifndef _LONG_LONG_TYPE |
#define _LONG_LONG_TYPE long long |
#endif |
#ifndef _PARAMS |
#define _PARAMS(paramlist) paramlist |
#endif |
#else |
#define _PTR char * |
#define _AND ; |
#define _NOARGS |
#define _CONST |
#define _VOLATILE |
#define _SIGNED |
#define _DOTS |
#define _VOID void |
#define _EXFUN(name, proto) name() |
#define _EXFUN_NOTHROW(name, proto) name() |
#define _DEFUN(name, arglist, args) name arglist args; |
#define _DEFUN_VOID(name) name() |
#define _CAST_VOID |
#define _LONG_DOUBLE double |
#define _LONG_LONG_TYPE long |
#ifndef _PARAMS |
#define _PARAMS(paramlist) () |
#endif |
#endif |
/* Support gcc's __attribute__ facility. */ |
#ifdef __GNUC__ |
#define _ATTRIBUTE(attrs) __attribute__ (attrs) |
#else |
#define _ATTRIBUTE(attrs) |
#endif |
/* The traditional meaning of 'extern inline' for GCC is not |
to emit the function body unless the address is explicitly |
taken. However this behaviour is changing to match the C99 |
standard, which uses 'extern inline' to indicate that the |
function body *must* be emitted. If we are using GCC, but do |
not have the new behaviour, we need to use extern inline; if |
we are using a new GCC with the C99-compatible behaviour, or |
a non-GCC compiler (which we will have to hope is C99, since |
there is no other way to achieve the effect of omitting the |
function if it isn't referenced) we just use plain 'inline', |
which c99 defines to mean more-or-less the same as the Gnu C |
'extern inline'. */ |
#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) |
/* We're using GCC, but without the new C99-compatible behaviour. */ |
#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__)) |
#else |
/* We're using GCC in C99 mode, or an unknown compiler which |
we just have to hope obeys the C99 semantics of inline. */ |
#define _ELIDABLE_INLINE __inline__ |
#endif |
#endif /* _ANSIDECL_H_ */ |
/programs/develop/libraries/newlib/include/_syslist.h |
---|
0,0 → 1,40 |
/* internal use only -- mapping of "system calls" for libraries that lose |
and only provide C names, so that we end up in violation of ANSI */ |
#ifndef __SYSLIST_H |
#define __SYSLIST_H |
#ifdef MISSING_SYSCALL_NAMES |
#define _close close |
#define _execve execve |
#define _fcntl fcntl |
#define _fork fork |
#define _fstat fstat |
#define _getpid getpid |
#define _gettimeofday gettimeofday |
#define _isatty isatty |
#define _kill kill |
#define _link link |
#define _lseek lseek |
#define _mkdir mkdir |
#define _open open |
#define _read read |
#define _sbrk sbrk |
#define _stat stat |
#define _times times |
#define _unlink unlink |
#define _wait wait |
#define _write write |
#endif /* MISSING_SYSCALL_NAMES */ |
#if defined MISSING_SYSCALL_NAMES || !defined HAVE_OPENDIR |
/* If the system call interface is missing opendir, readdir, and |
closedir, there is an implementation of these functions in |
libc/posix that is implemented using open, getdents, and close. |
Note, these functions are currently not in the libc/syscalls |
directory. */ |
#define _opendir opendir |
#define _readdir readdir |
#define _closedir closedir |
#endif /* MISSING_SYSCALL_NAMES || !HAVE_OPENDIR */ |
#endif /* !__SYSLIST_H_ */ |
/programs/develop/libraries/newlib/include/alloca.h |
---|
0,0 → 1,21 |
/* libc/include/alloca.h - Allocate memory on stack */ |
/* Written 2000 by Werner Almesberger */ |
/* Rearranged for general inclusion by stdlib.h. |
2001, Corinna Vinschen <vinschen@redhat.com> */ |
#ifndef _NEWLIB_ALLOCA_H |
#define _NEWLIB_ALLOCA_H |
#include "_ansi.h" |
#include <sys/reent.h> |
#undef alloca |
#ifdef __GNUC__ |
#define alloca(size) __builtin_alloca(size) |
#else |
void * _EXFUN(alloca,(size_t)); |
#endif |
#endif |
/programs/develop/libraries/newlib/include/ar.h |
---|
0,0 → 1,69 |
/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */ |
/*- |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* (c) UNIX System Laboratories, Inc. |
* All or some portions of this file are derived from material licensed |
* to the University of California by American Telephone and Telegraph |
* Co. or Unix System Laboratories, Inc. and are reproduced herein with |
* the permission of UNIX System Laboratories, Inc. |
* |
* This code is derived from software contributed to Berkeley by |
* Hugh Smith at The University of Guelph. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)ar.h 8.2 (Berkeley) 1/21/94 |
*/ |
#ifndef _AR_H_ |
#define _AR_H_ |
/* Pre-4BSD archives had these magic numbers in them. */ |
#define OARMAG1 0177555 |
#define OARMAG2 0177545 |
#define ARMAG "!<arch>\n" /* ar "magic number" */ |
#define SARMAG 8 /* strlen(ARMAG); */ |
#define AR_EFMT1 "#1/" /* extended format #1 */ |
struct ar_hdr { |
char ar_name[16]; /* name */ |
char ar_date[12]; /* modification time */ |
char ar_uid[6]; /* user id */ |
char ar_gid[6]; /* group id */ |
char ar_mode[8]; /* octal file permissions */ |
char ar_size[10]; /* size in bytes */ |
#define ARFMAG "`\n" |
char ar_fmag[2]; /* consistency check */ |
}; |
#endif /* !_AR_H_ */ |
/programs/develop/libraries/newlib/include/argz.h |
---|
0,0 → 1,33 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#ifndef _ARGZ_H_ |
#define _ARGZ_H_ |
#include <errno.h> |
#include <sys/types.h> |
#include "_ansi.h" |
_BEGIN_STD_C |
/* The newlib implementation of these functions assumes that sizeof(char) == 1. */ |
error_t argz_create (char *const argv[], char **argz, size_t *argz_len); |
error_t argz_create_sep (const char *string, int sep, char **argz, size_t *argz_len); |
size_t argz_count (const char *argz, size_t argz_len); |
void argz_extract (char *argz, size_t argz_len, char **argv); |
void argz_stringify (char *argz, size_t argz_len, int sep); |
error_t argz_add (char **argz, size_t *argz_len, const char *str); |
error_t argz_add_sep (char **argz, size_t *argz_len, const char *str, int sep); |
error_t argz_append (char **argz, size_t *argz_len, const char *buf, size_t buf_len); |
error_t argz_delete (char **argz, size_t *argz_len, char *entry); |
error_t argz_insert (char **argz, size_t *argz_len, char *before, const char *entry); |
char * argz_next (char *argz, size_t argz_len, const char *entry); |
error_t argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count); |
_END_STD_C |
#endif /* _ARGZ_H_ */ |
/programs/develop/libraries/newlib/include/assert.h |
---|
0,0 → 1,50 |
/* |
assert.h |
*/ |
#ifndef _NEWLIB_ASSERT_H |
#define _NEWLIB_ASSERT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include "_ansi.h" |
#undef assert |
#ifdef NDEBUG /* required by ANSI standard */ |
# define assert(__e) ((void)0) |
#else |
# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \ |
__ASSERT_FUNC, #__e)) |
# ifndef __ASSERT_FUNC |
/* Use g++'s demangled names in C++. */ |
# if defined __cplusplus && defined __GNUC__ |
# define __ASSERT_FUNC __PRETTY_FUNCTION__ |
/* C99 requires the use of __func__. */ |
# elif __STDC_VERSION__ >= 199901L |
# define __ASSERT_FUNC __func__ |
/* Older versions of gcc don't have __func__ but can use __FUNCTION__. */ |
# elif __GNUC__ >= 2 |
# define __ASSERT_FUNC __FUNCTION__ |
/* failed to detect __func__ support. */ |
# else |
# define __ASSERT_FUNC ((char *) 0) |
# endif |
# endif /* !__ASSERT_FUNC */ |
#endif /* !NDEBUG */ |
void _EXFUN(__assert, (const char *, int, const char *) |
_ATTRIBUTE ((__noreturn__))); |
void _EXFUN(__assert_func, (const char *, int, const char *, const char *) |
_ATTRIBUTE ((__noreturn__))); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _NEWLIB_ASSERT_H */ |
/programs/develop/libraries/newlib/include/complex.h |
---|
0,0 → 1,124 |
/* $NetBSD: complex.h,v 1.3 2010/09/15 16:11:30 christos Exp $ */ |
/* |
* Written by Matthias Drochner. |
* Public domain. |
*/ |
#ifndef _COMPLEX_H |
#define _COMPLEX_H |
#define complex _Complex |
#define _Complex_I 1.0fi |
#define I _Complex_I |
#include <sys/cdefs.h> |
__BEGIN_DECLS |
/* 7.3.5 Trigonometric functions */ |
/* 7.3.5.1 The cacos functions */ |
double complex cacos(double complex); |
float complex cacosf(float complex); |
/* 7.3.5.2 The casin functions */ |
double complex casin(double complex); |
float complex casinf(float complex); |
/* 7.3.5.1 The catan functions */ |
double complex catan(double complex); |
float complex catanf(float complex); |
/* 7.3.5.1 The ccos functions */ |
double complex ccos(double complex); |
float complex ccosf(float complex); |
/* 7.3.5.1 The csin functions */ |
double complex csin(double complex); |
float complex csinf(float complex); |
/* 7.3.5.1 The ctan functions */ |
double complex ctan(double complex); |
float complex ctanf(float complex); |
/* 7.3.6 Hyperbolic functions */ |
/* 7.3.6.1 The cacosh functions */ |
double complex cacosh(double complex); |
float complex cacoshf(float complex); |
/* 7.3.6.2 The casinh functions */ |
double complex casinh(double complex); |
float complex casinhf(float complex); |
/* 7.3.6.3 The catanh functions */ |
double complex catanh(double complex); |
float complex catanhf(float complex); |
/* 7.3.6.4 The ccosh functions */ |
double complex ccosh(double complex); |
float complex ccoshf(float complex); |
/* 7.3.6.5 The csinh functions */ |
double complex csinh(double complex); |
float complex csinhf(float complex); |
/* 7.3.6.6 The ctanh functions */ |
double complex ctanh(double complex); |
float complex ctanhf(float complex); |
/* 7.3.7 Exponential and logarithmic functions */ |
/* 7.3.7.1 The cexp functions */ |
double complex cexp(double complex); |
float complex cexpf(float complex); |
/* 7.3.7.2 The clog functions */ |
double complex clog(double complex); |
float complex clogf(float complex); |
/* 7.3.8 Power and absolute-value functions */ |
/* 7.3.8.1 The cabs functions */ |
/*#ifndef __LIBM0_SOURCE__ |
/* avoid conflict with historical cabs(struct complex) */ |
/* double cabs(double complex) __RENAME(__c99_cabs); |
float cabsf(float complex) __RENAME(__c99_cabsf); |
#endif |
*/ |
double cabs(double complex) ; |
float cabsf(float complex) ; |
/* 7.3.8.2 The cpow functions */ |
double complex cpow(double complex, double complex); |
float complex cpowf(float complex, float complex); |
/* 7.3.8.3 The csqrt functions */ |
double complex csqrt(double complex); |
float complex csqrtf(float complex); |
/* 7.3.9 Manipulation functions */ |
/* 7.3.9.1 The carg functions */ |
double carg(double complex); |
float cargf(float complex); |
/* 7.3.9.2 The cimag functions */ |
double cimag(double complex); |
float cimagf(float complex); |
/*long double cimagl(long double complex); */ |
/* 7.3.9.3 The conj functions */ |
double complex conj(double complex); |
float complex conjf(float complex); |
/*long double complex conjl(long double complex); */ |
/* 7.3.9.4 The cproj functions */ |
double complex cproj(double complex); |
float complex cprojf(float complex); |
/*long double complex cprojl(long double complex); */ |
/* 7.3.9.5 The creal functions */ |
double creal(double complex); |
float crealf(float complex); |
/*long double creall(long double complex); */ |
__END_DECLS |
#endif /* ! _COMPLEX_H */ |
/programs/develop/libraries/newlib/include/ctype.h |
---|
0,0 → 1,113 |
#ifndef _CTYPE_H_ |
#define _CTYPE_H_ |
#include "_ansi.h" |
_BEGIN_STD_C |
int _EXFUN(isalnum, (int __c)); |
int _EXFUN(isalpha, (int __c)); |
int _EXFUN(iscntrl, (int __c)); |
int _EXFUN(isdigit, (int __c)); |
int _EXFUN(isgraph, (int __c)); |
int _EXFUN(islower, (int __c)); |
int _EXFUN(isprint, (int __c)); |
int _EXFUN(ispunct, (int __c)); |
int _EXFUN(isspace, (int __c)); |
int _EXFUN(isupper, (int __c)); |
int _EXFUN(isxdigit,(int __c)); |
int _EXFUN(tolower, (int __c)); |
int _EXFUN(toupper, (int __c)); |
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L |
int _EXFUN(isblank, (int __c)); |
#endif |
#ifndef __STRICT_ANSI__ |
int _EXFUN(isascii, (int __c)); |
int _EXFUN(toascii, (int __c)); |
#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a') |
#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A') |
#endif |
#define _U 01 |
#define _L 02 |
#define _N 04 |
#define _S 010 |
#define _P 020 |
#define _C 040 |
#define _X 0100 |
#define _B 0200 |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
extern __IMPORT char *__ctype_ptr__; |
#ifndef __cplusplus |
/* These macros are intentionally written in a manner that will trigger |
a gcc -Wall warning if the user mistakenly passes a 'char' instead |
of an int containing an 'unsigned char'. Note that the sizeof will |
always be 1, which is what we want for mapping EOF to __ctype_ptr__[0]; |
the use of a raw index inside the sizeof triggers the gcc warning if |
__c was of type char, and sizeof masks side effects of the extra __c. |
Meanwhile, the real index to __ctype_ptr__+1 must be cast to int, |
since isalpha(0x100000001LL) must equal isalpha(1), rather than being |
an out-of-bounds reference on a 64-bit machine. */ |
#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)]) |
#define isalpha(__c) (__ctype_lookup(__c)&(_U|_L)) |
#define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U) |
#define islower(__c) ((__ctype_lookup(__c)&(_U|_L))==_L) |
#define isdigit(__c) (__ctype_lookup(__c)&_N) |
#define isxdigit(__c) (__ctype_lookup(__c)&(_X|_N)) |
#define isspace(__c) (__ctype_lookup(__c)&_S) |
#define ispunct(__c) (__ctype_lookup(__c)&_P) |
#define isalnum(__c) (__ctype_lookup(__c)&(_U|_L|_N)) |
#define isprint(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N|_B)) |
#define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N)) |
#define iscntrl(__c) (__ctype_lookup(__c)&_C) |
#if defined(__GNUC__) && \ |
(!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L) |
#define isblank(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
(__ctype_lookup(__x)&_B) || (int) (__x) == '\t';}) |
#endif |
/* Non-gcc versions will get the library versions, and will be |
slightly slower. These macros are not NLS-aware so they are |
disabled if the system supports the extended character sets. */ |
# if defined(__GNUC__) |
# if !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
# define toupper(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
islower (__x) ? (int) __x - 'a' + 'A' : (int) __x;}) |
# define tolower(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
isupper (__x) ? (int) __x - 'A' + 'a' : (int) __x;}) |
# else /* _MB_EXTENDED_CHARSETS* */ |
/* Allow a gcc warning if the user passed 'char', but defer to the |
function. */ |
# define toupper(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
(void) __ctype_ptr__[__x]; (toupper) (__x);}) |
# define tolower(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
(void) __ctype_ptr__[__x]; (tolower) (__x);}) |
# endif /* _MB_EXTENDED_CHARSETS* */ |
# endif /* __GNUC__ */ |
#endif /* !__cplusplus */ |
#ifndef __STRICT_ANSI__ |
#define isascii(__c) ((unsigned)(__c)<=0177) |
#define toascii(__c) ((__c)&0177) |
#endif |
/* For C++ backward-compatibility only. */ |
extern __IMPORT _CONST char _ctype_[]; |
_END_STD_C |
#endif /* _CTYPE_H_ */ |
/programs/develop/libraries/newlib/include/dirent.h |
---|
0,0 → 1,15 |
#ifndef _DIRENT_H_ |
#define _DIRENT_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/dirent.h> |
#if !defined(MAXNAMLEN) && !defined(_POSIX_SOURCE) |
#define MAXNAMLEN 1024 |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /*_DIRENT_H_*/ |
/programs/develop/libraries/newlib/include/envlock.h |
---|
0,0 → 1,15 |
/* envlock.h -- header file for env routines. */ |
#ifndef _INCLUDE_ENVLOCK_H_ |
#define _INCLUDE_ENVLOCK_H_ |
#include <_ansi.h> |
#include <sys/reent.h> |
#define ENV_LOCK __env_lock(reent_ptr) |
#define ENV_UNLOCK __env_unlock(reent_ptr) |
void _EXFUN(__env_lock,(struct _reent *reent)); |
void _EXFUN(__env_unlock,(struct _reent *reent)); |
#endif /* _INCLUDE_ENVLOCK_H_ */ |
/programs/develop/libraries/newlib/include/envz.h |
---|
0,0 → 1,16 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include <errno.h> |
#include <sys/types.h> |
/* The newlib implementation of these functions assumes that sizeof(char) == 1. */ |
char * envz_entry (const char *envz, size_t envz_len, const char *name); |
char * envz_get (const char *envz, size_t envz_len, const char *name); |
error_t envz_add (char **envz, size_t *envz_len, const char *name, const char *value); |
error_t envz_merge (char **envz, size_t *envz_len, const char *envz2, size_t envz2_len, int override); |
void envz_remove(char **envz, size_t *envz_len, const char *name); |
void envz_strip (char **envz, size_t *envz_len); |
/programs/develop/libraries/newlib/include/errno.h |
---|
0,0 → 1,11 |
#ifndef __ERRNO_H__ |
#define __ERRNO_H__ |
#ifndef __error_t_defined |
typedef int error_t; |
#define __error_t_defined 1 |
#endif |
#include <sys/errno.h> |
#endif /* !__ERRNO_H__ */ |
/programs/develop/libraries/newlib/include/fastmath.h |
---|
0,0 → 1,13 |
#ifndef _FASTMATH_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _FASTMATH_H_ |
#include <math.h> |
#include <machine/fastmath.h> |
#ifdef __cplusplus |
} |
#endif |
#endif /* _FASTMATH_H_ */ |
/programs/develop/libraries/newlib/include/fcntl.h |
---|
0,0 → 1,0 |
#include <sys/fcntl.h> |
/programs/develop/libraries/newlib/include/fnmatch.h |
---|
0,0 → 1,55 |
/*- |
* Copyright (c) 1992, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/include/fnmatch.h,v 1.10 2002/03/23 17:24:53 imp Exp $ |
* @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 |
*/ |
#ifndef _FNMATCH_H_ |
#define _FNMATCH_H_ |
#define FNM_NOMATCH 1 /* Match failed. */ |
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ |
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ |
#define FNM_PERIOD 0x04 /* Period must be matched by period. */ |
#if defined(_GNU_SOURCE) || !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */ |
#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ |
#define FNM_IGNORECASE FNM_CASEFOLD |
#define FNM_FILE_NAME FNM_PATHNAME |
#endif |
#include <sys/cdefs.h> |
__BEGIN_DECLS |
int fnmatch(const char *, const char *, int); |
__END_DECLS |
#endif /* !_FNMATCH_H_ */ |
/programs/develop/libraries/newlib/include/getopt.h |
---|
0,0 → 1,190 |
/**************************************************************************** |
getopt.h - Read command line options |
AUTHOR: Gregory Pietsch |
CREATED Thu Jan 09 22:37:00 1997 |
DESCRIPTION: |
The getopt() function parses the command line arguments. Its arguments argc |
and argv are the argument count and array as passed to the main() function |
on program invocation. The argument optstring is a list of available option |
characters. If such a character is followed by a colon (`:'), the option |
takes an argument, which is placed in optarg. If such a character is |
followed by two colons, the option takes an optional argument, which is |
placed in optarg. If the option does not take an argument, optarg is NULL. |
The external variable optind is the index of the next array element of argv |
to be processed; it communicates from one call to the next which element to |
process. |
The getopt_long() function works like getopt() except that it also accepts |
long options started by two dashes `--'. If these take values, it is either |
in the form |
--arg=value |
or |
--arg value |
It takes the additional arguments longopts which is a pointer to the first |
element of an array of type GETOPT_LONG_OPTION_T, defined below. The last |
element of the array has to be filled with NULL for the name field. |
The longind pointer points to the index of the current long option relative |
to longopts if it is non-NULL. |
The getopt() function returns the option character if the option was found |
successfully, `:' if there was a missing parameter for one of the options, |
`?' for an unknown option character, and EOF for the end of the option list. |
The getopt_long() function's return value is described below. |
The function getopt_long_only() is identical to getopt_long(), except that a |
plus sign `+' can introduce long options as well as `--'. |
Describe how to deal with options that follow non-option ARGV-elements. |
If the caller did not specify anything, the default is REQUIRE_ORDER if the |
environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. |
REQUIRE_ORDER means don't recognize them as options; stop option processing |
when the first non-option is seen. This is what Unix does. This mode of |
operation is selected by either setting the environment variable |
POSIXLY_CORRECT, or using `+' as the first character of the optstring |
parameter. |
PERMUTE is the default. We permute the contents of ARGV as we scan, so that |
eventually all the non-options are at the end. This allows options to be |
given in any order, even with programs that were not written to expect this. |
RETURN_IN_ORDER is an option available to programs that were written to |
expect options and other ARGV-elements in any order and that care about the |
ordering of the two. We describe each non-option ARGV-element as if it were |
the argument of an option with character code 1. Using `-' as the first |
character of the optstring parameter selects this mode of operation. |
The special argument `--' forces an end of option-scanning regardless of the |
value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause |
getopt() and friends to return EOF with optind != argc. |
COPYRIGHT NOTICE AND DISCLAIMER: |
Copyright (C) 1997 Gregory Pietsch |
This file and the accompanying getopt.c implementation file are hereby |
placed in the public domain without restrictions. Just give the author |
credit, don't claim you wrote it or prevent anyone else from using it. |
Gregory Pietsch's current e-mail address: |
gpietsch@comcast.net |
****************************************************************************/ |
/* This is a glibc-extension header file. */ |
#ifndef GETOPT_H |
#define GETOPT_H |
#include <_ansi.h> |
/* include files needed by this include file */ |
#define no_argument 0 |
#define required_argument 1 |
#define optional_argument 2 |
#ifdef __cplusplus |
extern "C" |
{ |
#endif /* __cplusplus */ |
/* types defined by this include file */ |
struct option |
{ |
char *name; /* the name of the long option */ |
int has_arg; /* one of the above macros */ |
int *flag; /* determines if getopt_long() returns a |
* value for a long option; if it is |
* non-NULL, 0 is returned as a function |
* value and the value of val is stored in |
* the area pointed to by flag. Otherwise, |
* val is returned. */ |
int val; /* determines the value to return if flag is |
* NULL. */ |
}; |
/* While getopt.h is a glibc extension, the following are newlib extensions. |
* They are optionally included via the __need_getopt_newlib flag. */ |
#ifdef __need_getopt_newlib |
/* macros defined by this include file */ |
#define NO_ARG no_argument |
#define REQUIRED_ARG required_argument |
#define OPTIONAL_ARG optional_argument |
/* The GETOPT_DATA_INITIALIZER macro is used to initialize a statically- |
allocated variable of type struct getopt_data. */ |
#define GETOPT_DATA_INITIALIZER {0,0,0,0,0} |
/* These #defines are to make accessing the reentrant functions easier. */ |
#define getopt_r __getopt_r |
#define getopt_long_r __getopt_long_r |
#define getopt_long_only_r __getopt_long_only_r |
/* The getopt_data structure is for reentrancy. Its members are similar to |
the externally-defined variables. */ |
typedef struct getopt_data |
{ |
char *optarg; |
int optind, opterr, optopt, optwhere; |
} getopt_data; |
#endif /* __need_getopt_newlib */ |
/* externally-defined variables */ |
extern char *optarg; |
extern int optind; |
extern int opterr; |
extern int optopt; |
/* function prototypes */ |
int _EXFUN (getopt, |
(int __argc, char *const __argv[], const char *__optstring)); |
int _EXFUN (getopt_long, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind)); |
int _EXFUN (getopt_long_only, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind)); |
#ifdef __need_getopt_newlib |
int _EXFUN (__getopt_r, |
(int __argc, char *const __argv[], const char *__optstring, |
struct getopt_data * __data)); |
int _EXFUN (__getopt_long_r, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind, |
struct getopt_data * __data)); |
int _EXFUN (__getopt_long_only_r, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind, |
struct getopt_data * __data)); |
#endif /* __need_getopt_newlib */ |
#ifdef __cplusplus |
}; |
#endif /* __cplusplus */ |
#endif /* GETOPT_H */ |
/* END OF FILE getopt.h */ |
/programs/develop/libraries/newlib/include/glob.h |
---|
0,0 → 1,89 |
/* |
* Copyright (c) 1989, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Guido van Rossum. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)glob.h 8.1 (Berkeley) 6/2/93 |
* $FreeBSD: src/include/glob.h,v 1.6 2002/03/23 17:24:53 imp Exp $ |
*/ |
#ifndef _GLOB_H_ |
#define _GLOB_H_ |
#include <sys/cdefs.h> |
struct stat; |
typedef struct { |
int gl_pathc; /* Count of total paths so far. */ |
int gl_matchc; /* Count of paths matching pattern. */ |
int gl_offs; /* Reserved at beginning of gl_pathv. */ |
int gl_flags; /* Copy of flags parameter to glob. */ |
char **gl_pathv; /* List of paths matching pattern. */ |
/* Copy of errfunc parameter to glob. */ |
int (*gl_errfunc)(const char *, int); |
/* |
* Alternate filesystem access methods for glob; replacement |
* versions of closedir(3), readdir(3), opendir(3), stat(2) |
* and lstat(2). |
*/ |
void (*gl_closedir)(void *); |
struct dirent *(*gl_readdir)(void *); |
void *(*gl_opendir)(const char *); |
int (*gl_lstat)(const char *, struct stat *); |
int (*gl_stat)(const char *, struct stat *); |
} glob_t; |
#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ |
#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ |
#define GLOB_ERR 0x0004 /* Return on error. */ |
#define GLOB_MARK 0x0008 /* Append / to matching directories. */ |
#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ |
#define GLOB_NOSORT 0x0020 /* Don't sort. */ |
#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ |
#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ |
#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ |
#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ |
#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ |
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ |
#define GLOB_LIMIT 0x1000 /* limit number of returned paths */ |
/* backwards compatibility, this is the old name for this option */ |
#define GLOB_MAXPATH GLOB_LIMIT |
#define GLOB_NOSPACE (-1) /* Malloc call failed. */ |
#define GLOB_ABEND (-2) /* Unignored error. */ |
__BEGIN_DECLS |
int glob(const char *, int, int (*)(const char *, int), glob_t *); |
void globfree(glob_t *); |
__END_DECLS |
#endif /* !_GLOB_H_ */ |
/programs/develop/libraries/newlib/include/grp.h |
---|
0,0 → 1,94 |
/* $NetBSD: grp.h,v 1.7 1995/04/29 05:30:40 cgd Exp $ */ |
/*- |
* Copyright (c) 1989, 1993 |
* The Regents of the University of California. All rights reserved. |
* (c) UNIX System Laboratories, Inc. |
* All or some portions of this file are derived from material licensed |
* to the University of California by American Telephone and Telegraph |
* Co. or Unix System Laboratories, Inc. and are reproduced herein with |
* the permission of UNIX System Laboratories, Inc. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)grp.h 8.2 (Berkeley) 1/21/94 |
*/ |
#ifndef _GRP_H_ |
#define _GRP_H_ |
#include <sys/types.h> |
#ifdef __CYGWIN__ |
#include <cygwin/grp.h> |
#endif |
#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) |
#define _PATH_GROUP "/etc/group" |
#endif |
struct group { |
char *gr_name; /* group name */ |
char *gr_passwd; /* group password */ |
gid_t gr_gid; /* group id */ |
char **gr_mem; /* group members */ |
}; |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef __INSIDE_CYGWIN__ |
struct group *getgrgid (gid_t); |
struct group *getgrnam (const char *); |
int getgrnam_r (const char *, struct group *, |
char *, size_t, struct group **); |
int getgrgid_r (gid_t, struct group *, |
char *, size_t, struct group **); |
#ifndef _POSIX_SOURCE |
struct group *getgrent (void); |
void setgrent (void); |
void endgrent (void); |
#ifndef __CYGWIN__ |
void setgrfile (const char *); |
#endif /* !__CYGWIN__ */ |
#ifndef _XOPEN_SOURCE |
#ifndef __CYGWIN__ |
char *group_from_gid (gid_t, int); |
int setgroupent (int); |
#endif /* !__CYGWIN__ */ |
int initgroups (const char *, gid_t); |
#endif /* !_XOPEN_SOURCE */ |
#endif /* !_POSIX_SOURCE */ |
#endif /* !__INSIDE_CYGWIN__ */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_GRP_H_ */ |
/programs/develop/libraries/newlib/include/iconv.h |
---|
0,0 → 1,62 |
/* |
* Copyright (c) 2003-2004, Artem B. Bityuckiy, SoftMine Corporation. |
* Rights transferred to Franklin Electronic Publishers. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifndef _ICONV_H_ |
#define _ICONV_H_ |
#include <_ansi.h> |
#include <reent.h> |
#include <sys/types.h> |
#include <sys/_types.h> |
/* iconv_t: charset conversion descriptor type */ |
typedef _iconv_t iconv_t; |
_BEGIN_STD_C |
#ifndef _REENT_ONLY |
iconv_t |
_EXFUN(iconv_open, (_CONST char *, _CONST char *)); |
size_t |
_EXFUN(iconv, (iconv_t, char **, size_t *, char **, size_t *)); |
int |
_EXFUN(iconv_close, (iconv_t)); |
#endif |
iconv_t |
_EXFUN(_iconv_open_r, (struct _reent *, _CONST char *, _CONST char *)); |
size_t |
_EXFUN(_iconv_r, (struct _reent *, iconv_t, _CONST char **, |
size_t *, char **, size_t *)); |
int |
_EXFUN(_iconv_close_r, (struct _reent *, iconv_t)); |
_END_STD_C |
#endif /* #ifndef _ICONV_H_ */ |
/programs/develop/libraries/newlib/include/ieeefp.h |
---|
0,0 → 1,256 |
#ifndef _IEEE_FP_H_ |
#define _IEEE_FP_H_ |
#include "_ansi.h" |
#include <machine/ieeefp.h> |
_BEGIN_STD_C |
/* FIXME FIXME FIXME: |
Neither of __ieee_{float,double}_shape_tape seem to be used anywhere |
except in libm/test. If that is the case, please delete these from here. |
If that is not the case, please insert documentation here describing why |
they're needed. */ |
#ifdef __IEEE_BIG_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
unsigned int sign : 1; |
unsigned int exponent: 11; |
unsigned int fraction0:4; |
unsigned int fraction1:16; |
unsigned int fraction2:16; |
unsigned int fraction3:16; |
} number; |
struct |
{ |
unsigned int sign : 1; |
unsigned int exponent: 11; |
unsigned int quiet:1; |
unsigned int function0:3; |
unsigned int function1:16; |
unsigned int function2:16; |
unsigned int function3:16; |
} nan; |
struct |
{ |
unsigned long msw; |
unsigned long lsw; |
} parts; |
long aslong[2]; |
} __ieee_double_shape_type; |
#endif |
#ifdef __IEEE_LITTLE_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
#ifdef __SMALL_BITFIELDS |
unsigned int fraction3:16; |
unsigned int fraction2:16; |
unsigned int fraction1:16; |
unsigned int fraction0: 4; |
#else |
unsigned int fraction1:32; |
unsigned int fraction0:20; |
#endif |
unsigned int exponent :11; |
unsigned int sign : 1; |
} number; |
struct |
{ |
#ifdef __SMALL_BITFIELDS |
unsigned int function3:16; |
unsigned int function2:16; |
unsigned int function1:16; |
unsigned int function0:3; |
#else |
unsigned int function1:32; |
unsigned int function0:19; |
#endif |
unsigned int quiet:1; |
unsigned int exponent: 11; |
unsigned int sign : 1; |
} nan; |
struct |
{ |
unsigned long lsw; |
unsigned long msw; |
} parts; |
long aslong[2]; |
} __ieee_double_shape_type; |
#endif |
#ifdef __IEEE_BIG_ENDIAN |
typedef union |
{ |
float value; |
struct |
{ |
unsigned int sign : 1; |
unsigned int exponent: 8; |
unsigned int fraction0: 7; |
unsigned int fraction1: 16; |
} number; |
struct |
{ |
unsigned int sign:1; |
unsigned int exponent:8; |
unsigned int quiet:1; |
unsigned int function0:6; |
unsigned int function1:16; |
} nan; |
long p1; |
} __ieee_float_shape_type; |
#endif |
#ifdef __IEEE_LITTLE_ENDIAN |
typedef union |
{ |
float value; |
struct |
{ |
unsigned int fraction0: 7; |
unsigned int fraction1: 16; |
unsigned int exponent: 8; |
unsigned int sign : 1; |
} number; |
struct |
{ |
unsigned int function1:16; |
unsigned int function0:6; |
unsigned int quiet:1; |
unsigned int exponent:8; |
unsigned int sign:1; |
} nan; |
long p1; |
} __ieee_float_shape_type; |
#endif |
/* FLOATING ROUNDING */ |
typedef int fp_rnd; |
#define FP_RN 0 /* Round to nearest */ |
#define FP_RM 1 /* Round down */ |
#define FP_RP 2 /* Round up */ |
#define FP_RZ 3 /* Round to zero (trunate) */ |
fp_rnd _EXFUN(fpgetround,(void)); |
fp_rnd _EXFUN(fpsetround, (fp_rnd)); |
/* EXCEPTIONS */ |
typedef int fp_except; |
#define FP_X_INV 0x10 /* Invalid operation */ |
#define FP_X_DX 0x80 /* Divide by zero */ |
#define FP_X_OFL 0x04 /* Overflow exception */ |
#define FP_X_UFL 0x02 /* Underflow exception */ |
#define FP_X_IMP 0x01 /* imprecise exception */ |
fp_except _EXFUN(fpgetmask,(void)); |
fp_except _EXFUN(fpsetmask,(fp_except)); |
fp_except _EXFUN(fpgetsticky,(void)); |
fp_except _EXFUN(fpsetsticky, (fp_except)); |
/* INTEGER ROUNDING */ |
typedef int fp_rdi; |
#define FP_RDI_TOZ 0 /* Round to Zero */ |
#define FP_RDI_RD 1 /* Follow float mode */ |
fp_rdi _EXFUN(fpgetroundtoi,(void)); |
fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi)); |
#undef isnan |
#undef isinf |
int _EXFUN(isnan, (double)); |
int _EXFUN(isinf, (double)); |
int _EXFUN(finite, (double)); |
int _EXFUN(isnanf, (float)); |
int _EXFUN(isinff, (float)); |
int _EXFUN(finitef, (float)); |
#define __IEEE_DBL_EXPBIAS 1023 |
#define __IEEE_FLT_EXPBIAS 127 |
#define __IEEE_DBL_EXPLEN 11 |
#define __IEEE_FLT_EXPLEN 8 |
#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1)) |
#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1)) |
#define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1)) |
#define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1)) |
#define __IEEE_DBL_NAN_EXP 0x7ff |
#define __IEEE_FLT_NAN_EXP 0xff |
#ifndef __ieeefp_isnanf |
#define __ieeefp_isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ |
((*(long *)&(x) & 0x007fffffL)!=0000000000L)) |
#endif |
#define isnanf(x) __ieeefp_isnanf(x) |
#ifndef __ieeefp_isinff |
#define __ieeefp_isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ |
((*(long *)&(x) & 0x007fffffL)==0000000000L)) |
#endif |
#define isinff(x) __ieeefp_isinff(x) |
#ifndef __ieeefp_finitef |
#define __ieeefp_finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L)) |
#endif |
#define finitef(x) __ieeefp_finitef(x) |
#ifdef _DOUBLE_IS_32BITS |
#undef __IEEE_DBL_EXPBIAS |
#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS |
#undef __IEEE_DBL_EXPLEN |
#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN |
#undef __IEEE_DBL_FRACLEN |
#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN |
#undef __IEEE_DBL_MAXPOWTWO |
#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO |
#undef __IEEE_DBL_NAN_EXP |
#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP |
#undef __ieee_double_shape_type |
#define __ieee_double_shape_type __ieee_float_shape_type |
#endif /* _DOUBLE_IS_32BITS */ |
_END_STD_C |
#endif /* _IEEE_FP_H_ */ |
/programs/develop/libraries/newlib/include/inttypes.h |
---|
0,0 → 1,290 |
/* |
* Copyright (c) 2004, 2005 by |
* Ralf Corsepius, Ulm/Germany. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/** |
* @file inttypes.h |
*/ |
#ifndef _INTTYPES_H |
#define _INTTYPES_H |
#include <stdint.h> |
#define __need_wchar_t |
#include <stddef.h> |
#define __STRINGIFY(a) #a |
/* 8-bit types */ |
#define __PRI8(x) __STRINGIFY(x) |
#define __SCN8(x) __STRINGIFY(hh##x) |
#define PRId8 __PRI8(d) |
#define PRIi8 __PRI8(i) |
#define PRIo8 __PRI8(o) |
#define PRIu8 __PRI8(u) |
#define PRIx8 __PRI8(x) |
#define PRIX8 __PRI8(X) |
#define SCNd8 __SCN8(d) |
#define SCNi8 __SCN8(i) |
#define SCNo8 __SCN8(o) |
#define SCNu8 __SCN8(u) |
#define SCNx8 __SCN8(x) |
#define PRIdLEAST8 __PRI8(d) |
#define PRIiLEAST8 __PRI8(i) |
#define PRIoLEAST8 __PRI8(o) |
#define PRIuLEAST8 __PRI8(u) |
#define PRIxLEAST8 __PRI8(x) |
#define PRIXLEAST8 __PRI8(X) |
#define SCNdLEAST8 __SCN8(d) |
#define SCNiLEAST8 __SCN8(i) |
#define SCNoLEAST8 __SCN8(o) |
#define SCNuLEAST8 __SCN8(u) |
#define SCNxLEAST8 __SCN8(x) |
#define PRIdFAST8 __PRI8(d) |
#define PRIiFAST8 __PRI8(i) |
#define PRIoFAST8 __PRI8(o) |
#define PRIuFAST8 __PRI8(u) |
#define PRIxFAST8 __PRI8(x) |
#define PRIXFAST8 __PRI8(X) |
#define SCNdFAST8 __SCN8(d) |
#define SCNiFAST8 __SCN8(i) |
#define SCNoFAST8 __SCN8(o) |
#define SCNuFAST8 __SCN8(u) |
#define SCNxFAST8 __SCN8(x) |
/* 16-bit types */ |
#define __PRI16(x) __STRINGIFY(x) |
#define __SCN16(x) __STRINGIFY(h##x) |
#define PRId16 __PRI16(d) |
#define PRIi16 __PRI16(i) |
#define PRIo16 __PRI16(o) |
#define PRIu16 __PRI16(u) |
#define PRIx16 __PRI16(x) |
#define PRIX16 __PRI16(X) |
#define SCNd16 __SCN16(d) |
#define SCNi16 __SCN16(i) |
#define SCNo16 __SCN16(o) |
#define SCNu16 __SCN16(u) |
#define SCNx16 __SCN16(x) |
#define PRIdLEAST16 __PRI16(d) |
#define PRIiLEAST16 __PRI16(i) |
#define PRIoLEAST16 __PRI16(o) |
#define PRIuLEAST16 __PRI16(u) |
#define PRIxLEAST16 __PRI16(x) |
#define PRIXLEAST16 __PRI16(X) |
#define SCNdLEAST16 __SCN16(d) |
#define SCNiLEAST16 __SCN16(i) |
#define SCNoLEAST16 __SCN16(o) |
#define SCNuLEAST16 __SCN16(u) |
#define SCNxLEAST16 __SCN16(x) |
#define PRIdFAST16 __PRI16(d) |
#define PRIiFAST16 __PRI16(i) |
#define PRIoFAST16 __PRI16(o) |
#define PRIuFAST16 __PRI16(u) |
#define PRIxFAST16 __PRI16(x) |
#define PRIXFAST16 __PRI16(X) |
#define SCNdFAST16 __SCN16(d) |
#define SCNiFAST16 __SCN16(i) |
#define SCNoFAST16 __SCN16(o) |
#define SCNuFAST16 __SCN16(u) |
#define SCNxFAST16 __SCN16(x) |
/* 32-bit types */ |
#if __have_long32 |
#define __PRI32(x) __STRINGIFY(l##x) |
#define __SCN32(x) __STRINGIFY(l##x) |
#else |
#define __PRI32(x) __STRINGIFY(x) |
#define __SCN32(x) __STRINGIFY(x) |
#endif |
#define PRId32 __PRI32(d) |
#define PRIi32 __PRI32(i) |
#define PRIo32 __PRI32(o) |
#define PRIu32 __PRI32(u) |
#define PRIx32 __PRI32(x) |
#define PRIX32 __PRI32(X) |
#define SCNd32 __SCN32(d) |
#define SCNi32 __SCN32(i) |
#define SCNo32 __SCN32(o) |
#define SCNu32 __SCN32(u) |
#define SCNx32 __SCN32(x) |
#define PRIdLEAST32 __PRI32(d) |
#define PRIiLEAST32 __PRI32(i) |
#define PRIoLEAST32 __PRI32(o) |
#define PRIuLEAST32 __PRI32(u) |
#define PRIxLEAST32 __PRI32(x) |
#define PRIXLEAST32 __PRI32(X) |
#define SCNdLEAST32 __SCN32(d) |
#define SCNiLEAST32 __SCN32(i) |
#define SCNoLEAST32 __SCN32(o) |
#define SCNuLEAST32 __SCN32(u) |
#define SCNxLEAST32 __SCN32(x) |
#define PRIdFAST32 __PRI32(d) |
#define PRIiFAST32 __PRI32(i) |
#define PRIoFAST32 __PRI32(o) |
#define PRIuFAST32 __PRI32(u) |
#define PRIxFAST32 __PRI32(x) |
#define PRIXFAST32 __PRI32(X) |
#define SCNdFAST32 __SCN32(d) |
#define SCNiFAST32 __SCN32(i) |
#define SCNoFAST32 __SCN32(o) |
#define SCNuFAST32 __SCN32(u) |
#define SCNxFAST32 __SCN32(x) |
/* 64-bit types */ |
#if __have_long64 |
#define __PRI64(x) __STRINGIFY(l##x) |
#define __SCN64(x) __STRINGIFY(l##x) |
#elif __have_longlong64 |
#define __PRI64(x) __STRINGIFY(ll##x) |
#define __SCN64(x) __STRINGIFY(ll##x) |
#else |
#define __PRI64(x) __STRINGIFY(x) |
#define __SCN64(x) __STRINGIFY(x) |
#endif |
#define PRId64 __PRI64(d) |
#define PRIi64 __PRI64(i) |
#define PRIo64 __PRI64(o) |
#define PRIu64 __PRI64(u) |
#define PRIx64 __PRI64(x) |
#define PRIX64 __PRI64(X) |
#define SCNd64 __SCN64(d) |
#define SCNi64 __SCN64(i) |
#define SCNo64 __SCN64(o) |
#define SCNu64 __SCN64(u) |
#define SCNx64 __SCN64(x) |
#if __int64_t_defined |
#define PRIdLEAST64 __PRI64(d) |
#define PRIiLEAST64 __PRI64(i) |
#define PRIoLEAST64 __PRI64(o) |
#define PRIuLEAST64 __PRI64(u) |
#define PRIxLEAST64 __PRI64(x) |
#define PRIXLEAST64 __PRI64(X) |
#define SCNdLEAST64 __SCN64(d) |
#define SCNiLEAST64 __SCN64(i) |
#define SCNoLEAST64 __SCN64(o) |
#define SCNuLEAST64 __SCN64(u) |
#define SCNxLEAST64 __SCN64(x) |
#define PRIdFAST64 __PRI64(d) |
#define PRIiFAST64 __PRI64(i) |
#define PRIoFAST64 __PRI64(o) |
#define PRIuFAST64 __PRI64(u) |
#define PRIxFAST64 __PRI64(x) |
#define PRIXFAST64 __PRI64(X) |
#define SCNdFAST64 __SCN64(d) |
#define SCNiFAST64 __SCN64(i) |
#define SCNoFAST64 __SCN64(o) |
#define SCNuFAST64 __SCN64(u) |
#define SCNxFAST64 __SCN64(x) |
#endif |
/* max-bit types */ |
#if __have_long64 |
#define __PRIMAX(x) __STRINGIFY(l##x) |
#define __SCNMAX(x) __STRINGIFY(l##x) |
#elif __have_longlong64 |
#define __PRIMAX(x) __STRINGIFY(ll##x) |
#define __SCNMAX(x) __STRINGIFY(ll##x) |
#else |
#define __PRIMAX(x) __STRINGIFY(x) |
#define __SCNMAX(x) __STRINGIFY(x) |
#endif |
#define PRIdMAX __PRIMAX(d) |
#define PRIiMAX __PRIMAX(i) |
#define PRIoMAX __PRIMAX(o) |
#define PRIuMAX __PRIMAX(u) |
#define PRIxMAX __PRIMAX(x) |
#define PRIXMAX __PRIMAX(X) |
#define SCNdMAX __SCNMAX(d) |
#define SCNiMAX __SCNMAX(i) |
#define SCNoMAX __SCNMAX(o) |
#define SCNuMAX __SCNMAX(u) |
#define SCNxMAX __SCNMAX(x) |
/* ptr types */ |
#if __have_long64 |
#define __PRIPTR(x) __STRINGIFY(l##x) |
#define __SCNPTR(x) __STRINGIFY(l##x) |
#elif __have_longlong64 |
#define __PRIPTR(x) __STRINGIFY(ll##x) |
#define __SCNPTR(x) __STRINGIFY(ll##x) |
#else |
#define __PRIPTR(x) __STRINGIFY(x) |
#define __SCNPTR(x) __STRINGIFY(x) |
#endif |
#define PRIdPTR __PRIPTR(d) |
#define PRIiPTR __PRIPTR(i) |
#define PRIoPTR __PRIPTR(o) |
#define PRIuPTR __PRIPTR(u) |
#define PRIxPTR __PRIPTR(x) |
#define PRIXPTR __PRIPTR(X) |
#define SCNdPTR __SCNPTR(d) |
#define SCNiPTR __SCNPTR(i) |
#define SCNoPTR __SCNPTR(o) |
#define SCNuPTR __SCNPTR(u) |
#define SCNxPTR __SCNPTR(x) |
typedef struct { |
intmax_t quot; |
intmax_t rem; |
} imaxdiv_t; |
#ifdef __cplusplus |
extern "C" { |
#endif |
extern intmax_t imaxabs(intmax_t j); |
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer); |
extern intmax_t strtoimax(const char *__restrict, char **__restrict, int); |
extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int); |
extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int); |
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); |
#ifdef __cplusplus |
} |
#endif |
#endif |
/programs/develop/libraries/newlib/include/langinfo.h |
---|
0,0 → 1,316 |
/*- |
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/include/langinfo.h,v 1.5 2002/03/23 17:24:53 imp Exp $ |
*/ |
#ifndef _LANGINFO_H_ |
#define _LANGINFO_H_ |
#include <newlib.h> |
#include <sys/config.h> |
#include <sys/cdefs.h> |
typedef int nl_item; |
enum __nl_item |
{ |
/* POSIX and BSD defined items have to stick to the original values |
to maintain backward compatibility. */ |
_NL_CTYPE_CODESET_NAME = 0, /* codeset name */ |
#define CODESET _NL_CTYPE_CODESET_NAME |
D_T_FMT, /* string for formatting date and time */ |
#define D_T_FMT D_T_FMT |
D_FMT, /* date format string */ |
#define D_FMT D_FMT |
T_FMT, /* time format string */ |
#define T_FMT T_FMT |
T_FMT_AMPM, /* a.m. or p.m. time formatting string */ |
#define T_FMT_AMPM T_FMT_AMPM |
AM_STR, /* Ante Meridian affix */ |
#define AM_STR AM_STR |
PM_STR, /* Post Meridian affix */ |
#define PM_STR PM_STR |
/* week day names */ |
DAY_1, |
#define DAY_1 DAY_1 |
DAY_2, |
#define DAY_2 DAY_2 |
DAY_3, |
#define DAY_3 DAY_3 |
DAY_4, |
#define DAY_4 DAY_4 |
DAY_5, |
#define DAY_5 DAY_5 |
DAY_6, |
#define DAY_6 DAY_6 |
DAY_7, |
#define DAY_7 DAY_7 |
/* abbreviated week day names */ |
ABDAY_1, |
#define ABDAY_1 ABDAY_1 |
ABDAY_2, |
#define ABDAY_2 ABDAY_2 |
ABDAY_3, |
#define ABDAY_3 ABDAY_3 |
ABDAY_4, |
#define ABDAY_4 ABDAY_4 |
ABDAY_5, |
#define ABDAY_5 ABDAY_5 |
ABDAY_6, |
#define ABDAY_6 ABDAY_6 |
ABDAY_7, |
#define ABDAY_7 ABDAY_7 |
/* month names */ |
MON_1, |
#define MON_1 MON_1 |
MON_2, |
#define MON_2 MON_2 |
MON_3, |
#define MON_3 MON_3 |
MON_4, |
#define MON_4 MON_4 |
MON_5, |
#define MON_5 MON_5 |
MON_6, |
#define MON_6 MON_6 |
MON_7, |
#define MON_7 MON_7 |
MON_8, |
#define MON_8 MON_8 |
MON_9, |
#define MON_9 MON_9 |
MON_10, |
#define MON_10 MON_10 |
MON_11, |
#define MON_11 MON_11 |
MON_12, |
#define MON_12 MON_12 |
/* abbreviated month names */ |
ABMON_1, |
#define ABMON_1 ABMON_1 |
ABMON_2, |
#define ABMON_2 ABMON_2 |
ABMON_3, |
#define ABMON_3 ABMON_3 |
ABMON_4, |
#define ABMON_4 ABMON_4 |
ABMON_5, |
#define ABMON_5 ABMON_5 |
ABMON_6, |
#define ABMON_6 ABMON_6 |
ABMON_7, |
#define ABMON_7 ABMON_7 |
ABMON_8, |
#define ABMON_8 ABMON_8 |
ABMON_9, |
#define ABMON_9 ABMON_9 |
ABMON_10, |
#define ABMON_10 ABMON_10 |
ABMON_11, |
#define ABMON_11 ABMON_11 |
ABMON_12, |
#define ABMON_12 ABMON_12 |
ERA, /* era description segments */ |
#define ERA ERA |
ERA_D_FMT, /* era date format string */ |
#define ERA_D_FMT ERA_D_FMT |
ERA_D_T_FMT, /* era date and time format string */ |
#define ERA_D_T_FMT ERA_D_T_FMT |
ERA_T_FMT, /* era time format string */ |
#define ERA_T_FMT ERA_T_FMT |
ALT_DIGITS, /* alternative symbols for digits */ |
#define ALT_DIGITS ALT_DIGITS |
RADIXCHAR, /* radix char */ |
#define RADIXCHAR RADIXCHAR |
THOUSEP, /* separator for thousands */ |
#define THOUSEP THOUSEP |
YESEXPR, /* affirmative response expression */ |
#define YESEXPR YESEXPR |
NOEXPR, /* negative response expression */ |
#define NOEXPR NOEXPR |
YESSTR, /* affirmative response for yes/no queries */ |
#define YESSTR YESSTR |
NOSTR, /* negative response for yes/no queries */ |
#define NOSTR NOSTR |
CRNCYSTR, /* currency symbol */ |
#define CRNCYSTR CRNCYSTR |
D_MD_ORDER, /* month/day order (BSD extension) */ |
#define D_MD_ORDER D_MD_ORDER |
_NL_TIME_DATE_FMT = 84, /* date fmt used by date(1) (GNU extension) */ |
#define _DATE_FMT _NL_TIME_DATE_FMT |
#ifdef __HAVE_LOCALE_INFO__ |
_NL_CTYPE_MB_CUR_MAX, |
_NL_MESSAGES_CODESET, |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
/* NOTE: |
Always maintain the order and position of existing entries! |
Always append new entry to the list, prior to the definition |
of _NL_LOCALE_EXTENDED_LAST_ENTRY. */ |
_NL_LOCALE_EXTENDED_FIRST_ENTRY, |
_NL_CTYPE_OUTDIGITS0_MB, |
_NL_CTYPE_OUTDIGITS1_MB, |
_NL_CTYPE_OUTDIGITS2_MB, |
_NL_CTYPE_OUTDIGITS3_MB, |
_NL_CTYPE_OUTDIGITS4_MB, |
_NL_CTYPE_OUTDIGITS5_MB, |
_NL_CTYPE_OUTDIGITS6_MB, |
_NL_CTYPE_OUTDIGITS7_MB, |
_NL_CTYPE_OUTDIGITS8_MB, |
_NL_CTYPE_OUTDIGITS9_MB, |
_NL_CTYPE_OUTDIGITS0_WC, |
_NL_CTYPE_OUTDIGITS1_WC, |
_NL_CTYPE_OUTDIGITS2_WC, |
_NL_CTYPE_OUTDIGITS3_WC, |
_NL_CTYPE_OUTDIGITS4_WC, |
_NL_CTYPE_OUTDIGITS5_WC, |
_NL_CTYPE_OUTDIGITS6_WC, |
_NL_CTYPE_OUTDIGITS7_WC, |
_NL_CTYPE_OUTDIGITS8_WC, |
_NL_CTYPE_OUTDIGITS9_WC, |
_NL_TIME_CODESET, |
_NL_TIME_WMON_1, |
_NL_TIME_WMON_2, |
_NL_TIME_WMON_3, |
_NL_TIME_WMON_4, |
_NL_TIME_WMON_5, |
_NL_TIME_WMON_6, |
_NL_TIME_WMON_7, |
_NL_TIME_WMON_8, |
_NL_TIME_WMON_9, |
_NL_TIME_WMON_10, |
_NL_TIME_WMON_11, |
_NL_TIME_WMON_12, |
_NL_TIME_WMONTH_1, |
_NL_TIME_WMONTH_2, |
_NL_TIME_WMONTH_3, |
_NL_TIME_WMONTH_4, |
_NL_TIME_WMONTH_5, |
_NL_TIME_WMONTH_6, |
_NL_TIME_WMONTH_7, |
_NL_TIME_WMONTH_8, |
_NL_TIME_WMONTH_9, |
_NL_TIME_WMONTH_10, |
_NL_TIME_WMONTH_11, |
_NL_TIME_WMONTH_12, |
_NL_TIME_WWDAY_1, |
_NL_TIME_WWDAY_2, |
_NL_TIME_WWDAY_3, |
_NL_TIME_WWDAY_4, |
_NL_TIME_WWDAY_5, |
_NL_TIME_WWDAY_6, |
_NL_TIME_WWDAY_7, |
_NL_TIME_WWEEKDAY_1, |
_NL_TIME_WWEEKDAY_2, |
_NL_TIME_WWEEKDAY_3, |
_NL_TIME_WWEEKDAY_4, |
_NL_TIME_WWEEKDAY_5, |
_NL_TIME_WWEEKDAY_6, |
_NL_TIME_WWEEKDAY_7, |
_NL_TIME_WT_FMT, |
_NL_TIME_WD_FMT, |
_NL_TIME_WD_T_FMT, |
_NL_TIME_WAM_STR, |
_NL_TIME_WPM_STR, |
_NL_TIME_WDATE_FMT, |
_NL_TIME_WT_FMT_AMPM, |
_NL_TIME_WERA, |
_NL_TIME_WERA_D_FMT, |
_NL_TIME_WERA_D_T_FMT, |
_NL_TIME_WERA_T_FMT, |
_NL_TIME_WALT_DIGITS, |
_NL_NUMERIC_CODESET, |
_NL_NUMERIC_GROUPING, |
_NL_NUMERIC_DECIMAL_POINT_WC, |
_NL_NUMERIC_THOUSANDS_SEP_WC, |
_NL_MONETARY_INT_CURR_SYMBOL, |
_NL_MONETARY_CURRENCY_SYMBOL, |
_NL_MONETARY_MON_DECIMAL_POINT, |
_NL_MONETARY_MON_THOUSANDS_SEP, |
_NL_MONETARY_MON_GROUPING, |
_NL_MONETARY_POSITIVE_SIGN, |
_NL_MONETARY_NEGATIVE_SIGN, |
_NL_MONETARY_INT_FRAC_DIGITS, |
_NL_MONETARY_FRAC_DIGITS, |
_NL_MONETARY_P_CS_PRECEDES, |
_NL_MONETARY_P_SEP_BY_SPACE, |
_NL_MONETARY_N_CS_PRECEDES, |
_NL_MONETARY_N_SEP_BY_SPACE, |
_NL_MONETARY_P_SIGN_POSN, |
_NL_MONETARY_N_SIGN_POSN, |
_NL_MONETARY_INT_P_CS_PRECEDES, |
_NL_MONETARY_INT_P_SEP_BY_SPACE, |
_NL_MONETARY_INT_N_CS_PRECEDES, |
_NL_MONETARY_INT_N_SEP_BY_SPACE, |
_NL_MONETARY_INT_P_SIGN_POSN, |
_NL_MONETARY_INT_N_SIGN_POSN, |
_NL_MONETARY_CODESET, |
_NL_MONETARY_WINT_CURR_SYMBOL, |
_NL_MONETARY_WCURRENCY_SYMBOL, |
_NL_MONETARY_WMON_DECIMAL_POINT, |
_NL_MONETARY_WMON_THOUSANDS_SEP, |
_NL_MONETARY_WPOSITIVE_SIGN, |
_NL_MONETARY_WNEGATIVE_SIGN, |
_NL_MESSAGES_WYESEXPR, |
_NL_MESSAGES_WNOEXPR, |
_NL_MESSAGES_WYESSTR, |
_NL_MESSAGES_WNOSTR, |
_NL_COLLATE_CODESET, |
/* This MUST be the last entry since it's used to check for an array |
index in nl_langinfo(). */ |
_NL_LOCALE_EXTENDED_LAST_ENTRY |
#endif /* __HAVE_LOCALE_INFO_EXTENDED__ */ |
#endif /* __HAVE_LOCALE_INFO__ */ |
}; |
__BEGIN_DECLS |
char *nl_langinfo(nl_item); |
__END_DECLS |
#endif /* !_LANGINFO_H_ */ |
/programs/develop/libraries/newlib/include/libgen.h |
---|
0,0 → 1,23 |
/* |
* libgen.h - defined by XPG4 |
*/ |
#ifndef _LIBGEN_H_ |
#define _LIBGEN_H_ |
#include "_ansi.h" |
#include <sys/reent.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
char *_EXFUN(basename, (char *)); |
char *_EXFUN(dirname, (char *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _LIBGEN_H_ */ |
/programs/develop/libraries/newlib/include/limits.h |
---|
0,0 → 1,146 |
#ifndef _LIBC_LIMITS_H_ |
# define _LIBC_LIMITS_H_ 1 |
#include <newlib.h> |
# ifdef _MB_LEN_MAX |
# define MB_LEN_MAX _MB_LEN_MAX |
# else |
# define MB_LEN_MAX 1 |
# endif |
/* Maximum number of positional arguments, if _WANT_IO_POS_ARGS. */ |
# ifndef NL_ARGMAX |
# define NL_ARGMAX 32 |
# endif |
/* if do not have #include_next support, then we |
have to define the limits here. */ |
# if !defined __GNUC__ || __GNUC__ < 2 |
# ifndef _LIMITS_H |
# define _LIMITS_H 1 |
# include <sys/config.h> |
/* Number of bits in a `char'. */ |
# undef CHAR_BIT |
# define CHAR_BIT 8 |
/* Minimum and maximum values a `signed char' can hold. */ |
# undef SCHAR_MIN |
# define SCHAR_MIN (-128) |
# undef SCHAR_MAX |
# define SCHAR_MAX 127 |
/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ |
# undef UCHAR_MAX |
# define UCHAR_MAX 255 |
/* Minimum and maximum values a `char' can hold. */ |
# ifdef __CHAR_UNSIGNED__ |
# undef CHAR_MIN |
# define CHAR_MIN 0 |
# undef CHAR_MAX |
# define CHAR_MAX 255 |
# else |
# undef CHAR_MIN |
# define CHAR_MIN (-128) |
# undef CHAR_MAX |
# define CHAR_MAX 127 |
# endif |
/* Minimum and maximum values a `signed short int' can hold. */ |
# undef SHRT_MIN |
/* For the sake of 16 bit hosts, we may not use -32768 */ |
# define SHRT_MIN (-32767-1) |
# undef SHRT_MAX |
# define SHRT_MAX 32767 |
/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ |
# undef USHRT_MAX |
# define USHRT_MAX 65535 |
/* Minimum and maximum values a `signed int' can hold. */ |
# ifndef __INT_MAX__ |
# define __INT_MAX__ 2147483647 |
# endif |
# undef INT_MIN |
# define INT_MIN (-INT_MAX-1) |
# undef INT_MAX |
# define INT_MAX __INT_MAX__ |
/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ |
# undef UINT_MAX |
# define UINT_MAX (INT_MAX * 2U + 1) |
/* Minimum and maximum values a `signed long int' can hold. |
(Same as `int'). */ |
# ifndef __LONG_MAX__ |
# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9) |
# define __LONG_MAX__ 9223372036854775807L |
# else |
# define __LONG_MAX__ 2147483647L |
# endif /* __alpha__ || sparc64 */ |
# endif |
# undef LONG_MIN |
# define LONG_MIN (-LONG_MAX-1) |
# undef LONG_MAX |
# define LONG_MAX __LONG_MAX__ |
/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ |
# undef ULONG_MAX |
# define ULONG_MAX (LONG_MAX * 2UL + 1) |
# ifndef __LONG_LONG_MAX__ |
# define __LONG_LONG_MAX__ 9223372036854775807LL |
# endif |
# if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
/* Minimum and maximum values a `signed long long int' can hold. */ |
# undef LLONG_MIN |
# define LLONG_MIN (-LLONG_MAX-1) |
# undef LLONG_MAX |
# define LLONG_MAX __LONG_LONG_MAX__ |
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ |
# undef ULLONG_MAX |
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) |
# endif |
# if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) |
/* Minimum and maximum values a `signed long long int' can hold. */ |
# undef LONG_LONG_MIN |
# define LONG_LONG_MIN (-LONG_LONG_MAX-1) |
# undef LONG_LONG_MAX |
# define LONG_LONG_MAX __LONG_LONG_MAX__ |
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ |
# undef ULONG_LONG_MAX |
# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) |
# endif |
# endif /* _LIMITS_H */ |
# endif /* GCC 2. */ |
#endif /* !_LIBC_LIMITS_H_ */ |
#if defined __GNUC__ && !defined _GCC_LIMITS_H_ |
/* `_GCC_LIMITS_H_' is what GCC's file defines. */ |
# include_next <limits.h> |
#endif /* __GNUC__ && !_GCC_LIMITS_H_ */ |
#ifndef _POSIX2_RE_DUP_MAX |
/* The maximum number of repeated occurrences of a regular expression |
* permitted when using the interval notation `\{M,N\}'. */ |
#define _POSIX2_RE_DUP_MAX 255 |
#endif /* _POSIX2_RE_DUP_MAX */ |
#ifndef ARG_MAX |
#define ARG_MAX 4096 |
#endif |
#ifndef PATH_MAX |
#define PATH_MAX 4096 |
#endif |
/programs/develop/libraries/newlib/include/locale.h |
---|
0,0 → 1,65 |
/* |
locale.h |
Values appropriate for the formatting of monetary and other |
numberic quantities. |
*/ |
#ifndef _LOCALE_H_ |
#define _LOCALE_H_ |
#include "_ansi.h" |
#ifndef NULL |
#define NULL 0 |
#endif |
#define LC_ALL 0 |
#define LC_COLLATE 1 |
#define LC_CTYPE 2 |
#define LC_MONETARY 3 |
#define LC_NUMERIC 4 |
#define LC_TIME 5 |
#define LC_MESSAGES 6 |
_BEGIN_STD_C |
struct lconv |
{ |
char *decimal_point; |
char *thousands_sep; |
char *grouping; |
char *int_curr_symbol; |
char *currency_symbol; |
char *mon_decimal_point; |
char *mon_thousands_sep; |
char *mon_grouping; |
char *positive_sign; |
char *negative_sign; |
char int_frac_digits; |
char frac_digits; |
char p_cs_precedes; |
char p_sep_by_space; |
char n_cs_precedes; |
char n_sep_by_space; |
char p_sign_posn; |
char n_sign_posn; |
char int_n_cs_precedes; |
char int_n_sep_by_space; |
char int_n_sign_posn; |
char int_p_cs_precedes; |
char int_p_sep_by_space; |
char int_p_sign_posn; |
}; |
#ifndef _REENT_ONLY |
char *_EXFUN(setlocale,(int category, const char *locale)); |
struct lconv *_EXFUN(localeconv,(void)); |
#endif |
struct _reent; |
char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale)); |
struct lconv *_EXFUN(_localeconv_r,(struct _reent *)); |
_END_STD_C |
#endif /* _LOCALE_H_ */ |
/programs/develop/libraries/newlib/include/machine/_default_types.h |
---|
0,0 → 1,121 |
/* |
* $Id: _default_types.h,v 1.2 2008/06/11 22:14:54 jjohnstn Exp $ |
*/ |
#ifndef _MACHINE__DEFAULT_TYPES_H |
#define _MACHINE__DEFAULT_TYPES_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* |
* Guess on types by examining *_MIN / *_MAX defines. |
*/ |
#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ >= 3 ) \ |
&& defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 )) |
/* GCC >= 3.3.0 has __<val>__ implicitly defined. */ |
#define __EXP(x) __##x##__ |
#else |
/* Fall back to POSIX versions from <limits.h> */ |
#define __EXP(x) x |
#include <limits.h> |
#endif |
#if __EXP(SCHAR_MAX) == 0x7f |
typedef signed char __int8_t ; |
typedef unsigned char __uint8_t ; |
#define ___int8_t_defined 1 |
#endif |
#if __EXP(INT_MAX) == 0x7fff |
typedef signed int __int16_t; |
typedef unsigned int __uint16_t; |
#define ___int16_t_defined 1 |
#elif __EXP(SHRT_MAX) == 0x7fff |
typedef signed short __int16_t; |
typedef unsigned short __uint16_t; |
#define ___int16_t_defined 1 |
#elif __EXP(SCHAR_MAX) == 0x7fff |
typedef signed char __int16_t; |
typedef unsigned char __uint16_t; |
#define ___int16_t_defined 1 |
#endif |
#if ___int16_t_defined |
typedef __int16_t __int_least16_t; |
typedef __uint16_t __uint_least16_t; |
#define ___int_least16_t_defined 1 |
#if !___int8_t_defined |
typedef __int16_t __int_least8_t; |
typedef __uint16_t __uint_least8_t; |
#define ___int_least8_t_defined 1 |
#endif |
#endif |
#if __EXP(INT_MAX) == 0x7fffffffL |
typedef signed int __int32_t; |
typedef unsigned int __uint32_t; |
#define ___int32_t_defined 1 |
#elif __EXP(LONG_MAX) == 0x7fffffffL |
typedef signed long __int32_t; |
typedef unsigned long __uint32_t; |
#define ___int32_t_defined 1 |
#elif __EXP(SHRT_MAX) == 0x7fffffffL |
typedef signed short __int32_t; |
typedef unsigned short __uint32_t; |
#define ___int32_t_defined 1 |
#elif __EXP(SCHAR_MAX) == 0x7fffffffL |
typedef signed char __int32_t; |
typedef unsigned char __uint32_t; |
#define ___int32_t_defined 1 |
#endif |
#if ___int32_t_defined |
typedef __int32_t __int_least32_t; |
typedef __uint32_t __uint_least32_t; |
#define ___int_least32_t_defined 1 |
#if !___int8_t_defined |
typedef __int32_t __int_least8_t; |
typedef __uint32_t __uint_least8_t; |
#define ___int_least8_t_defined 1 |
#endif |
#if !___int16_t_defined |
typedef __int32_t __int_least16_t; |
typedef __uint32_t __uint_least16_t; |
#define ___int_least16_t_defined 1 |
#endif |
#endif |
#if __EXP(LONG_MAX) > 0x7fffffff |
typedef signed long __int64_t; |
typedef unsigned long __uint64_t; |
#define ___int64_t_defined 1 |
/* GCC has __LONG_LONG_MAX__ */ |
#elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) |
typedef signed long long __int64_t; |
typedef unsigned long long __uint64_t; |
#define ___int64_t_defined 1 |
/* POSIX mandates LLONG_MAX in <limits.h> */ |
#elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) |
typedef signed long long __int64_t; |
typedef unsigned long long __uint64_t; |
#define ___int64_t_defined 1 |
#elif __EXP(INT_MAX) > 0x7fffffff |
typedef signed int __int64_t; |
typedef unsigned int __uint64_t; |
#define ___int64_t_defined 1 |
#endif |
#undef __EXP |
#ifdef __cplusplus |
} |
#endif |
#endif /* _MACHINE__DEFAULT_TYPES_H */ |
/programs/develop/libraries/newlib/include/machine/_types.h |
---|
0,0 → 1,8 |
/* |
* $Id: _types.h,v 1.3 2007/09/07 21:16:25 jjohnstn Exp $ |
*/ |
#ifndef _MACHINE__TYPES_H |
#define _MACHINE__TYPES_H |
#include <machine/_default_types.h> |
#endif |
/programs/develop/libraries/newlib/include/machine/ansi.h |
---|
0,0 → 1,0 |
/* dummy header file to support BSD compiler */ |
/programs/develop/libraries/newlib/include/machine/endian.h |
---|
0,0 → 1,20 |
#ifndef __MACHINE_ENDIAN_H__ |
#include <sys/config.h> |
#ifndef BIG_ENDIAN |
#define BIG_ENDIAN 4321 |
#endif |
#ifndef LITTLE_ENDIAN |
#define LITTLE_ENDIAN 1234 |
#endif |
#ifndef BYTE_ORDER |
#if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BYTES_LITTLE_ENDIAN) |
#define BYTE_ORDER LITTLE_ENDIAN |
#else |
#define BYTE_ORDER BIG_ENDIAN |
#endif |
#endif |
#endif /* __MACHINE_ENDIAN_H__ */ |
/programs/develop/libraries/newlib/include/machine/fastmath.h |
---|
0,0 → 1,100 |
#ifdef __sysvnecv70_target |
double EXFUN(fast_sin,(double)); |
double EXFUN(fast_cos,(double)); |
double EXFUN(fast_tan,(double)); |
double EXFUN(fast_asin,(double)); |
double EXFUN(fast_acos,(double)); |
double EXFUN(fast_atan,(double)); |
double EXFUN(fast_sinh,(double)); |
double EXFUN(fast_cosh,(double)); |
double EXFUN(fast_tanh,(double)); |
double EXFUN(fast_asinh,(double)); |
double EXFUN(fast_acosh,(double)); |
double EXFUN(fast_atanh,(double)); |
double EXFUN(fast_abs,(double)); |
double EXFUN(fast_sqrt,(double)); |
double EXFUN(fast_exp2,(double)); |
double EXFUN(fast_exp10,(double)); |
double EXFUN(fast_expe,(double)); |
double EXFUN(fast_log10,(double)); |
double EXFUN(fast_log2,(double)); |
double EXFUN(fast_loge,(double)); |
#define sin(x) fast_sin(x) |
#define cos(x) fast_cos(x) |
#define tan(x) fast_tan(x) |
#define asin(x) fast_asin(x) |
#define acos(x) fast_acos(x) |
#define atan(x) fast_atan(x) |
#define sinh(x) fast_sinh(x) |
#define cosh(x) fast_cosh(x) |
#define tanh(x) fast_tanh(x) |
#define asinh(x) fast_asinh(x) |
#define acosh(x) fast_acosh(x) |
#define atanh(x) fast_atanh(x) |
#define abs(x) fast_abs(x) |
#define sqrt(x) fast_sqrt(x) |
#define exp2(x) fast_exp2(x) |
#define exp10(x) fast_exp10(x) |
#define expe(x) fast_expe(x) |
#define log10(x) fast_log10(x) |
#define log2(x) fast_log2(x) |
#define loge(x) fast_loge(x) |
#ifdef _HAVE_STDC |
/* These functions are in assembler, they really do take floats. This |
can only be used with a real ANSI compiler */ |
float EXFUN(fast_sinf,(float)); |
float EXFUN(fast_cosf,(float)); |
float EXFUN(fast_tanf,(float)); |
float EXFUN(fast_asinf,(float)); |
float EXFUN(fast_acosf,(float)); |
float EXFUN(fast_atanf,(float)); |
float EXFUN(fast_sinhf,(float)); |
float EXFUN(fast_coshf,(float)); |
float EXFUN(fast_tanhf,(float)); |
float EXFUN(fast_asinhf,(float)); |
float EXFUN(fast_acoshf,(float)); |
float EXFUN(fast_atanhf,(float)); |
float EXFUN(fast_absf,(float)); |
float EXFUN(fast_sqrtf,(float)); |
float EXFUN(fast_exp2f,(float)); |
float EXFUN(fast_exp10f,(float)); |
float EXFUN(fast_expef,(float)); |
float EXFUN(fast_log10f,(float)); |
float EXFUN(fast_log2f,(float)); |
float EXFUN(fast_logef,(float)); |
#define sinf(x) fast_sinf(x) |
#define cosf(x) fast_cosf(x) |
#define tanf(x) fast_tanf(x) |
#define asinf(x) fast_asinf(x) |
#define acosf(x) fast_acosf(x) |
#define atanf(x) fast_atanf(x) |
#define sinhf(x) fast_sinhf(x) |
#define coshf(x) fast_coshf(x) |
#define tanhf(x) fast_tanhf(x) |
#define asinhf(x) fast_asinhf(x) |
#define acoshf(x) fast_acoshf(x) |
#define atanhf(x) fast_atanhf(x) |
#define absf(x) fast_absf(x) |
#define sqrtf(x) fast_sqrtf(x) |
#define exp2f(x) fast_exp2f(x) |
#define exp10f(x) fast_exp10f(x) |
#define expef(x) fast_expef(x) |
#define log10f(x) fast_log10f(x) |
#define log2f(x) fast_log2f(x) |
#define logef(x) fast_logef(x) |
#endif |
/* Override the functions defined in math.h */ |
#endif /* __sysvnecv70_target */ |
/programs/develop/libraries/newlib/include/machine/ieeefp.h |
---|
0,0 → 1,371 |
#ifndef __IEEE_BIG_ENDIAN |
#ifndef __IEEE_LITTLE_ENDIAN |
/* This file can define macros to choose variations of the IEEE float |
format: |
_FLT_LARGEST_EXPONENT_IS_NORMAL |
Defined if the float format uses the largest exponent for finite |
numbers rather than NaN and infinity representations. Such a |
format cannot represent NaNs or infinities at all, but it's FLT_MAX |
is twice the IEEE value. |
_FLT_NO_DENORMALS |
Defined if the float format does not support IEEE denormals. Every |
float with a zero exponent is taken to be a zero representation. |
??? At the moment, there are no equivalent macros above for doubles and |
the macros are not fully supported by --enable-newlib-hw-fp. |
__IEEE_BIG_ENDIAN |
Defined if the float format is big endian. This is mutually exclusive |
with __IEEE_LITTLE_ENDIAN. |
__IEEE_LITTLE_ENDIAN |
Defined if the float format is little endian. This is mutually exclusive |
with __IEEE_BIG_ENDIAN. |
Note that one of __IEEE_BIG_ENDIAN or __IEEE_LITTLE_ENDIAN must be specified for a |
platform or error will occur. |
__IEEE_BYTES_LITTLE_ENDIAN |
This flag is used in conjunction with __IEEE_BIG_ENDIAN to describe a situation |
whereby multiple words of an IEEE floating point are in big endian order, but the |
words themselves are little endian with respect to the bytes. |
_DOUBLE_IS_32BITS |
This is used on platforms that support double by using the 32-bit IEEE |
float type. |
_FLOAT_ARG |
This represents what type a float arg is passed as. It is used when the type is |
not promoted to double. |
*/ |
#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__) |
/* ARM traditionally used big-endian words; and within those words the |
byte ordering was big or little endian depending upon the target. |
Modern floating-point formats are naturally ordered; in this case |
__VFP_FP__ will be defined, even if soft-float. */ |
#ifdef __VFP_FP__ |
# ifdef __ARMEL__ |
# define __IEEE_LITTLE_ENDIAN |
# else |
# define __IEEE_BIG_ENDIAN |
# endif |
#else |
# define __IEEE_BIG_ENDIAN |
# ifdef __ARMEL__ |
# define __IEEE_BYTES_LITTLE_ENDIAN |
# endif |
#endif |
#endif |
#ifdef __hppa__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __SPU__ |
#define __IEEE_BIG_ENDIAN |
#define isfinite(__y) \ |
(__extension__ ({int __cy; \ |
(sizeof (__y) == sizeof (float)) ? (1) : \ |
(__cy = fpclassify(__y)) != FP_INFINITE && __cy != FP_NAN;})) |
#define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x)) |
#define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x)) |
/* |
* Macros for use in ieeefp.h. We can't just define the real ones here |
* (like those above) as we have name space issues when this is *not* |
* included via generic the ieeefp.h. |
*/ |
#define __ieeefp_isnanf(x) 0 |
#define __ieeefp_isinff(x) 0 |
#define __ieeefp_finitef(x) 1 |
#endif |
#ifdef __sparc__ |
#ifdef __LITTLE_ENDIAN_DATA__ |
#define __IEEE_LITTLE_ENDIAN |
#else |
#define __IEEE_BIG_ENDIAN |
#endif |
#endif |
#if defined(__m68k__) || defined(__mc68000__) |
#define __IEEE_BIG_ENDIAN |
#endif |
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__) |
#define __IEEE_BIG_ENDIAN |
#ifdef __HAVE_SHORT_DOUBLE__ |
# define _DOUBLE_IS_32BITS |
#endif |
#endif |
#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__) |
#define __IEEE_BIG_ENDIAN |
#define _FLOAT_ARG float |
#define _DOUBLE_IS_32BITS |
#endif |
#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__) |
#define __IEEE_LITTLE_ENDIAN |
#define _FLOAT_ARG float |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __sh__ |
#ifdef __LITTLE_ENDIAN__ |
#define __IEEE_LITTLE_ENDIAN |
#else |
#define __IEEE_BIG_ENDIAN |
#endif |
#if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__) |
#define _DOUBLE_IS_32BITS |
#endif |
#endif |
#ifdef _AM29K |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef _WIN32 |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __i386__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __i960__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __lm32__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __M32R__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#if defined(_C4x) || defined(_C3x) |
#define __IEEE_BIG_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __TMS320C6X__ |
#ifdef _BIG_ENDIAN |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#ifdef __TIC80__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __MIPSEL__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __MIPSEB__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __MMIX__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __D30V__ |
#define __IEEE_BIG_ENDIAN |
#endif |
/* necv70 was __IEEE_LITTLE_ENDIAN. */ |
#ifdef __W65__ |
#define __IEEE_LITTLE_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#if defined(__Z8001__) || defined(__Z8002__) |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __m88k__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __mn10300__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __mn10200__ |
#define __IEEE_LITTLE_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __v800 |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __v850 |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __D10V__ |
#define __IEEE_BIG_ENDIAN |
#if __DOUBLE__ == 32 |
#define _DOUBLE_IS_32BITS |
#endif |
#endif |
#ifdef __PPC__ |
#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX) |
#define __IEEE_BIG_ENDIAN |
#else |
#if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32) |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#endif |
#ifdef __xstormy16__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __arc__ |
#ifdef __big_endian__ |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#ifdef __CRX__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __fr30__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __mcore__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __mt__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __frv__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __moxie__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __ia64__ |
#ifdef __BIG_ENDIAN__ |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#ifdef __AVR__ |
#define __IEEE_LITTLE_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#if defined(__or32__) || defined(__or1k__) || defined(__or16__) |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __IP2K__ |
#define __IEEE_BIG_ENDIAN |
#define __SMALL_BITFIELDS |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __iq2000__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __MAVERICK__ |
#ifdef __ARMEL__ |
# define __IEEE_LITTLE_ENDIAN |
#else /* must be __ARMEB__ */ |
# define __IEEE_BIG_ENDIAN |
#endif /* __ARMEL__ */ |
#endif /* __MAVERICK__ */ |
#ifdef __m32c__ |
#define __IEEE_LITTLE_ENDIAN |
#define __SMALL_BITFIELDS |
#endif |
#ifdef __CRIS__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __BFIN__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __x86_64__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __mep__ |
#ifdef __LITTLE_ENDIAN__ |
#define __IEEE_LITTLE_ENDIAN |
#else |
#define __IEEE_BIG_ENDIAN |
#endif |
#endif |
#ifdef __MICROBLAZE__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __RX__ |
#ifdef __RX_BIG_ENDIAN__ |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifndef __RX_64BIT_DOUBLES__ |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __RX_16BIT_INTS__ |
#define __SMALL_BITFIELDS |
#endif |
#endif |
#ifndef __IEEE_BIG_ENDIAN |
#ifndef __IEEE_LITTLE_ENDIAN |
#error Endianess not declared!! |
#endif /* not __IEEE_LITTLE_ENDIAN */ |
#endif /* not __IEEE_BIG_ENDIAN */ |
#endif /* not __IEEE_LITTLE_ENDIAN */ |
#endif /* not __IEEE_BIG_ENDIAN */ |
/programs/develop/libraries/newlib/include/machine/malloc.h |
---|
0,0 → 1,8 |
#ifndef _MACHMALLOC_H_ |
#define _MACHMALLOC_H_ |
/* place holder so platforms may add malloc.h extensions */ |
#endif /* _MACHMALLOC_H_ */ |
/programs/develop/libraries/newlib/include/machine/param.h |
---|
0,0 → 1,0 |
/* Place holder for machine-specific param.h. */ |
/programs/develop/libraries/newlib/include/machine/setjmp-dj.h |
---|
0,0 → 1,43 |
/* |
* Copyright (C) 1991 DJ Delorie |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms is permitted |
* provided that the above copyright notice and following paragraph are |
* duplicated in all such forms. |
* |
* This file is distributed WITHOUT ANY WARRANTY; without even the implied |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* Modified to use SETJMP_DJ_H rather than SETJMP_H to avoid |
conflicting with setjmp.h. Ian Taylor, Cygnus support, April, |
1993. */ |
#ifndef _SETJMP_DJ_H_ |
#define _SETJMP_DJ_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
typedef struct { |
unsigned long eax; |
unsigned long ebx; |
unsigned long ecx; |
unsigned long edx; |
unsigned long esi; |
unsigned long edi; |
unsigned long ebp; |
unsigned long esp; |
unsigned long eip; |
} jmp_buf[1]; |
extern int setjmp(jmp_buf); |
extern void longjmp(jmp_buf, int); |
#ifdef __cplusplus |
} |
#endif |
#endif |
/programs/develop/libraries/newlib/include/machine/setjmp.h |
---|
0,0 → 1,349 |
_BEGIN_STD_C |
#if defined(__arm__) || defined(__thumb__) |
/* |
* All callee preserved registers: |
* v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7 |
*/ |
#define _JBLEN 23 |
#endif |
#if defined(__AVR__) |
#define _JBLEN 24 |
#endif |
#ifdef __sparc__ |
/* |
* onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext). |
* All else recovered by under/over(flow) handling. |
*/ |
#define _JBLEN 13 |
#endif |
#ifdef __BFIN__ |
#define _JBLEN 40 |
#endif |
/* necv70 was 9 as well. */ |
#if defined(__m68k__) || defined(__mc68000__) |
/* |
* onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6, |
* fp2-fp7 for 68881. |
* All else recovered by under/over(flow) handling. |
*/ |
#define _JBLEN 34 |
#endif |
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__) |
/* |
* D, X, Y are not saved. |
* Only take into account the pseudo soft registers (max 32). |
*/ |
#define _JBLEN 32 |
#endif |
#if defined(__Z8001__) || defined(__Z8002__) |
/* 16 regs + pc */ |
#define _JBLEN 20 |
#endif |
#ifdef _AM29K |
/* |
* onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext). |
* All else recovered by under/over(flow) handling. |
*/ |
#define _JBLEN 9 |
#endif |
#if defined(__CYGWIN__) && !defined (_JBLEN) |
#define _JBLEN (13 * 4) |
#elif defined (__i386__) |
#if defined(__unix__) || defined(__rtems__) |
# define _JBLEN 9 |
#else |
#include "setjmp-dj.h" |
#endif |
#endif |
#ifdef __x86_64__ |
#define _JBTYPE long long |
#define _JBLEN 8 |
#endif |
#ifdef __i960__ |
#define _JBLEN 35 |
#endif |
#ifdef __M32R__ |
/* Only 8 words are currently needed. 10 gives us some slop if we need |
to expand. */ |
#define _JBLEN 10 |
#endif |
#ifdef __mips__ |
#ifdef __mips64 |
#define _JBTYPE long long |
#endif |
#ifdef __mips_soft_float |
#define _JBLEN 11 |
#else |
#define _JBLEN 23 |
#endif |
#endif |
#ifdef __m88000__ |
#define _JBLEN 21 |
#endif |
#ifdef __H8300__ |
#define _JBLEN 5 |
#define _JBTYPE int |
#endif |
#ifdef __H8300H__ |
/* same as H8/300 but registers are twice as big */ |
#define _JBLEN 5 |
#define _JBTYPE long |
#endif |
#if defined (__H8300S__) || defined (__H8300SX__) |
/* same as H8/300 but registers are twice as big */ |
#define _JBLEN 5 |
#define _JBTYPE long |
#endif |
#ifdef __H8500__ |
#define _JBLEN 4 |
#endif |
#ifdef __sh__ |
#if __SH5__ |
#define _JBLEN 50 |
#define _JBTYPE long long |
#else |
#define _JBLEN 20 |
#endif /* __SH5__ */ |
#endif |
#ifdef __v800 |
#define _JBLEN 28 |
#endif |
#ifdef __PPC__ |
#ifdef __ALTIVEC__ |
#define _JBLEN 64 |
#else |
#define _JBLEN 32 |
#endif |
#define _JBTYPE double |
#endif |
#ifdef __MICROBLAZE__ |
#define _JBLEN 20 |
#define _JBTYPE unsigned int |
#endif |
#ifdef __hppa__ |
/* %r30, %r2-%r18, %r27, pad, %fr12-%fr15. |
Note space exists for the FP registers, but they are not |
saved. */ |
#define _JBLEN 28 |
#endif |
#if defined(__mn10300__) || defined(__mn10200__) |
#ifdef __AM33_2__ |
#define _JBLEN 26 |
#else |
/* A guess */ |
#define _JBLEN 10 |
#endif |
#endif |
#ifdef __v850 |
/* I think our setjmp is saving 15 regs at the moment. Gives us one word |
slop if we need to expand. */ |
#define _JBLEN 16 |
#endif |
#if defined(_C4x) |
#define _JBLEN 10 |
#endif |
#if defined(_C3x) |
#define _JBLEN 9 |
#endif |
#ifdef __TMS320C6X__ |
#define _JBLEN 13 |
#endif |
#ifdef __TIC80__ |
#define _JBLEN 13 |
#endif |
#ifdef __D10V__ |
#define _JBLEN 8 |
#endif |
#ifdef __D30V__ |
#define _JBLEN ((64 /* GPR */ + (2*2) /* ACs */ + 18 /* CRs */) / 2) |
#define _JBTYPE double |
#endif |
#ifdef __frv__ |
#define _JBLEN (68/2) /* room for 68 32-bit regs */ |
#define _JBTYPE double |
#endif |
#ifdef __moxie__ |
#define _JBLEN 16 |
#endif |
#ifdef __CRX__ |
#define _JBLEN 9 |
#endif |
#ifdef __fr30__ |
#define _JBLEN 10 |
#endif |
#ifdef __iq2000__ |
#define _JBLEN 32 |
#endif |
#ifdef __mcore__ |
#define _JBLEN 16 |
#endif |
#ifdef __MMIX__ |
/* Using a layout compatible with GCC's built-in. */ |
#define _JBLEN 5 |
#define _JBTYPE unsigned long |
#endif |
#ifdef __mt__ |
#define _JBLEN 16 |
#endif |
#ifdef __SPU__ |
#define _JBLEN 50 |
#define _JBTYPE __vector signed int |
#endif |
#ifdef __xstormy16__ |
/* 4 GPRs plus SP plus PC. */ |
#define _JBLEN 8 |
#endif |
#ifdef __mep__ |
/* 16 GPRs, pc, hi, lo */ |
#define _JBLEN 19 |
#endif |
#ifdef __CRIS__ |
#define _JBLEN 18 |
#endif |
#ifdef __lm32__ |
#define _JBLEN 19 |
#endif |
#ifdef __m32c__ |
#if defined(__r8c_cpu__) || defined(__m16c_cpu__) |
#define _JBLEN (22/2) |
#else |
#define _JBLEN (34/2) |
#endif |
#define _JBTYPE unsigned short |
#endif /* __m32c__ */ |
#ifdef __RX__ |
#define _JBLEN 0x44 |
#endif |
#ifdef _JBLEN |
#ifdef _JBTYPE |
typedef _JBTYPE jmp_buf[_JBLEN]; |
#else |
typedef int jmp_buf[_JBLEN]; |
#endif |
#endif |
_END_STD_C |
#if defined(__CYGWIN__) || defined(__rtems__) |
#include <signal.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* POSIX sigsetjmp/siglongjmp macros */ |
#ifdef _JBTYPE |
typedef _JBTYPE sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (_JBTYPE))]; |
#else |
typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))]; |
#endif |
#define _SAVEMASK _JBLEN |
#define _SIGMASK (_JBLEN+1) |
#ifdef __CYGWIN__ |
# define _CYGWIN_WORKING_SIGSETJMP |
#endif |
#ifdef _POSIX_THREADS |
#define __SIGMASK_FUNC pthread_sigmask |
#else |
#define __SIGMASK_FUNC sigprocmask |
#endif |
#if defined(__GNUC__) |
#define sigsetjmp(env, savemask) \ |
__extension__ \ |
({ \ |
sigjmp_buf *_sjbuf = &(env); \ |
((*_sjbuf)[_SAVEMASK] = savemask,\ |
__SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\ |
setjmp (*_sjbuf)); \ |
}) |
#define siglongjmp(env, val) \ |
__extension__ \ |
({ \ |
sigjmp_buf *_sjbuf = &(env); \ |
((((*_sjbuf)[_SAVEMASK]) ? \ |
__SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\ |
: 0), \ |
longjmp (*_sjbuf, val)); \ |
}) |
#else /* !__GNUC__ */ |
#define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\ |
__SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\ |
setjmp (env)) |
#define siglongjmp(env, val) ((((env)[_SAVEMASK])?\ |
__SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\ |
longjmp (env, val)) |
#endif |
/* POSIX _setjmp/_longjmp, maintained for XSI compatibility. These |
are equivalent to sigsetjmp/siglongjmp when not saving the signal mask. |
New applications should use sigsetjmp/siglongjmp instead. */ |
#ifdef __CYGWIN__ |
extern void _longjmp(jmp_buf, int); |
extern int _setjmp(jmp_buf); |
#else |
#define _setjmp(env) sigsetjmp ((env), 0) |
#define _longjmp(env, val) siglongjmp ((env), (val)) |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* __CYGWIN__ or __rtems__ */ |
/programs/develop/libraries/newlib/include/machine/stdlib.h |
---|
0,0 → 1,8 |
#ifndef _MACHSTDLIB_H_ |
#define _MACHSTDLIB_H_ |
/* place holder so platforms may add stdlib.h extensions */ |
#endif /* _MACHSTDLIB_H_ */ |
/programs/develop/libraries/newlib/include/machine/termios.h |
---|
0,0 → 1,0 |
#define __MAX_BAUD B4000000 |
/programs/develop/libraries/newlib/include/machine/time.h |
---|
0,0 → 1,19 |
#ifndef _MACHTIME_H_ |
#define _MACHTIME_H_ |
#if defined(__rtems__) |
#define _CLOCKS_PER_SEC_ sysconf(_SC_CLK_TCK) |
#else /* !__rtems__ */ |
#if defined(__arm__) || defined(__thumb__) |
#define _CLOCKS_PER_SEC_ 100 |
#endif |
#endif /* !__rtems__ */ |
#ifdef __SPU__ |
#include <sys/types.h> |
int nanosleep (const struct timespec *, struct timespec *); |
#endif |
#endif /* _MACHTIME_H_ */ |
/programs/develop/libraries/newlib/include/machine/types.h |
---|
0,0 → 1,30 |
#ifndef _MACHTYPES_H_ |
#define _MACHTYPES_H_ |
/* |
* The following section is RTEMS specific and is needed to more |
* closely match the types defined in the BSD machine/types.h. |
* This is needed to let the RTEMS/BSD TCP/IP stack compile. |
*/ |
#if defined(__rtems__) |
#include <machine/_types.h> |
#endif |
#define _CLOCK_T_ unsigned long /* clock() */ |
#define _TIME_T_ long /* time() */ |
#define _CLOCKID_T_ unsigned long |
#define _TIMER_T_ unsigned long |
#ifndef _HAVE_SYSTYPES |
typedef long int __off_t; |
typedef int __pid_t; |
#ifdef __GNUC__ |
__extension__ typedef long long int __loff_t; |
#else |
typedef long int __loff_t; |
#endif |
#endif |
#endif /* _MACHTYPES_H_ */ |
/programs/develop/libraries/newlib/include/machine |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/include/malloc.h |
---|
0,0 → 1,169 |
/* malloc.h -- header file for memory routines. */ |
#ifndef _INCLUDE_MALLOC_H_ |
#define _INCLUDE_MALLOC_H_ |
#include <_ansi.h> |
#include <sys/reent.h> |
#define __need_size_t |
#include <stddef.h> |
/* include any machine-specific extensions */ |
#include <machine/malloc.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* This version of struct mallinfo must match the one in |
libc/stdlib/mallocr.c. */ |
struct mallinfo { |
int arena; /* total space allocated from system */ |
int ordblks; /* number of non-inuse chunks */ |
int smblks; /* unused -- always zero */ |
int hblks; /* number of mmapped regions */ |
int hblkhd; /* total space in mmapped regions */ |
int usmblks; /* unused -- always zero */ |
int fsmblks; /* unused -- always zero */ |
int uordblks; /* total allocated space */ |
int fordblks; /* total non-inuse space */ |
int keepcost; /* top-most, releasable (via malloc_trim) space */ |
}; |
/* The routines. */ |
extern _PTR malloc _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _malloc_r |
#define _malloc_r(r, s) malloc (s) |
#else |
extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t)); |
#endif |
extern _VOID free _PARAMS ((_PTR)); |
#ifdef __CYGWIN__ |
#undef _free_r |
#define _free_r(r, p) free (p) |
#else |
extern _VOID _free_r _PARAMS ((struct _reent *, _PTR)); |
#endif |
extern _PTR realloc _PARAMS ((_PTR, size_t)); |
#ifdef __CYGWIN__ |
#undef _realloc_r |
#define _realloc_r(r, p, s) realloc (p, s) |
#else |
extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t)); |
#endif |
extern _PTR calloc _PARAMS ((size_t, size_t)); |
#ifdef __CYGWIN__ |
#undef _calloc_r |
#define _calloc_r(r, s1, s2) calloc (s1, s2); |
#else |
extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t)); |
#endif |
extern _PTR memalign _PARAMS ((size_t, size_t)); |
#ifdef __CYGWIN__ |
#undef _memalign_r |
#define _memalign_r(r, s1, s2) memalign (s1, s2); |
#else |
extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t)); |
#endif |
extern struct mallinfo mallinfo _PARAMS ((void)); |
#ifdef __CYGWIN__ |
#undef _mallinfo_r |
#define _mallinfo_r(r) mallinfo () |
#else |
extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *)); |
#endif |
extern void malloc_stats _PARAMS ((void)); |
#ifdef __CYGWIN__ |
#undef _malloc_stats_r |
#define _malloc_stats_r(r) malloc_stats () |
#else |
extern void _malloc_stats_r _PARAMS ((struct _reent *)); |
#endif |
extern int mallopt _PARAMS ((int, int)); |
#ifdef __CYGWIN__ |
#undef _mallopt_r |
#define _mallopt_r(i1, i2) mallopt (i1, i2) |
#else |
extern int _mallopt_r _PARAMS ((struct _reent *, int, int)); |
#endif |
extern size_t malloc_usable_size _PARAMS ((_PTR)); |
#ifdef __CYGWIN__ |
#undef _malloc_usable_size_r |
#define _malloc_usable_size_r(r, p) malloc_usable_size (p) |
#else |
extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR)); |
#endif |
/* These aren't too useful on an embedded system, but we define them |
anyhow. */ |
extern _PTR valloc _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _valloc_r |
#define _valloc_r(r, s) valloc (s) |
#else |
extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t)); |
#endif |
extern _PTR pvalloc _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _pvalloc_r |
#define _pvalloc_r(r, s) pvalloc (s) |
#else |
extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t)); |
#endif |
extern int malloc_trim _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _malloc_trim_r |
#define _malloc_trim_r(r, s) malloc_trim (s) |
#else |
extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t)); |
#endif |
/* A compatibility routine for an earlier version of the allocator. */ |
extern _VOID mstats _PARAMS ((char *)); |
#ifdef __CYGWIN__ |
#undef _mstats_r |
#define _mstats_r(r, p) mstats (p) |
#else |
extern _VOID _mstats_r _PARAMS ((struct _reent *, char *)); |
#endif |
/* SVID2/XPG mallopt options */ |
#define M_MXFAST 1 /* UNUSED in this malloc */ |
#define M_NLBLKS 2 /* UNUSED in this malloc */ |
#define M_GRAIN 3 /* UNUSED in this malloc */ |
#define M_KEEP 4 /* UNUSED in this malloc */ |
/* mallopt options that actually do something */ |
#define M_TRIM_THRESHOLD -1 |
#define M_TOP_PAD -2 |
#define M_MMAP_THRESHOLD -3 |
#define M_MMAP_MAX -4 |
#ifndef __CYGWIN__ |
/* Some systems provide this, so do too for compatibility. */ |
extern void cfree _PARAMS ((_PTR)); |
#endif /* __CYGWIN__ */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _INCLUDE_MALLOC_H_ */ |
/programs/develop/libraries/newlib/include/math.h |
---|
0,0 → 1,580 |
#ifndef _MATH_H_ |
#define _MATH_H_ |
#include <sys/reent.h> |
#include <machine/ieeefp.h> |
#include "_ansi.h" |
_BEGIN_STD_C |
/* __dmath, __fmath, and __ldmath are only here for backwards compatibility |
* in case any code used them. They are no longer used by Newlib, itself, |
* other than legacy. */ |
union __dmath |
{ |
double d; |
__ULong i[2]; |
}; |
union __fmath |
{ |
float f; |
__ULong i[1]; |
}; |
#if defined(_HAVE_LONG_DOUBLE) |
union __ldmath |
{ |
long double ld; |
__ULong i[4]; |
}; |
#endif |
/* Natural log of 2 */ |
#define _M_LOG2_E 0.693147180559945309417 |
#if defined(__GNUC__) && \ |
( (__GNUC__ >= 4) || \ |
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) |
/* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ |
# ifndef HUGE_VAL |
# define HUGE_VAL (__builtin_huge_val()) |
# endif |
# ifndef HUGE_VALF |
# define HUGE_VALF (__builtin_huge_valf()) |
# endif |
# ifndef HUGE_VALL |
# define HUGE_VALL (__builtin_huge_vall()) |
# endif |
# ifndef INFINITY |
# define INFINITY (__builtin_inff()) |
# endif |
# ifndef NAN |
# define NAN (__builtin_nanf("")) |
# endif |
#else /* !gcc >= 3.3 */ |
/* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY |
* and NAN macros are required to be constant expressions. Using a variable-- |
* even a static const--does not meet this requirement, as it cannot be |
* evaluated at translation time.) |
* The infinities are done using numbers that are far in excess of |
* something that would be expected to be encountered in a floating-point |
* implementation. (A more certain way uses values from float.h, but that is |
* avoided because system includes are not supposed to include each other.) |
* This method might produce warnings from some compilers. (It does in |
* newer GCCs, but not for ones that would hit this #else.) If this happens, |
* please report details to the Newlib mailing list. */ |
#ifndef HUGE_VAL |
#define HUGE_VAL (1.0e999999999) |
#endif |
#ifndef HUGE_VALF |
#define HUGE_VALF (1.0e999999999F) |
#endif |
#if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE) |
#define HUGE_VALL (1.0e999999999L) |
#endif |
#if !defined(INFINITY) |
#define INFINITY (HUGE_VALF) |
#endif |
#if !defined(NAN) |
#if defined(__GNUC__) && defined(__cplusplus) |
/* Exception: older g++ versions warn about the divide by 0 used in the |
* normal case (even though older gccs do not). This trick suppresses the |
* warning, but causes errors for plain gcc, so is only used in the one |
* special case. */ |
static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000}; |
#define NAN (__Nanf.__d) |
#else |
#define NAN (0.0F/0.0F) |
#endif |
#endif |
#endif /* !gcc >= 3.3 */ |
/* Reentrant ANSI C functions. */ |
#ifndef __math_68881 |
extern double atan _PARAMS((double)); |
extern double cos _PARAMS((double)); |
extern double sin _PARAMS((double)); |
extern double tan _PARAMS((double)); |
extern double tanh _PARAMS((double)); |
extern double frexp _PARAMS((double, int *)); |
extern double modf _PARAMS((double, double *)); |
extern double ceil _PARAMS((double)); |
extern double fabs _PARAMS((double)); |
extern double floor _PARAMS((double)); |
#endif /* ! defined (__math_68881) */ |
/* Non reentrant ANSI C functions. */ |
#ifndef _REENT_ONLY |
#ifndef __math_68881 |
extern double acos _PARAMS((double)); |
extern double asin _PARAMS((double)); |
extern double atan2 _PARAMS((double, double)); |
extern double cosh _PARAMS((double)); |
extern double sinh _PARAMS((double)); |
extern double exp _PARAMS((double)); |
extern double ldexp _PARAMS((double, int)); |
extern double log _PARAMS((double)); |
extern double log10 _PARAMS((double)); |
extern double pow _PARAMS((double, double)); |
extern double sqrt _PARAMS((double)); |
extern double fmod _PARAMS((double, double)); |
#endif /* ! defined (__math_68881) */ |
#endif /* ! defined (_REENT_ONLY) */ |
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L |
/* ISO C99 types and macros. */ |
#ifndef FLT_EVAL_METHOD |
#define FLT_EVAL_METHOD 0 |
typedef float float_t; |
typedef double double_t; |
#endif /* FLT_EVAL_METHOD */ |
#define FP_NAN 0 |
#define FP_INFINITE 1 |
#define FP_ZERO 2 |
#define FP_SUBNORMAL 3 |
#define FP_NORMAL 4 |
#ifndef FP_ILOGB0 |
# define FP_ILOGB0 (-INT_MAX) |
#endif |
#ifndef FP_ILOGBNAN |
# define FP_ILOGBNAN INT_MAX |
#endif |
#ifndef MATH_ERRNO |
# define MATH_ERRNO 1 |
#endif |
#ifndef MATH_ERREXCEPT |
# define MATH_ERREXCEPT 2 |
#endif |
#ifndef math_errhandling |
# define math_errhandling MATH_ERRNO |
#endif |
extern int __isinff (float x); |
extern int __isinfd (double x); |
extern int __isnanf (float x); |
extern int __isnand (double x); |
extern int __fpclassifyf (float x); |
extern int __fpclassifyd (double x); |
extern int __signbitf (float x); |
extern int __signbitd (double x); |
#define fpclassify(__x) \ |
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \ |
__fpclassifyd(__x)) |
#ifndef isfinite |
#define isfinite(__y) \ |
(__extension__ ({int __cy = fpclassify(__y); \ |
__cy != FP_INFINITE && __cy != FP_NAN;})) |
#endif |
/* Note: isinf and isnan were once functions in newlib that took double |
* arguments. C99 specifies that these names are reserved for macros |
* supporting multiple floating point types. Thus, they are |
* now defined as macros. Implementations of the old functions |
* taking double arguments still exist for compatibility purposes |
* (prototypes for them are in <ieeefp.h>). */ |
#ifndef isinf |
#define isinf(y) (fpclassify(y) == FP_INFINITE) |
#endif |
#ifndef isnan |
#define isnan(y) (fpclassify(y) == FP_NAN) |
#endif |
#define isnormal(y) (fpclassify(y) == FP_NORMAL) |
#define signbit(__x) \ |
((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ |
__signbitd(__x)) |
#define isgreater(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x > __y);})) |
#define isgreaterequal(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x >= __y);})) |
#define isless(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x < __y);})) |
#define islessequal(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x <= __y);})) |
#define islessgreater(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x < __y || __x > __y);})) |
#define isunordered(a,b) \ |
(__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ |
fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) |
/* Non ANSI double precision functions. */ |
extern double infinity _PARAMS((void)); |
extern double nan _PARAMS((const char *)); |
extern int finite _PARAMS((double)); |
extern double copysign _PARAMS((double, double)); |
extern double logb _PARAMS((double)); |
extern int ilogb _PARAMS((double)); |
extern double asinh _PARAMS((double)); |
extern double cbrt _PARAMS((double)); |
extern double nextafter _PARAMS((double, double)); |
extern double rint _PARAMS((double)); |
extern double scalbn _PARAMS((double, int)); |
extern double exp2 _PARAMS((double)); |
extern double scalbln _PARAMS((double, long int)); |
extern double tgamma _PARAMS((double)); |
extern double nearbyint _PARAMS((double)); |
extern long int lrint _PARAMS((double)); |
extern _LONG_LONG_TYPE int llrint _PARAMS((double)); |
extern double round _PARAMS((double)); |
extern long int lround _PARAMS((double)); |
extern long long int llround _PARAMS((double)); |
extern double trunc _PARAMS((double)); |
extern double remquo _PARAMS((double, double, int *)); |
extern double fdim _PARAMS((double, double)); |
extern double fmax _PARAMS((double, double)); |
extern double fmin _PARAMS((double, double)); |
extern double fma _PARAMS((double, double, double)); |
#ifndef __math_68881 |
extern double log1p _PARAMS((double)); |
extern double expm1 _PARAMS((double)); |
#endif /* ! defined (__math_68881) */ |
#ifndef _REENT_ONLY |
extern double acosh _PARAMS((double)); |
extern double atanh _PARAMS((double)); |
extern double remainder _PARAMS((double, double)); |
extern double gamma _PARAMS((double)); |
extern double lgamma _PARAMS((double)); |
extern double erf _PARAMS((double)); |
extern double erfc _PARAMS((double)); |
extern double log2 _PARAMS((double)); |
#if !defined(__cplusplus) |
#define log2(x) (log (x) / _M_LOG2_E) |
#endif |
#ifndef __math_68881 |
extern double hypot _PARAMS((double, double)); |
#endif |
#endif /* ! defined (_REENT_ONLY) */ |
/* Single precision versions of ANSI functions. */ |
extern float atanf _PARAMS((float)); |
extern float cosf _PARAMS((float)); |
extern float sinf _PARAMS((float)); |
extern float tanf _PARAMS((float)); |
extern float tanhf _PARAMS((float)); |
extern float frexpf _PARAMS((float, int *)); |
extern float modff _PARAMS((float, float *)); |
extern float ceilf _PARAMS((float)); |
extern float fabsf _PARAMS((float)); |
extern float floorf _PARAMS((float)); |
#ifndef _REENT_ONLY |
extern float acosf _PARAMS((float)); |
extern float asinf _PARAMS((float)); |
extern float atan2f _PARAMS((float, float)); |
extern float coshf _PARAMS((float)); |
extern float sinhf _PARAMS((float)); |
extern float expf _PARAMS((float)); |
extern float ldexpf _PARAMS((float, int)); |
extern float logf _PARAMS((float)); |
extern float log10f _PARAMS((float)); |
extern float powf _PARAMS((float, float)); |
extern float sqrtf _PARAMS((float)); |
extern float fmodf _PARAMS((float, float)); |
#endif /* ! defined (_REENT_ONLY) */ |
/* Other single precision functions. */ |
extern float exp2f _PARAMS((float)); |
extern float scalblnf _PARAMS((float, long int)); |
extern float tgammaf _PARAMS((float)); |
extern float nearbyintf _PARAMS((float)); |
extern long int lrintf _PARAMS((float)); |
extern _LONG_LONG_TYPE llrintf _PARAMS((float)); |
extern float roundf _PARAMS((float)); |
extern long int lroundf _PARAMS((float)); |
extern long long int llroundf _PARAMS((float)); |
extern float truncf _PARAMS((float)); |
extern float remquof _PARAMS((float, float, int *)); |
extern float fdimf _PARAMS((float, float)); |
extern float fmaxf _PARAMS((float, float)); |
extern float fminf _PARAMS((float, float)); |
extern float fmaf _PARAMS((float, float, float)); |
extern float infinityf _PARAMS((void)); |
extern float nanf _PARAMS((const char *)); |
extern int finitef _PARAMS((float)); |
extern float copysignf _PARAMS((float, float)); |
extern float logbf _PARAMS((float)); |
extern int ilogbf _PARAMS((float)); |
extern float asinhf _PARAMS((float)); |
extern float cbrtf _PARAMS((float)); |
extern float nextafterf _PARAMS((float, float)); |
extern float rintf _PARAMS((float)); |
extern float scalbnf _PARAMS((float, int)); |
extern float log1pf _PARAMS((float)); |
extern float expm1f _PARAMS((float)); |
#ifndef _REENT_ONLY |
extern float acoshf _PARAMS((float)); |
extern float atanhf _PARAMS((float)); |
extern float remainderf _PARAMS((float, float)); |
extern float gammaf _PARAMS((float)); |
extern float lgammaf _PARAMS((float)); |
extern float erff _PARAMS((float)); |
extern float erfcf _PARAMS((float)); |
extern float log2f _PARAMS((float)); |
#if !defined(__cplusplus) |
#define log2f(x) (logf (x) / (float) _M_LOG2_E) |
#endif |
extern float hypotf _PARAMS((float, float)); |
#endif /* ! defined (_REENT_ONLY) */ |
/* On platforms where long double equals double. */ |
#ifdef _LDBL_EQ_DBL |
/* Reentrant ANSI C functions. */ |
#ifndef __math_68881 |
extern long double atanl _PARAMS((long double)); |
extern long double cosl _PARAMS((long double)); |
extern long double sinl _PARAMS((long double)); |
extern long double tanl _PARAMS((long double)); |
extern long double tanhl _PARAMS((long double)); |
extern long double frexpl _PARAMS((long double value, int *)); |
extern long double modfl _PARAMS((long double, long double *)); |
extern long double ceill _PARAMS((long double)); |
extern long double fabsl _PARAMS((long double)); |
extern long double floorl _PARAMS((long double)); |
extern long double log1pl _PARAMS((long double)); |
extern long double expm1l _PARAMS((long double)); |
#endif /* ! defined (__math_68881) */ |
/* Non reentrant ANSI C functions. */ |
#ifndef _REENT_ONLY |
#ifndef __math_68881 |
extern long double acosl _PARAMS((long double)); |
extern long double asinl _PARAMS((long double)); |
extern long double atan2l _PARAMS((long double, long double)); |
extern long double coshl _PARAMS((long double)); |
extern long double sinhl _PARAMS((long double)); |
extern long double expl _PARAMS((long double)); |
extern long double ldexpl _PARAMS((long double, int)); |
extern long double logl _PARAMS((long double)); |
extern long double log10l _PARAMS((long double)); |
extern long double powl _PARAMS((long double, long double)); |
extern long double sqrtl _PARAMS((long double)); |
extern long double fmodl _PARAMS((long double, long double)); |
extern long double hypotl _PARAMS((long double, long double)); |
#endif /* ! defined (__math_68881) */ |
#endif /* ! defined (_REENT_ONLY) */ |
extern long double copysignl _PARAMS((long double, long double)); |
extern long double nanl _PARAMS((const char *)); |
extern int ilogbl _PARAMS((long double)); |
extern long double asinhl _PARAMS((long double)); |
extern long double cbrtl _PARAMS((long double)); |
extern long double nextafterl _PARAMS((long double, long double)); |
extern long double rintl _PARAMS((long double)); |
extern long double scalbnl _PARAMS((long double, int)); |
extern long double exp2l _PARAMS((long double)); |
extern long double scalblnl _PARAMS((long double, long)); |
extern long double tgammal _PARAMS((long double)); |
extern long double nearbyintl _PARAMS((long double)); |
extern long int lrintl _PARAMS((long double)); |
extern long long int llrintl _PARAMS((long double)); |
extern long double roundl _PARAMS((long double)); |
extern long lroundl _PARAMS((long double)); |
extern _LONG_LONG_TYPE int llroundl _PARAMS((long double)); |
extern long double truncl _PARAMS((long double)); |
extern long double remquol _PARAMS((long double, long double, int *)); |
extern long double fdiml _PARAMS((long double, long double)); |
extern long double fmaxl _PARAMS((long double, long double)); |
extern long double fminl _PARAMS((long double, long double)); |
extern long double fmal _PARAMS((long double, long double, long double)); |
#ifndef _REENT_ONLY |
extern long double acoshl _PARAMS((long double)); |
extern long double atanhl _PARAMS((long double)); |
extern long double remainderl _PARAMS((long double, long double)); |
extern long double lgammal _PARAMS((long double)); |
extern long double erfl _PARAMS((long double)); |
extern long double erfcl _PARAMS((long double)); |
#endif /* ! defined (_REENT_ONLY) */ |
#else /* !_LDBL_EQ_DBL */ |
#ifdef __i386__ |
/* Other long double precision functions. */ |
extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE)); |
extern long int lrintl _PARAMS((_LONG_DOUBLE)); |
extern _LONG_LONG_TYPE llrintl _PARAMS((_LONG_DOUBLE)); |
#endif /* __i386__ */ |
#endif /* !_LDBL_EQ_DBL */ |
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */ |
#if !defined (__STRICT_ANSI__) || defined(__cplusplus) |
extern double drem _PARAMS((double, double)); |
extern void sincos _PARAMS((double, double *, double *)); |
extern double gamma_r _PARAMS((double, int *)); |
extern double lgamma_r _PARAMS((double, int *)); |
extern double y0 _PARAMS((double)); |
extern double y1 _PARAMS((double)); |
extern double yn _PARAMS((int, double)); |
extern double j0 _PARAMS((double)); |
extern double j1 _PARAMS((double)); |
extern double jn _PARAMS((int, double)); |
extern float dremf _PARAMS((float, float)); |
extern void sincosf _PARAMS((float, float *, float *)); |
extern float gammaf_r _PARAMS((float, int *)); |
extern float lgammaf_r _PARAMS((float, int *)); |
extern float y0f _PARAMS((float)); |
extern float y1f _PARAMS((float)); |
extern float ynf _PARAMS((int, float)); |
extern float j0f _PARAMS((float)); |
extern float j1f _PARAMS((float)); |
extern float jnf _PARAMS((int, float)); |
/* GNU extensions */ |
# ifndef exp10 |
extern double exp10 _PARAMS((double)); |
# endif |
# ifndef pow10 |
extern double pow10 _PARAMS((double)); |
# endif |
# ifndef exp10f |
extern float exp10f _PARAMS((float)); |
# endif |
# ifndef pow10f |
extern float pow10f _PARAMS((float)); |
# endif |
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */ |
#ifndef __STRICT_ANSI__ |
/* The gamma functions use a global variable, signgam. */ |
#ifndef _REENT_ONLY |
#define signgam (*__signgam()) |
extern int *__signgam _PARAMS((void)); |
#endif /* ! defined (_REENT_ONLY) */ |
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr) |
/* The exception structure passed to the matherr routine. */ |
/* We have a problem when using C++ since `exception' is a reserved |
name in C++. */ |
#ifdef __cplusplus |
struct __exception |
#else |
struct exception |
#endif |
{ |
int type; |
char *name; |
double arg1; |
double arg2; |
double retval; |
int err; |
}; |
#ifdef __cplusplus |
extern int matherr _PARAMS((struct __exception *e)); |
#else |
extern int matherr _PARAMS((struct exception *e)); |
#endif |
/* Values for the type field of struct exception. */ |
#define DOMAIN 1 |
#define SING 2 |
#define OVERFLOW 3 |
#define UNDERFLOW 4 |
#define TLOSS 5 |
#define PLOSS 6 |
/* Useful constants. */ |
#define MAXFLOAT 3.40282347e+38F |
#define M_E 2.7182818284590452354 |
#define M_LOG2E 1.4426950408889634074 |
#define M_LOG10E 0.43429448190325182765 |
#define M_LN2 0.69314718055994530942 |
#define M_LN10 2.30258509299404568402 |
#define M_PI 3.14159265358979323846 |
#define M_TWOPI (M_PI * 2.0) |
#define M_PI_2 1.57079632679489661923 |
#define M_PI_4 0.78539816339744830962 |
#define M_3PI_4 2.3561944901923448370E0 |
#define M_SQRTPI 1.77245385090551602792981 |
#define M_1_PI 0.31830988618379067154 |
#define M_2_PI 0.63661977236758134308 |
#define M_2_SQRTPI 1.12837916709551257390 |
#define M_SQRT2 1.41421356237309504880 |
#define M_SQRT1_2 0.70710678118654752440 |
#define M_LN2LO 1.9082149292705877000E-10 |
#define M_LN2HI 6.9314718036912381649E-1 |
#define M_SQRT3 1.73205080756887719000 |
#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ |
#define M_LOG2_E _M_LOG2_E |
#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ |
/* Global control over fdlibm error handling. */ |
enum __fdlibm_version |
{ |
__fdlibm_ieee = -1, |
__fdlibm_svid, |
__fdlibm_xopen, |
__fdlibm_posix |
}; |
#define _LIB_VERSION_TYPE enum __fdlibm_version |
#define _LIB_VERSION __fdlib_version |
extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION; |
#define _IEEE_ __fdlibm_ieee |
#define _SVID_ __fdlibm_svid |
#define _XOPEN_ __fdlibm_xopen |
#define _POSIX_ __fdlibm_posix |
#endif /* ! defined (__STRICT_ANSI__) */ |
_END_STD_C |
#ifdef __FAST_MATH__ |
#include <machine/fastmath.h> |
#endif |
#endif /* _MATH_H_ */ |
/programs/develop/libraries/newlib/include/newlib.h |
---|
0,0 → 1,19 |
/* dummy file for external tools to use. Real file is created by |
newlib configuration. */ |
#ifndef _NEWLIB_H_ |
#define _NEWLIB_H_ |
#ifdef __LIBC_DLL__ |
#ifdef __LIBC_EXPORT__ |
#define API __attribute__ ((dllexport)) |
#else |
#define API __attribute__ ((dllimport)) |
#endif |
#else |
#define API |
#endif |
#endif /* _NEWLIB_H_ */ |
/programs/develop/libraries/newlib/include/paths.h |
---|
0,0 → 1,7 |
#ifndef _PATHS_H_ |
#define _PATHS_H_ |
#define _PATH_DEV "/dev/" |
#define _PATH_BSHELL "/bin/sh" |
#endif /* _PATHS_H_ */ |
/programs/develop/libraries/newlib/include/process.h |
---|
0,0 → 1,44 |
/* process.h. This file comes with MSDOS and WIN32 systems. */ |
#ifndef __PROCESS_H_ |
#define __PROCESS_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
int execl(const char *path, const char *argv0, ...); |
int execle(const char *path, const char *argv0, ... /*, char * const *envp */); |
int execlp(const char *path, const char *argv0, ...); |
int execlpe(const char *path, const char *argv0, ... /*, char * const *envp */); |
int execv(const char *path, char * const *argv); |
int execve(const char *path, char * const *argv, char * const *envp); |
int execvp(const char *path, char * const *argv); |
int execvpe(const char *path, char * const *argv, char * const *envp); |
int spawnl(int mode, const char *path, const char *argv0, ...); |
int spawnle(int mode, const char *path, const char *argv0, ... /*, char * const *envp */); |
int spawnlp(int mode, const char *path, const char *argv0, ...); |
int spawnlpe(int mode, const char *path, const char *argv0, ... /*, char * const *envp */); |
int spawnv(int mode, const char *path, const char * const *argv); |
int spawnve(int mode, const char *path, const char * const *argv, const char * const *envp); |
int spawnvp(int mode, const char *path, const char * const *argv); |
int spawnvpe(int mode, const char *path, const char * const *argv, const char * const *envp); |
int cwait(int *, int, int); |
#define _P_WAIT 1 |
#define _P_NOWAIT 2 /* always generates error */ |
#define _P_OVERLAY 3 |
#define _P_NOWAITO 4 |
#define _P_DETACH 5 |
#define WAIT_CHILD 1 |
#ifdef __cplusplus |
} |
#endif |
#endif |
/programs/develop/libraries/newlib/include/pthread.h |
---|
0,0 → 1,351 |
/* pthread.h |
* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2000. |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: pthread.h,v 1.8 2009/12/17 19:22:23 jjohnstn Exp $ |
*/ |
#ifndef __PTHREAD_h |
#define __PTHREAD_h |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <unistd.h> |
#if defined(_POSIX_THREADS) |
#include <sys/types.h> |
#include <time.h> |
#include <sys/sched.h> |
/* Register Fork Handlers */ |
int _EXFUN(pthread_atfork,(void (*prepare)(void), void (*parent)(void), |
void (*child)(void))); |
/* Mutex Initialization Attributes, P1003.1c/Draft 10, p. 81 */ |
int _EXFUN(pthread_mutexattr_init, (pthread_mutexattr_t *__attr)); |
int _EXFUN(pthread_mutexattr_destroy, (pthread_mutexattr_t *__attr)); |
int _EXFUN(pthread_mutexattr_getpshared, |
(_CONST pthread_mutexattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_mutexattr_setpshared, |
(pthread_mutexattr_t *__attr, int __pshared)); |
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
/* Single UNIX Specification 2 Mutex Attributes types */ |
int _EXFUN(pthread_mutexattr_gettype, |
(_CONST pthread_mutexattr_t *__attr, int *__kind)); |
int _EXFUN(pthread_mutexattr_settype, |
(pthread_mutexattr_t *__attr, int __kind)); |
#endif |
/* Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87 */ |
int _EXFUN(pthread_mutex_init, |
(pthread_mutex_t *__mutex, _CONST pthread_mutexattr_t *__attr)); |
int _EXFUN(pthread_mutex_destroy, (pthread_mutex_t *__mutex)); |
/* This is used to statically initialize a pthread_mutex_t. Example: |
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
*/ |
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF) |
/* Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93 |
NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29 */ |
int _EXFUN(pthread_mutex_lock, (pthread_mutex_t *__mutex)); |
int _EXFUN(pthread_mutex_trylock, (pthread_mutex_t *__mutex)); |
int _EXFUN(pthread_mutex_unlock, (pthread_mutex_t *__mutex)); |
#if defined(_POSIX_TIMEOUTS) |
int _EXFUN(pthread_mutex_timedlock, |
(pthread_mutex_t *__mutex, _CONST struct timespec *__timeout)); |
#endif /* _POSIX_TIMEOUTS */ |
/* Condition Variable Initialization Attributes, P1003.1c/Draft 10, p. 96 */ |
int _EXFUN(pthread_condattr_init, (pthread_condattr_t *__attr)); |
int _EXFUN(pthread_condattr_destroy, (pthread_condattr_t *__attr)); |
int _EXFUN(pthread_condattr_getpshared, |
(_CONST pthread_condattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_condattr_setpshared, |
(pthread_condattr_t *__attr, int __pshared)); |
/* Initializing and Destroying a Condition Variable, P1003.1c/Draft 10, p. 87 */ |
int _EXFUN(pthread_cond_init, |
(pthread_cond_t *__cond, _CONST pthread_condattr_t *__attr)); |
int _EXFUN(pthread_cond_destroy, (pthread_cond_t *__mutex)); |
/* This is used to statically initialize a pthread_cond_t. Example: |
pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
*/ |
#define PTHREAD_COND_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF) |
/* Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101 */ |
int _EXFUN(pthread_cond_signal, (pthread_cond_t *__cond)); |
int _EXFUN(pthread_cond_broadcast, (pthread_cond_t *__cond)); |
/* Waiting on a Condition, P1003.1c/Draft 10, p. 105 */ |
int _EXFUN(pthread_cond_wait, |
(pthread_cond_t *__cond, pthread_mutex_t *__mutex)); |
int _EXFUN(pthread_cond_timedwait, |
(pthread_cond_t *__cond, pthread_mutex_t *__mutex, |
_CONST struct timespec *__abstime)); |
#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) |
/* Thread Creation Scheduling Attributes, P1003.1c/Draft 10, p. 120 */ |
int _EXFUN(pthread_attr_setscope, |
(pthread_attr_t *__attr, int __contentionscope)); |
int _EXFUN(pthread_attr_getscope, |
(_CONST pthread_attr_t *__attr, int *__contentionscope)); |
int _EXFUN(pthread_attr_setinheritsched, |
(pthread_attr_t *__attr, int __inheritsched)); |
int _EXFUN(pthread_attr_getinheritsched, |
(_CONST pthread_attr_t *__attr, int *__inheritsched)); |
int _EXFUN(pthread_attr_setschedpolicy, |
(pthread_attr_t *__attr, int __policy)); |
int _EXFUN(pthread_attr_getschedpolicy, |
(_CONST pthread_attr_t *__attr, int *__policy)); |
#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */ |
int _EXFUN(pthread_attr_setschedparam, |
(pthread_attr_t *__attr, _CONST struct sched_param *__param)); |
int _EXFUN(pthread_attr_getschedparam, |
(_CONST pthread_attr_t *__attr, struct sched_param *__param)); |
#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) |
/* Dynamic Thread Scheduling Parameters Access, P1003.1c/Draft 10, p. 124 */ |
int _EXFUN(pthread_getschedparam, |
(pthread_t __pthread, int *__policy, struct sched_param *__param)); |
int _EXFUN(pthread_setschedparam, |
(pthread_t __pthread, int __policy, struct sched_param *__param)); |
#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */ |
#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) |
/* Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128 */ |
int _EXFUN(pthread_mutexattr_setprotocol, |
(pthread_mutexattr_t *__attr, int __protocol)); |
int _EXFUN(pthread_mutexattr_getprotocol, |
(_CONST pthread_mutexattr_t *__attr, int *__protocol)); |
int _EXFUN(pthread_mutexattr_setprioceiling, |
(pthread_mutexattr_t *__attr, int __prioceiling)); |
int _EXFUN(pthread_mutexattr_getprioceiling, |
(_CONST pthread_mutexattr_t *__attr, int *__prioceiling)); |
#endif /* _POSIX_THREAD_PRIO_INHERIT || _POSIX_THREAD_PRIO_PROTECT */ |
#if defined(_POSIX_THREAD_PRIO_PROTECT) |
/* Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131 */ |
int _EXFUN(pthread_mutex_setprioceiling, |
(pthread_mutex_t *__mutex, int __prioceiling, int *__old_ceiling)); |
int _EXFUN(pthread_mutex_getprioceiling, |
(pthread_mutex_t *__mutex, int *__prioceiling)); |
#endif /* _POSIX_THREAD_PRIO_PROTECT */ |
/* Thread Creation Attributes, P1003.1c/Draft 10, p, 140 */ |
int _EXFUN(pthread_attr_init, (pthread_attr_t *__attr)); |
int _EXFUN(pthread_attr_destroy, (pthread_attr_t *__attr)); |
int _EXFUN(pthread_attr_getstacksize, |
(_CONST pthread_attr_t *__attr, size_t *__stacksize)); |
int _EXFUN(pthread_attr_setstacksize, |
(pthread_attr_t *__attr, size_t stacksize)); |
int _EXFUN(pthread_attr_getstackaddr, |
(_CONST pthread_attr_t *__attr, void **__stackaddr)); |
int _EXFUN(pthread_attr_setstackaddr, |
(pthread_attr_t *__attr, void *__stackaddr)); |
int _EXFUN(pthread_attr_getdetachstate, |
(_CONST pthread_attr_t *__attr, int *__detachstate)); |
int _EXFUN(pthread_attr_setdetachstate, |
(pthread_attr_t *__attr, int __detachstate)); |
/* Thread Creation, P1003.1c/Draft 10, p. 144 */ |
int _EXFUN(pthread_create, |
(pthread_t *__pthread, _CONST pthread_attr_t *__attr, |
void *(*__start_routine)( void * ), void *__arg)); |
/* Wait for Thread Termination, P1003.1c/Draft 10, p. 147 */ |
int _EXFUN(pthread_join, (pthread_t __pthread, void **__value_ptr)); |
/* Detaching a Thread, P1003.1c/Draft 10, p. 149 */ |
int _EXFUN(pthread_detach, (pthread_t __pthread)); |
/* Thread Termination, p1003.1c/Draft 10, p. 150 */ |
void _EXFUN(pthread_exit, (void *__value_ptr)); |
/* Get Calling Thread's ID, p1003.1c/Draft 10, p. XXX */ |
pthread_t _EXFUN(pthread_self, (void)); |
/* Compare Thread IDs, p1003.1c/Draft 10, p. 153 */ |
int _EXFUN(pthread_equal, (pthread_t __t1, pthread_t __t2)); |
/* Dynamic Package Initialization */ |
/* This is used to statically initialize a pthread_once_t. Example: |
pthread_once_t once = PTHREAD_ONCE_INIT; |
NOTE: This is named inconsistently -- it should be INITIALIZER. */ |
#define PTHREAD_ONCE_INIT { 1, 0 } /* is initialized and not run */ |
int _EXFUN(pthread_once, |
(pthread_once_t *__once_control, void (*__init_routine)(void))); |
/* Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163 */ |
int _EXFUN(pthread_key_create, |
(pthread_key_t *__key, void (*__destructor)( void * ))); |
/* Thread-Specific Data Management, P1003.1c/Draft 10, p. 165 */ |
int _EXFUN(pthread_setspecific, |
(pthread_key_t __key, _CONST void *__value)); |
void * _EXFUN(pthread_getspecific, (pthread_key_t __key)); |
/* Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167 */ |
int _EXFUN(pthread_key_delete, (pthread_key_t __key)); |
/* Execution of a Thread, P1003.1c/Draft 10, p. 181 */ |
#define PTHREAD_CANCEL_ENABLE 0 |
#define PTHREAD_CANCEL_DISABLE 1 |
#define PTHREAD_CANCEL_DEFERRED 0 |
#define PTHREAD_CANCEL_ASYNCHRONOUS 1 |
#define PTHREAD_CANCELED ((void *) -1) |
int _EXFUN(pthread_cancel, (pthread_t __pthread)); |
/* Setting Cancelability State, P1003.1c/Draft 10, p. 183 */ |
int _EXFUN(pthread_setcancelstate, (int __state, int *__oldstate)); |
int _EXFUN(pthread_setcanceltype, (int __type, int *__oldtype)); |
void _EXFUN(pthread_testcancel, (void)); |
/* Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184 */ |
void _EXFUN(pthread_cleanup_push, |
(void (*__routine)( void * ), void *__arg)); |
void _EXFUN(pthread_cleanup_pop, (int __execute)); |
#if defined(_POSIX_THREAD_CPUTIME) |
/* Accessing a Thread CPU-time Clock, P1003.4b/D8, p. 58 */ |
int _EXFUN(pthread_getcpuclockid, |
(pthread_t __pthread_id, clockid_t *__clock_id)); |
#endif /* defined(_POSIX_THREAD_CPUTIME) */ |
#endif /* defined(_POSIX_THREADS) */ |
#if defined(_POSIX_BARRIERS) |
int _EXFUN(pthread_barrierattr_init, (pthread_barrierattr_t *__attr)); |
int _EXFUN(pthread_barrierattr_destroy, (pthread_barrierattr_t *__attr)); |
int _EXFUN(pthread_barrierattr_getpshared, |
(_CONST pthread_barrierattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_barrierattr_setpshared, |
(pthread_barrierattr_t *__attr, int __pshared)); |
#define PTHREAD_BARRIER_SERIAL_THREAD -1 |
int _EXFUN(pthread_barrier_init, |
(pthread_barrier_t *__barrier, |
_CONST pthread_barrierattr_t *__attr, unsigned __count)); |
int _EXFUN(pthread_barrier_destroy, (pthread_barrier_t *__barrier)); |
int _EXFUN(pthread_barrier_wait,(pthread_barrier_t *__barrier)); |
#endif /* defined(_POSIX_BARRIERS) */ |
#if defined(_POSIX_SPIN_LOCKS) |
int _EXFUN(pthread_spin_init, |
(pthread_spinlock_t *__spinlock, int __pshared)); |
int _EXFUN(pthread_spin_destroy, (pthread_spinlock_t *__spinlock)); |
int _EXFUN(pthread_spin_lock, (pthread_spinlock_t *__spinlock)); |
int _EXFUN(pthread_spin_trylock, (pthread_spinlock_t *__spinlock)); |
int _EXFUN(pthread_spin_unlock, (pthread_spinlock_t *__spinlock)); |
#endif /* defined(_POSIX_SPIN_LOCKS) */ |
#if defined(_POSIX_READER_WRITER_LOCKS) |
int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr)); |
int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr)); |
int _EXFUN(pthread_rwlockattr_getpshared, |
(_CONST pthread_rwlockattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_rwlockattr_setpshared, |
(pthread_rwlockattr_t *__attr, int __pshared)); |
int _EXFUN(pthread_rwlock_init, |
(pthread_rwlock_t *__rwlock, _CONST pthread_rwlockattr_t *__attr)); |
int _EXFUN(pthread_rwlock_destroy, (pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_rdlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_tryrdlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_timedrdlock, |
(pthread_rwlock_t *__rwlock, _CONST struct timespec *__abstime)); |
int _EXFUN(pthread_rwlock_unlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_wrlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_trywrlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_timedwrlock, |
(pthread_rwlock_t *__rwlock, _CONST struct timespec *__abstime)); |
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */ |
#ifdef __cplusplus |
} |
#endif |
#endif |
/* end of include file */ |
/programs/develop/libraries/newlib/include/pwd.h |
---|
0,0 → 1,78 |
/*- |
* Copyright (c) 1989 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)pwd.h 5.13 (Berkeley) 5/28/91 |
*/ |
#ifndef _PWD_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _PWD_H_ |
#include <sys/types.h> |
#ifndef _POSIX_SOURCE |
#define _PATH_PASSWD "/etc/passwd" |
#define _PASSWORD_LEN 128 /* max length, not counting NULL */ |
#endif |
struct passwd { |
char *pw_name; /* user name */ |
char *pw_passwd; /* encrypted password */ |
uid_t pw_uid; /* user uid */ |
gid_t pw_gid; /* user gid */ |
char *pw_comment; /* comment */ |
char *pw_gecos; /* Honeywell login info */ |
char *pw_dir; /* home directory */ |
char *pw_shell; /* default shell */ |
}; |
#ifndef __INSIDE_CYGWIN__ |
struct passwd *getpwuid (uid_t); |
struct passwd *getpwnam (const char *); |
int getpwnam_r (const char *, struct passwd *, |
char *, size_t , struct passwd **); |
int getpwuid_r (uid_t, struct passwd *, char *, |
size_t, struct passwd **); |
#ifndef _POSIX_SOURCE |
struct passwd *getpwent (void); |
void setpwent (void); |
void endpwent (void); |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _PWD_H_ */ |
/programs/develop/libraries/newlib/include/reent.h |
---|
0,0 → 1,191 |
/* This header file provides the reentrancy. */ |
/* The reentrant system calls here serve two purposes: |
1) Provide reentrant versions of the system calls the ANSI C library |
requires. |
2) Provide these system calls in a namespace clean way. |
It is intended that *all* system calls that the ANSI C library needs |
be declared here. It documents them all in one place. All library access |
to the system is via some form of these functions. |
The target may provide the needed syscalls by any of the following: |
1) Define the reentrant versions of the syscalls directly. |
(eg: _open_r, _close_r, etc.). Please keep the namespace clean. |
When you do this, set "syscall_dir" to "syscalls" and add |
-DREENTRANT_SYSCALLS_PROVIDED to newlib_cflags in configure.host. |
2) Define namespace clean versions of the system calls by prefixing |
them with '_' (eg: _open, _close, etc.). Technically, there won't be |
true reentrancy at the syscall level, but the library will be namespace |
clean. |
When you do this, set "syscall_dir" to "syscalls" in configure.host. |
3) Define or otherwise provide the regular versions of the syscalls |
(eg: open, close, etc.). The library won't be reentrant nor namespace |
clean, but at least it will work. |
When you do this, add -DMISSING_SYSCALL_NAMES to newlib_cflags in |
configure.host. |
4) Define or otherwise provide the regular versions of the syscalls, |
and do not supply functional interfaces for any of the reentrant |
calls. With this method, the reentrant syscalls are redefined to |
directly call the regular system call without the reentrancy argument. |
When you do this, specify both -DREENTRANT_SYSCALLS_PROVIDED and |
-DMISSING_SYSCALL_NAMES via newlib_cflags in configure.host and do |
not specify "syscall_dir". |
Stubs of the reentrant versions of the syscalls exist in the libc/reent |
source directory and are provided if REENTRANT_SYSCALLS_PROVIDED isn't |
defined. These stubs call the native system calls: _open, _close, etc. |
if MISSING_SYSCALL_NAMES is *not* defined, otherwise they call the |
non-underscored versions: open, close, etc. when MISSING_SYSCALL_NAMES |
*is* defined. |
By default, newlib functions call the reentrant syscalls internally, |
passing a reentrancy structure as an argument. This reentrancy structure |
contains data that is thread-specific. For example, the errno value is |
kept in the reentrancy structure. If multiple threads exist, each will |
keep a separate errno value which is intuitive since the application flow |
cannot check for failure reliably otherwise. |
The reentrant syscalls are either provided by the platform, by the |
libc/reent stubs, or in the case of both MISSING_SYSCALL_NAMES and |
REENTRANT_SYSCALLS_PROVIDED being defined, the calls are redefined to |
simply call the regular syscalls with no reentrancy struct argument. |
A single-threaded application does not need to worry about the reentrancy |
structure. It is used internally. |
A multi-threaded application needs either to manually manage reentrancy |
structures or use dynamic reentrancy. |
Manually managing reentrancy structures entails calling special reentrant |
versions of newlib functions that have an additional reentrancy argument. |
For example, _printf_r. By convention, the first argument is the |
reentrancy structure. By default, the normal version of the function |
uses the default reentrancy structure: _REENT. The reentrancy structure |
is passed internally, eventually to the reentrant syscalls themselves. |
How the structures are stored and accessed in this model is up to the |
application. |
Dynamic reentrancy is specified by the __DYNAMIC_REENT__ flag. This |
flag denotes setting up a macro to replace _REENT with a function call |
to __getreent(). This function needs to be implemented by the platform |
and it is meant to return the reentrancy structure for the current |
thread. When the regular C functions (e.g. printf) go to call internal |
routines with the default _REENT structure, they end up calling with |
the reentrancy structure for the thread. Thus, application code does not |
need to call the _r routines nor worry about reentrancy structures. */ |
/* WARNING: All identifiers here must begin with an underscore. This file is |
included by stdio.h and others and we therefore must only use identifiers |
in the namespace allotted to us. */ |
#ifndef _REENT_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _REENT_H_ |
#include <sys/reent.h> |
#include <sys/_types.h> |
#include <machine/types.h> |
#define __need_size_t |
#define __need_ptrdiff_t |
#include <stddef.h> |
/* FIXME: not namespace clean */ |
struct stat; |
struct tms; |
struct timeval; |
struct timezone; |
typedef struct |
{ |
char *name; |
unsigned int offset; |
int (*write)(const char*, const void *, size_t, size_t, size_t*); |
}__file_handle; |
#if defined(REENTRANT_SYSCALLS_PROVIDED) && defined(MISSING_SYSCALL_NAMES) |
#define _close_r(__reent, __fd) close(__fd) |
#define _execve_r(__reent, __f, __arg, __env) execve(__f, __arg, __env) |
#define _fcntl_r(__reent, __fd, __cmd, __arg) fcntl(__fd, __cmd, __arg) |
#define _fork_r(__reent) fork() |
#define _fstat_r(__reent, __fdes, __stat) fstat(__fdes, __stat) |
#define _getpid_r(__reent) getpid() |
#define _isatty_r(__reent, __desc) isatty(__desc) |
#define _kill_r(__reent, __pid, __signal) kill(__pid, __signal) |
#define _link_r(__reent, __oldpath, __newpath) link(__oldpath, __newpath) |
#define _lseek_r(__reent, __fdes, __off, __w) lseek(__fdes, __off, __w) |
#define _mkdir_r(__reent, __path, __m) mkdir(__path, __m) |
#define _open_r(__reent, __path, __flag, __m) open(__path, __flag, __m) |
#define _read_r(__reent, __fd, __buff, __cnt) read(__fd, __buff, __cnt) |
#define _rename_r(__reent, __old, __new) rename(__old, __new) |
#define _sbrk_r(__reent, __incr) sbrk(__incr) |
#define _stat_r(__reent, __path, __buff) stat(__path, __buff) |
#define _times_r(__reent, __time) times(__time) |
#define _unlink_r(__reent, __path) unlink(__path) |
#define _wait_r(__reent, __status) wait(__status) |
#define _write_r(__reent, __fd, __buff, __cnt) write(__fd, __buff, __cnt) |
#define _gettimeofday_r(__reent, __tp, __tzp) gettimeofday(__tp, __tzp) |
#ifdef __LARGE64_FILES |
#define _lseek64_r(__reent, __fd, __off, __w) lseek64(__fd, __off, __w) |
#define _fstat64_r(__reent, __fd, __buff) fstat64(__fd, __buff) |
#define _open64_r(__reent, __path, __flag, __m) open64(__path, __flag, __m) |
#endif |
#else |
/* Reentrant versions of system calls. */ |
extern int _close_r _PARAMS ((struct _reent *, int)); |
extern int _execve_r _PARAMS ((struct _reent *, const char *, char *const *, char *const *)); |
extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int)); |
extern int _fork_r _PARAMS ((struct _reent *)); |
extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *)); |
extern int _getpid_r _PARAMS ((struct _reent *)); |
extern int _isatty_r _PARAMS ((struct _reent *, int)); |
extern int _kill_r _PARAMS ((struct _reent *, int, int)); |
extern int _link_r _PARAMS ((struct _reent *, const char *, const char *)); |
extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int)); |
extern int _mkdir_r _PARAMS ((struct _reent *, const char *, int)); |
extern int _open_r _PARAMS ((struct _reent *, const char *, int, int)); |
extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t)); |
extern int _rename_r _PARAMS ((struct _reent *, const char *, const char *)); |
extern void *_sbrk_r _PARAMS ((struct _reent *, ptrdiff_t)); |
extern int _stat_r _PARAMS ((struct _reent *, const char *, struct stat *)); |
extern _CLOCK_T_ _times_r _PARAMS ((struct _reent *, struct tms *)); |
extern int _unlink_r _PARAMS ((struct _reent *, const char *)); |
extern int _wait_r _PARAMS ((struct _reent *, int *)); |
extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t)); |
/* This one is not guaranteed to be available on all targets. */ |
extern int _gettimeofday_r _PARAMS ((struct _reent *, struct timeval *__tp, void *__tzp)); |
#ifdef __LARGE64_FILES |
#if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB) |
#define stat64 __stat64 |
#endif |
struct stat64; |
extern _off64_t _lseek64_r _PARAMS ((struct _reent *, int, _off64_t, int)); |
extern int _fstat64_r _PARAMS ((struct _reent *, int, struct stat64 *)); |
extern int _open64_r _PARAMS ((struct _reent *, const char *, int, int)); |
extern int _stat64_r _PARAMS ((struct _reent *, const char *, struct stat64 *)); |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _REENT_H_ */ |
/programs/develop/libraries/newlib/include/regdef.h |
---|
0,0 → 1,7 |
/* regdef.h -- define register names. */ |
/* This is a standard include file for MIPS targets. Other target |
probably don't define it, and attempts to include this file will |
fail. */ |
#include <machine/regdef.h> |
/programs/develop/libraries/newlib/include/regex.h |
---|
0,0 → 1,102 |
/*- |
* Copyright (c) 1992 Henry Spencer. |
* Copyright (c) 1992, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Henry Spencer of the University of Toronto. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)regex.h 8.2 (Berkeley) 1/3/94 |
* $FreeBSD: src/include/regex.h,v 1.4 2002/03/23 17:24:53 imp Exp $ |
*/ |
#ifndef _REGEX_H_ |
#define _REGEX_H_ |
#include <sys/cdefs.h> |
/* types */ |
typedef off_t regoff_t; |
typedef struct { |
int re_magic; |
size_t re_nsub; /* number of parenthesized subexpressions */ |
__const char *re_endp; /* end pointer for REG_PEND */ |
struct re_guts *re_g; /* none of your business :-) */ |
} regex_t; |
typedef struct { |
regoff_t rm_so; /* start of match */ |
regoff_t rm_eo; /* end of match */ |
} regmatch_t; |
/* regcomp() flags */ |
#define REG_BASIC 0000 |
#define REG_EXTENDED 0001 |
#define REG_ICASE 0002 |
#define REG_NOSUB 0004 |
#define REG_NEWLINE 0010 |
#define REG_NOSPEC 0020 |
#define REG_PEND 0040 |
#define REG_DUMP 0200 |
/* regerror() flags */ |
#define REG_NOMATCH 1 |
#define REG_BADPAT 2 |
#define REG_ECOLLATE 3 |
#define REG_ECTYPE 4 |
#define REG_EESCAPE 5 |
#define REG_ESUBREG 6 |
#define REG_EBRACK 7 |
#define REG_EPAREN 8 |
#define REG_EBRACE 9 |
#define REG_BADBR 10 |
#define REG_ERANGE 11 |
#define REG_ESPACE 12 |
#define REG_BADRPT 13 |
#define REG_EMPTY 14 |
#define REG_ASSERT 15 |
#define REG_INVARG 16 |
#define REG_ATOI 255 /* convert name to number (!) */ |
#define REG_ITOA 0400 /* convert number to name (!) */ |
/* regexec() flags */ |
#define REG_NOTBOL 00001 |
#define REG_NOTEOL 00002 |
#define REG_STARTEND 00004 |
#define REG_TRACE 00400 /* tracing of execution */ |
#define REG_LARGE 01000 /* force large representation */ |
#define REG_BACKR 02000 /* force use of backref code */ |
__BEGIN_DECLS |
int regcomp(regex_t *, const char *, int); |
size_t regerror(int, const regex_t *, char *, size_t); |
int regexec(const regex_t *, const char *, size_t, regmatch_t [], int); |
void regfree(regex_t *); |
__END_DECLS |
#endif /* !_REGEX_H_ */ |
/programs/develop/libraries/newlib/include/rpc/types.h |
---|
0,0 → 1,85 |
/* |
* Copyright (c) 2009, Sun Microsystems, Inc. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are met: |
* - Redistributions of source code must retain the above copyright notice, |
* this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright notice, |
* this list of conditions and the following disclaimer in the documentation |
* and/or other materials provided with the distribution. |
* - Neither the name of Sun Microsystems, Inc. nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
* POSSIBILITY OF SUCH DAMAGE. |
* |
* from: @(#)types.h 1.18 87/07/24 SMI |
* from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC |
* $FreeBSD: src/include/rpc/types.h,v 1.10.6.1 2003/12/18 00:59:50 peter Exp $ |
* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ |
*/ |
/* |
* Rpc additions to <sys/types.h> |
*/ |
#ifndef _RPC_TYPES_H |
#define _RPC_TYPES_H |
#include <stdint.h> |
#include <sys/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#if defined(___int64_t_defined) |
typedef u_int64_t u_quad_t; |
typedef int64_t quad_t; |
#endif /* ___int64_t_defined */ |
typedef int32_t bool_t; |
typedef int32_t enum_t; |
typedef u_int32_t rpcprog_t; |
typedef u_int32_t rpcvers_t; |
typedef u_int32_t rpcproc_t; |
typedef u_int32_t rpcprot_t; |
typedef u_int32_t rpcport_t; |
typedef int32_t rpc_inline_t; |
#ifndef NULL |
# define NULL 0 |
#endif |
#define __dontcare__ -1 |
#ifndef FALSE |
# define FALSE 0 |
#endif |
#ifndef TRUE |
# define TRUE 1 |
#endif |
#ifndef mem_alloc |
#define mem_alloc(bsize) calloc(1, bsize) |
#endif |
#ifndef mem_free |
#define mem_free(ptr, bsize) free(ptr) |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_RPC_TYPES_H */ |
/programs/develop/libraries/newlib/include/rpc/xdr.h |
---|
0,0 → 1,389 |
/* |
* Copyright (c) 2009, Sun Microsystems, Inc. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are met: |
* - Redistributions of source code must retain the above copyright notice, |
* this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright notice, |
* this list of conditions and the following disclaimer in the documentation |
* and/or other materials provided with the distribution. |
* - Neither the name of Sun Microsystems, Inc. nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
* POSSIBILITY OF SUCH DAMAGE. |
* |
* from: @(#)xdr.h 1.19 87/04/22 SMI |
* from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC |
* $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $ |
* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ |
*/ |
/* |
* xdr.h, External Data Representation Serialization Routines. |
* |
* Copyright (C) 1984, Sun Microsystems, Inc. |
*/ |
#ifndef _RPC_XDR_H |
#define _RPC_XDR_H |
#include <_ansi.h> |
#include <rpc/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* |
* XDR provides a conventional way for converting between C data |
* types and an external bit-string representation. Library supplied |
* routines provide for the conversion on built-in C data types. These |
* routines and utility routines defined here are used to help implement |
* a type encode/decode routine for each user-defined type. |
* |
* Each data type provides a single procedure which takes two arguments: |
* |
* bool_t |
* xdrproc(XDR *xdrs, <type> *argresp) |
* |
* xdrs is an instance of a XDR handle, to which or from which the data |
* type is to be converted. argresp is a pointer to the structure to be |
* converted. The XDR handle contains an operation field which indicates |
* which of the operations (ENCODE, DECODE * or FREE) is to be performed. |
* |
* XDR_DECODE may allocate space if the pointer argresp is null. This |
* data can be freed with the XDR_FREE operation. |
* |
* We write only one procedure per data type to make it easy |
* to keep the encode and decode procedures for a data type consistent. |
* In many cases the same code performs all operations on a user defined type, |
* because all the hard work is done in the component type routines. |
* decode as a series of calls on the nested data types. |
*/ |
/* |
* Xdr operations. XDR_ENCODE causes the type to be encoded into the |
* stream. XDR_DECODE causes the type to be extracted from the stream. |
* XDR_FREE can be used to release the space allocated by an XDR_DECODE |
* request. |
*/ |
enum xdr_op |
{ |
XDR_ENCODE = 0, |
XDR_DECODE = 1, |
XDR_FREE = 2 |
}; |
/* |
* This is the number of bytes per unit of external data. |
*/ |
#define BYTES_PER_XDR_UNIT (4) |
#if 1 |
/* faster version when BYTES_PER_XDR_UNIT is a power of two */ |
# define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1)) |
#else /* old version */ |
#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ |
* BYTES_PER_XDR_UNIT) |
#endif |
/* |
* The XDR handle. |
* Contains operation which is being applied to the stream, |
* an operations vector for the particular implementation (e.g. see xdr_mem.c), |
* and two private fields for the use of the particular implementation. |
*/ |
typedef struct __rpc_xdr |
{ |
enum xdr_op x_op; /* operation; fast additional param */ |
_CONST struct xdr_ops |
{ |
/* get a long from underlying stream */ |
bool_t _EXFNPTR (x_getlong, (struct __rpc_xdr *, long *)); |
/* put a long to " */ |
bool_t _EXFNPTR (x_putlong, (struct __rpc_xdr *, _CONST long *)); |
/* get some bytes from " */ |
bool_t _EXFNPTR (x_getbytes, (struct __rpc_xdr *, char *, u_int)); |
/* put some bytes to " */ |
bool_t _EXFNPTR (x_putbytes, (struct __rpc_xdr *, _CONST char *, u_int)); |
/* returns bytes off from beginning */ |
u_int _EXFNPTR (x_getpostn, (struct __rpc_xdr *)); |
/* lets you reposition the stream */ |
bool_t _EXFNPTR (x_setpostn, (struct __rpc_xdr *, u_int)); |
/* buf quick ptr to buffered data */ |
int32_t * _EXFNPTR (x_inline, (struct __rpc_xdr *, u_int)); |
/* free privates of this xdr_stream */ |
void _EXFNPTR (x_destroy, (struct __rpc_xdr *)); |
/* get an int32 from this xdr_stream */ |
bool_t _EXFNPTR (x_getint32, (struct __rpc_xdr *, int32_t *)); |
/* put an int32 to the underlying stream */ |
bool_t _EXFNPTR (x_putint32, (struct __rpc_xdr *, _CONST int32_t *)); |
} *x_ops; |
char *x_public; /* users' data */ |
void *x_private; /* pointer to private data */ |
char *x_base; /* private used for position info */ |
u_int x_handy; /* extra private word */ |
} XDR; |
/* |
* A xdrproc_t exists for each data type which is to be encoded or decoded. |
* |
* The second argument to the xdrproc_t is a pointer to an opaque pointer. |
* The opaque pointer generally points to a structure of the data type |
* to be decoded. If this pointer is 0, then the type routines should |
* allocate dynamic storage of the appropriate size and return it. |
* bool_t (*xdrproc_t)(XDR *, some_type *) |
*/ |
typedef bool_t _EXFNPTR(xdrproc_t, (XDR *, ...)); |
/* |
* Operations defined on a XDR handle |
* |
* XDR *xdrs; |
* long *longp; |
* char *addr; |
* u_int len; |
* u_int pos; |
*/ |
#define XDR_GETINT32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_getint32)(xdrs, int32p) |
#define xdr_getint32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_getint32)(xdrs, int32p) |
#define XDR_PUTINT32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_putint32)(xdrs, int32p) |
#define xdr_putint32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_putint32)(xdrs, int32p) |
#define XDR_GETLONG(xdrs, longp) \ |
(*(xdrs)->x_ops->x_getlong)(xdrs, longp) |
#define xdr_getlong(xdrs, longp) \ |
(*(xdrs)->x_ops->x_getlong)(xdrs, longp) |
#define XDR_PUTLONG(xdrs, longp) \ |
(*(xdrs)->x_ops->x_putlong)(xdrs, longp) |
#define xdr_putlong(xdrs, longp) \ |
(*(xdrs)->x_ops->x_putlong)(xdrs, longp) |
#define XDR_GETBYTES(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) |
#define xdr_getbytes(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) |
#define XDR_PUTBYTES(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) |
#define xdr_putbytes(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) |
#define XDR_GETPOS(xdrs) \ |
(*(xdrs)->x_ops->x_getpostn)(xdrs) |
#define xdr_getpos(xdrs) \ |
(*(xdrs)->x_ops->x_getpostn)(xdrs) |
#define XDR_SETPOS(xdrs, pos) \ |
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos) |
#define xdr_setpos(xdrs, pos) \ |
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos) |
#define XDR_INLINE(xdrs, len) \ |
(*(xdrs)->x_ops->x_inline)(xdrs, len) |
#define xdr_inline(xdrs, len) \ |
(*(xdrs)->x_ops->x_inline)(xdrs, len) |
#define XDR_DESTROY(xdrs) \ |
do { \ |
if ((xdrs)->x_ops->x_destroy) \ |
(*(xdrs)->x_ops->x_destroy)(xdrs); \ |
} while (0) |
#define xdr_destroy(xdrs) \ |
do { \ |
if ((xdrs)->x_ops->x_destroy) \ |
(*(xdrs)->x_ops->x_destroy)(xdrs); \ |
} while (0) |
/* |
* Solaris strips the '_t' from these types -- not sure why. |
* But, let's be compatible. |
*/ |
#define xdr_rpcvers(xdrs, versp) xdr_u_int32(xdrs, versp) |
#define xdr_rpcprog(xdrs, progp) xdr_u_int32(xdrs, progp) |
#define xdr_rpcproc(xdrs, procp) xdr_u_int32(xdrs, procp) |
#define xdr_rpcprot(xdrs, protp) xdr_u_int32(xdrs, protp) |
#define xdr_rpcport(xdrs, portp) xdr_u_int32(xdrs, portp) |
/* |
* Support struct for discriminated unions. |
* You create an array of xdrdiscrim structures, terminated with |
* an entry with a null procedure pointer. The xdr_union routine gets |
* the discriminant value and then searches the array of structures |
* for a matching value. If a match is found the associated xdr routine |
* is called to handle that part of the union. If there is |
* no match, then a default routine may be called. |
* If there is no match and no default routine it is an error. |
*/ |
#define NULL_xdrproc_t ((xdrproc_t)0) |
struct xdr_discrim |
{ |
int value; |
xdrproc_t proc; |
}; |
/* |
* In-line routines for fast encode/decode of primitive data types. |
* Caveat emptor: these use single memory cycles to get the |
* data from the underlying buffer, and will fail to operate |
* properly if the data is not aligned. The standard way to use these |
* is to say: |
* if ((buf = XDR_INLINE(xdrs, count)) == NULL) |
* return (FALSE); |
* <<< macro calls >>> |
* where ``count'' is the number of bytes of data occupied |
* by the primitive data types. |
* |
* N.B. and frozen for all time: each data type here uses 4 bytes |
* of external representation. |
*/ |
#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++)) |
#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) |
#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) |
#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) |
/* Warning: inline long routines are broken for 64 bit platforms. |
* Because the other inline routines below are implemented in terms |
* of them, they are all also broken for 64 bit platforms. |
*/ |
#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++)) |
#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) |
#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) |
#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) |
#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) |
#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) |
#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) |
#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) |
/* |
* These are the "generic" xdr routines. |
*/ |
extern bool_t _EXFUN (xdr_void, (void)); |
extern bool_t _EXFUN (xdr_short, (XDR *, short *)); |
extern bool_t _EXFUN (xdr_u_short, (XDR *, u_short *)); |
extern bool_t _EXFUN (xdr_int, (XDR *, int *)); |
extern bool_t _EXFUN (xdr_u_int, (XDR *, u_int *)); |
extern bool_t _EXFUN (xdr_long, (XDR *, long *)); |
extern bool_t _EXFUN (xdr_u_long, (XDR *, u_long *)); |
extern bool_t _EXFUN (xdr_int8_t, (XDR *, int8_t *)); |
extern bool_t _EXFUN (xdr_uint8_t, (XDR *, uint8_t *)); |
extern bool_t _EXFUN (xdr_u_int8_t, (XDR *, u_int8_t *)); |
extern bool_t _EXFUN (xdr_int16_t, (XDR *, int16_t *)); |
extern bool_t _EXFUN (xdr_uint16_t, (XDR *, uint16_t *)); |
extern bool_t _EXFUN (xdr_u_int16_t, (XDR *, u_int16_t *)); |
extern bool_t _EXFUN (xdr_int32_t, (XDR *, int32_t *)); |
extern bool_t _EXFUN (xdr_uint32_t, (XDR *, uint32_t *)); |
extern bool_t _EXFUN (xdr_u_int32_t, (XDR *, u_int32_t *)); |
#if defined(___int64_t_defined) |
extern bool_t _EXFUN (xdr_int64_t, (XDR *, int64_t *)); |
extern bool_t _EXFUN (xdr_uint64_t, (XDR *, uint64_t *)); |
extern bool_t _EXFUN (xdr_u_int64_t, (XDR *, u_int64_t *)); |
#endif /* ___int64_t_defined */ |
extern bool_t _EXFUN (xdr_bool, (XDR *, bool_t *)); |
extern bool_t _EXFUN (xdr_enum, (XDR *, enum_t *)); |
extern bool_t _EXFUN (xdr_array, (XDR *, char **, u_int *, u_int, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_bytes, (XDR *, char **, u_int *, u_int)); |
extern bool_t _EXFUN (xdr_opaque, (XDR *, char *, u_int)); |
extern bool_t _EXFUN (xdr_string, (XDR *, char **, u_int)); |
extern bool_t _EXFUN (xdr_union, (XDR *, enum_t *, char *, |
_CONST struct xdr_discrim *, xdrproc_t)); |
extern bool_t _EXFUN (xdr_char, (XDR *, char *)); |
extern bool_t _EXFUN (xdr_u_char, (XDR *, u_char *)); |
extern bool_t _EXFUN (xdr_vector, (XDR *, char *, u_int, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_float, (XDR *, float *)); |
extern bool_t _EXFUN (xdr_double, (XDR *, double *)); |
/* extern bool_t _EXFUN (xdr_quadruple, (XDR *, long double *)); */ |
extern bool_t _EXFUN (xdr_reference, (XDR *, char **, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_pointer, (XDR *, char **, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_wrapstring, (XDR *, char **)); |
#if defined(___int64_t_defined) |
extern bool_t _EXFUN (xdr_hyper, (XDR *, quad_t *)); |
extern bool_t _EXFUN (xdr_u_hyper, (XDR *, u_quad_t *)); |
extern bool_t _EXFUN (xdr_longlong_t, (XDR *, quad_t *)); |
extern bool_t _EXFUN (xdr_u_longlong_t, (XDR *, u_quad_t *)); |
#endif /* ___int64_t_defined */ |
extern u_long _EXFUN (xdr_sizeof, (xdrproc_t, void *)); |
/* |
* Common opaque bytes objects used by many rpc protocols; |
* declared here due to commonality. |
*/ |
#define MAX_NETOBJ_SZ 1024 |
struct netobj |
{ |
u_int n_len; |
char *n_bytes; |
}; |
typedef struct netobj netobj; |
extern bool_t _EXFUN (xdr_netobj, (XDR *, struct netobj *)); |
/* |
* These are the public routines for the various implementations of |
* xdr streams. |
*/ |
/* XDR using memory buffers */ |
extern void _EXFUN (xdrmem_create, (XDR *, char *, u_int, enum xdr_op)); |
/* XDR using stdio library */ |
#if defined(_STDIO_H_) |
extern void _EXFUN (xdrstdio_create, (XDR *, FILE *, enum xdr_op)); |
#endif |
/* XDR pseudo records for tcp */ |
extern void _EXFUN (xdrrec_create, (XDR *, u_int, u_int, void *, |
int _EXPARM (, (void *, void *, int)), |
int _EXPARM (, (void *, void *, int)))); |
/* make end of xdr record */ |
extern bool_t _EXFUN (xdrrec_endofrecord, (XDR *, bool_t)); |
/* move to beginning of next record */ |
extern bool_t _EXFUN (xdrrec_skiprecord, (XDR *)); |
/* true if no more input */ |
extern bool_t _EXFUN (xdrrec_eof, (XDR *)); |
extern u_int _EXFUN (xdrrec_readbytes, (XDR *, caddr_t, u_int)); |
/* free memory buffers for xdr */ |
extern void _EXFUN (xdr_free, (xdrproc_t, void *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_RPC_XDR_H */ |
/programs/develop/libraries/newlib/include/rpc |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/include/sched.h |
---|
0,0 → 1,97 |
/* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2010. |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: sched.h,v 1.2 2010/04/01 18:33:33 jjohnstn Exp $ |
*/ |
#ifndef _SCHED_H_ |
#define _SCHED_H_ |
#include <sys/types.h> |
#include <sys/sched.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#if defined(_POSIX_PRIORITY_SCHEDULING) |
/* |
* XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1803 |
*/ |
int sched_setparam( |
pid_t __pid, |
const struct sched_param *__param |
); |
/* |
* XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1800 |
*/ |
int sched_getparam( |
pid_t __pid, |
struct sched_param *__param |
); |
/* |
* XBD 13 - Set Scheduling Policy and Scheduling Parameters, |
* P1003.1b-2008, p. 1805 |
*/ |
int sched_setscheduler( |
pid_t __pid, |
int __policy, |
const struct sched_param *__param |
); |
/* |
* XBD 13 - Get Scheduling Policy, P1003.1b-2008, p. 1801 |
*/ |
int sched_getscheduler( |
pid_t __pid |
); |
/* |
* XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1799 |
*/ |
int sched_get_priority_max( |
int __policy |
); |
int sched_get_priority_min( |
int __policy |
); |
/* |
* XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1802 |
*/ |
int sched_rr_get_interval( |
pid_t __pid, |
struct timespec *__interval |
); |
#endif /* _POSIX_PRIORITY_SCHEDULING */ |
#if defined(_POSIX_THREADS) || defined(_POSIX_PRIORITY_SCHEDULING) |
/* |
* XBD 13 - Yield Processor, P1003.1b-2008, p. 1807 |
*/ |
int sched_yield( void ); |
#endif /* _POSIX_THREADS or _POSIX_PRIORITY_SCHEDULING */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SCHED_H_ */ |
/programs/develop/libraries/newlib/include/search.h |
---|
0,0 → 1,59 |
/* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ |
/* $FreeBSD: src/include/search.h,v 1.4 2002/03/23 17:24:53 imp Exp $ */ |
/* |
* Written by J.T. Conklin <jtc@netbsd.org> |
* Public domain. |
*/ |
#ifndef _SEARCH_H_ |
#define _SEARCH_H_ |
#include <sys/cdefs.h> |
#include <machine/ansi.h> |
#include <sys/types.h> |
typedef struct entry { |
char *key; |
void *data; |
} ENTRY; |
typedef enum { |
FIND, ENTER |
} ACTION; |
typedef enum { |
preorder, |
postorder, |
endorder, |
leaf |
} VISIT; |
#ifdef _SEARCH_PRIVATE |
typedef struct node { |
char *key; |
struct node *llink, *rlink; |
} node_t; |
#endif |
struct hsearch_data |
{ |
struct internal_head *htable; |
size_t htablesize; |
}; |
__BEGIN_DECLS |
int hcreate(size_t); |
void hdestroy(void); |
ENTRY *hsearch(ENTRY, ACTION); |
int hcreate_r(size_t, struct hsearch_data *); |
void hdestroy_r(struct hsearch_data *); |
int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); |
void *tdelete(const void *, void **, int (*)(const void *, const void *)); |
void tdestroy (void *, void (*)(void *)); |
void *tfind(const void *, void **, int (*)(const void *, const void *)); |
void *tsearch(const void *, void **, int (*)(const void *, const void *)); |
void twalk(const void *, void (*)(const void *, VISIT, int)); |
__END_DECLS |
#endif /* !_SEARCH_H_ */ |
/programs/develop/libraries/newlib/include/setjmp.h |
---|
0,0 → 1,20 |
/* |
setjmp.h |
stubs for future use. |
*/ |
#ifndef _SETJMP_H_ |
#define _SETJMP_H_ |
#include "_ansi.h" |
#include <machine/setjmp.h> |
_BEGIN_STD_C |
void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval)); |
int _EXFUN(setjmp,(jmp_buf __jmpb)); |
_END_STD_C |
#endif /* _SETJMP_H_ */ |
/programs/develop/libraries/newlib/include/signal.h |
---|
0,0 → 1,30 |
#ifndef _SIGNAL_H_ |
#define _SIGNAL_H_ |
#include "_ansi.h" |
#include <sys/signal.h> |
_BEGIN_STD_C |
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ |
#ifndef _POSIX_SOURCE |
typedef _sig_func_ptr sighandler_t; /* glibc naming */ |
#endif /* !_POSIX_SOURCE */ |
#define SIG_DFL ((_sig_func_ptr)0) /* Default action */ |
#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ |
#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */ |
struct _reent; |
_sig_func_ptr _EXFUN(_signal_r, (struct _reent *, int, _sig_func_ptr)); |
int _EXFUN(_raise_r, (struct _reent *, int)); |
#ifndef _REENT_ONLY |
_sig_func_ptr _EXFUN(signal, (int, _sig_func_ptr)); |
int _EXFUN(raise, (int)); |
#endif |
_END_STD_C |
#endif /* _SIGNAL_H_ */ |
/programs/develop/libraries/newlib/include/stdint.h |
---|
0,0 → 1,497 |
/* |
* Copyright (c) 2004, 2005 by |
* Ralf Corsepius, Ulm/Germany. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#ifndef _STDINT_H |
#define _STDINT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#if defined(__GNUC__) && \ |
( (__GNUC__ >= 4) || \ |
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) ) |
/* gcc > 3.2 implicitly defines the values we are interested */ |
#define __STDINT_EXP(x) __##x##__ |
#else |
#define __STDINT_EXP(x) x |
#include <limits.h> |
#endif |
/* Check if "long long" is 64bit wide */ |
/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */ |
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \ |
|| ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) ) |
#define __have_longlong64 1 |
#endif |
/* Check if "long" is 64bit or 32bit wide */ |
#if __STDINT_EXP(LONG_MAX) > 0x7fffffff |
#define __have_long64 1 |
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__) |
#define __have_long32 1 |
#define __have_long64 0 |
#endif |
#if __STDINT_EXP(SCHAR_MAX) == 0x7f |
typedef signed char int8_t ; |
typedef unsigned char uint8_t ; |
#define __int8_t_defined 1 |
#endif |
#if __int8_t_defined |
typedef signed char int_least8_t; |
typedef unsigned char uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#if __STDINT_EXP(SHRT_MAX) == 0x7fff |
typedef signed short int16_t; |
typedef unsigned short uint16_t; |
#define __int16_t_defined 1 |
#elif __STDINT_EXP(INT_MAX) == 0x7fff |
typedef signed int int16_t; |
typedef unsigned int uint16_t; |
#define __int16_t_defined 1 |
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fff |
typedef signed char int16_t; |
typedef unsigned char uint16_t; |
#define __int16_t_defined 1 |
#endif |
#if __int16_t_defined |
typedef int16_t int_least16_t; |
typedef uint16_t uint_least16_t; |
#define __int_least16_t_defined 1 |
#if !__int_least8_t_defined |
typedef int16_t int_least8_t; |
typedef uint16_t uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#endif |
#if __have_long32 |
typedef signed long int32_t; |
typedef unsigned long uint32_t; |
#define __int32_t_defined 1 |
#elif __STDINT_EXP(INT_MAX) == 0x7fffffffL |
typedef signed int int32_t; |
typedef unsigned int uint32_t; |
#define __int32_t_defined 1 |
#elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL |
typedef signed short int32_t; |
typedef unsigned short uint32_t; |
#define __int32_t_defined 1 |
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fffffffL |
typedef signed char int32_t; |
typedef unsigned char uint32_t; |
#define __int32_t_defined 1 |
#endif |
#if __int32_t_defined |
typedef int32_t int_least32_t; |
typedef uint32_t uint_least32_t; |
#define __int_least32_t_defined 1 |
#if !__int_least8_t_defined |
typedef int32_t int_least8_t; |
typedef uint32_t uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#if !__int_least16_t_defined |
typedef int32_t int_least16_t; |
typedef uint32_t uint_least16_t; |
#define __int_least16_t_defined 1 |
#endif |
#endif |
#if __have_long64 |
typedef signed long int64_t; |
typedef unsigned long uint64_t; |
#define __int64_t_defined 1 |
#elif __have_longlong64 |
typedef signed long long int64_t; |
typedef unsigned long long uint64_t; |
#define __int64_t_defined 1 |
#elif __STDINT_EXP(INT_MAX) > 0x7fffffff |
typedef signed int int64_t; |
typedef unsigned int uint64_t; |
#define __int64_t_defined 1 |
#endif |
#if __int64_t_defined |
typedef int64_t int_least64_t; |
typedef uint64_t uint_least64_t; |
#define __int_least64_t_defined 1 |
#if !__int_least8_t_defined |
typedef int64_t int_least8_t; |
typedef uint64_t uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#if !__int_least16_t_defined |
typedef int64_t int_least16_t; |
typedef uint64_t uint_least16_t; |
#define __int_least16_t_defined 1 |
#endif |
#if !__int_least32_t_defined |
typedef int64_t int_least32_t; |
typedef uint64_t uint_least32_t; |
#define __int_least32_t_defined 1 |
#endif |
#endif |
/* |
* Fastest minimum-width integer types |
* |
* Assume int to be the fastest type for all types with a width |
* less than __INT_MAX__ rsp. INT_MAX |
*/ |
#if __STDINT_EXP(INT_MAX) >= 0x7f |
typedef signed int int_fast8_t; |
typedef unsigned int uint_fast8_t; |
#define __int_fast8_t_defined 1 |
#endif |
#if __STDINT_EXP(INT_MAX) >= 0x7fff |
typedef signed int int_fast16_t; |
typedef unsigned int uint_fast16_t; |
#define __int_fast16_t_defined 1 |
#endif |
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff |
typedef signed int int_fast32_t; |
typedef unsigned int uint_fast32_t; |
#define __int_fast32_t_defined 1 |
#endif |
#if __STDINT_EXP(INT_MAX) > 0x7fffffff |
typedef signed int int_fast64_t; |
typedef unsigned int uint_fast64_t; |
#define __int_fast64_t_defined 1 |
#else |
#define __int_fast64_t_defined 0 |
#endif |
/* |
* Fall back to [u]int_least<N>_t for [u]int_fast<N>_t types |
* not having been defined, yet. |
* Leave undefined, if [u]int_least<N>_t should not be available. |
*/ |
#if !__int_fast8_t_defined |
#if __int_least8_t_defined |
typedef int_least8_t int_fast8_t; |
typedef uint_least8_t uint_fast8_t; |
#define __int_fast8_t_defined 1 |
#endif |
#endif |
#if !__int_fast16_t_defined |
#if __int_least16_t_defined |
typedef int_least16_t int_fast16_t; |
typedef uint_least16_t uint_fast16_t; |
#define __int_fast16_t_defined 1 |
#endif |
#endif |
#if !__int_fast32_t_defined |
#if __int_least32_t_defined |
typedef int_least32_t int_fast32_t; |
typedef uint_least32_t uint_fast32_t; |
#define __int_fast32_t_defined 1 |
#endif |
#endif |
#if !__int_fast64_t_defined |
#if __int_least64_t_defined |
typedef int_least64_t int_fast64_t; |
typedef uint_least64_t uint_fast64_t; |
#undef __int_fast64_t_defined |
#define __int_fast64_t_defined 1 |
#endif |
#endif |
/* Greatest-width integer types */ |
/* Modern GCCs provide __INTMAX_TYPE__ */ |
#if defined(__INTMAX_TYPE__) |
typedef __INTMAX_TYPE__ intmax_t; |
#elif __have_longlong64 |
typedef signed long long intmax_t; |
#else |
typedef signed long intmax_t; |
#endif |
/* Modern GCCs provide __UINTMAX_TYPE__ */ |
#if defined(__UINTMAX_TYPE__) |
typedef __UINTMAX_TYPE__ uintmax_t; |
#elif __have_longlong64 |
typedef unsigned long long uintmax_t; |
#else |
typedef unsigned long uintmax_t; |
#endif |
/* |
* GCC doesn't provide an appropriate macro for [u]intptr_t |
* For now, use __PTRDIFF_TYPE__ |
*/ |
#if defined(__PTRDIFF_TYPE__) |
typedef signed __PTRDIFF_TYPE__ intptr_t; |
typedef unsigned __PTRDIFF_TYPE__ uintptr_t; |
#define INTPTR_MAX PTRDIFF_MAX |
#define INTPTR_MIN PTRDIFF_MIN |
#ifdef __UINTPTR_MAX__ |
#define UINTPTR_MAX __UINTPTR_MAX__ |
#else |
#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1) |
#endif |
#else |
/* |
* Fallback to hardcoded values, |
* should be valid on cpu's with 32bit int/32bit void* |
*/ |
typedef signed long intptr_t; |
typedef unsigned long uintptr_t; |
#define INTPTR_MAX __STDINT_EXP(LONG_MAX) |
#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1) |
#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
#endif |
/* Limits of Specified-Width Integer Types */ |
#if __int8_t_defined |
#define INT8_MIN -128 |
#define INT8_MAX 127 |
#define UINT8_MAX 255 |
#endif |
#if __int_least8_t_defined |
#define INT_LEAST8_MIN -128 |
#define INT_LEAST8_MAX 127 |
#define UINT_LEAST8_MAX 255 |
#else |
#error required type int_least8_t missing |
#endif |
#if __int16_t_defined |
#define INT16_MIN -32768 |
#define INT16_MAX 32767 |
#define UINT16_MAX 65535 |
#endif |
#if __int_least16_t_defined |
#define INT_LEAST16_MIN -32768 |
#define INT_LEAST16_MAX 32767 |
#define UINT_LEAST16_MAX 65535 |
#else |
#error required type int_least16_t missing |
#endif |
#if __int32_t_defined |
#if __have_long32 |
#define INT32_MIN (-2147483647L-1) |
#define INT32_MAX 2147483647L |
#define UINT32_MAX 4294967295UL |
#else |
#define INT32_MIN (-2147483647-1) |
#define INT32_MAX 2147483647 |
#define UINT32_MAX 4294967295U |
#endif |
#endif |
#if __int_least32_t_defined |
#if __have_long32 |
#define INT_LEAST32_MIN (-2147483647L-1) |
#define INT_LEAST32_MAX 2147483647L |
#define UINT_LEAST32_MAX 4294967295UL |
#else |
#define INT_LEAST32_MIN (-2147483647-1) |
#define INT_LEAST32_MAX 2147483647 |
#define UINT_LEAST32_MAX 4294967295U |
#endif |
#else |
#error required type int_least32_t missing |
#endif |
#if __int64_t_defined |
#if __have_long64 |
#define INT64_MIN (-9223372036854775807L-1L) |
#define INT64_MAX 9223372036854775807L |
#define UINT64_MAX 18446744073709551615U |
#elif __have_longlong64 |
#define INT64_MIN (-9223372036854775807LL-1LL) |
#define INT64_MAX 9223372036854775807LL |
#define UINT64_MAX 18446744073709551615ULL |
#endif |
#endif |
#if __int_least64_t_defined |
#if __have_long64 |
#define INT_LEAST64_MIN (-9223372036854775807L-1L) |
#define INT_LEAST64_MAX 9223372036854775807L |
#define UINT_LEAST64_MAX 18446744073709551615U |
#elif __have_longlong64 |
#define INT_LEAST64_MIN (-9223372036854775807LL-1LL) |
#define INT_LEAST64_MAX 9223372036854775807LL |
#define UINT_LEAST64_MAX 18446744073709551615ULL |
#endif |
#endif |
#if __int_fast8_t_defined |
#if __STDINT_EXP(INT_MAX) >= 0x7f |
#define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST8_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST8_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST8_MIN INT_LEAST8_MIN |
#define INT_FAST8_MAX INT_LEAST8_MAX |
#define UINT_FAST8_MAX UINT_LEAST8_MAX |
#endif |
#endif |
#if __int_fast16_t_defined |
#if __STDINT_EXP(INT_MAX) >= 0x7fff |
#define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST16_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST16_MIN INT_LEAST16_MIN |
#define INT_FAST16_MAX INT_LEAST16_MAX |
#define UINT_FAST16_MAX UINT_LEAST16_MAX |
#endif |
#endif |
#if __int_fast32_t_defined |
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff |
#define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST32_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST32_MIN INT_LEAST32_MIN |
#define INT_FAST32_MAX INT_LEAST32_MAX |
#define UINT_FAST32_MAX UINT_LEAST32_MAX |
#endif |
#endif |
#if __int_fast64_t_defined |
#if __STDINT_EXP(INT_MAX) > 0x7fffffff |
#define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST64_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST64_MIN INT_LEAST64_MIN |
#define INT_FAST64_MAX INT_LEAST64_MAX |
#define UINT_FAST64_MAX UINT_LEAST64_MAX |
#endif |
#endif |
#ifdef __INTMAX_MAX__ |
#define INTMAX_MAX __INTMAX_MAX__ |
#define INTMAX_MIN (-INTMAX_MAX - 1) |
#elif defined(__INTMAX_TYPE__) |
/* All relevant GCC versions prefer long to long long for intmax_t. */ |
#define INTMAX_MAX INT64_MAX |
#define INTMAX_MIN INT64_MIN |
#endif |
#ifdef __UINTMAX_MAX__ |
#define UINTMAX_MAX __UINTMAX_MAX__ |
#elif defined(__UINTMAX_TYPE__) |
/* All relevant GCC versions prefer long to long long for intmax_t. */ |
#define UINTMAX_MAX UINT64_MAX |
#endif |
/* This must match size_t in stddef.h, currently long unsigned int */ |
#ifdef __SIZE_MAX__ |
#define SIZE_MAX __SIZE_MAX__ |
#else |
#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
#endif |
/* This must match sig_atomic_t in <signal.h> (currently int) */ |
#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1) |
#define SIG_ATOMIC_MAX __STDINT_EXP(INT_MAX) |
/* This must match ptrdiff_t in <stddef.h> (currently long int) */ |
#ifdef __PTRDIFF_MAX__ |
#define PTRDIFF_MAX __PTRDIFF_MAX__ |
#else |
#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX) |
#endif |
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) |
#ifdef __WCHAR_MAX__ |
#define WCHAR_MAX __WCHAR_MAX__ |
#endif |
#ifdef __WCHAR_MIN__ |
#define WCHAR_MIN __WCHAR_MIN__ |
#endif |
/* wint_t is unsigned int on almost all GCC targets. */ |
#ifdef __WINT_MAX__ |
#define WINT_MAX __WINT_MAX__ |
#else |
#define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U) |
#endif |
#ifdef __WINT_MIN__ |
#define WINT_MIN __WINT_MIN__ |
#else |
#define WINT_MIN 0U |
#endif |
/** Macros for minimum-width integer constant expressions */ |
#define INT8_C(x) x |
#if __STDINT_EXP(INT_MAX) > 0x7f |
#define UINT8_C(x) x |
#else |
#define UINT8_C(x) x##U |
#endif |
#define INT16_C(x) x |
#if __STDINT_EXP(INT_MAX) > 0x7fff |
#define UINT16_C(x) x |
#else |
#define UINT16_C(x) x##U |
#endif |
#if __have_long32 |
#define INT32_C(x) x##L |
#define UINT32_C(x) x##UL |
#else |
#define INT32_C(x) x |
#define UINT32_C(x) x##U |
#endif |
#if __int64_t_defined |
#if __have_long64 |
#define INT64_C(x) x##L |
#define UINT64_C(x) x##UL |
#else |
#define INT64_C(x) x##LL |
#define UINT64_C(x) x##ULL |
#endif |
#endif |
/** Macros for greatest-width integer constant expression */ |
#if __have_long64 |
#define INTMAX_C(x) x##L |
#define UINTMAX_C(x) x##UL |
#else |
#define INTMAX_C(x) x##LL |
#define UINTMAX_C(x) x##ULL |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _STDINT_H */ |
/programs/develop/libraries/newlib/include/stdio.h |
---|
0,0 → 1,685 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
* |
* @(#)stdio.h 5.3 (Berkeley) 3/15/86 |
*/ |
/* |
* NB: to fit things in six character monocase externals, the |
* stdio code uses the prefix `__s' for stdio objects, typically |
* followed by a three-character attempt at a mnemonic. |
*/ |
#ifndef _STDIO_H_ |
#define _STDIO_H_ |
#include "_ansi.h" |
#define _FSTDIO /* ``function stdio'' */ |
#define __need_size_t |
#include <stddef.h> |
#define __need___va_list |
#include <stdarg.h> |
/* |
* <sys/reent.h> defines __FILE, _fpos_t. |
* They must be defined there because struct _reent needs them (and we don't |
* want reent.h to include this file. |
*/ |
#include <sys/reent.h> |
#include <sys/types.h> |
_BEGIN_STD_C |
typedef __FILE FILE; |
#ifdef __CYGWIN__ |
typedef _fpos64_t fpos_t; |
#else |
typedef _fpos_t fpos_t; |
#ifdef __LARGE64_FILES |
typedef _fpos64_t fpos64_t; |
#endif |
#endif /* !__CYGWIN__ */ |
#include <sys/stdio.h> |
#define __SLBF 0x0001 /* line buffered */ |
#define __SNBF 0x0002 /* unbuffered */ |
#define __SRD 0x0004 /* OK to read */ |
#define __SWR 0x0008 /* OK to write */ |
/* RD and WR are never simultaneously asserted */ |
#define __SRW 0x0010 /* open for reading & writing */ |
#define __SEOF 0x0020 /* found EOF */ |
#define __SERR 0x0040 /* found error */ |
#define __SMBF 0x0080 /* _buf is from malloc */ |
#define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */ |
#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ |
#define __SOPT 0x0400 /* do fseek() optimisation */ |
#define __SNPT 0x0800 /* do not do fseek() optimisation */ |
#define __SOFF 0x1000 /* set iff _offset is in fact correct */ |
#define __SORD 0x2000 /* true => stream orientation (byte/wide) decided */ |
#if defined(__CYGWIN__) |
# define __SCLE 0x4000 /* convert line endings CR/LF <-> NL */ |
#endif |
#define __SL64 0x8000 /* is 64-bit offset large file */ |
/* _flags2 flags */ |
#define __SWID 0x2000 /* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */ |
/* |
* The following three definitions are for ANSI C, which took them |
* from System V, which stupidly took internal interface macros and |
* made them official arguments to setvbuf(), without renaming them. |
* Hence, these ugly _IOxxx names are *supposed* to appear in user code. |
* |
* Although these happen to match their counterparts above, the |
* implementation does not rely on that (so these could be renumbered). |
*/ |
#define _IOFBF 0 /* setvbuf should set fully buffered */ |
#define _IOLBF 1 /* setvbuf should set line buffered */ |
#define _IONBF 2 /* setvbuf should set unbuffered */ |
#ifndef NULL |
#define NULL 0 |
#endif |
#define EOF (-1) |
#ifdef __BUFSIZ__ |
#define BUFSIZ __BUFSIZ__ |
#else |
#define BUFSIZ 1024 |
#endif |
#ifdef __FOPEN_MAX__ |
#define FOPEN_MAX __FOPEN_MAX__ |
#else |
#define FOPEN_MAX 20 |
#endif |
#ifdef __FILENAME_MAX__ |
#define FILENAME_MAX __FILENAME_MAX__ |
#else |
#define FILENAME_MAX 1024 |
#endif |
#ifdef __L_tmpnam__ |
#define L_tmpnam __L_tmpnam__ |
#else |
#define L_tmpnam FILENAME_MAX |
#endif |
#ifndef __STRICT_ANSI__ |
#define P_tmpdir "/tmp" |
#endif |
#ifndef SEEK_SET |
#define SEEK_SET 0 /* set file offset to offset */ |
#endif |
#ifndef SEEK_CUR |
#define SEEK_CUR 1 /* set file offset to current plus offset */ |
#endif |
#ifndef SEEK_END |
#define SEEK_END 2 /* set file offset to EOF plus offset */ |
#endif |
#define TMP_MAX 26 |
#ifndef _REENT_ONLY |
#define stdin (_REENT->_stdin) |
#define stdout (_REENT->_stdout) |
#define stderr (_REENT->_stderr) |
#else /* _REENT_ONLY */ |
#define stdin (_impure_ptr->_stdin) |
#define stdout (_impure_ptr->_stdout) |
#define stderr (_impure_ptr->_stderr) |
#endif /* _REENT_ONLY */ |
#define _stdin_r(x) ((x)->_stdin) |
#define _stdout_r(x) ((x)->_stdout) |
#define _stderr_r(x) ((x)->_stderr) |
/* |
* Functions defined in ANSI C standard. |
*/ |
#ifndef __VALIST |
#ifdef __GNUC__ |
#define __VALIST __gnuc_va_list |
#else |
#define __VALIST char* |
#endif |
#endif |
FILE * _EXFUN(tmpfile, (void)); |
char * _EXFUN(tmpnam, (char *)); |
int _EXFUN(fclose, (FILE *)); |
int _EXFUN(fflush, (FILE *)); |
FILE * _EXFUN(freopen, (const char *, const char *, FILE *)); |
void _EXFUN(setbuf, (FILE *, char *)); |
int _EXFUN(setvbuf, (FILE *, char *, int, size_t)); |
int _EXFUN(fprintf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(fscanf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(printf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 1, 2)))); |
int _EXFUN(scanf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 2)))); |
int _EXFUN(sscanf, (const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(vfprintf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vprintf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 1, 0)))); |
int _EXFUN(vsprintf, (char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(fgetc, (FILE *)); |
char * _EXFUN(fgets, (char *, int, FILE *)); |
int _EXFUN(fputc, (int, FILE *)); |
int _EXFUN(fputs, (const char *, FILE *)); |
int _EXFUN(getc, (FILE *)); |
int _EXFUN(getchar, (void)); |
char * _EXFUN(gets, (char *)); |
int _EXFUN(putc, (int, FILE *)); |
int _EXFUN(putchar, (int)); |
int _EXFUN(puts, (const char *)); |
int _EXFUN(ungetc, (int, FILE *)); |
size_t _EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *)); |
size_t _EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *)); |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(fgetpos, (FILE *, _fpos_t *)); |
#else |
int _EXFUN(fgetpos, (FILE *, fpos_t *)); |
#endif |
int _EXFUN(fseek, (FILE *, long, int)); |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(fsetpos, (FILE *, const _fpos_t *)); |
#else |
int _EXFUN(fsetpos, (FILE *, const fpos_t *)); |
#endif |
long _EXFUN(ftell, ( FILE *)); |
void _EXFUN(rewind, (FILE *)); |
void _EXFUN(clearerr, (FILE *)); |
int _EXFUN(feof, (FILE *)); |
int _EXFUN(ferror, (FILE *)); |
void _EXFUN(perror, (const char *)); |
#ifndef _REENT_ONLY |
FILE * _EXFUN(fopen, (const char *_name, const char *_type)); |
int _EXFUN(sprintf, (char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(remove, (const char *)); |
int _EXFUN(rename, (const char *, const char *)); |
#endif |
#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K) |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(fseeko, (FILE *, _off_t, int)); |
_off_t _EXFUN(ftello, ( FILE *)); |
#else |
int _EXFUN(fseeko, (FILE *, off_t, int)); |
off_t _EXFUN(ftello, ( FILE *)); |
#endif |
#endif |
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) |
#ifndef _REENT_ONLY |
int _EXFUN(asiprintf, (char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
char * _EXFUN(asnprintf, (char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(asprintf, (char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
#ifndef diprintf |
int _EXFUN(diprintf, (int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
#endif |
int _EXFUN(fcloseall, (_VOID)); |
int _EXFUN(fiprintf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(fiscanf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(iprintf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 1, 2)))); |
int _EXFUN(iscanf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 2)))); |
int _EXFUN(siprintf, (char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(siscanf, (const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(snprintf, (char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(sniprintf, (char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
char * _EXFUN(tempnam, (const char *, const char *)); |
int _EXFUN(vasiprintf, (char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
char * _EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(vasprintf, (char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vdiprintf, (int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(vfscanf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(viprintf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 1, 0)))); |
int _EXFUN(viscanf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 0)))); |
int _EXFUN(vscanf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 0)))); |
int _EXFUN(vsiprintf, (char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vsiscanf, (const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(vsscanf, (const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
#endif /* !_REENT_ONLY */ |
#endif /* !__STRICT_ANSI__ */ |
/* |
* Routines in POSIX 1003.1:2001. |
*/ |
#ifndef __STRICT_ANSI__ |
#ifndef _REENT_ONLY |
FILE * _EXFUN(fdopen, (int, const char *)); |
#endif |
int _EXFUN(fileno, (FILE *)); |
int _EXFUN(getw, (FILE *)); |
int _EXFUN(pclose, (FILE *)); |
FILE * _EXFUN(popen, (const char *, const char *)); |
int _EXFUN(putw, (int, FILE *)); |
void _EXFUN(setbuffer, (FILE *, char *, int)); |
int _EXFUN(setlinebuf, (FILE *)); |
int _EXFUN(getc_unlocked, (FILE *)); |
int _EXFUN(getchar_unlocked, (void)); |
void _EXFUN(flockfile, (FILE *)); |
int _EXFUN(ftrylockfile, (FILE *)); |
void _EXFUN(funlockfile, (FILE *)); |
int _EXFUN(putc_unlocked, (int, FILE *)); |
int _EXFUN(putchar_unlocked, (int)); |
#endif /* ! __STRICT_ANSI__ */ |
/* |
* Routines in POSIX 1003.1:200x. |
*/ |
#ifndef __STRICT_ANSI__ |
# ifndef _REENT_ONLY |
# ifndef dprintf |
int _EXFUN(dprintf, (int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
# endif |
FILE * _EXFUN(fmemopen, (void *, size_t, const char *)); |
/* getdelim - see __getdelim for now */ |
/* getline - see __getline for now */ |
FILE * _EXFUN(open_memstream, (char **, size_t *)); |
#if defined (__CYGWIN__) |
int _EXFUN(renameat, (int, const char *, int, const char *)); |
#endif |
int _EXFUN(vdprintf, (int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
# endif |
#endif |
/* |
* Recursive versions of the above. |
*/ |
int _EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
char * _EXFUN(_asniprintf_r, (struct _reent *, char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
char * _EXFUN(_asnprintf_r, (struct _reent *, char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
int _EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_dprintf_r, (struct _reent *, int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_fclose_r, (struct _reent *, FILE *)); |
int _EXFUN(_fcloseall_r, (struct _reent *)); |
FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *)); |
int _EXFUN(_fflush_r, (struct _reent *, FILE *)); |
int _EXFUN(_fgetc_r, (struct _reent *, FILE *)); |
char * _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *)); |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, _fpos_t *)); |
int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const _fpos_t *)); |
#else |
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, fpos_t *)); |
int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const fpos_t *)); |
#endif |
int _EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
FILE * _EXFUN(_fmemopen_r, (struct _reent *, void *, size_t, const char *)); |
FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *)); |
FILE * _EXFUN(_freopen_r, (struct _reent *, const char *, const char *, FILE *)); |
int _EXFUN(_fprintf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_fpurge_r, (struct _reent *, FILE *)); |
int _EXFUN(_fputc_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_fputs_r, (struct _reent *, const char *, FILE *)); |
size_t _EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE *)); |
int _EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int)); |
int _EXFUN(_fseeko_r,(struct _reent *, FILE *, _off_t, int)); |
long _EXFUN(_ftell_r, (struct _reent *, FILE *)); |
_off_t _EXFUN(_ftello_r,(struct _reent *, FILE *)); |
void _EXFUN(_rewind_r, (struct _reent *, FILE *)); |
size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR , size_t _size, size_t _n, FILE *)); |
int _EXFUN(_getc_r, (struct _reent *, FILE *)); |
int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *)); |
int _EXFUN(_getchar_r, (struct _reent *)); |
int _EXFUN(_getchar_unlocked_r, (struct _reent *)); |
char * _EXFUN(_gets_r, (struct _reent *, char *)); |
int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(_iscanf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
FILE * _EXFUN(_open_memstream_r, (struct _reent *, char **, size_t *)); |
void _EXFUN(_perror_r, (struct _reent *, const char *)); |
int _EXFUN(_printf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(_putc_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_putchar_unlocked_r, (struct _reent *, int)); |
int _EXFUN(_putchar_r, (struct _reent *, int)); |
int _EXFUN(_puts_r, (struct _reent *, const char *)); |
int _EXFUN(_remove_r, (struct _reent *, const char *)); |
int _EXFUN(_rename_r, (struct _reent *, |
const char *_old, const char *_new)); |
int _EXFUN(_scanf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
int _EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
int _EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
int _EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_sscanf_r, (struct _reent *, const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
char * _EXFUN(_tempnam_r, (struct _reent *, const char *, const char *)); |
FILE * _EXFUN(_tmpfile_r, (struct _reent *)); |
char * _EXFUN(_tmpnam_r, (struct _reent *, char *)); |
int _EXFUN(_ungetc_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
char * _EXFUN(_vasniprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
char * _EXFUN(_vasnprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
int _EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vdprintf_r, (struct _reent *, int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
int _EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vfscanf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
int _EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(_vscanf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
int _EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
int _EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
int _EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vsscanf_r, (struct _reent *, const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
/* Other extensions. */ |
int _EXFUN(fpurge, (FILE *)); |
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *)); |
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *)); |
#ifdef __LARGE64_FILES |
#if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB) |
FILE * _EXFUN(fdopen64, (int, const char *)); |
FILE * _EXFUN(fopen64, (const char *, const char *)); |
FILE * _EXFUN(freopen64, (_CONST char *, _CONST char *, FILE *)); |
_off64_t _EXFUN(ftello64, (FILE *)); |
_off64_t _EXFUN(fseeko64, (FILE *, _off64_t, int)); |
int _EXFUN(fgetpos64, (FILE *, _fpos64_t *)); |
int _EXFUN(fsetpos64, (FILE *, const _fpos64_t *)); |
FILE * _EXFUN(tmpfile64, (void)); |
FILE * _EXFUN(_fdopen64_r, (struct _reent *, int, const char *)); |
FILE * _EXFUN(_fopen64_r, (struct _reent *,const char *, const char *)); |
FILE * _EXFUN(_freopen64_r, (struct _reent *, _CONST char *, _CONST char *, FILE *)); |
_off64_t _EXFUN(_ftello64_r, (struct _reent *, FILE *)); |
_off64_t _EXFUN(_fseeko64_r, (struct _reent *, FILE *, _off64_t, int)); |
int _EXFUN(_fgetpos64_r, (struct _reent *, FILE *, _fpos64_t *)); |
int _EXFUN(_fsetpos64_r, (struct _reent *, FILE *, const _fpos64_t *)); |
FILE * _EXFUN(_tmpfile64_r, (struct _reent *)); |
#endif /* !__CYGWIN__ */ |
#endif /* __LARGE64_FILES */ |
/* |
* Routines internal to the implementation. |
*/ |
int _EXFUN(__srget_r, (struct _reent *, FILE *)); |
int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *)); |
/* |
* Stdio function-access interface. |
*/ |
#ifndef __STRICT_ANSI__ |
# ifdef __LARGE64_FILES |
FILE *_EXFUN(funopen,(const _PTR __cookie, |
int (*__readfn)(_PTR __c, char *__buf, int __n), |
int (*__writefn)(_PTR __c, const char *__buf, int __n), |
_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence), |
int (*__closefn)(_PTR __c))); |
FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie, |
int (*__readfn)(_PTR __c, char *__buf, int __n), |
int (*__writefn)(_PTR __c, const char *__buf, int __n), |
_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence), |
int (*__closefn)(_PTR __c))); |
# else |
FILE *_EXFUN(funopen,(const _PTR __cookie, |
int (*__readfn)(_PTR __cookie, char *__buf, int __n), |
int (*__writefn)(_PTR __cookie, const char *__buf, int __n), |
fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence), |
int (*__closefn)(_PTR __cookie))); |
FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie, |
int (*__readfn)(_PTR __cookie, char *__buf, int __n), |
int (*__writefn)(_PTR __cookie, const char *__buf, int __n), |
fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence), |
int (*__closefn)(_PTR __cookie))); |
# endif /* !__LARGE64_FILES */ |
# define fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \ |
(fpos_t (*)())0, (int (*)())0) |
# define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \ |
(fpos_t (*)())0, (int (*)())0) |
typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n); |
typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf, |
size_t __n); |
# ifdef __LARGE64_FILES |
typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off, |
int __whence); |
# else |
typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence); |
# endif /* !__LARGE64_FILES */ |
typedef int cookie_close_function_t(void *__cookie); |
typedef struct |
{ |
/* These four struct member names are dictated by Linux; hopefully, |
they don't conflict with any macros. */ |
cookie_read_function_t *read; |
cookie_write_function_t *write; |
cookie_seek_function_t *seek; |
cookie_close_function_t *close; |
} cookie_io_functions_t; |
FILE *_EXFUN(fopencookie,(void *__cookie, |
const char *__mode, cookie_io_functions_t __functions)); |
FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie, |
const char *__mode, cookie_io_functions_t __functions)); |
#endif /* ! __STRICT_ANSI__ */ |
#ifndef __CUSTOM_FILE_IO__ |
/* |
* The __sfoo macros are here so that we can |
* define function versions in the C library. |
*/ |
#define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++)) |
#ifdef __SCLE |
/* For a platform with CR/LF, additional logic is required by |
__sgetc_r which would otherwise simply be a macro; therefore we |
use an inlined function. The function is only meant to be inlined |
in place as used and the function body should never be emitted. |
There are two possible means to this end when compiling with GCC, |
one when compiling with a standard C99 compiler, and for other |
compilers we're just stuck. At the moment, this issue only |
affects the Cygwin target, so we'll most likely be using GCC. */ |
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p); |
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p) |
{ |
int __c = __sgetc_raw_r(__ptr, __p); |
if ((__p->_flags & __SCLE) && (__c == '\r')) |
{ |
int __c2 = __sgetc_raw_r(__ptr, __p); |
if (__c2 == '\n') |
__c = __c2; |
else |
ungetc(__c2, __p); |
} |
return __c; |
} |
#else |
#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p) |
#endif |
#ifdef _never /* __GNUC__ */ |
/* If this inline is actually used, then systems using coff debugging |
info get hopelessly confused. 21sept93 rich@cygnus.com. */ |
_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { |
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) |
return (*_p->_p++ = _c); |
else |
return (__swbuf_r(_ptr, _c, _p)); |
} |
#else |
/* |
* This has been tuned to generate reasonable code on the vax using pcc |
*/ |
#define __sputc_raw_r(__ptr, __c, __p) \ |
(--(__p)->_w < 0 ? \ |
(__p)->_w >= (__p)->_lbfsize ? \ |
(*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \ |
(int)*(__p)->_p++ : \ |
__swbuf_r(__ptr, '\n', __p) : \ |
__swbuf_r(__ptr, (int)(__c), __p) : \ |
(*(__p)->_p = (__c), (int)*(__p)->_p++)) |
#ifdef __SCLE |
#define __sputc_r(__ptr, __c, __p) \ |
((((__p)->_flags & __SCLE) && ((__c) == '\n')) \ |
? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \ |
__sputc_raw_r((__ptr), (__c), (__p))) |
#else |
#define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p) |
#endif |
#endif |
#define __sfeof(p) (((p)->_flags & __SEOF) != 0) |
#define __sferror(p) (((p)->_flags & __SERR) != 0) |
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) |
#define __sfileno(p) ((p)->_file) |
#ifndef _REENT_SMALL |
#define feof(p) __sfeof(p) |
#define ferror(p) __sferror(p) |
#define clearerr(p) __sclearerr(p) |
#endif |
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */ |
#define fileno(p) __sfileno(p) |
#endif |
#ifndef __CYGWIN__ |
#ifndef lint |
#define getc(fp) __sgetc_r(_REENT, fp) |
#define putc(x, fp) __sputc_r(_REENT, x, fp) |
#endif /* lint */ |
#endif /* __CYGWIN__ */ |
#ifndef __STRICT_ANSI__ |
/* fast always-buffered version, true iff error */ |
#define fast_putc(x,p) (--(p)->_w < 0 ? \ |
__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0)) |
#define L_cuserid 9 /* posix says it goes in stdio.h :( */ |
#ifdef __CYGWIN__ |
#define L_ctermid 16 |
#endif |
#endif |
#endif /* !__CUSTOM_FILE_IO__ */ |
#define getchar() getc(stdin) |
#define putchar(x) putc(x, stdout) |
_END_STD_C |
#endif /* _STDIO_H_ */ |
/programs/develop/libraries/newlib/include/stdlib.h |
---|
0,0 → 1,226 |
/* |
* stdlib.h |
* |
* Definitions for common types, variables, and functions. |
*/ |
#ifndef _STDLIB_H_ |
#define _STDLIB_H_ |
#include <machine/ieeefp.h> |
#include "_ansi.h" |
#define __need_size_t |
#define __need_wchar_t |
#include <stddef.h> |
#include <sys/reent.h> |
#include <machine/stdlib.h> |
#ifndef __STRICT_ANSI__ |
#include <alloca.h> |
#endif |
#ifdef __CYGWIN__ |
#include <cygwin/stdlib.h> |
#endif |
_BEGIN_STD_C |
typedef struct |
{ |
int quot; /* quotient */ |
int rem; /* remainder */ |
} div_t; |
typedef struct |
{ |
long quot; /* quotient */ |
long rem; /* remainder */ |
} ldiv_t; |
#ifndef __STRICT_ANSI__ |
typedef struct |
{ |
long long int quot; /* quotient */ |
long long int rem; /* remainder */ |
} lldiv_t; |
#endif |
#ifndef NULL |
#define NULL 0 |
#endif |
#define EXIT_FAILURE 1 |
#define EXIT_SUCCESS 0 |
#define RAND_MAX __RAND_MAX |
int _EXFUN(__locale_mb_cur_max,(_VOID)); |
#define MB_CUR_MAX __locale_mb_cur_max() |
_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); |
int _EXFUN(abs,(int)); |
int _EXFUN(atexit,(_VOID (*__func)(_VOID))); |
double _EXFUN(atof,(const char *__nptr)); |
#ifndef __STRICT_ANSI__ |
float _EXFUN(atoff,(const char *__nptr)); |
#endif |
int _EXFUN(atoi,(const char *__nptr)); |
int _EXFUN(_atoi_r,(struct _reent *, const char *__nptr)); |
long _EXFUN(atol,(const char *__nptr)); |
long _EXFUN(_atol_r,(struct _reent *, const char *__nptr)); |
_PTR _EXFUN(bsearch,(const _PTR __key, |
const _PTR __base, |
size_t __nmemb, |
size_t __size, |
int _EXFNPTR(_compar,(const _PTR, const _PTR)))); |
_PTR _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size)); |
div_t _EXFUN(div,(int __numer, int __denom)); |
_VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn))); |
_VOID _EXFUN_NOTHROW(free,(_PTR)); |
char * _EXFUN(getenv,(const char *__string)); |
char * _EXFUN(_getenv_r,(struct _reent *, const char *__string)); |
char * _EXFUN(_findenv,(_CONST char *, int *)); |
char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *)); |
#ifndef __STRICT_ANSI__ |
extern char *suboptarg; /* getsubopt(3) external variable */ |
int _EXFUN(getsubopt,(char **, char * const *, char **)); |
#endif |
long _EXFUN(labs,(long)); |
ldiv_t _EXFUN(ldiv,(long __numer, long __denom)); |
_PTR _EXFUN_NOTHROW(malloc,(size_t __size)); |
int _EXFUN(mblen,(const char *, size_t)); |
int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *)); |
int _EXFUN(mbtowc,(wchar_t *, const char *, size_t)); |
int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); |
int _EXFUN(wctomb,(char *, wchar_t)); |
int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *)); |
size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t)); |
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); |
size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t)); |
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *)); |
#ifndef __STRICT_ANSI__ |
#ifndef _REENT_ONLY |
char * _EXFUN(mkdtemp,(char *)); |
int _EXFUN(mkostemp,(char *, int)); |
int _EXFUN(mkostemps,(char *, int, int)); |
int _EXFUN(mkstemp,(char *)); |
int _EXFUN(mkstemps,(char *, int)); |
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")))); |
#endif |
char * _EXFUN(_mkdtemp_r, (struct _reent *, char *)); |
int _EXFUN(_mkostemp_r, (struct _reent *, char *, int)); |
int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int)); |
int _EXFUN(_mkstemp_r, (struct _reent *, char *)); |
int _EXFUN(_mkstemps_r, (struct _reent *, char *, int)); |
char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")))); |
#endif |
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR))); |
int _EXFUN(rand,(_VOID)); |
_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size)); |
#ifndef __STRICT_ANSI__ |
_PTR _EXFUN(reallocf,(_PTR __r, size_t __size)); |
#endif |
_VOID _EXFUN(srand,(unsigned __seed)); |
double _EXFUN(strtod,(const char *__n, char **__end_PTR)); |
double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR)); |
float _EXFUN(strtof,(const char *__n, char **__end_PTR)); |
#ifndef __STRICT_ANSI__ |
/* the following strtodf interface is deprecated...use strtof instead */ |
# ifndef strtodf |
# define strtodf strtof |
# endif |
#endif |
long _EXFUN(strtol,(const char *__n, char **__end_PTR, int __base)); |
long _EXFUN(_strtol_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); |
unsigned long _EXFUN(strtoul,(const char *__n, char **__end_PTR, int __base)); |
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); |
int _EXFUN(system,(const char *__string)); |
#ifndef __STRICT_ANSI__ |
long _EXFUN(a64l,(const char *__input)); |
char * _EXFUN(l64a,(long __input)); |
char * _EXFUN(_l64a_r,(struct _reent *,long __input)); |
int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg)); |
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn))); |
int _EXFUN(putenv,(char *__string)); |
int _EXFUN(_putenv_r,(struct _reent *, char *__string)); |
_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t)); |
int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite)); |
int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite)); |
char * _EXFUN(gcvt,(double,int,char *)); |
char * _EXFUN(gcvtf,(float,int,char *)); |
char * _EXFUN(fcvt,(double,int,int *,int *)); |
char * _EXFUN(fcvtf,(float,int,int *,int *)); |
char * _EXFUN(ecvt,(double,int,int *,int *)); |
char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *)); |
char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *)); |
char * _EXFUN(ecvtf,(float,int,int *,int *)); |
char * _EXFUN(dtoa,(double, int, int, int *, int*, char**)); |
int _EXFUN(rand_r,(unsigned *__seed)); |
double _EXFUN(drand48,(_VOID)); |
double _EXFUN(_drand48_r,(struct _reent *)); |
double _EXFUN(erand48,(unsigned short [3])); |
double _EXFUN(_erand48_r,(struct _reent *, unsigned short [3])); |
long _EXFUN(jrand48,(unsigned short [3])); |
long _EXFUN(_jrand48_r,(struct _reent *, unsigned short [3])); |
_VOID _EXFUN(lcong48,(unsigned short [7])); |
_VOID _EXFUN(_lcong48_r,(struct _reent *, unsigned short [7])); |
long _EXFUN(lrand48,(_VOID)); |
long _EXFUN(_lrand48_r,(struct _reent *)); |
long _EXFUN(mrand48,(_VOID)); |
long _EXFUN(_mrand48_r,(struct _reent *)); |
long _EXFUN(nrand48,(unsigned short [3])); |
long _EXFUN(_nrand48_r,(struct _reent *, unsigned short [3])); |
unsigned short * |
_EXFUN(seed48,(unsigned short [3])); |
unsigned short * |
_EXFUN(_seed48_r,(struct _reent *, unsigned short [3])); |
_VOID _EXFUN(srand48,(long)); |
_VOID _EXFUN(_srand48_r,(struct _reent *, long)); |
long long _EXFUN(atoll,(const char *__nptr)); |
long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr)); |
long long _EXFUN(llabs,(long long)); |
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom)); |
long long _EXFUN(strtoll,(const char *__n, char **__end_PTR, int __base)); |
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); |
unsigned long long _EXFUN(strtoull,(const char *__n, char **__end_PTR, int __base)); |
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); |
#ifndef __CYGWIN__ |
_VOID _EXFUN(cfree,(_PTR)); |
int _EXFUN(unsetenv,(const char *__string)); |
int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string)); |
#endif |
#ifdef __rtems__ |
int _EXFUN(posix_memalign,(void **, size_t, size_t)); |
#endif |
#endif /* ! __STRICT_ANSI__ */ |
char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); |
#ifndef __CYGWIN__ |
_PTR _EXFUN_NOTHROW(_malloc_r,(struct _reent *, size_t)); |
_PTR _EXFUN_NOTHROW(_calloc_r,(struct _reent *, size_t, size_t)); |
_VOID _EXFUN_NOTHROW(_free_r,(struct _reent *, _PTR)); |
_PTR _EXFUN_NOTHROW(_realloc_r,(struct _reent *, _PTR, size_t)); |
_VOID _EXFUN(_mstats_r,(struct _reent *, char *)); |
#endif |
int _EXFUN(_system_r,(struct _reent *, const char *)); |
_VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); |
/* On platforms where long double equals double. */ |
#ifdef _LDBL_EQ_DBL |
extern long double strtold (const char *, char **); |
extern long double wcstold (const wchar_t *, wchar_t **); |
#endif /* _LDBL_EQ_DBL */ |
_END_STD_C |
#endif /* _STDLIB_H_ */ |
/programs/develop/libraries/newlib/include/string.h |
---|
0,0 → 1,104 |
/* |
* string.h |
* |
* Definitions for memory and string functions. |
*/ |
#ifndef _STRING_H_ |
#define _STRING_H_ |
#include "_ansi.h" |
#include <sys/reent.h> |
#define __need_size_t |
#include <stddef.h> |
#ifndef NULL |
#define NULL 0 |
#endif |
_BEGIN_STD_C |
_PTR _EXFUN(memchr,(const _PTR, int, size_t)); |
int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); |
_PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t)); |
_PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); |
_PTR _EXFUN(memset,(_PTR, int, size_t)); |
char *_EXFUN(strcat,(char *, const char *)); |
char *_EXFUN(strchr,(const char *, int)); |
int _EXFUN(strcmp,(const char *, const char *)); |
int _EXFUN(strcoll,(const char *, const char *)); |
char *_EXFUN(strcpy,(char *, const char *)); |
size_t _EXFUN(strcspn,(const char *, const char *)); |
char *_EXFUN(strerror,(int)); |
size_t _EXFUN(strlen,(const char *)); |
char *_EXFUN(strncat,(char *, const char *, size_t)); |
int _EXFUN(strncmp,(const char *, const char *, size_t)); |
char *_EXFUN(strncpy,(char *, const char *, size_t)); |
char *_EXFUN(strpbrk,(const char *, const char *)); |
char *_EXFUN(strrchr,(const char *, int)); |
size_t _EXFUN(strspn,(const char *, const char *)); |
char *_EXFUN(strstr,(const char *, const char *)); |
#ifndef _REENT_ONLY |
char *_EXFUN(strtok,(char *, const char *)); |
#endif |
size_t _EXFUN(strxfrm,(char *, const char *, size_t)); |
#ifndef __STRICT_ANSI__ |
char *_EXFUN(strtok_r,(char *, const char *, char **)); |
int _EXFUN(bcmp,(const void *, const void *, size_t)); |
void _EXFUN(bcopy,(const void *, void *, size_t)); |
void _EXFUN(bzero,(void *, size_t)); |
int _EXFUN(ffs,(int)); |
char *_EXFUN(index,(const char *, int)); |
_PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t)); |
_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); |
_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); |
char *_EXFUN(rindex,(const char *, int)); |
char *_EXFUN(stpcpy,(char *, const char *)); |
char *_EXFUN(stpncpy,(char *, const char *, size_t)); |
int _EXFUN(strcasecmp,(const char *, const char *)); |
char *_EXFUN(strcasestr,(const char *, const char *)); |
char *_EXFUN(strdup,(const char *)); |
char *_EXFUN(_strdup_r,(struct _reent *, const char *)); |
char *_EXFUN(strndup,(const char *, size_t)); |
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); |
char *_EXFUN(strerror_r,(int, char *, size_t)); |
size_t _EXFUN(strlcat,(char *, const char *, size_t)); |
size_t _EXFUN(strlcpy,(char *, const char *, size_t)); |
int _EXFUN(strncasecmp,(const char *, const char *, size_t)); |
size_t _EXFUN(strnlen,(const char *, size_t)); |
char *_EXFUN(strsep,(char **, const char *)); |
char *_EXFUN(strlwr,(char *)); |
char *_EXFUN(strupr,(char *)); |
#ifdef __CYGWIN__ |
#ifndef DEFS_H /* Kludge to work around problem compiling in gdb */ |
char *_EXFUN(strsignal, (int __signo)); |
#endif |
int _EXFUN(strtosigno, (const char *__name)); |
#endif |
/* These function names are used on Windows and perhaps other systems. */ |
#ifndef strcmpi |
#define strcmpi strcasecmp |
#endif |
#ifndef stricmp |
#define stricmp strcasecmp |
#endif |
#ifndef strncmpi |
#define strncmpi strncasecmp |
#endif |
#ifndef strnicmp |
#define strnicmp strncasecmp |
#endif |
#endif /* ! __STRICT_ANSI__ */ |
#include <sys/string.h> |
_END_STD_C |
#endif /* _STRING_H_ */ |
/programs/develop/libraries/newlib/include/sys/_default_fcntl.h |
---|
0,0 → 1,204 |
#ifndef _SYS__DEFAULT_FCNTL_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS__DEFAULT_FCNTL_H_ |
#include <_ansi.h> |
#define _FOPEN (-1) /* from sys/file.h, kernel use only */ |
#define _FREAD 0x0001 /* read enabled */ |
#define _FWRITE 0x0002 /* write enabled */ |
#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ |
#define _FMARK 0x0010 /* internal; mark during gc() */ |
#define _FDEFER 0x0020 /* internal; defer for next gc pass */ |
#define _FASYNC 0x0040 /* signal pgrp when data ready */ |
#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ |
#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ |
#define _FCREAT 0x0200 /* open with file create */ |
#define _FTRUNC 0x0400 /* open with truncation */ |
#define _FEXCL 0x0800 /* error on open if file exists */ |
#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ |
#define _FSYNC 0x2000 /* do all writes synchronously */ |
#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ |
#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ |
#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ |
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) |
/* |
* Flag values for open(2) and fcntl(2) |
* The kernel adds 1 to the open modes to turn it into some |
* combination of FREAD and FWRITE. |
*/ |
#define O_RDONLY 0 /* +1 == FREAD */ |
#define O_WRONLY 1 /* +1 == FWRITE */ |
#define O_RDWR 2 /* +1 == FREAD|FWRITE */ |
#define O_APPEND _FAPPEND |
#define O_CREAT _FCREAT |
#define O_TRUNC _FTRUNC |
#define O_EXCL _FEXCL |
#define O_SYNC _FSYNC |
/* O_NDELAY _FNDELAY set in include/fcntl.h */ |
/* O_NDELAY _FNBIO set in include/fcntl.h */ |
#define O_NONBLOCK _FNONBLOCK |
#define O_NOCTTY _FNOCTTY |
/* For machines which care - */ |
#if defined (_WIN32) || defined (__CYGWIN__) |
#define _FBINARY 0x10000 |
#define _FTEXT 0x20000 |
#define _FNOINHERIT 0x40000 |
#define O_BINARY _FBINARY |
#define O_TEXT _FTEXT |
#define O_NOINHERIT _FNOINHERIT |
/* O_CLOEXEC is the Linux equivalent to O_NOINHERIT */ |
#define O_CLOEXEC _FNOINHERIT |
/* The windows header files define versions with a leading underscore. */ |
#define _O_RDONLY O_RDONLY |
#define _O_WRONLY O_WRONLY |
#define _O_RDWR O_RDWR |
#define _O_APPEND O_APPEND |
#define _O_CREAT O_CREAT |
#define _O_TRUNC O_TRUNC |
#define _O_EXCL O_EXCL |
#define _O_TEXT O_TEXT |
#define _O_BINARY O_BINARY |
#define _O_RAW O_BINARY |
#define _O_NOINHERIT O_NOINHERIT |
#endif |
#ifndef _POSIX_SOURCE |
/* |
* Flags that work for fcntl(fd, F_SETFL, FXXXX) |
*/ |
#define FAPPEND _FAPPEND |
#define FSYNC _FSYNC |
#define FASYNC _FASYNC |
#define FNBIO _FNBIO |
#define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */ |
#define FNDELAY _FNDELAY |
/* |
* Flags that are disallowed for fcntl's (FCNTLCANT); |
* used for opens, internal state, or locking. |
*/ |
#define FREAD _FREAD |
#define FWRITE _FWRITE |
#define FMARK _FMARK |
#define FDEFER _FDEFER |
#define FSHLOCK _FSHLOCK |
#define FEXLOCK _FEXLOCK |
/* |
* The rest of the flags, used only for opens |
*/ |
#define FOPEN _FOPEN |
#define FCREAT _FCREAT |
#define FTRUNC _FTRUNC |
#define FEXCL _FEXCL |
#define FNOCTTY _FNOCTTY |
#endif /* !_POSIX_SOURCE */ |
/* XXX close on exec request; must match UF_EXCLOSE in user.h */ |
#define FD_CLOEXEC 1 /* posix */ |
/* fcntl(2) requests */ |
#define F_DUPFD 0 /* Duplicate fildes */ |
#define F_GETFD 1 /* Get fildes flags (close on exec) */ |
#define F_SETFD 2 /* Set fildes flags (close on exec) */ |
#define F_GETFL 3 /* Get file flags */ |
#define F_SETFL 4 /* Set file flags */ |
#ifndef _POSIX_SOURCE |
#define F_GETOWN 5 /* Get owner - for ASYNC */ |
#define F_SETOWN 6 /* Set owner - for ASYNC */ |
#endif /* !_POSIX_SOURCE */ |
#define F_GETLK 7 /* Get record-locking information */ |
#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */ |
#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */ |
#ifndef _POSIX_SOURCE |
#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */ |
#define F_RSETLK 11 /* Set or unlock a remote lock */ |
#define F_CNVT 12 /* Convert a fhandle to an open fd */ |
#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */ |
#endif /* !_POSIX_SOURCE */ |
#ifdef __CYGWIN__ |
#define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */ |
#endif |
/* fcntl(2) flags (l_type field of flock structure) */ |
#define F_RDLCK 1 /* read lock */ |
#define F_WRLCK 2 /* write lock */ |
#define F_UNLCK 3 /* remove lock(s) */ |
#ifndef _POSIX_SOURCE |
#define F_UNLKSYS 4 /* remove remote locks for a given system */ |
#endif /* !_POSIX_SOURCE */ |
#ifdef __CYGWIN__ |
/* Special descriptor value to denote the cwd in calls to openat(2) etc. */ |
#define AT_FDCWD -2 |
/* Flag values for faccessat2) et al. */ |
#define AT_EACCESS 1 |
#define AT_SYMLINK_NOFOLLOW 2 |
#define AT_SYMLINK_FOLLOW 4 |
#define AT_REMOVEDIR 8 |
#endif |
/*#include <sys/stdtypes.h>*/ |
#ifndef __CYGWIN__ |
/* file segment locking set data type - information passed to system by user */ |
struct flock { |
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ |
short l_whence; /* flag to choose starting offset */ |
long l_start; /* relative offset, in bytes */ |
long l_len; /* length, in bytes; 0 means lock to EOF */ |
short l_pid; /* returned with F_GETLK */ |
short l_xxx; /* reserved for future use */ |
}; |
#endif /* __CYGWIN__ */ |
#ifndef _POSIX_SOURCE |
/* extended file segment locking set data type */ |
struct eflock { |
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ |
short l_whence; /* flag to choose starting offset */ |
long l_start; /* relative offset, in bytes */ |
long l_len; /* length, in bytes; 0 means lock to EOF */ |
short l_pid; /* returned with F_GETLK */ |
short l_xxx; /* reserved for future use */ |
long l_rpid; /* Remote process id wanting this lock */ |
long l_rsys; /* Remote system id wanting this lock */ |
}; |
#endif /* !_POSIX_SOURCE */ |
#include <sys/types.h> |
#include <sys/stat.h> /* sigh. for the mode bits for open/creat */ |
extern int open _PARAMS ((const char *, int, ...)); |
extern int creat _PARAMS ((const char *, mode_t)); |
extern int fcntl _PARAMS ((int, int, ...)); |
#ifdef __CYGWIN__ |
#include <sys/time.h> |
extern int futimesat _PARAMS ((int, const char *, const struct timeval *)); |
extern int openat _PARAMS ((int, const char *, int, ...)); |
#endif |
/* Provide _<systemcall> prototypes for functions provided by some versions |
of newlib. */ |
#ifdef _COMPILING_NEWLIB |
extern int _open _PARAMS ((const char *, int, ...)); |
extern int _fcntl _PARAMS ((int, int, ...)); |
#ifdef __LARGE64_FILES |
extern int _open64 _PARAMS ((const char *, int, ...)); |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_SYS__DEFAULT_FCNTL_H_ */ |
/programs/develop/libraries/newlib/include/sys/_types.h |
---|
0,0 → 1,87 |
/* ANSI C namespace clean utility typedefs */ |
/* This file defines various typedefs needed by the system calls that support |
the C library. Basically, they're just the POSIX versions with an '_' |
prepended. This file lives in the `sys' directory so targets can provide |
their own if desired (or they can put target dependant conditionals here). |
*/ |
#ifndef _SYS__TYPES_H |
#define _SYS__TYPES_H |
#include <machine/_types.h> |
#include <sys/lock.h> |
#ifndef __off_t_defined |
typedef long _off_t; |
#endif |
#if defined(__rtems__) |
/* device numbers are 32-bit major and and 32-bit minor */ |
typedef unsigned long long __dev_t; |
#else |
#ifndef __dev_t_defined |
typedef short __dev_t; |
#endif |
#endif |
#ifndef __uid_t_defined |
typedef unsigned short __uid_t; |
#endif |
#ifndef __gid_t_defined |
typedef unsigned short __gid_t; |
#endif |
#ifndef __off64_t_defined |
__extension__ typedef long long _off64_t; |
#endif |
/* |
* We need fpos_t for the following, but it doesn't have a leading "_", |
* so we use _fpos_t instead. |
*/ |
#ifndef __fpos_t_defined |
typedef long _fpos_t; /* XXX must match off_t in <sys/types.h> */ |
/* (and must be `long' for now) */ |
#endif |
#ifdef __LARGE64_FILES |
#ifndef __fpos64_t_defined |
typedef _off64_t _fpos64_t; |
#endif |
#endif |
#ifndef __ssize_t_defined |
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647 |
typedef int _ssize_t; |
#else |
typedef long _ssize_t; |
#endif |
#endif |
#define __need_wint_t |
#include <stddef.h> |
#ifndef __mbstate_t_defined |
/* Conversion state information. */ |
typedef struct |
{ |
int __count; |
union |
{ |
wint_t __wch; |
unsigned char __wchb[4]; |
} __value; /* Value so far. */ |
} _mbstate_t; |
#endif |
#ifndef __flock_t_defined |
typedef _LOCK_RECURSIVE_T _flock_t; |
#endif |
#ifndef __iconv_t_defined |
/* Iconv descriptor type */ |
typedef void *_iconv_t; |
#endif |
#endif /* _SYS__TYPES_H */ |
/programs/develop/libraries/newlib/include/sys/cdefs.h |
---|
0,0 → 1,123 |
/* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */ |
/* Written 2000 by Werner Almesberger */ |
/* |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Berkeley Software Design, Inc. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)cdefs.h 8.8 (Berkeley) 1/9/95 |
* $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $ |
*/ |
#ifndef _SYS_CDEFS_H |
#define _SYS_CDEFS_H |
#define __FBSDID(x) /* nothing */ |
/* |
* Note: the goal here is not compatibility to K&R C. Since we know that we |
* have GCC which understands ANSI C perfectly well, we make use of this. |
*/ |
#define __P(args) args |
#define __PMT(args) args |
#define __const const |
#define __signed signed |
#define __volatile volatile |
#define __DOTS , ... |
#define __THROW |
#define __ptr_t void * |
#define __long_double_t long double |
#define __attribute_malloc__ |
#define __attribute_pure__ |
#define __attribute_format_strfmon__(a,b) |
#define __flexarr [0] |
#ifdef __cplusplus |
# define __BEGIN_DECLS extern "C" { |
# define __END_DECLS } |
#else |
# define __BEGIN_DECLS |
# define __END_DECLS |
#endif |
#ifndef __BOUNDED_POINTERS__ |
# define __bounded /* nothing */ |
# define __unbounded /* nothing */ |
# define __ptrvalue /* nothing */ |
#endif |
#ifdef __GNUC__ |
#define __strong_reference(sym,aliassym) \ |
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))); |
#ifdef __ELF__ |
#ifdef __STDC__ |
#define __weak_reference(sym,alias) \ |
__asm__(".weak " #alias); \ |
__asm__(".equ " #alias ", " #sym) |
#define __warn_references(sym,msg) \ |
__asm__(".section .gnu.warning." #sym); \ |
__asm__(".asciz \"" msg "\""); \ |
__asm__(".previous") |
#else |
#define __weak_reference(sym,alias) \ |
__asm__(".weak alias"); \ |
__asm__(".equ alias, sym") |
#define __warn_references(sym,msg) \ |
__asm__(".section .gnu.warning.sym"); \ |
__asm__(".asciz \"msg\""); \ |
__asm__(".previous") |
#endif /* __STDC__ */ |
#else /* !__ELF__ */ |
#ifdef __STDC__ |
#define __weak_reference(sym,alias) \ |
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \ |
__asm__(".stabs \"_" #sym "\",1,0,0,0") |
#define __warn_references(sym,msg) \ |
__asm__(".stabs \"" msg "\",30,0,0,0"); \ |
__asm__(".stabs \"_" #sym "\",1,0,0,0") |
#else |
#define __weak_reference(sym,alias) \ |
__asm__(".stabs \"_/**/alias\",11,0,0,0"); \ |
__asm__(".stabs \"_/**/sym\",1,0,0,0") |
#define __warn_references(sym,msg) \ |
__asm__(".stabs msg,30,0,0,0"); \ |
__asm__(".stabs \"_/**/sym\",1,0,0,0") |
#endif /* __STDC__ */ |
#endif /* __ELF__ */ |
#endif /* __GNUC__ */ |
#endif /* _SYS_CDEFS_H */ |
/programs/develop/libraries/newlib/include/sys/config.h |
---|
0,0 → 1,239 |
#ifndef __SYS_CONFIG_H__ |
#define __SYS_CONFIG_H__ |
#include <machine/ieeefp.h> /* floating point macros */ |
#include <sys/features.h> /* POSIX defs */ |
/* exceptions first */ |
#if defined(__H8500__) || defined(__W65__) |
#define __SMALL_BITFIELDS |
/* ??? This conditional is true for the h8500 and the w65, defining H8300 |
in those cases probably isn't the right thing to do. */ |
#define H8300 1 |
#endif |
/* 16 bit integer machines */ |
#if defined(__Z8001__) || defined(__Z8002__) || defined(__H8500__) || defined(__W65__) || defined (__mn10200__) || defined (__AVR__) |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX 32767 |
#define UINT_MAX 65535 |
#endif |
#if defined (__H8300__) || defined (__H8300H__) || defined(__H8300S__) || defined (__H8300SX__) |
#define __SMALL_BITFIELDS |
#define H8300 1 |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#endif |
#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__) |
#define __SMALL_BITFIELDS |
#endif |
#ifdef __W65__ |
#define __SMALL_BITFIELDS |
#endif |
#if defined(__D10V__) |
#define __SMALL_BITFIELDS |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define _POINTER_INT short |
#endif |
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__) |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define _POINTER_INT short |
#endif |
#ifdef ___AM29K__ |
#define _FLOAT_RET double |
#endif |
#ifdef __i386__ |
#ifndef __unix__ |
/* in other words, go32 */ |
#define _FLOAT_RET double |
#endif |
#if defined(__linux__) || defined(__RDOS__) |
/* we want the reentrancy structure to be returned by a function */ |
#define __DYNAMIC_REENT__ |
#define HAVE_GETDATE |
#define _HAVE_SYSTYPES |
#define _READ_WRITE_RETURN_TYPE _ssize_t |
#define __LARGE64_FILES 1 |
/* we use some glibc header files so turn on glibc large file feature */ |
#define _LARGEFILE64_SOURCE 1 |
#endif |
#endif |
#ifdef __mn10200__ |
#define __SMALL_BITFIELDS |
#endif |
#ifdef __AVR__ |
#define __SMALL_BITFIELDS |
#define _POINTER_INT short |
#endif |
#ifdef __v850 |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__sda__)) |
#endif |
/* For the PowerPC eabi, force the _impure_ptr to be in .sdata */ |
#if defined(__PPC__) |
#if defined(_CALL_SYSV) |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) |
#endif |
#ifdef __SPE__ |
#define _LONG_DOUBLE double |
#endif |
#endif |
/* Configure small REENT structure for Xilinx MicroBlaze platforms */ |
#if defined (__MICROBLAZE__) |
#ifndef _REENT_SMALL |
#define _REENT_SMALL |
#endif |
/* Xilinx XMK uses Unix98 mutex */ |
#ifdef __XMK__ |
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES |
#endif |
#endif |
#if defined(__mips__) && !defined(__rtems__) |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) |
#endif |
#ifdef __xstormy16__ |
#define __SMALL_BITFIELDS |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define MALLOC_ALIGNMENT 8 |
#define _POINTER_INT short |
#define __BUFSIZ__ 16 |
#define _REENT_SMALL |
#endif |
#ifdef __m32c__ |
#define __SMALL_BITFIELDS |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define MALLOC_ALIGNMENT 8 |
#if defined(__r8c_cpu__) || defined(__m16c_cpu__) |
#define _POINTER_INT short |
#else |
#define _POINTER_INT long |
#endif |
#define __BUFSIZ__ 16 |
#define _REENT_SMALL |
#endif /* __m32c__ */ |
#ifdef __SPU__ |
#define MALLOC_ALIGNMENT 16 |
#define __CUSTOM_FILE_IO__ |
#endif |
/* This block should be kept in sync with GCC's limits.h. The point |
of having these definitions here is to not include limits.h, which |
would pollute the user namespace, while still using types of the |
the correct widths when deciding how to define __int32_t and |
__int64_t. */ |
#ifndef __INT_MAX__ |
# ifdef INT_MAX |
# define __INT_MAX__ INT_MAX |
# else |
# define __INT_MAX__ 2147483647 |
# endif |
#endif |
#ifndef __LONG_MAX__ |
# ifdef LONG_MAX |
# define __LONG_MAX__ LONG_MAX |
# else |
# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) \ |
|| defined (__sparcv9) |
# define __LONG_MAX__ 9223372036854775807L |
# else |
# define __LONG_MAX__ 2147483647L |
# endif /* __alpha__ || sparc64 */ |
# endif |
#endif |
/* End of block that should be kept in sync with GCC's limits.h. */ |
#ifndef _POINTER_INT |
#define _POINTER_INT long |
#endif |
#ifdef __frv__ |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) |
#endif |
#undef __RAND_MAX |
#if __INT_MAX__ == 32767 |
#define __RAND_MAX 32767 |
#else |
#define __RAND_MAX 0x7fffffff |
#endif |
#if defined(__CYGWIN__) |
#include <cygwin/config.h> |
#if !defined (__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) |
#define __USE_XOPEN2K 1 |
#endif |
#endif |
#if defined(__rtems__) |
#define __FILENAME_MAX__ 255 |
#define _READ_WRITE_RETURN_TYPE _ssize_t |
#endif |
#ifndef __EXPORT |
#define __EXPORT |
#endif |
#ifndef __IMPORT |
#define __IMPORT |
#endif |
/* Define return type of read/write routines. In POSIX, the return type |
for read()/write() is "ssize_t" but legacy newlib code has been using |
"int" for some time. If not specified, "int" is defaulted. */ |
#ifndef _READ_WRITE_RETURN_TYPE |
#define _READ_WRITE_RETURN_TYPE int |
#endif |
#ifndef __WCHAR_MAX__ |
#if __INT_MAX__ == 32767 || defined (_WIN32) |
#define __WCHAR_MAX__ 0xffffu |
#endif |
#endif |
/* See if small reent asked for at configuration time and |
is not chosen by the platform by default. */ |
#ifdef _WANT_REENT_SMALL |
#ifndef _REENT_SMALL |
#define _REENT_SMALL |
#endif |
#endif |
/* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended |
charsets. The extended charsets add a few functions and a couple |
of tables of a few K each. */ |
#ifdef _MB_EXTENDED_CHARSETS_ALL |
#define _MB_EXTENDED_CHARSETS_ISO 1 |
#define _MB_EXTENDED_CHARSETS_WINDOWS 1 |
#endif |
#endif /* __SYS_CONFIG_H__ */ |
/programs/develop/libraries/newlib/include/sys/custom_file.h |
---|
0,0 → 1,2 |
#error System-specific custom_file.h is missing. |
/programs/develop/libraries/newlib/include/sys/dir.h |
---|
0,0 → 1,10 |
/* BSD predecessor of POSIX.1 <dirent.h> and struct dirent */ |
#ifndef _SYS_DIR_H_ |
#define _SYS_DIR_H_ |
#include <dirent.h> |
#define direct dirent |
#endif /*_SYS_DIR_H_*/ |
/programs/develop/libraries/newlib/include/sys/dirent.h |
---|
0,0 → 1,13 |
/* <dirent.h> includes <sys/dirent.h>, which is this file. On a |
system which supports <dirent.h>, this file is overridden by |
dirent.h in the libc/sys/.../sys directory. On a system which does |
not support <dirent.h>, we will get this file which uses #error to force |
an error. */ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#error "<dirent.h> not supported" |
#ifdef __cplusplus |
} |
#endif |
/programs/develop/libraries/newlib/include/sys/errno.h |
---|
0,0 → 1,190 |
/* errno is not a global variable, because that would make using it |
non-reentrant. Instead, its address is returned by the function |
__errno. */ |
#ifndef _SYS_ERRNO_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_ERRNO_H_ |
#include <sys/reent.h> |
#ifndef _REENT_ONLY |
#define errno (*__errno()) |
extern int *__errno _PARAMS ((void)); |
#endif |
/* Please don't use these variables directly. |
Use strerror instead. */ |
extern __IMPORT _CONST char * _CONST _sys_errlist[]; |
extern __IMPORT int _sys_nerr; |
#ifdef __CYGWIN__ |
extern __IMPORT const char * const sys_errlist[]; |
extern __IMPORT int sys_nerr; |
#endif |
#define __errno_r(ptr) ((ptr)->_errno) |
#define EPERM 1 /* Not super-user */ |
#define ENOENT 2 /* No such file or directory */ |
#define ESRCH 3 /* No such process */ |
#define EINTR 4 /* Interrupted system call */ |
#define EIO 5 /* I/O error */ |
#define ENXIO 6 /* No such device or address */ |
#define E2BIG 7 /* Arg list too long */ |
#define ENOEXEC 8 /* Exec format error */ |
#define EBADF 9 /* Bad file number */ |
#define ECHILD 10 /* No children */ |
#define EAGAIN 11 /* No more processes */ |
#define ENOMEM 12 /* Not enough core */ |
#define EACCES 13 /* Permission denied */ |
#define EFAULT 14 /* Bad address */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENOTBLK 15 /* Block device required */ |
#endif |
#define EBUSY 16 /* Mount device busy */ |
#define EEXIST 17 /* File exists */ |
#define EXDEV 18 /* Cross-device link */ |
#define ENODEV 19 /* No such device */ |
#define ENOTDIR 20 /* Not a directory */ |
#define EISDIR 21 /* Is a directory */ |
#define EINVAL 22 /* Invalid argument */ |
#define ENFILE 23 /* Too many open files in system */ |
#define EMFILE 24 /* Too many open files */ |
#define ENOTTY 25 /* Not a typewriter */ |
#define ETXTBSY 26 /* Text file busy */ |
#define EFBIG 27 /* File too large */ |
#define ENOSPC 28 /* No space left on device */ |
#define ESPIPE 29 /* Illegal seek */ |
#define EROFS 30 /* Read only file system */ |
#define EMLINK 31 /* Too many links */ |
#define EPIPE 32 /* Broken pipe */ |
#define EDOM 33 /* Math arg out of domain of func */ |
#define ERANGE 34 /* Math result not representable */ |
#define ENOMSG 35 /* No message of desired type */ |
#define EIDRM 36 /* Identifier removed */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ECHRNG 37 /* Channel number out of range */ |
#define EL2NSYNC 38 /* Level 2 not synchronized */ |
#define EL3HLT 39 /* Level 3 halted */ |
#define EL3RST 40 /* Level 3 reset */ |
#define ELNRNG 41 /* Link number out of range */ |
#define EUNATCH 42 /* Protocol driver not attached */ |
#define ENOCSI 43 /* No CSI structure available */ |
#define EL2HLT 44 /* Level 2 halted */ |
#endif |
#define EDEADLK 45 /* Deadlock condition */ |
#define ENOLCK 46 /* No record locks available */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define EBADE 50 /* Invalid exchange */ |
#define EBADR 51 /* Invalid request descriptor */ |
#define EXFULL 52 /* Exchange full */ |
#define ENOANO 53 /* No anode */ |
#define EBADRQC 54 /* Invalid request code */ |
#define EBADSLT 55 /* Invalid slot */ |
#define EDEADLOCK 56 /* File locking deadlock error */ |
#define EBFONT 57 /* Bad font file fmt */ |
#endif |
#define ENOSTR 60 /* Device not a stream */ |
#define ENODATA 61 /* No data (for no delay io) */ |
#define ETIME 62 /* Timer expired */ |
#define ENOSR 63 /* Out of streams resources */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENONET 64 /* Machine is not on the network */ |
#define ENOPKG 65 /* Package not installed */ |
#define EREMOTE 66 /* The object is remote */ |
#endif |
#define ENOLINK 67 /* The link has been severed */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define EADV 68 /* Advertise error */ |
#define ESRMNT 69 /* Srmount error */ |
#define ECOMM 70 /* Communication error on send */ |
#endif |
#define EPROTO 71 /* Protocol error */ |
#define EMULTIHOP 74 /* Multihop attempted */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ELBIN 75 /* Inode is remote (not really error) */ |
#define EDOTDOT 76 /* Cross mount point (not really error) */ |
#endif |
#define EBADMSG 77 /* Trying to read unreadable message */ |
#define EFTYPE 79 /* Inappropriate file type or format */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENOTUNIQ 80 /* Given log. name not unique */ |
#define EBADFD 81 /* f.d. invalid for this operation */ |
#define EREMCHG 82 /* Remote address changed */ |
#define ELIBACC 83 /* Can't access a needed shared lib */ |
#define ELIBBAD 84 /* Accessing a corrupted shared lib */ |
#define ELIBSCN 85 /* .lib section in a.out corrupted */ |
#define ELIBMAX 86 /* Attempting to link in too many libs */ |
#define ELIBEXEC 87 /* Attempting to exec a shared library */ |
#endif |
#define ENOSYS 88 /* Function not implemented */ |
#ifdef __CYGWIN__ |
#define ENMFILE 89 /* No more files */ |
#endif |
#define ENOTEMPTY 90 /* Directory not empty */ |
#define ENAMETOOLONG 91 /* File or path name too long */ |
#define ELOOP 92 /* Too many symbolic links */ |
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ |
#define EPFNOSUPPORT 96 /* Protocol family not supported */ |
#define ECONNRESET 104 /* Connection reset by peer */ |
#define ENOBUFS 105 /* No buffer space available */ |
#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */ |
#define EPROTOTYPE 107 /* Protocol wrong type for socket */ |
#define ENOTSOCK 108 /* Socket operation on non-socket */ |
#define ENOPROTOOPT 109 /* Protocol not available */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ESHUTDOWN 110 /* Can't send after socket shutdown */ |
#endif |
#define ECONNREFUSED 111 /* Connection refused */ |
#define EADDRINUSE 112 /* Address already in use */ |
#define ECONNABORTED 113 /* Connection aborted */ |
#define ENETUNREACH 114 /* Network is unreachable */ |
#define ENETDOWN 115 /* Network interface is not configured */ |
#define ETIMEDOUT 116 /* Connection timed out */ |
#define EHOSTDOWN 117 /* Host is down */ |
#define EHOSTUNREACH 118 /* Host is unreachable */ |
#define EINPROGRESS 119 /* Connection already in progress */ |
#define EALREADY 120 /* Socket already connected */ |
#define EDESTADDRREQ 121 /* Destination address required */ |
#define EMSGSIZE 122 /* Message too long */ |
#define EPROTONOSUPPORT 123 /* Unknown protocol */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ESOCKTNOSUPPORT 124 /* Socket type not supported */ |
#endif |
#define EADDRNOTAVAIL 125 /* Address not available */ |
#define ENETRESET 126 |
#define EISCONN 127 /* Socket is already connected */ |
#define ENOTCONN 128 /* Socket is not connected */ |
#define ETOOMANYREFS 129 |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define EPROCLIM 130 |
#define EUSERS 131 |
#endif |
#define EDQUOT 132 |
#define ESTALE 133 |
#define ENOTSUP 134 /* Not supported */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENOMEDIUM 135 /* No medium (in tape drive) */ |
#endif |
#ifdef __CYGWIN__ |
#define ENOSHARE 136 /* No such host or network path */ |
#define ECASECLASH 137 /* Filename exists with different case */ |
#endif |
#define EILSEQ 138 |
#define EOVERFLOW 139 /* Value too large for defined data type */ |
#define ECANCELED 140 /* Operation canceled */ |
#define ENOTRECOVERABLE 141 /* State not recoverable */ |
#define EOWNERDEAD 142 /* Previous owner died */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ESTRPIPE 143 /* Streams pipe error */ |
#endif |
#define EWOULDBLOCK EAGAIN /* Operation would block */ |
#define __ELASTERROR 2000 /* Users can add values starting here */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_ERRNO_H */ |
/programs/develop/libraries/newlib/include/sys/fcntl.h |
---|
0,0 → 1,4 |
#ifndef _SYS_FCNTL_H_ |
#define _SYS_FCNTL_H_ |
#include <sys/_default_fcntl.h> |
#endif |
/programs/develop/libraries/newlib/include/sys/features.h |
---|
0,0 → 1,205 |
/* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2000. |
* |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: features.h,v 1.22 2010/08/09 08:29:22 corinna Exp $ |
*/ |
#ifndef _SYS_FEATURES_H |
#define _SYS_FEATURES_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */ |
#ifdef __rtems__ |
#define _POSIX_JOB_CONTROL 1 |
#define _POSIX_SAVED_IDS 1 |
#define _POSIX_VERSION 199309L |
#define _POSIX_ASYNCHRONOUS_IO 1 |
#define _POSIX_FSYNC 1 |
#define _POSIX_MAPPED_FILES 1 |
#define _POSIX_MEMLOCK 1 |
#define _POSIX_MEMLOCK_RANGE 1 |
#define _POSIX_MEMORY_PROTECTION 1 |
#define _POSIX_MESSAGE_PASSING 1 |
#define _POSIX_MONOTONIC_CLOCK 200112L |
#define _POSIX_PRIORITIZED_IO 1 |
#define _POSIX_PRIORITY_SCHEDULING 1 |
#define _POSIX_REALTIME_SIGNALS 1 |
#define _POSIX_SEMAPHORES 1 |
/* #define _POSIX_SHARED_MEMORY_OBJECTS 1 */ |
#define _POSIX_SYNCHRONIZED_IO 1 |
#define _POSIX_TIMERS 1 |
#define _POSIX_BARRIERS 200112L |
#define _POSIX_READER_WRITER_LOCKS 200112L |
#define _POSIX_SPIN_LOCKS 200112L |
/* In P1003.1b but defined by drafts at least as early as P1003.1c/D10 */ |
#define _POSIX_THREADS 1 |
#define _POSIX_THREAD_ATTR_STACKADDR 1 |
#define _POSIX_THREAD_ATTR_STACKSIZE 1 |
#define _POSIX_THREAD_PRIORITY_SCHEDULING 1 |
#define _POSIX_THREAD_PRIO_INHERIT 1 |
#define _POSIX_THREAD_PRIO_PROTECT 1 |
#define _POSIX_THREAD_PROCESS_SHARED 1 |
#define _POSIX_THREAD_SAFE_FUNCTIONS 1 |
/* P1003.4b/D8 defines the constants below this comment. */ |
#define _POSIX_SPAWN 1 |
#define _POSIX_TIMEOUTS 1 |
#define _POSIX_CPUTIME 1 |
#define _POSIX_THREAD_CPUTIME 1 |
#define _POSIX_SPORADIC_SERVER 1 |
#define _POSIX_THREAD_SPORADIC_SERVER 1 |
#define _POSIX_DEVICE_CONTROL 1 |
#define _POSIX_DEVCTL_DIRECTION 1 |
#define _POSIX_INTERRUPT_CONTROL 1 |
#define _POSIX_ADVISORY_INFO 1 |
/* UNIX98 added some new pthread mutex attributes */ |
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1 |
#endif |
/* XMK loosely adheres to POSIX -- 1003.1 */ |
#ifdef __XMK__ |
#define _POSIX_THREADS 1 |
#define _POSIX_THREAD_PRIORITY_SCHEDULING 1 |
#endif |
#ifdef __svr4__ |
# define _POSIX_JOB_CONTROL 1 |
# define _POSIX_SAVED_IDS 1 |
# define _POSIX_VERSION 199009L |
#endif |
#ifdef __CYGWIN__ |
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L |
#define _POSIX_VERSION 200112L |
#define _POSIX2_VERSION 200112L |
#define _XOPEN_VERSION 600 |
#define _POSIX_ADVISORY_INFO 200112L |
/* #define _POSIX_ASYNCHRONOUS_IO -1 */ |
/* #define _POSIX_BARRIERS -1 */ |
#define _POSIX_CHOWN_RESTRICTED 1 |
/* #define _POSIX_CLOCK_SELECTION -1 */ |
/* #define _POSIX_CPUTIME -1 */ |
#define _POSIX_FSYNC 200112L |
#define _POSIX_IPV6 200112L |
#define _POSIX_JOB_CONTROL 1 |
#define _POSIX_MAPPED_FILES 200112L |
/* #define _POSIX_MEMLOCK -1 */ |
#define _POSIX_MEMLOCK_RANGE 200112L |
#define _POSIX_MEMORY_PROTECTION 200112L |
#define _POSIX_MESSAGE_PASSING 200112L |
#define _POSIX_MONOTONIC_CLOCK 200112L |
#define _POSIX_NO_TRUNC 1 |
/* #define _POSIX_PRIORITIZED_IO -1 */ |
#define _POSIX_PRIORITY_SCHEDULING 200112L |
#define _POSIX_RAW_SOCKETS 200112L |
#define _POSIX_READER_WRITER_LOCKS 200112L |
#define _POSIX_REALTIME_SIGNALS 200112L |
#define _POSIX_REGEXP 1 |
#define _POSIX_SAVED_IDS 1 |
#define _POSIX_SEMAPHORES 200112L |
#define _POSIX_SHARED_MEMORY_OBJECTS 200112L |
#define _POSIX_SHELL 1 |
/* #define _POSIX_SPAWN -1 */ |
/* #define _POSIX_SPIN_LOCKS -1 */ |
/* #define _POSIX_SPORADIC_SERVER -1 */ |
#define _POSIX_SYNCHRONIZED_IO 200112L |
/* #define _POSIX_THREAD_ATTR_STACKADDR -1 */ |
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L |
/* #define _POSIX_THREAD_CPUTIME -1 */ |
/* #define _POSIX_THREAD_PRIO_INHERIT -1 */ |
/* #define _POSIX_THREAD_PRIO_PROTECT -1 */ |
#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L |
#define _POSIX_THREAD_PROCESS_SHARED 200112L |
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L |
/* #define _POSIX_THREAD_SPORADIC_SERVER -1 */ |
#define _POSIX_THREADS 200112L |
/* #define _POSIX_TIMEOUTS -1 */ |
#define _POSIX_TIMERS 1 |
/* #define _POSIX_TRACE -1 */ |
/* #define _POSIX_TRACE_EVENT_FILTER -1 */ |
/* #define _POSIX_TRACE_INHERIT -1 */ |
/* #define _POSIX_TRACE_LOG -1 */ |
/* #define _POSIX_TYPED_MEMORY_OBJECTS -1 */ |
#define _POSIX_VDISABLE '\0' |
#define _POSIX2_C_BIND 200112L |
#define _POSIX2_C_DEV 200112L |
#define _POSIX2_CHAR_TERM 200112L |
/* #define _POSIX2_FORT_DEV -1 */ |
/* #define _POSIX2_FORT_RUN -1 */ |
/* #define _POSIX2_LOCALEDEF -1 */ |
/* #define _POSIX2_PBS -1 */ |
/* #define _POSIX2_PBS_ACCOUNTING -1 */ |
/* #define _POSIX2_PBS_CHECKPOINT -1 */ |
/* #define _POSIX2_PBS_LOCATE -1 */ |
/* #define _POSIX2_PBS_MESSAGE -1 */ |
/* #define _POSIX2_PBS_TRACK -1 */ |
#define _POSIX2_SW_DEV 200112L |
#define _POSIX2_UPE 200112L |
#define _POSIX_V6_ILP32_OFF32 -1 |
#define _XBS5_ILP32_OFF32 _POSIX_V6_ILP32_OFF32 |
#define _POSIX_V6_ILP32_OFFBIG 1 |
#define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG |
#define _POSIX_V6_LP64_OFF64 -1 |
#define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64 |
#define _POSIX_V6_LPBIG_OFFBIG -1 |
#define _XBS5_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG |
#define _XOPEN_CRYPT 1 |
#define _XOPEN_ENH_I18N 1 |
/* #define _XOPEN_LEGACY -1 */ |
/* #define _XOPEN_REALTIME -1 */ |
/* #define _XOPEN_REALTIME_THREADS -1 */ |
#define _XOPEN_SHM 1 |
/* #define _XOPEN_STREAMS -1 */ |
/* #define _XOPEN_UNIX -1 */ |
#endif /* !__STRICT_ANSI__ || __cplusplus || __STDC_VERSION__ >= 199901L */ |
#endif /* __CYGWIN__ */ |
/* Per the permission given in POSIX.1-2008 section 2.2.1, define |
* _POSIX_C_SOURCE if _XOPEN_SOURCE is defined and _POSIX_C_SOURCE is not. |
* (_XOPEN_SOURCE indicates that XSI extensions are desired by an application.) |
* This permission is first granted in 2008, but use it for older ones, also. |
* Allow for _XOPEN_SOURCE to be empty (from the earliest form of it, before it |
* was required to have specific values). |
*/ |
#if !defined(_POSIX_C_SOURCE) && defined(_XOPEN_SOURCE) |
#if (_XOPEN_SOURCE - 0) == 700 /* POSIX.1-2008 */ |
#define _POSIX_C_SOURCE 200809L |
#elif (_XOPEN_SOURCE - 0) == 600 /* POSIX.1-2001 or 2004 */ |
#define _POSIX_C_SOURCE 200112L |
#elif (_XOPEN_SOURCE - 0) == 500 /* POSIX.1-1995 */ |
#define _POSIX_C_SOURCE 199506L |
#elif (_XOPEN_SOURCE - 0) < 500 /* really old */ |
#define _POSIX_C_SOURCE 2 |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_FEATURES_H */ |
/programs/develop/libraries/newlib/include/sys/file.h |
---|
0,0 → 1,2 |
#include <sys/fcntl.h> |
/programs/develop/libraries/newlib/include/sys/iconvnls.h |
---|
0,0 → 1,77 |
/* |
* Copyright (c) 2003-2004, Artem B. Bityuckiy. |
* Rights transferred to Franklin Electronic Publishers. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
/* |
* Funtions, macros, etc implimented in iconv library but used by other |
* NLS-related subsystems too. |
*/ |
#ifndef __SYS_ICONVNLS_H__ |
#define __SYS_ICONVNLS_H__ |
#include <_ansi.h> |
#include <reent.h> |
#include <wchar.h> |
#include <iconv.h> |
/* Iconv data path environment variable name */ |
#define NLS_ENVVAR_NAME "NLSPATH" |
/* Default NLSPATH value */ |
#define ICONV_DEFAULT_NLSPATH "/usr/locale" |
/* Direction markers */ |
#define ICONV_NLS_FROM 0 |
#define ICONV_NLS_TO 1 |
_VOID |
_EXFUN(_iconv_nls_get_state, (iconv_t cd, mbstate_t *ps, int direction)); |
int |
_EXFUN(_iconv_nls_set_state, (iconv_t cd, mbstate_t *ps, int direction)); |
int |
_EXFUN(_iconv_nls_is_stateful, (iconv_t cd, int direction)); |
int |
_EXFUN(_iconv_nls_get_mb_cur_max, (iconv_t cd, int direction)); |
size_t |
_EXFUN(_iconv_nls_conv, (struct _reent *rptr, iconv_t cd, |
_CONST char **inbuf, size_t *inbytesleft, |
char **outbuf, size_t *outbytesleft)); |
_CONST char * |
_EXFUN(_iconv_nls_construct_filename, (struct _reent *rptr, _CONST char *file, |
_CONST char *dir, _CONST char *ext)); |
int |
_EXFUN(_iconv_nls_open, (struct _reent *rptr, _CONST char *encoding, |
iconv_t *towc, iconv_t *fromwc, int flag)); |
char * |
_EXFUN(_iconv_resolve_encoding_name, (struct _reent *rptr, _CONST char *ca)); |
#endif /* __SYS_ICONVNLS_H__ */ |
/programs/develop/libraries/newlib/include/sys/lock.h |
---|
0,0 → 1,65 |
#ifndef __SYS_LOCK_H__ |
#define __SYS_LOCK_H__ |
#define _LIBC 1 |
#define NOT_IN_libc 1 |
#ifndef __USE_GNU |
#define __USE_GNU 1 |
#endif |
void __mutex_lock(volatile int *val); |
typedef volatile int __libc_lock_t; |
typedef struct { volatile int mutex; } __libc_lock_recursive_t; |
#define __libc_lock_define(CLASS,NAME) \ |
CLASS __libc_lock_t NAME; |
#define __libc_rwlock_define(CLASS,NAME) \ |
CLASS __libc_rwlock_t NAME; |
#define __libc_lock_define_recursive(CLASS,NAME) \ |
CLASS __libc_lock_recursive_t NAME; |
#define __rtld_lock_define_recursive(CLASS,NAME) \ |
CLASS __rtld_lock_recursive_t NAME; |
typedef __libc_lock_t _LOCK_T; |
typedef __libc_lock_recursive_t _LOCK_RECURSIVE_T; |
#define __LOCK_INIT(class,lock) \ |
__libc_lock_define_initialized(class, lock) |
#define __LOCK_INIT_RECURSIVE(class, lock) \ |
__libc_lock_define_initialized_recursive(class, lock) |
#define __libc_lock_define_initialized_recursive(CLASS,NAME) \ |
CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER; |
#define _LIBC_LOCK_RECURSIVE_INITIALIZER {0} |
#define __lock_init(__lock) __libc_lock_init(__lock) |
#define __lock_init_recursive(__lock) __libc_lock_init_recursive(__lock) |
#define __lock_acquire(__lock) __libc_lock_lock(__lock) |
#define __lock_acquire_recursive(__lock) __libc_lock_lock_recursive(__lock) |
#define __lock_release(__lock) __libc_lock_unlock(__lock) |
#define __lock_release_recursive(__lock) __libc_lock_unlock_recursive(__lock) |
#define __lock_try_acquire(__lock) __libc_lock_trylock(__lock) |
#define __lock_try_acquire_recursive(__lock) \ |
__libc_lock_trylock_recursive(__lock) |
#define __lock_close(__lock) __libc_lock_fini(__lock) |
#define __lock_close_recursive(__lock) __libc_lock_fini_recursive(__lock) |
#define __libc_lock_init_recursive(NAME) ((NAME).mutex=0) |
#define __libc_lock_fini(NAME) |
#define __libc_lock_fini_recursive(NAME) __libc_lock_fini ((NAME).mutex) |
#define __libc_lock_lock(NAME) __mutex_lock (&(NAME)) |
/* Lock the recursive named lock variable. */ |
#define __libc_lock_lock_recursive(NAME) __libc_lock_lock ((NAME).mutex) |
#define __libc_lock_unlock(NAME) ((NAME)=0) |
#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock ((NAME).mutex) |
#endif /* __SYS_LOCK_H__ */ |
/programs/develop/libraries/newlib/include/sys/param.h |
---|
0,0 → 1,25 |
/* This is a dummy <sys/param.h> file, not customized for any |
particular system. If there is a param.h in libc/sys/SYSDIR/sys, |
it will override this one. */ |
#ifndef _SYS_PARAM_H |
# define _SYS_PARAM_H |
#include <sys/config.h> |
#include <machine/endian.h> |
#include <machine/param.h> |
#ifndef HZ |
# define HZ (60) |
#endif |
#ifndef NOFILE |
# define NOFILE (60) |
#endif |
#ifndef PATHSIZE |
# define PATHSIZE (1024) |
#endif |
#define MAX(a,b) ((a) > (b) ? (a) : (b)) |
#define MIN(a,b) ((a) < (b) ? (a) : (b)) |
#endif |
/programs/develop/libraries/newlib/include/sys/queue.h |
---|
0,0 → 1,471 |
/* |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)queue.h 8.5 (Berkeley) 8/20/94 |
* $FreeBSD: src/sys/sys/queue.h,v 1.48 2002/04/17 14:00:37 tmm Exp $ |
*/ |
#ifndef _SYS_QUEUE_H_ |
#define _SYS_QUEUE_H_ |
#include <machine/ansi.h> /* for __offsetof */ |
/* |
* This file defines four types of data structures: singly-linked lists, |
* singly-linked tail queues, lists and tail queues. |
* |
* A singly-linked list is headed by a single forward pointer. The elements |
* are singly linked for minimum space and pointer manipulation overhead at |
* the expense of O(n) removal for arbitrary elements. New elements can be |
* added to the list after an existing element or at the head of the list. |
* Elements being removed from the head of the list should use the explicit |
* macro for this purpose for optimum efficiency. A singly-linked list may |
* only be traversed in the forward direction. Singly-linked lists are ideal |
* for applications with large datasets and few or no removals or for |
* implementing a LIFO queue. |
* |
* A singly-linked tail queue is headed by a pair of pointers, one to the |
* head of the list and the other to the tail of the list. The elements are |
* singly linked for minimum space and pointer manipulation overhead at the |
* expense of O(n) removal for arbitrary elements. New elements can be added |
* to the list after an existing element, at the head of the list, or at the |
* end of the list. Elements being removed from the head of the tail queue |
* should use the explicit macro for this purpose for optimum efficiency. |
* A singly-linked tail queue may only be traversed in the forward direction. |
* Singly-linked tail queues are ideal for applications with large datasets |
* and few or no removals or for implementing a FIFO queue. |
* |
* A list is headed by a single forward pointer (or an array of forward |
* pointers for a hash table header). The elements are doubly linked |
* so that an arbitrary element can be removed without a need to |
* traverse the list. New elements can be added to the list before |
* or after an existing element or at the head of the list. A list |
* may only be traversed in the forward direction. |
* |
* A tail queue is headed by a pair of pointers, one to the head of the |
* list and the other to the tail of the list. The elements are doubly |
* linked so that an arbitrary element can be removed without a need to |
* traverse the list. New elements can be added to the list before or |
* after an existing element, at the head of the list, or at the end of |
* the list. A tail queue may be traversed in either direction. |
* |
* For details on the use of these macros, see the queue(3) manual page. |
* |
* |
* SLIST LIST STAILQ TAILQ |
* _HEAD + + + + |
* _HEAD_INITIALIZER + + + + |
* _ENTRY + + + + |
* _INIT + + + + |
* _EMPTY + + + + |
* _FIRST + + + + |
* _NEXT + + + + |
* _PREV - - - + |
* _LAST - - + + |
* _FOREACH + + + + |
* _FOREACH_REVERSE - - - + |
* _INSERT_HEAD + + + + |
* _INSERT_BEFORE - + - + |
* _INSERT_AFTER + + + + |
* _INSERT_TAIL - - + + |
* _CONCAT - - + + |
* _REMOVE_HEAD + - + - |
* _REMOVE + + + + |
* |
*/ |
/* |
* Singly-linked List declarations. |
*/ |
#define SLIST_HEAD(name, type) \ |
struct name { \ |
struct type *slh_first; /* first element */ \ |
} |
#define SLIST_HEAD_INITIALIZER(head) \ |
{ NULL } |
#define SLIST_ENTRY(type) \ |
struct { \ |
struct type *sle_next; /* next element */ \ |
} |
/* |
* Singly-linked List functions. |
*/ |
#define SLIST_EMPTY(head) ((head)->slh_first == NULL) |
#define SLIST_FIRST(head) ((head)->slh_first) |
#define SLIST_FOREACH(var, head, field) \ |
for ((var) = SLIST_FIRST((head)); \ |
(var); \ |
(var) = SLIST_NEXT((var), field)) |
#define SLIST_INIT(head) do { \ |
SLIST_FIRST((head)) = NULL; \ |
} while (0) |
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ |
SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ |
SLIST_NEXT((slistelm), field) = (elm); \ |
} while (0) |
#define SLIST_INSERT_HEAD(head, elm, field) do { \ |
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ |
SLIST_FIRST((head)) = (elm); \ |
} while (0) |
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) |
#define SLIST_REMOVE(head, elm, type, field) do { \ |
if (SLIST_FIRST((head)) == (elm)) { \ |
SLIST_REMOVE_HEAD((head), field); \ |
} \ |
else { \ |
struct type *curelm = SLIST_FIRST((head)); \ |
while (SLIST_NEXT(curelm, field) != (elm)) \ |
curelm = SLIST_NEXT(curelm, field); \ |
SLIST_NEXT(curelm, field) = \ |
SLIST_NEXT(SLIST_NEXT(curelm, field), field); \ |
} \ |
} while (0) |
#define SLIST_REMOVE_HEAD(head, field) do { \ |
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ |
} while (0) |
/* |
* Singly-linked Tail queue declarations. |
*/ |
#define STAILQ_HEAD(name, type) \ |
struct name { \ |
struct type *stqh_first;/* first element */ \ |
struct type **stqh_last;/* addr of last next element */ \ |
} |
#define STAILQ_HEAD_INITIALIZER(head) \ |
{ NULL, &(head).stqh_first } |
#define STAILQ_ENTRY(type) \ |
struct { \ |
struct type *stqe_next; /* next element */ \ |
} |
/* |
* Singly-linked Tail queue functions. |
*/ |
#define STAILQ_CONCAT(head1, head2) do { \ |
if (!STAILQ_EMPTY((head2))) { \ |
*(head1)->stqh_last = (head2)->stqh_first; \ |
(head1)->stqh_last = (head2)->stqh_last; \ |
STAILQ_INIT((head2)); \ |
} \ |
} while (0) |
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) |
#define STAILQ_FIRST(head) ((head)->stqh_first) |
#define STAILQ_FOREACH(var, head, field) \ |
for((var) = STAILQ_FIRST((head)); \ |
(var); \ |
(var) = STAILQ_NEXT((var), field)) |
#define STAILQ_INIT(head) do { \ |
STAILQ_FIRST((head)) = NULL; \ |
(head)->stqh_last = &STAILQ_FIRST((head)); \ |
} while (0) |
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ |
if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ |
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ |
STAILQ_NEXT((tqelm), field) = (elm); \ |
} while (0) |
#define STAILQ_INSERT_HEAD(head, elm, field) do { \ |
if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ |
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ |
STAILQ_FIRST((head)) = (elm); \ |
} while (0) |
#define STAILQ_INSERT_TAIL(head, elm, field) do { \ |
STAILQ_NEXT((elm), field) = NULL; \ |
*(head)->stqh_last = (elm); \ |
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ |
} while (0) |
#define STAILQ_LAST(head, type, field) \ |
(STAILQ_EMPTY((head)) ? \ |
NULL : \ |
((struct type *) \ |
((char *)((head)->stqh_last) - __offsetof(struct type, field)))) |
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) |
#define STAILQ_REMOVE(head, elm, type, field) do { \ |
if (STAILQ_FIRST((head)) == (elm)) { \ |
STAILQ_REMOVE_HEAD((head), field); \ |
} \ |
else { \ |
struct type *curelm = STAILQ_FIRST((head)); \ |
while (STAILQ_NEXT(curelm, field) != (elm)) \ |
curelm = STAILQ_NEXT(curelm, field); \ |
if ((STAILQ_NEXT(curelm, field) = \ |
STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\ |
(head)->stqh_last = &STAILQ_NEXT((curelm), field);\ |
} \ |
} while (0) |
#define STAILQ_REMOVE_HEAD(head, field) do { \ |
if ((STAILQ_FIRST((head)) = \ |
STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ |
(head)->stqh_last = &STAILQ_FIRST((head)); \ |
} while (0) |
#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ |
if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \ |
(head)->stqh_last = &STAILQ_FIRST((head)); \ |
} while (0) |
/* |
* List declarations. |
*/ |
#define LIST_HEAD(name, type) \ |
struct name { \ |
struct type *lh_first; /* first element */ \ |
} |
#define LIST_HEAD_INITIALIZER(head) \ |
{ NULL } |
#define LIST_ENTRY(type) \ |
struct { \ |
struct type *le_next; /* next element */ \ |
struct type **le_prev; /* address of previous next element */ \ |
} |
/* |
* List functions. |
*/ |
#define LIST_EMPTY(head) ((head)->lh_first == NULL) |
#define LIST_FIRST(head) ((head)->lh_first) |
#define LIST_FOREACH(var, head, field) \ |
for ((var) = LIST_FIRST((head)); \ |
(var); \ |
(var) = LIST_NEXT((var), field)) |
#define LIST_INIT(head) do { \ |
LIST_FIRST((head)) = NULL; \ |
} while (0) |
#define LIST_INSERT_AFTER(listelm, elm, field) do { \ |
if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ |
LIST_NEXT((listelm), field)->field.le_prev = \ |
&LIST_NEXT((elm), field); \ |
LIST_NEXT((listelm), field) = (elm); \ |
(elm)->field.le_prev = &LIST_NEXT((listelm), field); \ |
} while (0) |
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ |
(elm)->field.le_prev = (listelm)->field.le_prev; \ |
LIST_NEXT((elm), field) = (listelm); \ |
*(listelm)->field.le_prev = (elm); \ |
(listelm)->field.le_prev = &LIST_NEXT((elm), field); \ |
} while (0) |
#define LIST_INSERT_HEAD(head, elm, field) do { \ |
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ |
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ |
LIST_FIRST((head)) = (elm); \ |
(elm)->field.le_prev = &LIST_FIRST((head)); \ |
} while (0) |
#define LIST_NEXT(elm, field) ((elm)->field.le_next) |
#define LIST_REMOVE(elm, field) do { \ |
if (LIST_NEXT((elm), field) != NULL) \ |
LIST_NEXT((elm), field)->field.le_prev = \ |
(elm)->field.le_prev; \ |
*(elm)->field.le_prev = LIST_NEXT((elm), field); \ |
} while (0) |
/* |
* Tail queue declarations. |
*/ |
#define TAILQ_HEAD(name, type) \ |
struct name { \ |
struct type *tqh_first; /* first element */ \ |
struct type **tqh_last; /* addr of last next element */ \ |
} |
#define TAILQ_HEAD_INITIALIZER(head) \ |
{ NULL, &(head).tqh_first } |
#define TAILQ_ENTRY(type) \ |
struct { \ |
struct type *tqe_next; /* next element */ \ |
struct type **tqe_prev; /* address of previous next element */ \ |
} |
/* |
* Tail queue functions. |
*/ |
#define TAILQ_CONCAT(head1, head2, field) do { \ |
if (!TAILQ_EMPTY(head2)) { \ |
*(head1)->tqh_last = (head2)->tqh_first; \ |
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ |
(head1)->tqh_last = (head2)->tqh_last; \ |
TAILQ_INIT((head2)); \ |
} \ |
} while (0) |
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) |
#define TAILQ_FIRST(head) ((head)->tqh_first) |
#define TAILQ_FOREACH(var, head, field) \ |
for ((var) = TAILQ_FIRST((head)); \ |
(var); \ |
(var) = TAILQ_NEXT((var), field)) |
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ |
for ((var) = TAILQ_LAST((head), headname); \ |
(var); \ |
(var) = TAILQ_PREV((var), headname, field)) |
#define TAILQ_INIT(head) do { \ |
TAILQ_FIRST((head)) = NULL; \ |
(head)->tqh_last = &TAILQ_FIRST((head)); \ |
} while (0) |
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ |
TAILQ_NEXT((elm), field)->field.tqe_prev = \ |
&TAILQ_NEXT((elm), field); \ |
else \ |
(head)->tqh_last = &TAILQ_NEXT((elm), field); \ |
TAILQ_NEXT((listelm), field) = (elm); \ |
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ |
} while (0) |
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ |
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ |
TAILQ_NEXT((elm), field) = (listelm); \ |
*(listelm)->field.tqe_prev = (elm); \ |
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ |
} while (0) |
#define TAILQ_INSERT_HEAD(head, elm, field) do { \ |
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ |
TAILQ_FIRST((head))->field.tqe_prev = \ |
&TAILQ_NEXT((elm), field); \ |
else \ |
(head)->tqh_last = &TAILQ_NEXT((elm), field); \ |
TAILQ_FIRST((head)) = (elm); \ |
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ |
} while (0) |
#define TAILQ_INSERT_TAIL(head, elm, field) do { \ |
TAILQ_NEXT((elm), field) = NULL; \ |
(elm)->field.tqe_prev = (head)->tqh_last; \ |
*(head)->tqh_last = (elm); \ |
(head)->tqh_last = &TAILQ_NEXT((elm), field); \ |
} while (0) |
#define TAILQ_LAST(head, headname) \ |
(*(((struct headname *)((head)->tqh_last))->tqh_last)) |
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) |
#define TAILQ_PREV(elm, headname, field) \ |
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) |
#define TAILQ_REMOVE(head, elm, field) do { \ |
if ((TAILQ_NEXT((elm), field)) != NULL) \ |
TAILQ_NEXT((elm), field)->field.tqe_prev = \ |
(elm)->field.tqe_prev; \ |
else \ |
(head)->tqh_last = (elm)->field.tqe_prev; \ |
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ |
} while (0) |
#ifdef _KERNEL |
/* |
* XXX insque() and remque() are an old way of handling certain queues. |
* They bogusly assumes that all queue heads look alike. |
*/ |
struct quehead { |
struct quehead *qh_link; |
struct quehead *qh_rlink; |
}; |
#ifdef __GNUC__ |
static __inline void |
insque(void *a, void *b) |
{ |
struct quehead *element = (struct quehead *)a, |
*head = (struct quehead *)b; |
element->qh_link = head->qh_link; |
element->qh_rlink = head; |
head->qh_link = element; |
element->qh_link->qh_rlink = element; |
} |
static __inline void |
remque(void *a) |
{ |
struct quehead *element = (struct quehead *)a; |
element->qh_link->qh_rlink = element->qh_rlink; |
element->qh_rlink->qh_link = element->qh_link; |
element->qh_rlink = 0; |
} |
#else /* !__GNUC__ */ |
void insque(void *a, void *b); |
void remque(void *a); |
#endif /* __GNUC__ */ |
#endif /* _KERNEL */ |
#endif /* !_SYS_QUEUE_H_ */ |
/programs/develop/libraries/newlib/include/sys/reent.h |
---|
0,0 → 1,843 |
/* This header file provides the reentrancy. */ |
/* WARNING: All identifiers here must begin with an underscore. This file is |
included by stdio.h and others and we therefore must only use identifiers |
in the namespace allotted to us. */ |
#ifndef _SYS_REENT_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_REENT_H_ |
#include <_ansi.h> |
#include <sys/_types.h> |
#define _NULL 0 |
#ifndef __Long |
#if __LONG_MAX__ == 2147483647L |
#define __Long long |
typedef unsigned __Long __ULong; |
#elif __INT_MAX__ == 2147483647 |
#define __Long int |
typedef unsigned __Long __ULong; |
#endif |
#endif |
#if !defined( __Long) |
#include <sys/types.h> |
#endif |
#ifndef __Long |
#define __Long __int32_t |
typedef __uint32_t __ULong; |
#endif |
struct _reent; |
/* |
* If _REENT_SMALL is defined, we make struct _reent as small as possible, |
* by having nearly everything possible allocated at first use. |
*/ |
struct _Bigint |
{ |
struct _Bigint *_next; |
int _k, _maxwds, _sign, _wds; |
__ULong _x[1]; |
}; |
/* needed by reentrant structure */ |
struct __tm |
{ |
int __tm_sec; |
int __tm_min; |
int __tm_hour; |
int __tm_mday; |
int __tm_mon; |
int __tm_year; |
int __tm_wday; |
int __tm_yday; |
int __tm_isdst; |
}; |
/* |
* atexit() support. |
*/ |
#define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */ |
struct _on_exit_args { |
void * _fnargs[_ATEXIT_SIZE]; /* user fn args */ |
void * _dso_handle[_ATEXIT_SIZE]; |
/* Bitmask is set if user function takes arguments. */ |
__ULong _fntypes; /* type of exit routine - |
Must have at least _ATEXIT_SIZE bits */ |
/* Bitmask is set if function was registered via __cxa_atexit. */ |
__ULong _is_cxa; |
}; |
#ifdef _REENT_SMALL |
struct _atexit { |
struct _atexit *_next; /* next in list */ |
int _ind; /* next index in this table */ |
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */ |
struct _on_exit_args * _on_exit_args_ptr; |
}; |
#else |
struct _atexit { |
struct _atexit *_next; /* next in list */ |
int _ind; /* next index in this table */ |
/* Some entries may already have been called, and will be NULL. */ |
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */ |
struct _on_exit_args _on_exit_args; |
}; |
#endif |
/* |
* Stdio buffers. |
* |
* This and __FILE are defined here because we need them for struct _reent, |
* but we don't want stdio.h included when stdlib.h is. |
*/ |
struct __sbuf { |
unsigned char *_base; |
int _size; |
}; |
/* |
* Stdio state variables. |
* |
* The following always hold: |
* |
* if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), |
* _lbfsize is -_bf._size, else _lbfsize is 0 |
* if _flags&__SRD, _w is 0 |
* if _flags&__SWR, _r is 0 |
* |
* This ensures that the getc and putc macros (or inline functions) never |
* try to write or read from a file that is in `read' or `write' mode. |
* (Moreover, they can, and do, automatically switch from read mode to |
* write mode, and back, on "r+" and "w+" files.) |
* |
* _lbfsize is used only to make the inline line-buffered output stream |
* code as compact as possible. |
* |
* _ub, _up, and _ur are used when ungetc() pushes back more characters |
* than fit in the current _bf, or when ungetc() pushes back a character |
* that does not match the previous one in _bf. When this happens, |
* _ub._base becomes non-nil (i.e., a stream has ungetc() data iff |
* _ub._base!=NULL) and _up and _ur save the current values of _p and _r. |
*/ |
#ifdef _REENT_SMALL |
/* |
* struct __sFILE_fake is the start of a struct __sFILE, with only the |
* minimal fields allocated. In __sinit() we really allocate the 3 |
* standard streams, etc., and point away from this fake. |
*/ |
struct __sFILE_fake { |
unsigned char *_p; /* current position in (some) buffer */ |
int _r; /* read space left for getc() */ |
int _w; /* write space left for putc() */ |
short _flags; /* flags, below; this FILE is free if 0 */ |
short _file; /* fileno, if Unix descriptor, else -1 */ |
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ |
int _lbfsize; /* 0 or -_bf._size, for inline putc */ |
struct _reent *_data; |
}; |
/* Following is needed both in libc/stdio and libc/stdlib so we put it |
* here instead of libc/stdio/local.h where it was previously. */ |
extern _VOID _EXFUN(__sinit,(struct _reent *)); |
# define _REENT_SMALL_CHECK_INIT(ptr) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
} \ |
while (0) |
#else |
# define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */ |
#endif |
struct __sFILE { |
unsigned char *_p; /* current position in (some) buffer */ |
int _r; /* read space left for getc() */ |
int _w; /* write space left for putc() */ |
short _flags; /* flags, below; this FILE is free if 0 */ |
short _file; /* fileno, if Unix descriptor, else -1 */ |
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ |
int _lbfsize; /* 0 or -_bf._size, for inline putc */ |
#ifdef _REENT_SMALL |
struct _reent *_data; |
#endif |
/* operations */ |
_PTR _cookie; /* cookie passed to io functions */ |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR, |
char *, int)); |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR, |
const char *, int)); |
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int)); |
int _EXFNPTR(_close, (struct _reent *, _PTR)); |
/* separate buffer for long sequences of ungetc() */ |
struct __sbuf _ub; /* ungetc buffer */ |
unsigned char *_up; /* saved _p when _p is doing ungetc data */ |
int _ur; /* saved _r when _r is counting ungetc data */ |
/* tricks to meet minimum requirements even when malloc() fails */ |
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ |
unsigned char _nbuf[1]; /* guarantee a getc() buffer */ |
/* separate buffer for fgetline() when line crosses buffer boundary */ |
struct __sbuf _lb; /* buffer for fgetline() */ |
/* Unix stdio files get aligned to block boundaries on fseek() */ |
int _blksize; /* stat.st_blksize (may be != _bf._size) */ |
int _offset; /* current lseek offset */ |
#ifndef _REENT_SMALL |
struct _reent *_data; /* Here for binary compatibility? Remove? */ |
#endif |
#ifndef __SINGLE_THREAD__ |
_flock_t _lock; /* for thread-safety locking */ |
#endif |
_mbstate_t _mbstate; /* for wide char stdio functions. */ |
int _flags2; /* for future use */ |
}; |
#ifdef __CUSTOM_FILE_IO__ |
/* Get custom _FILE definition. */ |
#include <sys/custom_file.h> |
#else /* !__CUSTOM_FILE_IO__ */ |
#ifdef __LARGE64_FILES |
struct __sFILE64 { |
unsigned char *_p; /* current position in (some) buffer */ |
int _r; /* read space left for getc() */ |
int _w; /* write space left for putc() */ |
short _flags; /* flags, below; this FILE is free if 0 */ |
short _file; /* fileno, if Unix descriptor, else -1 */ |
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ |
int _lbfsize; /* 0 or -_bf._size, for inline putc */ |
struct _reent *_data; |
/* operations */ |
_PTR _cookie; /* cookie passed to io functions */ |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR, |
char *, int)); |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR, |
const char *, int)); |
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int)); |
int _EXFNPTR(_close, (struct _reent *, _PTR)); |
/* separate buffer for long sequences of ungetc() */ |
struct __sbuf _ub; /* ungetc buffer */ |
unsigned char *_up; /* saved _p when _p is doing ungetc data */ |
int _ur; /* saved _r when _r is counting ungetc data */ |
/* tricks to meet minimum requirements even when malloc() fails */ |
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ |
unsigned char _nbuf[1]; /* guarantee a getc() buffer */ |
/* separate buffer for fgetline() when line crosses buffer boundary */ |
struct __sbuf _lb; /* buffer for fgetline() */ |
/* Unix stdio files get aligned to block boundaries on fseek() */ |
int _blksize; /* stat.st_blksize (may be != _bf._size) */ |
int _flags2; /* for future use */ |
_off64_t _offset; /* current lseek offset */ |
_fpos64_t _EXFNPTR(_seek64, (struct _reent *, _PTR, _fpos64_t, int)); |
#ifndef __SINGLE_THREAD__ |
_flock_t _lock; /* for thread-safety locking */ |
#endif |
_mbstate_t _mbstate; /* for wide char stdio functions. */ |
}; |
typedef struct __sFILE64 __FILE; |
#else |
typedef struct __sFILE __FILE; |
#endif /* __LARGE64_FILES */ |
#endif /* !__CUSTOM_FILE_IO__ */ |
struct _glue |
{ |
struct _glue *_next; |
int _niobs; |
__FILE *_iobs; |
}; |
/* |
* rand48 family support |
* |
* Copyright (c) 1993 Martin Birgmeier |
* All rights reserved. |
* |
* You may redistribute unmodified or modified versions of this source |
* code provided that the above copyright notice and this and the |
* following conditions are retained. |
* |
* This software is provided ``as is'', and comes with no warranties |
* of any kind. I shall in no event be liable for anything that happens |
* to anyone/anything when using this software. |
*/ |
#define _RAND48_SEED_0 (0x330e) |
#define _RAND48_SEED_1 (0xabcd) |
#define _RAND48_SEED_2 (0x1234) |
#define _RAND48_MULT_0 (0xe66d) |
#define _RAND48_MULT_1 (0xdeec) |
#define _RAND48_MULT_2 (0x0005) |
#define _RAND48_ADD (0x000b) |
struct _rand48 { |
unsigned short _seed[3]; |
unsigned short _mult[3]; |
unsigned short _add; |
#ifdef _REENT_SMALL |
/* Put this in here as well, for good luck. */ |
__extension__ unsigned long long _rand_next; |
#endif |
}; |
/* How big the some arrays are. */ |
#define _REENT_EMERGENCY_SIZE 25 |
#define _REENT_ASCTIME_SIZE 26 |
#define _REENT_SIGNAL_SIZE 24 |
/* |
* struct _reent |
* |
* This structure contains *all* globals needed by the library. |
* It's raison d'etre is to facilitate threads by making all library routines |
* reentrant. IE: All state information is contained here. |
*/ |
#ifdef _REENT_SMALL |
struct _mprec |
{ |
/* used by mprec routines */ |
struct _Bigint *_result; |
int _result_k; |
struct _Bigint *_p5s; |
struct _Bigint **_freelist; |
}; |
struct _misc_reent |
{ |
/* miscellaneous reentrant data */ |
char *_strtok_last; |
_mbstate_t _mblen_state; |
_mbstate_t _wctomb_state; |
_mbstate_t _mbtowc_state; |
char _l64a_buf[8]; |
int _getdate_err; |
_mbstate_t _mbrlen_state; |
_mbstate_t _mbrtowc_state; |
_mbstate_t _mbsrtowcs_state; |
_mbstate_t _wcrtomb_state; |
_mbstate_t _wcsrtombs_state; |
}; |
/* This version of _reent is layed our with "int"s in pairs, to help |
* ports with 16-bit int's but 32-bit pointers, align nicely. */ |
struct _reent |
{ |
/* As an exception to the above put _errno first for binary |
compatibility with non _REENT_SMALL targets. */ |
int _errno; /* local copy of errno */ |
/* FILE is a big struct and may change over time. To try to achieve binary |
compatibility with future versions, put stdin,stdout,stderr here. |
These are pointers into member __sf defined below. */ |
__FILE *_stdin, *_stdout, *_stderr; /* XXX */ |
int _inc; /* used by tmpnam */ |
char *_emergency; |
int __sdidinit; /* 1 means stdio has been init'd */ |
int _current_category; /* unused */ |
_CONST char *_current_locale; /* unused */ |
struct _mprec *_mp; |
void _EXFNPTR(__cleanup, (struct _reent *)); |
int _gamma_signgam; |
/* used by some fp conversion routines */ |
int _cvtlen; /* should be size_t */ |
char *_cvtbuf; |
struct _rand48 *_r48; |
struct __tm *_localtime_buf; |
char *_asctime_buf; |
/* signal info */ |
void (**(_sig_func))(int); |
/* atexit stuff */ |
struct _atexit *_atexit; |
struct _atexit _atexit0; |
struct _glue __sglue; /* root of glue chain */ |
__FILE *__sf; /* file descriptors */ |
struct _misc_reent *_misc; /* strtok, multibyte states */ |
char *_signal_buf; /* strsignal */ |
}; |
extern const struct __sFILE_fake __sf_fake_stdin; |
extern const struct __sFILE_fake __sf_fake_stdout; |
extern const struct __sFILE_fake __sf_fake_stderr; |
# define _REENT_INIT(var) \ |
{ 0, \ |
(__FILE *)&__sf_fake_stdin, \ |
(__FILE *)&__sf_fake_stdout, \ |
(__FILE *)&__sf_fake_stderr, \ |
0, \ |
_NULL, \ |
0, \ |
0, \ |
"C", \ |
_NULL, \ |
_NULL, \ |
0, \ |
0, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
{_NULL, 0, {_NULL}, _NULL}, \ |
{_NULL, 0, _NULL}, \ |
_NULL, \ |
_NULL, \ |
_NULL \ |
} |
#define _REENT_INIT_PTR(var) \ |
{ (var)->_stdin = (__FILE *)&__sf_fake_stdin; \ |
(var)->_stdout = (__FILE *)&__sf_fake_stdout; \ |
(var)->_stderr = (__FILE *)&__sf_fake_stderr; \ |
(var)->_errno = 0; \ |
(var)->_inc = 0; \ |
(var)->_emergency = _NULL; \ |
(var)->__sdidinit = 0; \ |
(var)->_current_category = 0; \ |
(var)->_current_locale = "C"; \ |
(var)->_mp = _NULL; \ |
(var)->__cleanup = _NULL; \ |
(var)->_gamma_signgam = 0; \ |
(var)->_cvtlen = 0; \ |
(var)->_cvtbuf = _NULL; \ |
(var)->_r48 = _NULL; \ |
(var)->_localtime_buf = _NULL; \ |
(var)->_asctime_buf = _NULL; \ |
(var)->_sig_func = _NULL; \ |
(var)->_atexit = _NULL; \ |
(var)->_atexit0._next = _NULL; \ |
(var)->_atexit0._ind = 0; \ |
(var)->_atexit0._fns[0] = _NULL; \ |
(var)->_atexit0._on_exit_args_ptr = _NULL; \ |
(var)->__sglue._next = _NULL; \ |
(var)->__sglue._niobs = 0; \ |
(var)->__sglue._iobs = _NULL; \ |
(var)->__sf = 0; \ |
(var)->_misc = _NULL; \ |
(var)->_signal_buf = _NULL; \ |
} |
/* Only built the assert() calls if we are built with debugging. */ |
#if DEBUG |
#include <assert.h> |
#define __reent_assert(x) assert(x) |
#else |
#define __reent_assert(x) ((void)0) |
#endif |
#ifdef __CUSTOM_FILE_IO__ |
#error Custom FILE I/O and _REENT_SMALL not currently supported. |
#endif |
/* Generic _REENT check macro. */ |
#define _REENT_CHECK(var, what, type, size, init) do { \ |
struct _reent *_r = (var); \ |
if (_r->what == NULL) { \ |
_r->what = (type)malloc(size); \ |
__reent_assert(_r->what); \ |
init; \ |
} \ |
} while (0) |
#define _REENT_CHECK_TM(var) \ |
_REENT_CHECK(var, _localtime_buf, struct __tm *, sizeof *((var)->_localtime_buf), \ |
/* nothing */) |
#define _REENT_CHECK_ASCTIME_BUF(var) \ |
_REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \ |
memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE)) |
/* Handle the dynamically allocated rand48 structure. */ |
#define _REENT_INIT_RAND48(var) do { \ |
struct _reent *_r = (var); \ |
_r->_r48->_seed[0] = _RAND48_SEED_0; \ |
_r->_r48->_seed[1] = _RAND48_SEED_1; \ |
_r->_r48->_seed[2] = _RAND48_SEED_2; \ |
_r->_r48->_mult[0] = _RAND48_MULT_0; \ |
_r->_r48->_mult[1] = _RAND48_MULT_1; \ |
_r->_r48->_mult[2] = _RAND48_MULT_2; \ |
_r->_r48->_add = _RAND48_ADD; \ |
_r->_r48->_rand_next = 1; \ |
} while (0) |
#define _REENT_CHECK_RAND48(var) \ |
_REENT_CHECK(var, _r48, struct _rand48 *, sizeof *((var)->_r48), _REENT_INIT_RAND48((var))) |
#define _REENT_INIT_MP(var) do { \ |
struct _reent *_r = (var); \ |
_r->_mp->_result_k = 0; \ |
_r->_mp->_result = _r->_mp->_p5s = _NULL; \ |
_r->_mp->_freelist = _NULL; \ |
} while (0) |
#define _REENT_CHECK_MP(var) \ |
_REENT_CHECK(var, _mp, struct _mprec *, sizeof *((var)->_mp), _REENT_INIT_MP(var)) |
#define _REENT_CHECK_EMERGENCY(var) \ |
_REENT_CHECK(var, _emergency, char *, _REENT_EMERGENCY_SIZE, /* nothing */) |
#define _REENT_INIT_MISC(var) do { \ |
struct _reent *_r = (var); \ |
_r->_misc->_strtok_last = _NULL; \ |
_r->_misc->_mblen_state.__count = 0; \ |
_r->_misc->_mblen_state.__value.__wch = 0; \ |
_r->_misc->_wctomb_state.__count = 0; \ |
_r->_misc->_wctomb_state.__value.__wch = 0; \ |
_r->_misc->_mbtowc_state.__count = 0; \ |
_r->_misc->_mbtowc_state.__value.__wch = 0; \ |
_r->_misc->_mbrlen_state.__count = 0; \ |
_r->_misc->_mbrlen_state.__value.__wch = 0; \ |
_r->_misc->_mbrtowc_state.__count = 0; \ |
_r->_misc->_mbrtowc_state.__value.__wch = 0; \ |
_r->_misc->_mbsrtowcs_state.__count = 0; \ |
_r->_misc->_mbsrtowcs_state.__value.__wch = 0; \ |
_r->_misc->_wcrtomb_state.__count = 0; \ |
_r->_misc->_wcrtomb_state.__value.__wch = 0; \ |
_r->_misc->_wcsrtombs_state.__count = 0; \ |
_r->_misc->_wcsrtombs_state.__value.__wch = 0; \ |
_r->_misc->_l64a_buf[0] = '\0'; \ |
_r->_misc->_getdate_err = 0; \ |
} while (0) |
#define _REENT_CHECK_MISC(var) \ |
_REENT_CHECK(var, _misc, struct _misc_reent *, sizeof *((var)->_misc), _REENT_INIT_MISC(var)) |
#define _REENT_CHECK_SIGNAL_BUF(var) \ |
_REENT_CHECK(var, _signal_buf, char *, _REENT_SIGNAL_SIZE, /* nothing */) |
#define _REENT_SIGNGAM(ptr) ((ptr)->_gamma_signgam) |
#define _REENT_RAND_NEXT(ptr) ((ptr)->_r48->_rand_next) |
#define _REENT_RAND48_SEED(ptr) ((ptr)->_r48->_seed) |
#define _REENT_RAND48_MULT(ptr) ((ptr)->_r48->_mult) |
#define _REENT_RAND48_ADD(ptr) ((ptr)->_r48->_add) |
#define _REENT_MP_RESULT(ptr) ((ptr)->_mp->_result) |
#define _REENT_MP_RESULT_K(ptr) ((ptr)->_mp->_result_k) |
#define _REENT_MP_P5S(ptr) ((ptr)->_mp->_p5s) |
#define _REENT_MP_FREELIST(ptr) ((ptr)->_mp->_freelist) |
#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_asctime_buf) |
#define _REENT_TM(ptr) ((ptr)->_localtime_buf) |
#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency) |
#define _REENT_STRTOK_LAST(ptr) ((ptr)->_misc->_strtok_last) |
#define _REENT_MBLEN_STATE(ptr) ((ptr)->_misc->_mblen_state) |
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_misc->_mbtowc_state) |
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_misc->_wctomb_state) |
#define _REENT_MBRLEN_STATE(ptr) ((ptr)->_misc->_mbrlen_state) |
#define _REENT_MBRTOWC_STATE(ptr) ((ptr)->_misc->_mbrtowc_state) |
#define _REENT_MBSRTOWCS_STATE(ptr) ((ptr)->_misc->_mbsrtowcs_state) |
#define _REENT_WCRTOMB_STATE(ptr) ((ptr)->_misc->_wcrtomb_state) |
#define _REENT_WCSRTOMBS_STATE(ptr) ((ptr)->_misc->_wcsrtombs_state) |
#define _REENT_L64A_BUF(ptr) ((ptr)->_misc->_l64a_buf) |
#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_misc->_getdate_err)) |
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_signal_buf) |
#else /* !_REENT_SMALL */ |
struct _reent |
{ |
int _errno; /* local copy of errno */ |
/* FILE is a big struct and may change over time. To try to achieve binary |
compatibility with future versions, put stdin,stdout,stderr here. |
These are pointers into member __sf defined below. */ |
__FILE *_stdin, *_stdout, *_stderr; |
int _inc; /* used by tmpnam */ |
char _emergency[_REENT_EMERGENCY_SIZE]; |
int _current_category; /* used by setlocale */ |
_CONST char *_current_locale; |
int __sdidinit; /* 1 means stdio has been init'd */ |
void _EXFNPTR(__cleanup, (struct _reent *)); |
/* used by mprec routines */ |
struct _Bigint *_result; |
int _result_k; |
struct _Bigint *_p5s; |
struct _Bigint **_freelist; |
/* used by some fp conversion routines */ |
int _cvtlen; /* should be size_t */ |
char *_cvtbuf; |
union |
{ |
struct |
{ |
unsigned int _unused_rand; |
char * _strtok_last; |
char _asctime_buf[_REENT_ASCTIME_SIZE]; |
struct __tm _localtime_buf; |
int _gamma_signgam; |
__extension__ unsigned long long _rand_next; |
struct _rand48 _r48; |
_mbstate_t _mblen_state; |
_mbstate_t _mbtowc_state; |
_mbstate_t _wctomb_state; |
char _l64a_buf[8]; |
char _signal_buf[_REENT_SIGNAL_SIZE]; |
int _getdate_err; |
_mbstate_t _mbrlen_state; |
_mbstate_t _mbrtowc_state; |
_mbstate_t _mbsrtowcs_state; |
_mbstate_t _wcrtomb_state; |
_mbstate_t _wcsrtombs_state; |
int _h_errno; |
} _reent; |
/* Two next two fields were once used by malloc. They are no longer |
used. They are used to preserve the space used before so as to |
allow addition of new reent fields and keep binary compatibility. */ |
struct |
{ |
#define _N_LISTS 30 |
unsigned char * _nextf[_N_LISTS]; |
unsigned int _nmalloc[_N_LISTS]; |
} _unused; |
} _new; |
/* atexit stuff */ |
struct _atexit *_atexit; /* points to head of LIFO stack */ |
struct _atexit _atexit0; /* one guaranteed table, required by ANSI */ |
/* signal info */ |
void (**(_sig_func))(int); |
/* These are here last so that __FILE can grow without changing the offsets |
of the above members (on the off chance that future binary compatibility |
would be broken otherwise). */ |
struct _glue __sglue; /* root of glue chain */ |
__FILE __sf[3]; /* first three file descriptors */ |
}; |
#define _REENT_INIT(var) \ |
{ 0, \ |
&(var).__sf[0], \ |
&(var).__sf[1], \ |
&(var).__sf[2], \ |
0, \ |
"", \ |
0, \ |
"C", \ |
0, \ |
_NULL, \ |
_NULL, \ |
0, \ |
_NULL, \ |
_NULL, \ |
0, \ |
_NULL, \ |
{ \ |
{ \ |
0, \ |
_NULL, \ |
"", \ |
{0, 0, 0, 0, 0, 0, 0, 0, 0}, \ |
0, \ |
1, \ |
{ \ |
{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \ |
{_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, \ |
_RAND48_ADD \ |
}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
"", \ |
"", \ |
0, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}} \ |
} \ |
}, \ |
_NULL, \ |
{_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \ |
_NULL, \ |
{_NULL, 0, _NULL} \ |
} |
#define _REENT_INIT_PTR(var) \ |
{ (var)->_errno = 0; \ |
(var)->_stdin = &(var)->__sf[0]; \ |
(var)->_stdout = &(var)->__sf[1]; \ |
(var)->_stderr = &(var)->__sf[2]; \ |
(var)->_inc = 0; \ |
memset(&(var)->_emergency, 0, sizeof((var)->_emergency)); \ |
(var)->_current_category = 0; \ |
(var)->_current_locale = "C"; \ |
(var)->__sdidinit = 0; \ |
(var)->__cleanup = _NULL; \ |
(var)->_result = _NULL; \ |
(var)->_result_k = 0; \ |
(var)->_p5s = _NULL; \ |
(var)->_freelist = _NULL; \ |
(var)->_cvtlen = 0; \ |
(var)->_cvtbuf = _NULL; \ |
(var)->_new._reent._unused_rand = 0; \ |
(var)->_new._reent._strtok_last = _NULL; \ |
(var)->_new._reent._asctime_buf[0] = 0; \ |
memset(&(var)->_new._reent._localtime_buf, 0, sizeof((var)->_new._reent._localtime_buf)); \ |
(var)->_new._reent._gamma_signgam = 0; \ |
(var)->_new._reent._rand_next = 1; \ |
(var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \ |
(var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \ |
(var)->_new._reent._r48._seed[2] = _RAND48_SEED_2; \ |
(var)->_new._reent._r48._mult[0] = _RAND48_MULT_0; \ |
(var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; \ |
(var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; \ |
(var)->_new._reent._r48._add = _RAND48_ADD; \ |
(var)->_new._reent._mblen_state.__count = 0; \ |
(var)->_new._reent._mblen_state.__value.__wch = 0; \ |
(var)->_new._reent._mbtowc_state.__count = 0; \ |
(var)->_new._reent._mbtowc_state.__value.__wch = 0; \ |
(var)->_new._reent._wctomb_state.__count = 0; \ |
(var)->_new._reent._wctomb_state.__value.__wch = 0; \ |
(var)->_new._reent._mbrlen_state.__count = 0; \ |
(var)->_new._reent._mbrlen_state.__value.__wch = 0; \ |
(var)->_new._reent._mbrtowc_state.__count = 0; \ |
(var)->_new._reent._mbrtowc_state.__value.__wch = 0; \ |
(var)->_new._reent._mbsrtowcs_state.__count = 0; \ |
(var)->_new._reent._mbsrtowcs_state.__value.__wch = 0; \ |
(var)->_new._reent._wcrtomb_state.__count = 0; \ |
(var)->_new._reent._wcrtomb_state.__value.__wch = 0; \ |
(var)->_new._reent._wcsrtombs_state.__count = 0; \ |
(var)->_new._reent._wcsrtombs_state.__value.__wch = 0; \ |
(var)->_new._reent._l64a_buf[0] = '\0'; \ |
(var)->_new._reent._signal_buf[0] = '\0'; \ |
(var)->_new._reent._getdate_err = 0; \ |
(var)->_atexit = _NULL; \ |
(var)->_atexit0._next = _NULL; \ |
(var)->_atexit0._ind = 0; \ |
(var)->_atexit0._fns[0] = _NULL; \ |
(var)->_atexit0._on_exit_args._fntypes = 0; \ |
(var)->_atexit0._on_exit_args._fnargs[0] = _NULL; \ |
(var)->_sig_func = _NULL; \ |
(var)->__sglue._next = _NULL; \ |
(var)->__sglue._niobs = 0; \ |
(var)->__sglue._iobs = _NULL; \ |
memset(&(var)->__sf, 0, sizeof((var)->__sf)); \ |
} |
#define _REENT_CHECK_RAND48(ptr) /* nothing */ |
#define _REENT_CHECK_MP(ptr) /* nothing */ |
#define _REENT_CHECK_TM(ptr) /* nothing */ |
#define _REENT_CHECK_ASCTIME_BUF(ptr) /* nothing */ |
#define _REENT_CHECK_EMERGENCY(ptr) /* nothing */ |
#define _REENT_CHECK_MISC(ptr) /* nothing */ |
#define _REENT_CHECK_SIGNAL_BUF(ptr) /* nothing */ |
#define _REENT_SIGNGAM(ptr) ((ptr)->_new._reent._gamma_signgam) |
#define _REENT_RAND_NEXT(ptr) ((ptr)->_new._reent._rand_next) |
#define _REENT_RAND48_SEED(ptr) ((ptr)->_new._reent._r48._seed) |
#define _REENT_RAND48_MULT(ptr) ((ptr)->_new._reent._r48._mult) |
#define _REENT_RAND48_ADD(ptr) ((ptr)->_new._reent._r48._add) |
#define _REENT_MP_RESULT(ptr) ((ptr)->_result) |
#define _REENT_MP_RESULT_K(ptr) ((ptr)->_result_k) |
#define _REENT_MP_P5S(ptr) ((ptr)->_p5s) |
#define _REENT_MP_FREELIST(ptr) ((ptr)->_freelist) |
#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_new._reent._asctime_buf) |
#define _REENT_TM(ptr) (&(ptr)->_new._reent._localtime_buf) |
#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency) |
#define _REENT_STRTOK_LAST(ptr) ((ptr)->_new._reent._strtok_last) |
#define _REENT_MBLEN_STATE(ptr) ((ptr)->_new._reent._mblen_state) |
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_new._reent._mbtowc_state) |
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_new._reent._wctomb_state) |
#define _REENT_MBRLEN_STATE(ptr)((ptr)->_new._reent._mbrlen_state) |
#define _REENT_MBRTOWC_STATE(ptr)((ptr)->_new._reent._mbrtowc_state) |
#define _REENT_MBSRTOWCS_STATE(ptr)((ptr)->_new._reent._mbsrtowcs_state) |
#define _REENT_WCRTOMB_STATE(ptr)((ptr)->_new._reent._wcrtomb_state) |
#define _REENT_WCSRTOMBS_STATE(ptr)((ptr)->_new._reent._wcsrtombs_state) |
#define _REENT_L64A_BUF(ptr) ((ptr)->_new._reent._l64a_buf) |
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_new._reent._signal_buf) |
#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_new._reent._getdate_err)) |
#endif /* !_REENT_SMALL */ |
/* This value is used in stdlib/misc.c. reent/reent.c has to know it |
as well to make sure the freelist is correctly free'd. Therefore |
we define it here, rather than in stdlib/misc.c, as before. */ |
#define _Kmax (sizeof (size_t) << 3) |
/* |
* All references to struct _reent are via this pointer. |
* Internally, newlib routines that need to reference it should use _REENT. |
*/ |
#ifndef __ATTRIBUTE_IMPURE_PTR__ |
#define __ATTRIBUTE_IMPURE_PTR__ |
#endif |
extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__; |
extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__; |
void _reclaim_reent _PARAMS ((struct _reent *)); |
/* #define _REENT_ONLY define this to get only reentrant routines */ |
#ifndef _REENT_ONLY |
#if defined(__DYNAMIC_REENT__) && !defined(__SINGLE_THREAD__) |
#ifndef __getreent |
struct _reent * _EXFUN(__getreent, (void)); |
#endif |
# define _REENT (__getreent()) |
#else /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */ |
# define _REENT _impure_ptr |
#endif /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */ |
#endif /* !_REENT_ONLY */ |
#define _GLOBAL_REENT _global_impure_ptr |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_REENT_H_ */ |
/programs/develop/libraries/newlib/include/sys/resource.h |
---|
0,0 → 1,15 |
#ifndef _SYS_RESOURCE_H_ |
#define _SYS_RESOURCE_H_ |
#include <sys/time.h> |
#define RUSAGE_SELF 0 /* calling process */ |
#define RUSAGE_CHILDREN -1 /* terminated child processes */ |
struct rusage { |
struct timeval ru_utime; /* user time used */ |
struct timeval ru_stime; /* system time used */ |
}; |
#endif |
/programs/develop/libraries/newlib/include/sys/sched.h |
---|
0,0 → 1,67 |
/* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2010. |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: sched.h,v 1.3 2010/04/01 18:33:37 jjohnstn Exp $ |
*/ |
#ifndef _SYS_SCHED_H_ |
#define _SYS_SCHED_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Scheduling Policies */ |
/* Open Group Specifications Issue 6 */ |
#if defined(__CYGWIN__) |
#define SCHED_OTHER 3 |
#else |
#define SCHED_OTHER 0 |
#endif |
#define SCHED_FIFO 1 |
#define SCHED_RR 2 |
#if defined(_POSIX_SPORADIC_SERVER) |
#define SCHED_SPORADIC 4 |
#endif |
/* Scheduling Parameters */ |
/* Open Group Specifications Issue 6 */ |
struct sched_param { |
int sched_priority; /* Process execution scheduling priority */ |
#if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER) |
int sched_ss_low_priority; /* Low scheduling priority for sporadic */ |
/* server */ |
struct timespec sched_ss_repl_period; |
/* Replenishment period for sporadic server */ |
struct timespec sched_ss_init_budget; |
/* Initial budget for sporadic server */ |
int sched_ss_max_repl; /* Maximum pending replenishments for */ |
/* sporadic server */ |
#endif |
}; |
#ifdef __cplusplus |
} |
#endif |
#endif |
/* end of include file */ |
/programs/develop/libraries/newlib/include/sys/signal.h |
---|
0,0 → 1,310 |
/* sys/signal.h */ |
#ifndef _SYS_SIGNAL_H |
#define _SYS_SIGNAL_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include "_ansi.h" |
#include <sys/features.h> |
#include <sys/types.h> |
/* #ifndef __STRICT_ANSI__*/ |
typedef unsigned long sigset_t; |
#if defined(__rtems__) |
#if defined(_POSIX_REALTIME_SIGNALS) |
/* sigev_notify values |
NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ |
#define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */ |
/* when the event of interest occurs. */ |
#define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */ |
/* value, shall be delivered when the event of */ |
/* interest occurs. */ |
#define SIGEV_THREAD 3 /* A notification function shall be called to */ |
/* perform notification. */ |
/* Signal Generation and Delivery, P1003.1b-1993, p. 63 |
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and |
sigev_notify_attributes to the sigevent structure. */ |
union sigval { |
int sival_int; /* Integer signal value */ |
void *sival_ptr; /* Pointer signal value */ |
}; |
struct sigevent { |
int sigev_notify; /* Notification type */ |
int sigev_signo; /* Signal number */ |
union sigval sigev_value; /* Signal value */ |
#if defined(_POSIX_THREADS) |
void (*sigev_notify_function)( union sigval ); |
/* Notification function */ |
pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */ |
#endif |
}; |
/* Signal Actions, P1003.1b-1993, p. 64 */ |
/* si_code values, p. 66 */ |
#define SI_USER 1 /* Sent by a user. kill(), abort(), etc */ |
#define SI_QUEUE 2 /* Sent by sigqueue() */ |
#define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */ |
#define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */ |
#define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */ |
typedef struct { |
int si_signo; /* Signal number */ |
int si_code; /* Cause of the signal */ |
union sigval si_value; /* Signal value */ |
} siginfo_t; |
#endif |
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */ |
#define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */ |
#define SA_SIGINFO 2 /* Invoke the signal catching function with */ |
/* three arguments instead of one. */ |
/* struct sigaction notes from POSIX: |
* |
* (1) Routines stored in sa_handler should take a single int as |
* their argument although the POSIX standard does not require this. |
* (2) The fields sa_handler and sa_sigaction may overlap, and a conforming |
* application should not use both simultaneously. |
*/ |
typedef void (*_sig_func_ptr)(); |
struct sigaction { |
int sa_flags; /* Special flags to affect behavior of signal */ |
sigset_t sa_mask; /* Additional set of signals to be blocked */ |
/* during execution of signal-catching */ |
/* function. */ |
union { |
_sig_func_ptr _handler; /* SIG_DFL, SIG_IGN, or pointer to a function */ |
#if defined(_POSIX_REALTIME_SIGNALS) |
void (*_sigaction)( int, siginfo_t *, void * ); |
#endif |
} _signal_handlers; |
}; |
#define sa_handler _signal_handlers._handler |
#if defined(_POSIX_REALTIME_SIGNALS) |
#define sa_sigaction _signal_handlers._sigaction |
#endif |
#elif defined(__CYGWIN__) |
#include <cygwin/signal.h> |
#else |
#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */ |
typedef void (*_sig_func_ptr)(int); |
struct sigaction |
{ |
_sig_func_ptr sa_handler; |
sigset_t sa_mask; |
int sa_flags; |
}; |
#endif /* defined(__rtems__) */ |
#define SIG_SETMASK 0 /* set mask with sigprocmask() */ |
#define SIG_BLOCK 1 /* set of signals to block */ |
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ |
/* These depend upon the type of sigset_t, which right now |
is always a long.. They're in the POSIX namespace, but |
are not ANSI. */ |
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0) |
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0) |
#define sigemptyset(what) (*(what) = 0, 0) |
#define sigfillset(what) (*(what) = ~(0), 0) |
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0) |
int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset)); |
#if defined(_POSIX_THREADS) |
int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); |
#endif |
/* protos for functions found in winsup sources for CYGWIN */ |
#if defined(__CYGWIN__) || defined(__rtems__) |
#undef sigaddset |
#undef sigdelset |
#undef sigemptyset |
#undef sigfillset |
#undef sigismember |
int _EXFUN(kill, (pid_t, int)); |
int _EXFUN(killpg, (pid_t, int)); |
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); |
int _EXFUN(sigaddset, (sigset_t *, const int)); |
int _EXFUN(sigdelset, (sigset_t *, const int)); |
int _EXFUN(sigismember, (const sigset_t *, int)); |
int _EXFUN(sigfillset, (sigset_t *)); |
int _EXFUN(sigemptyset, (sigset_t *)); |
int _EXFUN(sigpending, (sigset_t *)); |
int _EXFUN(sigsuspend, (const sigset_t *)); |
int _EXFUN(sigpause, (int)); |
#if defined(_POSIX_THREADS) |
#ifdef __CYGWIN__ |
# ifndef _CYGWIN_TYPES_H |
# error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib. |
# endif |
#endif |
int _EXFUN(pthread_kill, (pthread_t thread, int sig)); |
#endif |
#if defined(_POSIX_REALTIME_SIGNALS) |
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 |
NOTE: P1003.1c/D10, p. 39 adds sigwait(). */ |
int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info)); |
int _EXFUN(sigtimedwait, |
(const sigset_t *set, siginfo_t *info, const struct timespec *timeout) |
); |
int _EXFUN(sigwait, (const sigset_t *set, int *sig)); |
/* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */ |
int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value)); |
#endif /* defined(_POSIX_REALTIME_SIGNALS) */ |
#endif /* defined(__CYGWIN__) || defined(__rtems__) */ |
/* #endif __STRICT_ANSI__ */ |
#if defined(___AM29K__) |
/* These all need to be defined for ANSI C, but I don't think they are |
meaningful. */ |
#define SIGABRT 1 |
#define SIGFPE 1 |
#define SIGILL 1 |
#define SIGINT 1 |
#define SIGSEGV 1 |
#define SIGTERM 1 |
/* These need to be defined for POSIX, and some others do too. */ |
#define SIGHUP 1 |
#define SIGQUIT 1 |
#define NSIG 2 |
#elif defined(__GO32__) |
#define SIGINT 1 |
#define SIGKILL 2 |
#define SIGPIPE 3 |
#define SIGFPE 4 |
#define SIGHUP 5 |
#define SIGTERM 6 |
#define SIGSEGV 7 |
#define SIGTSTP 8 |
#define SIGQUIT 9 |
#define SIGTRAP 10 |
#define SIGILL 11 |
#define SIGEMT 12 |
#define SIGALRM 13 |
#define SIGBUS 14 |
#define SIGLOST 15 |
#define SIGSTOP 16 |
#define SIGABRT 17 |
#define SIGUSR1 18 |
#define SIGUSR2 19 |
#define NSIG 20 |
#elif !defined(SIGTRAP) |
#define SIGHUP 1 /* hangup */ |
#define SIGINT 2 /* interrupt */ |
#define SIGQUIT 3 /* quit */ |
#define SIGILL 4 /* illegal instruction (not reset when caught) */ |
#define SIGTRAP 5 /* trace trap (not reset when caught) */ |
#define SIGIOT 6 /* IOT instruction */ |
#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ |
#define SIGEMT 7 /* EMT instruction */ |
#define SIGFPE 8 /* floating point exception */ |
#define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
#define SIGBUS 10 /* bus error */ |
#define SIGSEGV 11 /* segmentation violation */ |
#define SIGSYS 12 /* bad argument to system call */ |
#define SIGPIPE 13 /* write on a pipe with no one to read it */ |
#define SIGALRM 14 /* alarm clock */ |
#define SIGTERM 15 /* software termination signal from kill */ |
#if defined(__rtems__) |
#define SIGURG 16 /* urgent condition on IO channel */ |
#define SIGSTOP 17 /* sendable stop signal not from tty */ |
#define SIGTSTP 18 /* stop signal from tty */ |
#define SIGCONT 19 /* continue a stopped process */ |
#define SIGCHLD 20 /* to parent on child stop or exit */ |
#define SIGCLD 20 /* System V name for SIGCHLD */ |
#define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
#define SIGIO 23 /* input/output possible signal */ |
#define SIGPOLL SIGIO /* System V name for SIGIO */ |
#define SIGWINCH 24 /* window changed */ |
#define SIGUSR1 25 /* user defined signal 1 */ |
#define SIGUSR2 26 /* user defined signal 2 */ |
/* Real-Time Signals Range, P1003.1b-1993, p. 61 |
NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX |
(which is a minimum of 8) signals. |
*/ |
#define SIGRTMIN 27 |
#define SIGRTMAX 31 |
#define __SIGFIRSTNOTRT SIGHUP |
#define __SIGLASTNOTRT SIGUSR2 |
#define NSIG 32 /* signal 0 implied */ |
#elif defined(__svr4__) |
/* svr4 specifics. different signals above 15, and sigaction. */ |
#define SIGUSR1 16 |
#define SIGUSR2 17 |
#define SIGCLD 18 |
#define SIGPWR 19 |
#define SIGWINCH 20 |
#define SIGPOLL 22 /* 20 for x.out binaries!!!! */ |
#define SIGSTOP 23 /* sendable stop signal not from tty */ |
#define SIGTSTP 24 /* stop signal from tty */ |
#define SIGCONT 25 /* continue a stopped process */ |
#define SIGTTIN 26 /* to readers pgrp upon background tty read */ |
#define SIGTTOU 27 /* like TTIN for output if (tp->t_local<OSTOP) */ |
#define NSIG 28 |
#else |
#define SIGURG 16 /* urgent condition on IO channel */ |
#define SIGSTOP 17 /* sendable stop signal not from tty */ |
#define SIGTSTP 18 /* stop signal from tty */ |
#define SIGCONT 19 /* continue a stopped process */ |
#define SIGCHLD 20 /* to parent on child stop or exit */ |
#define SIGCLD 20 /* System V name for SIGCHLD */ |
#define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
#define SIGIO 23 /* input/output possible signal */ |
#define SIGPOLL SIGIO /* System V name for SIGIO */ |
#define SIGXCPU 24 /* exceeded CPU time limit */ |
#define SIGXFSZ 25 /* exceeded file size limit */ |
#define SIGVTALRM 26 /* virtual time alarm */ |
#define SIGPROF 27 /* profiling time alarm */ |
#define SIGWINCH 28 /* window changed */ |
#define SIGLOST 29 /* resource lost (eg, record-lock lost) */ |
#define SIGUSR1 30 /* user defined signal 1 */ |
#define SIGUSR2 31 /* user defined signal 2 */ |
#define NSIG 32 /* signal 0 implied */ |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#ifndef _SIGNAL_H_ |
/* Some applications take advantage of the fact that <sys/signal.h> |
* and <signal.h> are equivalent in glibc. Allow for that here. */ |
#include <signal.h> |
#endif |
#endif /* _SYS_SIGNAL_H */ |
/programs/develop/libraries/newlib/include/sys/stat.h |
---|
0,0 → 1,183 |
#ifndef _SYS_STAT_H |
#define _SYS_STAT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <_ansi.h> |
#include <time.h> |
#include <sys/types.h> |
/* dj's stat defines _STAT_H_ */ |
#ifndef _STAT_H_ |
/* It is intended that the layout of this structure not change when the |
sizes of any of the basic types change (short, int, long) [via a compile |
time option]. */ |
#ifdef __CYGWIN__ |
#include <cygwin/stat.h> |
#ifdef _COMPILING_NEWLIB |
#define stat64 __stat64 |
#endif |
#else |
struct stat |
{ |
dev_t st_dev; |
ino_t st_ino; |
mode_t st_mode; |
nlink_t st_nlink; |
uid_t st_uid; |
gid_t st_gid; |
dev_t st_rdev; |
off_t st_size; |
#if defined(__rtems__) |
struct timespec st_atim; |
struct timespec st_mtim; |
struct timespec st_ctim; |
blksize_t st_blksize; |
blkcnt_t st_blocks; |
#else |
/* SysV/sco doesn't have the rest... But Solaris, eabi does. */ |
#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__) |
time_t st_atime; |
time_t st_mtime; |
time_t st_ctime; |
#else |
time_t st_atime; |
long st_spare1; |
time_t st_mtime; |
long st_spare2; |
time_t st_ctime; |
long st_spare3; |
long st_blksize; |
long st_blocks; |
long st_spare4[2]; |
#endif |
#endif |
}; |
#if defined(__rtems__) |
#define st_atime st_atim.tv_sec |
#define st_ctime st_ctim.tv_sec |
#define st_mtime st_mtim.tv_sec |
#endif |
#endif |
#define _IFMT 0170000 /* type of file */ |
#define _IFDIR 0040000 /* directory */ |
#define _IFCHR 0020000 /* character special */ |
#define _IFBLK 0060000 /* block special */ |
#define _IFREG 0100000 /* regular */ |
#define _IFLNK 0120000 /* symbolic link */ |
#define _IFSOCK 0140000 /* socket */ |
#define _IFIFO 0010000 /* fifo */ |
#define S_BLKSIZE 1024 /* size of a block */ |
#define S_ISUID 0004000 /* set user id on execution */ |
#define S_ISGID 0002000 /* set group id on execution */ |
#define S_ISVTX 0001000 /* save swapped text even after use */ |
#ifndef _POSIX_SOURCE |
#define S_IREAD 0000400 /* read permission, owner */ |
#define S_IWRITE 0000200 /* write permission, owner */ |
#define S_IEXEC 0000100 /* execute/search permission, owner */ |
#define S_ENFMT 0002000 /* enforcement-mode locking */ |
#endif /* !_POSIX_SOURCE */ |
#define S_IFMT _IFMT |
#define S_IFDIR _IFDIR |
#define S_IFCHR _IFCHR |
#define S_IFBLK _IFBLK |
#define S_IFREG _IFREG |
#define S_IFLNK _IFLNK |
#define S_IFSOCK _IFSOCK |
#define S_IFIFO _IFIFO |
#ifdef _WIN32 |
/* The Windows header files define _S_ forms of these, so we do too |
for easier portability. */ |
#define _S_IFMT _IFMT |
#define _S_IFDIR _IFDIR |
#define _S_IFCHR _IFCHR |
#define _S_IFIFO _IFIFO |
#define _S_IFREG _IFREG |
#define _S_IREAD 0000400 |
#define _S_IWRITE 0000200 |
#define _S_IEXEC 0000100 |
#endif |
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) |
#define S_IRUSR 0000400 /* read permission, owner */ |
#define S_IWUSR 0000200 /* write permission, owner */ |
#define S_IXUSR 0000100/* execute/search permission, owner */ |
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) |
#define S_IRGRP 0000040 /* read permission, group */ |
#define S_IWGRP 0000020 /* write permission, grougroup */ |
#define S_IXGRP 0000010/* execute/search permission, group */ |
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) |
#define S_IROTH 0000004 /* read permission, other */ |
#define S_IWOTH 0000002 /* write permission, other */ |
#define S_IXOTH 0000001/* execute/search permission, other */ |
#ifndef _POSIX_SOURCE |
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */ |
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */ |
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */ |
#endif |
#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK) |
#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR) |
#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR) |
#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO) |
#define S_ISREG(m) (((m)&_IFMT) == _IFREG) |
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK) |
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK) |
#if defined(__CYGWIN__) |
/* Special tv_nsec values for futimens(2) and utimensat(2). */ |
#define UTIME_NOW -2L |
#define UTIME_OMIT -1L |
#endif |
int _EXFUN(chmod,( const char *__path, mode_t __mode )); |
int _EXFUN(fchmod,(int __fd, mode_t __mode)); |
int _EXFUN(fstat,( int __fd, struct stat *__sbuf )); |
int _EXFUN(mkdir,( const char *_path, mode_t __mode )); |
int _EXFUN(mkfifo,( const char *__path, mode_t __mode )); |
int _EXFUN(stat,( const char *__path, struct stat *__sbuf )); |
mode_t _EXFUN(umask,( mode_t __mask )); |
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) |
int _EXFUN(lstat,( const char *__path, struct stat *__buf )); |
int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev )); |
#endif |
#if defined (__CYGWIN__) && !defined(__INSIDE_CYGWIN__) |
int _EXFUN(fchmodat, (int, const char *, mode_t, int)); |
int _EXFUN(fstatat, (int, const char *, struct stat *, int)); |
int _EXFUN(mkdirat, (int, const char *, mode_t)); |
int _EXFUN(mkfifoat, (int, const char *, mode_t)); |
int _EXFUN(mknodat, (int, const char *, mode_t, dev_t)); |
int _EXFUN(utimensat, (int, const char *, const struct timespec *, int)); |
int _EXFUN(futimens, (int, const struct timespec *)); |
#endif |
/* Provide prototypes for most of the _<systemcall> names that are |
provided in newlib for some compilers. */ |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(_fstat,( int __fd, struct stat *__sbuf )); |
int _EXFUN(_stat,( const char *__path, struct stat *__sbuf )); |
#ifdef __LARGE64_FILES |
struct stat64; |
int _EXFUN(_fstat64,( int __fd, struct stat64 *__sbuf )); |
#endif |
#endif |
#endif /* !_STAT_H_ */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_STAT_H */ |
/programs/develop/libraries/newlib/include/sys/stdio.h |
---|
0,0 → 1,27 |
#ifndef _NEWLIB_STDIO_H |
#define _NEWLIB_STDIO_H |
#include <sys/lock.h> |
#include <sys/reent.h> |
/* Internal locking macros, used to protect stdio functions. In the |
general case, expand to nothing. Use __SSTR flag in FILE _flags to |
detect if FILE is private to sprintf/sscanf class of functions; if |
set then do nothing as lock is not initialised. */ |
#if !defined(_flockfile) |
//#ifndef __SINGLE_THREAD__ |
//# define _flockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_acquire_recursive((fp)->_lock)) |
//#else |
# define _flockfile(fp) (_CAST_VOID 0) |
//#endif |
#endif |
#if !defined(_funlockfile) |
#ifndef __SINGLE_THREAD__ |
# define _funlockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_release_recursive((fp)->_lock)) |
#else |
# define _funlockfile(fp) (_CAST_VOID 0) |
#endif |
#endif |
#endif /* _NEWLIB_STDIO_H */ |
/programs/develop/libraries/newlib/include/sys/string.h |
---|
0,0 → 1,2 |
/* This is a dummy <sys/string.h> used as a placeholder for |
systems that need to have a special header file. */ |
/programs/develop/libraries/newlib/include/sys/syslimits.h |
---|
0,0 → 1,65 |
/* |
* Copyright (c) 1988, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)syslimits.h 8.1 (Berkeley) 6/2/93 |
* $FreeBSD: src/sys/sys/syslimits.h,v 1.10 2001/06/18 20:24:54 wollman Exp $ |
*/ |
#ifndef _SYS_SYSLIMITS_H_ |
#define _SYS_SYSLIMITS_H_ |
#define ARG_MAX 65536 /* max bytes for an exec function */ |
#ifndef CHILD_MAX |
#define CHILD_MAX 40 /* max simultaneous processes */ |
#endif |
#define LINK_MAX 32767 /* max file link count */ |
#define MAX_CANON 255 /* max bytes in term canon input line */ |
#define MAX_INPUT 255 /* max bytes in terminal input */ |
#define NAME_MAX 255 /* max bytes in a file name */ |
#define NGROUPS_MAX 16 /* max supplemental group id's */ |
#ifndef OPEN_MAX |
#define OPEN_MAX 64 /* max open files per process */ |
#endif |
#define PATH_MAX 1024 /* max bytes in pathname */ |
#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ |
#define IOV_MAX 1024 /* max elements in i/o vector */ |
#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ |
#define BC_DIM_MAX 2048 /* max array elements in bc(1) */ |
#define BC_SCALE_MAX 99 /* max scale value in bc(1) */ |
#define BC_STRING_MAX 1000 /* max const string length in bc(1) */ |
#define COLL_WEIGHTS_MAX 0 /* max weights for order keyword */ |
#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ |
#define LINE_MAX 2048 /* max bytes in an input line */ |
#define RE_DUP_MAX 255 /* max RE's in interval notation */ |
#endif |
/programs/develop/libraries/newlib/include/sys/time.h |
---|
0,0 → 1,84 |
/* time.h -- An implementation of the standard Unix <sys/time.h> file. |
Written by Geoffrey Noer <noer@cygnus.com> |
Public domain; no rights reserved. */ |
#ifndef _SYS_TIME_H_ |
#define _SYS_TIME_H_ |
#include <_ansi.h> |
#include <sys/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef _WINSOCK_H |
#define _TIMEVAL_DEFINED |
struct timeval { |
time_t tv_sec; |
suseconds_t tv_usec; |
}; |
struct timezone { |
int tz_minuteswest; |
int tz_dsttime; |
}; |
#ifdef __CYGWIN__ |
#include <cygwin/sys_time.h> |
#endif /* __CYGWIN__ */ |
#endif /* _WINSOCK_H */ |
#define ITIMER_REAL 0 |
#define ITIMER_VIRTUAL 1 |
#define ITIMER_PROF 2 |
struct itimerval { |
struct timeval it_interval; |
struct timeval it_value; |
}; |
/* BSD time macros used by RTEMS code */ |
#if defined (__rtems__) || defined (__CYGWIN__) |
/* Convenience macros for operations on timevals. |
NOTE: `timercmp' does not work for >= or <=. */ |
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) |
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) |
#define timercmp(a, b, CMP) \ |
(((a)->tv_sec == (b)->tv_sec) ? \ |
((a)->tv_usec CMP (b)->tv_usec) : \ |
((a)->tv_sec CMP (b)->tv_sec)) |
#define timeradd(a, b, result) \ |
do { \ |
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ |
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ |
if ((result)->tv_usec >= 1000000) \ |
{ \ |
++(result)->tv_sec; \ |
(result)->tv_usec -= 1000000; \ |
} \ |
} while (0) |
#define timersub(a, b, result) \ |
do { \ |
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ |
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ |
if ((result)->tv_usec < 0) { \ |
--(result)->tv_sec; \ |
(result)->tv_usec += 1000000; \ |
} \ |
} while (0) |
#endif /* defined (__rtems__) || defined (__CYGWIN__) */ |
int _EXFUN(gettimeofday, (struct timeval *__p, void *__tz)); |
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *)); |
int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp)); |
int _EXFUN(getitimer, (int __which, struct itimerval *__value)); |
int _EXFUN(setitimer, (int __which, const struct itimerval *__value, |
struct itimerval *__ovalue)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_TIME_H_ */ |
/programs/develop/libraries/newlib/include/sys/timeb.h |
---|
0,0 → 1,39 |
/* timeb.h -- An implementation of the standard Unix <sys/timeb.h> file. |
Written by Ian Lance Taylor <ian@cygnus.com> |
Public domain; no rights reserved. |
<sys/timeb.h> declares the structure used by the ftime function, as |
well as the ftime function itself. Newlib does not provide an |
implementation of ftime. */ |
#ifndef _SYS_TIMEB_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_TIMEB_H |
#include <_ansi.h> |
#include <machine/types.h> |
#ifndef __time_t_defined |
typedef _TIME_T_ time_t; |
#define __time_t_defined |
#endif |
struct timeb |
{ |
time_t time; |
unsigned short millitm; |
short timezone; |
short dstflag; |
}; |
extern int ftime _PARAMS ((struct timeb *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* ! defined (_SYS_TIMEB_H) */ |
/programs/develop/libraries/newlib/include/sys/times.h |
---|
0,0 → 1,28 |
#ifndef _SYS_TIMES_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_TIMES_H |
#include <_ansi.h> |
#include <machine/types.h> |
#ifndef __clock_t_defined |
typedef _CLOCK_T_ clock_t; |
#define __clock_t_defined |
#endif |
/* Get Process Times, P1003.1b-1993, p. 92 */ |
struct tms { |
clock_t tms_utime; /* user time */ |
clock_t tms_stime; /* system time */ |
clock_t tms_cutime; /* user time, children */ |
clock_t tms_cstime; /* system time, children */ |
}; |
clock_t _EXFUN(times,(struct tms *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_SYS_TIMES_H */ |
/programs/develop/libraries/newlib/include/sys/types.h |
---|
0,0 → 1,480 |
/* unified sys/types.h: |
start with sef's sysvi386 version. |
merge go32 version -- a few ifdefs. |
h8300hms, h8300xray, and sysvnecv70 disagree on the following types: |
typedef int gid_t; |
typedef int uid_t; |
typedef int dev_t; |
typedef int ino_t; |
typedef int mode_t; |
typedef int caddr_t; |
however, these aren't "reasonable" values, the sysvi386 ones make far |
more sense, and should work sufficiently well (in particular, h8300 |
doesn't have a stat, and the necv70 doesn't matter.) -- eichin |
*/ |
#ifndef _SYS_TYPES_H |
#include <_ansi.h> |
#ifndef __INTTYPES_DEFINED__ |
#define __INTTYPES_DEFINED__ |
#include <machine/_types.h> |
#if defined(__rtems__) || defined(__XMK__) |
/* |
* The following section is RTEMS specific and is needed to more |
* closely match the types defined in the BSD sys/types.h. |
* This is needed to let the RTEMS/BSD TCP/IP stack compile. |
*/ |
/* deprecated */ |
#if ___int8_t_defined |
typedef __uint8_t u_int8_t; |
#endif |
#if ___int16_t_defined |
typedef __uint16_t u_int16_t; |
#endif |
#if ___int32_t_defined |
typedef __uint32_t u_int32_t; |
#endif |
#if ___int64_t_defined |
typedef __uint64_t u_int64_t; |
/* deprecated */ |
typedef __uint64_t u_quad_t; |
typedef __int64_t quad_t; |
typedef quad_t * qaddr_t; |
#endif |
#endif |
#endif /* ! __INTTYPES_DEFINED */ |
#ifndef __need_inttypes |
#define _SYS_TYPES_H |
#include <sys/_types.h> |
#ifdef __i386__ |
#if defined (GO32) || defined (__MSDOS__) |
#define __MS_types__ |
#endif |
#endif |
# include <stddef.h> |
# include <machine/types.h> |
/* To ensure the stat struct's layout doesn't change when sizeof(int), etc. |
changes, we assume sizeof short and long never change and have all types |
used to define struct stat use them and not int where possible. |
Where not possible, _ST_INTxx are used. It would be preferable to not have |
such assumptions, but until the extra fluff is necessary, it's avoided. |
No 64 bit targets use stat yet. What to do about them is postponed |
until necessary. */ |
#ifdef __GNUC__ |
#define _ST_INT32 __attribute__ ((__mode__ (__SI__))) |
#else |
#define _ST_INT32 |
#endif |
# ifndef _POSIX_SOURCE |
# define physadr physadr_t |
# define quad quad_t |
#ifndef _BSDTYPES_DEFINED |
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */ |
typedef unsigned char u_char; |
typedef unsigned short u_short; |
typedef unsigned int u_int; |
typedef unsigned long u_long; |
#define _BSDTYPES_DEFINED |
#endif |
typedef unsigned short ushort; /* System V compatibility */ |
typedef unsigned int uint; /* System V compatibility */ |
# endif /*!_POSIX_SOURCE */ |
#ifndef __clock_t_defined |
typedef _CLOCK_T_ clock_t; |
#define __clock_t_defined |
#endif |
#ifndef __time_t_defined |
typedef _TIME_T_ time_t; |
#define __time_t_defined |
/* Time Value Specification Structures, P1003.1b-1993, p. 261 */ |
struct timespec { |
time_t tv_sec; /* Seconds */ |
long tv_nsec; /* Nanoseconds */ |
}; |
struct itimerspec { |
struct timespec it_interval; /* Timer period */ |
struct timespec it_value; /* Timer expiration */ |
}; |
#endif |
typedef long daddr_t; |
typedef char * caddr_t; |
#ifndef __CYGWIN__ |
#if defined(__MS_types__) || defined(__rtems__) || \ |
defined(__sparc__) || defined(__SPU__) |
typedef unsigned long ino_t; |
#else |
typedef unsigned short ino_t; |
#endif |
#endif /*__CYGWIN__*/ |
#ifdef __MS_types__ |
typedef unsigned long vm_offset_t; |
typedef unsigned long vm_size_t; |
#define __BIT_TYPES_DEFINED__ |
typedef signed char int8_t; |
typedef unsigned char u_int8_t; |
typedef short int16_t; |
typedef unsigned short u_int16_t; |
typedef int int32_t; |
typedef unsigned int u_int32_t; |
typedef long long int64_t; |
typedef unsigned long long u_int64_t; |
typedef int32_t register_t; |
#endif /* __MS_types__ */ |
/* |
* All these should be machine specific - right now they are all broken. |
* However, for all of Cygnus' embedded targets, we want them to all be |
* the same. Otherwise things like sizeof (struct stat) might depend on |
* how the file was compiled (e.g. -mint16 vs -mint32, etc.). |
*/ |
#ifndef __CYGWIN__ /* which defines these types in it's own types.h. */ |
typedef _off_t off_t; |
typedef __dev_t dev_t; |
typedef __uid_t uid_t; |
typedef __gid_t gid_t; |
#endif |
#if defined(__XMK__) |
typedef signed char pid_t; |
#else |
typedef int pid_t; |
#endif |
#ifndef __CYGWIN__ |
typedef long key_t; |
#endif |
typedef _ssize_t ssize_t; |
#ifndef __CYGWIN__ |
#ifdef __MS_types__ |
typedef char * addr_t; |
typedef int mode_t; |
#else |
#if defined (__sparc__) && !defined (__sparc_v9__) |
#ifdef __svr4__ |
typedef unsigned long mode_t; |
#else |
typedef unsigned short mode_t; |
#endif |
#else |
typedef unsigned int mode_t _ST_INT32; |
#endif |
#endif /* ! __MS_types__ */ |
#endif /*__CYGWIN__*/ |
typedef unsigned short nlink_t; |
/* We don't define fd_set and friends if we are compiling POSIX |
source, or if we have included (or may include as indicated |
by __USE_W32_SOCKETS) the W32api winsock[2].h header which |
defines Windows versions of them. Note that a program which |
includes the W32api winsock[2].h header must know what it is doing; |
it must not call the cygwin32 select function. |
*/ |
# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) |
# define _SYS_TYPES_FD_SET |
# define NBBY 8 /* number of bits in a byte */ |
/* |
* Select uses bit masks of file descriptors in longs. |
* These macros manipulate such bit fields (the filesystem macros use chars). |
* FD_SETSIZE may be defined by the user, but the default here |
* should be >= NOFILE (param.h). |
*/ |
# ifndef FD_SETSIZE |
# define FD_SETSIZE 64 |
# endif |
typedef long fd_mask; |
# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ |
# ifndef howmany |
# define howmany(x,y) (((x)+((y)-1))/(y)) |
# endif |
/* We use a macro for fd_set so that including Sockets.h afterwards |
can work. */ |
typedef struct _types_fd_set { |
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; |
} _types_fd_set; |
#define fd_set _types_fd_set |
# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) |
# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) |
# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) |
# define FD_ZERO(p) (__extension__ (void)({ \ |
size_t __i; \ |
char *__tmp = (char *)p; \ |
for (__i = 0; __i < sizeof (*(p)); ++__i) \ |
*__tmp++ = 0; \ |
})) |
# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */ |
#undef __MS_types__ |
#undef _ST_INT32 |
#ifndef __clockid_t_defined |
typedef _CLOCKID_T_ clockid_t; |
#define __clockid_t_defined |
#endif |
#ifndef __timer_t_defined |
typedef _TIMER_T_ timer_t; |
#define __timer_t_defined |
#endif |
typedef unsigned long useconds_t; |
typedef long suseconds_t; |
#include <sys/features.h> |
/* Cygwin will probably never have full posix compliance due to little things |
* like an inability to set the stackaddress. Cygwin is also using void * |
* pointers rather than structs to ensure maximum binary compatability with |
* previous releases. |
* This means that we don't use the types defined here, but rather in |
* <cygwin/types.h> |
*/ |
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__) |
#include <sys/sched.h> |
/* |
* 2.5 Primitive System Data Types, P1003.1c/D10, p. 19. |
*/ |
#if defined(__XMK__) |
typedef unsigned int pthread_t; /* identify a thread */ |
#else |
typedef __uint32_t pthread_t; /* identify a thread */ |
#endif |
/* P1003.1c/D10, p. 118-119 */ |
#define PTHREAD_SCOPE_PROCESS 0 |
#define PTHREAD_SCOPE_SYSTEM 1 |
/* P1003.1c/D10, p. 111 */ |
#define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */ |
/* attributes are inherited from */ |
/* the calling thread. */ |
#define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */ |
/* P1003.1c/D10, p. 141 */ |
#define PTHREAD_CREATE_DETACHED 0 |
#define PTHREAD_CREATE_JOINABLE 1 |
#if defined(__XMK__) || defined(__rtems__) |
/* The following defines are part of the X/Open System Interface (XSI). */ |
/* This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking |
* it shall deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behavior. |
* Attempting to unlock an unlocked mutex results in undefined behavior. |
*/ |
#define PTHREAD_MUTEX_NORMAL 1 |
/* |
* This type of mutex provides error checking. A thread attempting to relock this mutex without first unlocking |
* it shall return with an error. A thread attempting to unlock a mutex which another thread has locked shall return |
* with an error. A thread attempting to unlock an unlocked mutex shall return with an error. |
*/ |
#define PTHREAD_MUTEX_ERRORCHECK 2 |
/* A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mutex. |
* The relocking deadlock which can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex. |
* Multiple locks of this mutex shall require the same number of unlocks to release the mutex before another thread can |
* acquire the mutex. A thread attempting to unlock a mutex which another thread has locked shall return with an error. |
* A thread attempting to unlock an unlocked mutex shall return with an error. |
*/ |
#define PTHREAD_MUTEX_RECURSIVE 3 |
/* Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a |
* mutex of this type which was not locked by the calling thread results in undefined behavior. Attempting to |
* unlock a mutex of this type which is not locked results in undefined behavior. An implementation may map this |
* mutex to one of the other mutex types. |
*/ |
#define PTHREAD_MUTEX_DEFAULT 4 |
#endif /* defined(__XMK__) || defined(__rtems__) */ |
#if defined(__XMK__) |
typedef struct pthread_attr_s { |
int contentionscope; |
struct sched_param schedparam; |
int detachstate; |
void *stackaddr; |
size_t stacksize; |
} pthread_attr_t; |
#define PTHREAD_STACK_MIN 200 |
#else /* !defined(__XMK__) */ |
typedef struct { |
int is_initialized; |
void *stackaddr; |
int stacksize; |
int contentionscope; |
int inheritsched; |
int schedpolicy; |
struct sched_param schedparam; |
/* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */ |
#if defined(_POSIX_THREAD_CPUTIME) |
int cputime_clock_allowed; /* see time.h */ |
#endif |
int detachstate; |
} pthread_attr_t; |
#endif /* !defined(__XMK__) */ |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */ |
#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */ |
#define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */ |
/* the memory where the resource is */ |
/* located */ |
#endif |
#if defined(_POSIX_THREAD_PRIO_PROTECT) |
/* Mutexes */ |
/* Values for blocking protocol. */ |
#define PTHREAD_PRIO_NONE 0 |
#define PTHREAD_PRIO_INHERIT 1 |
#define PTHREAD_PRIO_PROTECT 2 |
#endif |
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
/* Values for mutex type */ |
#define PTHREAD_MUTEX_NORMAL 0 |
#define PTHREAD_MUTEX_RECURSIVE 1 |
#define PTHREAD_MUTEX_ERRORCHECK 2 |
#define PTHREAD_MUTEX_DEFAULT 3 |
#endif |
#if defined(__XMK__) |
typedef unsigned int pthread_mutex_t; /* identify a mutex */ |
typedef struct { |
int type; |
} pthread_mutexattr_t; |
#else /* !defined(__XMK__) */ |
typedef __uint32_t pthread_mutex_t; /* identify a mutex */ |
typedef struct { |
int is_initialized; |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow mutex to be shared amongst processes */ |
#endif |
#if defined(_POSIX_THREAD_PRIO_PROTECT) |
int prio_ceiling; |
int protocol; |
#endif |
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
int type; |
#endif |
int recursive; |
} pthread_mutexattr_t; |
#endif /* !defined(__XMK__) */ |
/* Condition Variables */ |
typedef __uint32_t pthread_cond_t; /* identify a condition variable */ |
typedef struct { |
int is_initialized; |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow this to be shared amongst processes */ |
#endif |
} pthread_condattr_t; /* a condition attribute object */ |
/* Keys */ |
typedef __uint32_t pthread_key_t; /* thread-specific data keys */ |
typedef struct { |
int is_initialized; /* is this structure initialized? */ |
int init_executed; /* has the initialization routine been run? */ |
} pthread_once_t; /* dynamic package initialization */ |
#else |
#if defined (__CYGWIN__) |
#include <cygwin/types.h> |
#endif |
#endif /* defined(_POSIX_THREADS) */ |
/* POSIX Barrier Types */ |
#if defined(_POSIX_BARRIERS) |
typedef __uint32_t pthread_barrier_t; /* POSIX Barrier Object */ |
typedef struct { |
int is_initialized; /* is this structure initialized? */ |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow this to be shared amongst processes */ |
#endif |
} pthread_barrierattr_t; |
#endif /* defined(_POSIX_BARRIERS) */ |
/* POSIX Spin Lock Types */ |
#if defined(_POSIX_SPIN_LOCKS) |
typedef __uint32_t pthread_spinlock_t; /* POSIX Spin Lock Object */ |
#endif /* defined(_POSIX_SPIN_LOCKS) */ |
/* POSIX Reader/Writer Lock Types */ |
#if !defined (__CYGWIN__) |
#if defined(_POSIX_READER_WRITER_LOCKS) |
typedef __uint32_t pthread_rwlock_t; /* POSIX RWLock Object */ |
typedef struct { |
int is_initialized; /* is this structure initialized? */ |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow this to be shared amongst processes */ |
#endif |
} pthread_rwlockattr_t; |
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */ |
#endif /* __CYGWIN__ */ |
#endif /* !__need_inttypes */ |
#undef __need_inttypes |
#endif /* _SYS_TYPES_H */ |
/programs/develop/libraries/newlib/include/sys/unistd.h |
---|
0,0 → 1,503 |
#ifndef _SYS_UNISTD_H |
#define _SYS_UNISTD_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <_ansi.h> |
#include <sys/types.h> |
#include <sys/_types.h> |
#define __need_size_t |
#define __need_ptrdiff_t |
#include <stddef.h> |
extern char **environ; |
void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn))); |
int _EXFUN(access,(const char *__path, int __amode )); |
unsigned _EXFUN(alarm, (unsigned __secs )); |
int _EXFUN(chdir, (const char *__path )); |
int _EXFUN(chmod, (const char *__path, mode_t __mode )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group )); |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(chroot, (const char *__path )); |
#endif |
int _EXFUN(close, (int __fildes )); |
#if defined(__CYGWIN__) |
size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len)); |
#endif |
char * _EXFUN(ctermid, (char *__s )); |
char * _EXFUN(cuserid, (char *__s )); |
#if defined(__CYGWIN__) |
int _EXFUN(daemon, (int nochdir, int noclose)); |
#endif |
int _EXFUN(dup, (int __fildes )); |
int _EXFUN(dup2, (int __fildes, int __fildes2 )); |
#if defined(__CYGWIN__) |
int _EXFUN(dup3, (int __fildes, int __fildes2, int flags)); |
int _EXFUN(eaccess, (const char *__path, int __mode)); |
void _EXFUN(endusershell, (void)); |
int _EXFUN(euidaccess, (const char *__path, int __mode)); |
#endif |
int _EXFUN(execl, (const char *__path, const char *, ... )); |
int _EXFUN(execle, (const char *__path, const char *, ... )); |
int _EXFUN(execlp, (const char *__file, const char *, ... )); |
int _EXFUN(execv, (const char *__path, char * const __argv[] )); |
int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] )); |
int _EXFUN(execvp, (const char *__file, char * const __argv[] )); |
#if defined(__CYGWIN__) |
int _EXFUN(execvpe, (const char *__file, char * const __argv[], char * const __envp[] )); |
int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags)); |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__) |
int _EXFUN(fchdir, (int __fildes)); |
#endif |
int _EXFUN(fchmod, (int __fildes, mode_t __mode )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group )); |
#endif |
#if defined(__CYGWIN__) |
int _EXFUN(fchownat, (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags)); |
int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] )); |
#endif |
pid_t _EXFUN(fork, (void )); |
long _EXFUN(fpathconf, (int __fd, int __name )); |
int _EXFUN(fsync, (int __fd)); |
int _EXFUN(fdatasync, (int __fd)); |
char * _EXFUN(getcwd, (char *__buf, size_t __size )); |
#if defined(__CYGWIN__) |
int _EXFUN(getdomainname ,(char *__name, size_t __len)); |
#endif |
#if !defined(__INSIDE_CYGWIN__) |
gid_t _EXFUN(getegid, (void )); |
uid_t _EXFUN(geteuid, (void )); |
gid_t _EXFUN(getgid, (void )); |
#endif |
int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] )); |
#if defined(__CYGWIN__) |
long _EXFUN(gethostid, (void)); |
#endif |
char * _EXFUN(getlogin, (void )); |
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) |
int _EXFUN(getlogin_r, (char *name, size_t namesize) ); |
#endif |
char * _EXFUN(getpass, (const char *__prompt)); |
int _EXFUN(getpagesize, (void)); |
#if defined(__CYGWIN__) |
int _EXFUN(getpeereid, (int, uid_t *, gid_t *)); |
#endif |
pid_t _EXFUN(getpgid, (pid_t)); |
pid_t _EXFUN(getpgrp, (void )); |
pid_t _EXFUN(getpid, (void )); |
pid_t _EXFUN(getppid, (void )); |
#if defined(__CYGWIN__) || defined(__rtems__) |
pid_t _EXFUN(getsid, (pid_t)); |
#endif |
#if !defined(__INSIDE_CYGWIN__) |
uid_t _EXFUN(getuid, (void )); |
#endif |
#ifdef __CYGWIN__ |
char * _EXFUN(getusershell, (void)); |
char * _EXFUN(getwd, (char *__buf )); |
int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser)); |
#endif |
int _EXFUN(isatty, (int __fildes )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group )); |
#endif |
int _EXFUN(link, (const char *__path1, const char *__path2 )); |
#if defined(__CYGWIN__) |
int _EXFUN(linkat, (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags )); |
#endif |
int _EXFUN(nice, (int __nice_value )); |
#if !defined(__INSIDE_CYGWIN__) |
off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence )); |
#endif |
#if defined(__SPU__) || defined(__CYGWIN__) |
#define F_ULOCK 0 |
#define F_LOCK 1 |
#define F_TLOCK 2 |
#define F_TEST 3 |
int _EXFUN(lockf, (int __fd, int __cmd, off_t __len)); |
#endif |
long _EXFUN(pathconf, (const char *__path, int __name )); |
int _EXFUN(pause, (void )); |
#ifdef __CYGWIN__ |
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void))); |
#endif |
int _EXFUN(pipe, (int __fildes[2] )); |
#ifdef __CYGWIN__ |
int _EXFUN(pipe2, (int __fildes[2], int flags)); |
#endif |
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset)); |
ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset)); |
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte )); |
#if defined(__CYGWIN__) |
int _EXFUN(rresvport, (int *__alport)); |
int _EXFUN(revoke, (char *__path)); |
#endif |
int _EXFUN(rmdir, (const char *__path )); |
#if defined(__CYGWIN__) |
int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser)); |
#endif |
void * _EXFUN(sbrk, (ptrdiff_t __incr)); |
#if !defined(__INSIDE_CYGWIN__) |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(setegid, (gid_t __gid )); |
int _EXFUN(seteuid, (uid_t __uid )); |
#endif |
int _EXFUN(setgid, (gid_t __gid )); |
#endif |
#if defined(__CYGWIN__) |
int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist )); |
#endif |
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid )); |
int _EXFUN(setpgrp, (void )); |
#if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) |
int _EXFUN(setregid, (gid_t __rgid, gid_t __egid)); |
int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid)); |
#endif |
pid_t _EXFUN(setsid, (void )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(setuid, (uid_t __uid )); |
#endif |
#if defined(__CYGWIN__) |
void _EXFUN(setusershell, (void)); |
#endif |
unsigned _EXFUN(sleep, (unsigned int __seconds )); |
void _EXFUN(swab, (const void *, void *, ssize_t)); |
long _EXFUN(sysconf, (int __name )); |
pid_t _EXFUN(tcgetpgrp, (int __fildes )); |
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id )); |
char * _EXFUN(ttyname, (int __fildes )); |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(ttyname_r, (int, char *, size_t)); |
#endif |
int _EXFUN(unlink, (const char *__path )); |
int _EXFUN(usleep, (useconds_t __useconds)); |
int _EXFUN(vhangup, (void )); |
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte )); |
#ifdef __CYGWIN__ |
# define __UNISTD_GETOPT__ |
# include <getopt.h> |
# undef __UNISTD_GETOPT__ |
#else |
extern char *optarg; /* getopt(3) external variables */ |
extern int optind, opterr, optopt; |
int getopt(int, char * const [], const char *); |
extern int optreset; /* getopt(3) external variable */ |
#endif |
#ifndef _POSIX_SOURCE |
pid_t _EXFUN(vfork, (void )); |
#endif /* _POSIX_SOURCE */ |
#ifdef _COMPILING_NEWLIB |
/* Provide prototypes for most of the _<systemcall> names that are |
provided in newlib for some compilers. */ |
int _EXFUN(_close, (int __fildes )); |
pid_t _EXFUN(_fork, (void )); |
pid_t _EXFUN(_getpid, (void )); |
int _EXFUN(_isatty, (int __fildes )); |
int _EXFUN(_link, (const char *__path1, const char *__path2 )); |
_off_t _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence )); |
#ifdef __LARGE64_FILES |
_off64_t _EXFUN(_lseek64, (int __filedes, _off64_t __offset, int __whence )); |
#endif |
_READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte )); |
void * _EXFUN(_sbrk, (ptrdiff_t __incr)); |
int _EXFUN(_unlink, (const char *__path )); |
_READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte )); |
int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] )); |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__) || defined(__SPU__) |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(ftruncate, (int __fd, off_t __length)); |
int _EXFUN(truncate, (const char *, off_t __length)); |
#endif |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(getdtablesize, (void)); |
int _EXFUN(setdtablesize, (int)); |
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval)); |
#if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) |
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */ |
int _EXFUN(gethostname, (char *__name, size_t __len)); |
#endif |
char * _EXFUN(mktemp, (char *)); |
#endif |
#if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__) |
void _EXFUN(sync, (void)); |
#endif |
ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen)); |
#if defined(__CYGWIN__) |
ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen)); |
#endif |
int _EXFUN(symlink, (const char *__name1, const char *__name2)); |
#if defined(__CYGWIN__) |
int _EXFUN(symlinkat, (const char *, int, const char *)); |
int _EXFUN(unlinkat, (int, const char *, int)); |
#endif |
#define F_OK 0 |
#define R_OK 4 |
#define W_OK 2 |
#define X_OK 1 |
# define SEEK_SET 0 |
# define SEEK_CUR 1 |
# define SEEK_END 2 |
#include <sys/features.h> |
#define STDIN_FILENO 0 /* standard input file descriptor */ |
#define STDOUT_FILENO 1 /* standard output file descriptor */ |
#define STDERR_FILENO 2 /* standard error file descriptor */ |
/* |
* sysconf values per IEEE Std 1003.1, 2008 Edition |
*/ |
#define _SC_ARG_MAX 0 |
#define _SC_CHILD_MAX 1 |
#define _SC_CLK_TCK 2 |
#define _SC_NGROUPS_MAX 3 |
#define _SC_OPEN_MAX 4 |
#define _SC_JOB_CONTROL 5 |
#define _SC_SAVED_IDS 6 |
#define _SC_VERSION 7 |
#define _SC_PAGESIZE 8 |
#define _SC_PAGE_SIZE _SC_PAGESIZE |
/* These are non-POSIX values we accidentally introduced in 2000 without |
guarding them. Keeping them unguarded for backward compatibility. */ |
#define _SC_NPROCESSORS_CONF 9 |
#define _SC_NPROCESSORS_ONLN 10 |
#define _SC_PHYS_PAGES 11 |
#define _SC_AVPHYS_PAGES 12 |
/* End of non-POSIX values. */ |
#define _SC_MQ_OPEN_MAX 13 |
#define _SC_MQ_PRIO_MAX 14 |
#define _SC_RTSIG_MAX 15 |
#define _SC_SEM_NSEMS_MAX 16 |
#define _SC_SEM_VALUE_MAX 17 |
#define _SC_SIGQUEUE_MAX 18 |
#define _SC_TIMER_MAX 19 |
#define _SC_TZNAME_MAX 20 |
#define _SC_ASYNCHRONOUS_IO 21 |
#define _SC_FSYNC 22 |
#define _SC_MAPPED_FILES 23 |
#define _SC_MEMLOCK 24 |
#define _SC_MEMLOCK_RANGE 25 |
#define _SC_MEMORY_PROTECTION 26 |
#define _SC_MESSAGE_PASSING 27 |
#define _SC_PRIORITIZED_IO 28 |
#define _SC_REALTIME_SIGNALS 29 |
#define _SC_SEMAPHORES 30 |
#define _SC_SHARED_MEMORY_OBJECTS 31 |
#define _SC_SYNCHRONIZED_IO 32 |
#define _SC_TIMERS 33 |
#define _SC_AIO_LISTIO_MAX 34 |
#define _SC_AIO_MAX 35 |
#define _SC_AIO_PRIO_DELTA_MAX 36 |
#define _SC_DELAYTIMER_MAX 37 |
#define _SC_THREAD_KEYS_MAX 38 |
#define _SC_THREAD_STACK_MIN 39 |
#define _SC_THREAD_THREADS_MAX 40 |
#define _SC_TTY_NAME_MAX 41 |
#define _SC_THREADS 42 |
#define _SC_THREAD_ATTR_STACKADDR 43 |
#define _SC_THREAD_ATTR_STACKSIZE 44 |
#define _SC_THREAD_PRIORITY_SCHEDULING 45 |
#define _SC_THREAD_PRIO_INHERIT 46 |
/* _SC_THREAD_PRIO_PROTECT was _SC_THREAD_PRIO_CEILING in early drafts */ |
#define _SC_THREAD_PRIO_PROTECT 47 |
#define _SC_THREAD_PRIO_CEILING _SC_THREAD_PRIO_PROTECT |
#define _SC_THREAD_PROCESS_SHARED 48 |
#define _SC_THREAD_SAFE_FUNCTIONS 49 |
#define _SC_GETGR_R_SIZE_MAX 50 |
#define _SC_GETPW_R_SIZE_MAX 51 |
#define _SC_LOGIN_NAME_MAX 52 |
#define _SC_THREAD_DESTRUCTOR_ITERATIONS 53 |
#define _SC_ADVISORY_INFO 54 |
#define _SC_ATEXIT_MAX 55 |
#define _SC_BARRIERS 56 |
#define _SC_BC_BASE_MAX 57 |
#define _SC_BC_DIM_MAX 58 |
#define _SC_BC_SCALE_MAX 59 |
#define _SC_BC_STRING_MAX 60 |
#define _SC_CLOCK_SELECTION 61 |
#define _SC_COLL_WEIGHTS_MAX 62 |
#define _SC_CPUTIME 63 |
#define _SC_EXPR_NEST_MAX 64 |
#define _SC_HOST_NAME_MAX 65 |
#define _SC_IOV_MAX 66 |
#define _SC_IPV6 67 |
#define _SC_LINE_MAX 68 |
#define _SC_MONOTONIC_CLOCK 69 |
#define _SC_RAW_SOCKETS 70 |
#define _SC_READER_WRITER_LOCKS 71 |
#define _SC_REGEXP 72 |
#define _SC_RE_DUP_MAX 73 |
#define _SC_SHELL 74 |
#define _SC_SPAWN 75 |
#define _SC_SPIN_LOCKS 76 |
#define _SC_SPORADIC_SERVER 77 |
#define _SC_SS_REPL_MAX 78 |
#define _SC_SYMLOOP_MAX 79 |
#define _SC_THREAD_CPUTIME 80 |
#define _SC_THREAD_SPORADIC_SERVER 81 |
#define _SC_TIMEOUTS 82 |
#define _SC_TRACE 83 |
#define _SC_TRACE_EVENT_FILTER 84 |
#define _SC_TRACE_EVENT_NAME_MAX 85 |
#define _SC_TRACE_INHERIT 86 |
#define _SC_TRACE_LOG 87 |
#define _SC_TRACE_NAME_MAX 88 |
#define _SC_TRACE_SYS_MAX 89 |
#define _SC_TRACE_USER_EVENT_MAX 90 |
#define _SC_TYPED_MEMORY_OBJECTS 91 |
#define _SC_V7_ILP32_OFF32 92 |
#define _SC_V6_ILP32_OFF32 _SC_V7_ILP32_OFF32 |
#define _SC_XBS5_ILP32_OFF32 _SC_V7_ILP32_OFF32 |
#define _SC_V7_ILP32_OFFBIG 93 |
#define _SC_V6_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG |
#define _SC_XBS5_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG |
#define _SC_V7_LP64_OFF64 94 |
#define _SC_V6_LP64_OFF64 _SC_V7_LP64_OFF64 |
#define _SC_XBS5_LP64_OFF64 _SC_V7_LP64_OFF64 |
#define _SC_V7_LPBIG_OFFBIG 95 |
#define _SC_V6_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG |
#define _SC_XBS5_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG |
#define _SC_XOPEN_CRYPT 96 |
#define _SC_XOPEN_ENH_I18N 97 |
#define _SC_XOPEN_LEGACY 98 |
#define _SC_XOPEN_REALTIME 99 |
#define _SC_STREAM_MAX 100 |
#define _SC_PRIORITY_SCHEDULING 101 |
#define _SC_XOPEN_REALTIME_THREADS 102 |
#define _SC_XOPEN_SHM 103 |
#define _SC_XOPEN_STREAMS 104 |
#define _SC_XOPEN_UNIX 105 |
#define _SC_XOPEN_VERSION 106 |
#define _SC_2_CHAR_TERM 107 |
#define _SC_2_C_BIND 108 |
#define _SC_2_C_DEV 109 |
#define _SC_2_FORT_DEV 110 |
#define _SC_2_FORT_RUN 111 |
#define _SC_2_LOCALEDEF 112 |
#define _SC_2_PBS 113 |
#define _SC_2_PBS_ACCOUNTING 114 |
#define _SC_2_PBS_CHECKPOINT 115 |
#define _SC_2_PBS_LOCATE 116 |
#define _SC_2_PBS_MESSAGE 117 |
#define _SC_2_PBS_TRACK 118 |
#define _SC_2_SW_DEV 119 |
#define _SC_2_UPE 120 |
#define _SC_2_VERSION 121 |
#define _SC_THREAD_ROBUST_PRIO_INHERIT 122 |
#define _SC_THREAD_ROBUST_PRIO_PROTECT 123 |
#define _SC_XOPEN_UUCP 124 |
/* |
* pathconf values per IEEE Std 1003.1, 2008 Edition |
*/ |
#define _PC_LINK_MAX 0 |
#define _PC_MAX_CANON 1 |
#define _PC_MAX_INPUT 2 |
#define _PC_NAME_MAX 3 |
#define _PC_PATH_MAX 4 |
#define _PC_PIPE_BUF 5 |
#define _PC_CHOWN_RESTRICTED 6 |
#define _PC_NO_TRUNC 7 |
#define _PC_VDISABLE 8 |
#define _PC_ASYNC_IO 9 |
#define _PC_PRIO_IO 10 |
#define _PC_SYNC_IO 11 |
#define _PC_FILESIZEBITS 12 |
#define _PC_2_SYMLINKS 13 |
#define _PC_SYMLINK_MAX 14 |
#define _PC_ALLOC_SIZE_MIN 15 |
#define _PC_REC_INCR_XFER_SIZE 16 |
#define _PC_REC_MAX_XFER_SIZE 17 |
#define _PC_REC_MIN_XFER_SIZE 18 |
#define _PC_REC_XFER_ALIGN 19 |
#define _PC_TIMESTAMP_RESOLUTION 20 |
#ifdef __CYGWIN__ |
/* Ask for POSIX permission bits support. */ |
#define _PC_POSIX_PERMISSIONS 90 |
/* Ask for full POSIX permission support including uid/gid settings. */ |
#define _PC_POSIX_SECURITY 91 |
#endif |
/* |
* confstr values per IEEE Std 1003.1, 2004 Edition |
*/ |
#ifdef __CYGWIN__ /* Only defined on Cygwin for now. */ |
#define _CS_PATH 0 |
#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1 |
#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS |
#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS |
#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 2 |
#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS |
#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS |
#define _CS_POSIX_V7_ILP32_OFF32_LIBS 3 |
#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS |
#define _CS_XBS5_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS |
#define _CS_XBS5_ILP32_OFF32_LINTFLAGS 4 |
#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 5 |
#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS |
#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS |
#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 6 |
#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS |
#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS |
#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 7 |
#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS |
#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS |
#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 8 |
#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 9 |
#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS |
#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS |
#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 10 |
#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS |
#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS |
#define _CS_POSIX_V7_LP64_OFF64_LIBS 11 |
#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS |
#define _CS_XBS5_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS |
#define _CS_XBS5_LP64_OFF64_LINTFLAGS 12 |
#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 13 |
#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS |
#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS |
#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 14 |
#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS |
#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS |
#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 15 |
#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS |
#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS |
#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 16 |
#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 17 |
#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS |
#define _CS_POSIX_V7_THREADS_CFLAGS 18 |
#define _CS_POSIX_V7_THREADS_LDFLAGS 19 |
#define _CS_V7_ENV 20 |
#define _CS_V6_ENV _CS_V6_ENV |
#endif |
#ifndef __CYGWIN__ |
# define MAXPATHLEN 1024 |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_UNISTD_H */ |
/programs/develop/libraries/newlib/include/sys/utime.h |
---|
0,0 → 1,22 |
#ifndef _SYS_UTIME_H |
#define _SYS_UTIME_H |
/* This is a dummy <sys/utime.h> file, not customized for any |
particular system. If there is a utime.h in libc/sys/SYSDIR/sys, |
it will override this one. */ |
#ifdef __cplusplus |
extern "C" { |
#endif |
struct utimbuf |
{ |
time_t actime; |
time_t modtime; |
}; |
#ifdef __cplusplus |
}; |
#endif |
#endif /* _SYS_UTIME_H */ |
/programs/develop/libraries/newlib/include/sys/wait.h |
---|
0,0 → 1,40 |
#ifndef _SYS_WAIT_H |
#define _SYS_WAIT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/types.h> |
#define WNOHANG 1 |
#define WUNTRACED 2 |
/* A status looks like: |
<2 bytes info> <2 bytes code> |
<code> == 0, child has exited, info is the exit value |
<code> == 1..7e, child has exited, info is the signal number. |
<code> == 7f, child has stopped, info was the signal number. |
<code> == 80, there was a core dump. |
*/ |
#define WIFEXITED(w) (((w) & 0xff) == 0) |
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) |
#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) |
#define WEXITSTATUS(w) (((w) >> 8) & 0xff) |
#define WTERMSIG(w) ((w) & 0x7f) |
#define WSTOPSIG WEXITSTATUS |
pid_t wait (int *); |
pid_t waitpid (pid_t, int *, int); |
/* Provide prototypes for most of the _<systemcall> names that are |
provided in newlib for some compilers. */ |
pid_t _wait (int *); |
#ifdef __cplusplus |
}; |
#endif |
#endif |
/programs/develop/libraries/newlib/include/sys |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/include/tar.h |
---|
0,0 → 1,39 |
/* |
* tar.h |
*/ |
#ifndef _TAR_H |
#define _TAR_H |
/* General definitions */ |
#define TMAGIC "ustar" /* ustar plus null byte. */ |
#define TMAGLEN 6 /* Length of the above. */ |
#define TVERSION "00" /* 00 without a null byte. */ |
#define TVERSLEN 2 /* Length of the above. */ |
/* Typeflag field definitions */ |
#define REGTYPE '0' /* Regular file. */ |
#define AREGTYPE '\0' /* Regular file. */ |
#define LNKTYPE '1' /* Link. */ |
#define SYMTYPE '2' /* Symbolic link. */ |
#define CHRTYPE '3' /* Character special. */ |
#define BLKTYPE '4' /* Block special. */ |
#define DIRTYPE '5' /* Directory. */ |
#define FIFOTYPE '6' /* FIFO special. */ |
#define CONTTYPE '7' /* Reserved. */ |
/* Mode field bit definitions (octal) */ |
#define TSUID 04000 /* Set UID on execution. */ |
#define TSGID 02000 /* Set GID on execution. */ |
#define TSVTX 01000 /* On directories, restricted deletion flag. */ |
#define TUREAD 00400 /* Read by owner. */ |
#define TUWRITE 00200 /* Write by owner. */ |
#define TUEXEC 00100 /* Execute/search by owner. */ |
#define TGREAD 00040 /* Read by group. */ |
#define TGWRITE 00020 /* Write by group. */ |
#define TGEXEC 00010 /* Execute/search by group. */ |
#define TOREAD 00004 /* Read by other. */ |
#define TOWRITE 00002 /* Write by other. */ |
#define TOEXEC 00001 /* Execute/search by other. */ |
#endif |
/programs/develop/libraries/newlib/include/termios.h |
---|
0,0 → 1,7 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/termios.h> |
#ifdef __cplusplus |
} |
#endif |
/programs/develop/libraries/newlib/include/time.h |
---|
0,0 → 1,261 |
/* |
* time.h |
* |
* Struct and function declarations for dealing with time. |
*/ |
#ifndef _TIME_H_ |
#define _TIME_H_ |
#include "_ansi.h" |
#include <sys/reent.h> |
#ifndef NULL |
#define NULL 0 |
#endif |
/* Get _CLOCKS_PER_SEC_ */ |
#include <machine/time.h> |
#ifndef _CLOCKS_PER_SEC_ |
#define _CLOCKS_PER_SEC_ 1000 |
#endif |
#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_ |
#define CLK_TCK CLOCKS_PER_SEC |
#define __need_size_t |
#include <stddef.h> |
#include <sys/types.h> |
_BEGIN_STD_C |
struct tm |
{ |
int tm_sec; |
int tm_min; |
int tm_hour; |
int tm_mday; |
int tm_mon; |
int tm_year; |
int tm_wday; |
int tm_yday; |
int tm_isdst; |
}; |
clock_t _EXFUN(clock, (void)); |
double _EXFUN(difftime, (time_t _time2, time_t _time1)); |
time_t _EXFUN(mktime, (struct tm *_timeptr)); |
time_t _EXFUN(time, (time_t *_timer)); |
#ifndef _REENT_ONLY |
char *_EXFUN(asctime, (const struct tm *_tblock)); |
char *_EXFUN(ctime, (const time_t *_time)); |
struct tm *_EXFUN(gmtime, (const time_t *_timer)); |
struct tm *_EXFUN(localtime,(const time_t *_timer)); |
#endif |
size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t)); |
char *_EXFUN(asctime_r, (const struct tm *, char *)); |
char *_EXFUN(ctime_r, (const time_t *, char *)); |
struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *)); |
struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *)); |
_END_STD_C |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef __STRICT_ANSI__ |
char *_EXFUN(strptime, (const char *, const char *, struct tm *)); |
_VOID _EXFUN(tzset, (_VOID)); |
_VOID _EXFUN(_tzset_r, (struct _reent *)); |
typedef struct __tzrule_struct |
{ |
char ch; |
int m; |
int n; |
int d; |
int s; |
time_t change; |
long offset; /* Match type of _timezone. */ |
} __tzrule_type; |
typedef struct __tzinfo_struct |
{ |
int __tznorth; |
int __tzyear; |
__tzrule_type __tzrule[2]; |
} __tzinfo_type; |
__tzinfo_type *_EXFUN (__gettzinfo, (_VOID)); |
/* getdate functions */ |
#ifdef HAVE_GETDATE |
#ifndef _REENT_ONLY |
#define getdate_err (*__getdate_err()) |
int *_EXFUN(__getdate_err,(_VOID)); |
struct tm * _EXFUN(getdate, (const char *)); |
/* getdate_err is set to one of the following values to indicate the error. |
1 the DATEMSK environment variable is null or undefined, |
2 the template file cannot be opened for reading, |
3 failed to get file status information, |
4 the template file is not a regular file, |
5 an error is encountered while reading the template file, |
6 memory allication failed (not enough memory available), |
7 there is no line in the template that matches the input, |
8 invalid input specification */ |
#endif /* !_REENT_ONLY */ |
/* getdate_r returns the error code as above */ |
int _EXFUN(getdate_r, (const char *, struct tm *)); |
#endif /* HAVE_GETDATE */ |
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */ |
extern __IMPORT long _timezone; |
extern __IMPORT int _daylight; |
extern __IMPORT char *_tzname[2]; |
/* POSIX defines the external tzname being defined in time.h */ |
#ifndef tzname |
#define tzname _tzname |
#endif |
#endif /* !__STRICT_ANSI__ */ |
#ifdef __cplusplus |
} |
#endif |
#include <sys/features.h> |
#ifdef __CYGWIN__ |
#include <cygwin/time.h> |
#endif /*__CYGWIN__*/ |
#if defined(_POSIX_TIMERS) |
#include <signal.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Clocks, P1003.1b-1993, p. 263 */ |
int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); |
int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp)); |
int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res)); |
/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */ |
int _EXFUN(timer_create, |
(clockid_t clock_id, struct sigevent *evp, timer_t *timerid)); |
/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */ |
int _EXFUN(timer_delete, (timer_t timerid)); |
/* Per-Process Timers, P1003.1b-1993, p. 267 */ |
int _EXFUN(timer_settime, |
(timer_t timerid, int flags, const struct itimerspec *value, |
struct itimerspec *ovalue)); |
int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value)); |
int _EXFUN(timer_getoverrun, (timer_t timerid)); |
/* High Resolution Sleep, P1003.1b-1993, p. 269 */ |
int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _POSIX_TIMERS */ |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */ |
/* values for the clock enable attribute */ |
#define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */ |
#define CLOCK_DISABLED 0 /* clock is disabled */ |
/* values for the pthread cputime_clock_allowed attribute */ |
#define CLOCK_ALLOWED 1 /* If a thread is created with this value a */ |
/* CPU-time clock attached to that thread */ |
/* shall be accessible. */ |
#define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */ |
/* thread shall not have a CPU-time clock */ |
/* accessible. */ |
/* Manifest Constants, P1003.1b-1993, p. 262 */ |
#define CLOCK_REALTIME (clockid_t)1 |
/* Flag indicating time is "absolute" with respect to the clock |
associated with a time. */ |
#define TIMER_ABSTIME 4 |
/* Manifest Constants, P1003.4b/D8, p. 55 */ |
#if defined(_POSIX_CPUTIME) |
/* When used in a clock or timer function call, this is interpreted as |
the identifier of the CPU_time clock associated with the PROCESS |
making the function call. */ |
#define CLOCK_PROCESS_CPUTIME (clockid_t)2 |
#endif |
#if defined(_POSIX_THREAD_CPUTIME) |
/* When used in a clock or timer function call, this is interpreted as |
the identifier of the CPU_time clock associated with the THREAD |
making the function call. */ |
#define CLOCK_THREAD_CPUTIME (clockid_t)3 |
#endif |
#if defined(_POSIX_MONOTONIC_CLOCK) |
/* The identifier for the system-wide monotonic clock, which is defined |
* as a clock whose value cannot be set via clock_settime() and which |
* cannot have backward clock jumps. */ |
#define CLOCK_MONOTONIC (clockid_t)4 |
#endif |
#if defined(_POSIX_CPUTIME) |
/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */ |
int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id)); |
#endif /* _POSIX_CPUTIME */ |
#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME) |
/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */ |
int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr)); |
int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr)); |
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _TIME_H_ */ |
/programs/develop/libraries/newlib/include/unctrl.h |
---|
0,0 → 1,46 |
/* From curses.h. */ |
/* |
* Copyright (c) 1981, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifndef _UNCTRL_H_ |
#define _UNCTRL_H_ |
#include <_ansi.h> |
#define unctrl(c) __unctrl[(c) & 0xff] |
#define unctrllen(ch) __unctrllen[(ch) & 0xff] |
extern __IMPORT _CONST char * _CONST __unctrl[256]; /* Control strings. */ |
extern __IMPORT _CONST char __unctrllen[256]; /* Control strings length. */ |
#endif /* _UNCTRL_H_ */ |
/programs/develop/libraries/newlib/include/unistd.h |
---|
0,0 → 1,6 |
#ifndef _UNISTD_H_ |
#define _UNISTD_H_ |
# include <sys/unistd.h> |
#endif /* _UNISTD_H_ */ |
/programs/develop/libraries/newlib/include/utime.h |
---|
0,0 → 1,12 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <_ansi.h> |
/* The utime function is defined in libc/sys/<arch>/sys if it exists. */ |
#include <sys/utime.h> |
#ifdef __cplusplus |
} |
#endif |
/programs/develop/libraries/newlib/include/utmp.h |
---|
0,0 → 1,8 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/utmp.h> |
#ifdef __cplusplus |
} |
#endif |
/programs/develop/libraries/newlib/include/wchar.h |
---|
0,0 → 1,192 |
#ifndef _WCHAR_H_ |
#define _WCHAR_H_ |
#include <_ansi.h> |
#include <sys/reent.h> |
#define __need_size_t |
#define __need_wchar_t |
#define __need_wint_t |
#include <stddef.h> |
#define __need___va_list |
#include <stdarg.h> |
/* For _mbstate_t definition. */ |
#include <sys/_types.h> |
#ifndef NULL |
#define NULL 0 |
#endif |
#ifndef WEOF |
# define WEOF ((wint_t)-1) |
#endif |
#ifndef WCHAR_MIN |
#define WCHAR_MIN 0 |
#endif |
#ifndef WCHAR_MAX |
#ifdef __WCHAR_MAX__ |
#define WCHAR_MAX __WCHAR_MAX__ |
#else |
#define WCHAR_MAX 0x7fffffffu |
#endif |
#endif |
_BEGIN_STD_C |
/* As required by POSIX.1-2008, declare tm as incomplete type. |
The actual definition is in time.h. */ |
struct tm; |
#ifndef _MBSTATE_T |
#define _MBSTATE_T |
typedef _mbstate_t mbstate_t; |
#endif /* _MBSTATE_T */ |
wint_t _EXFUN(btowc, (int)); |
int _EXFUN(wctob, (wint_t)); |
size_t _EXFUN(mbrlen, (const char * , size_t, mbstate_t *)); |
size_t _EXFUN(mbrtowc, (wchar_t * , const char * , size_t, mbstate_t *)); |
size_t _EXFUN(_mbrtowc_r, (struct _reent *, wchar_t * , const char * , |
size_t, mbstate_t *)); |
int _EXFUN(mbsinit, (const mbstate_t *)); |
size_t _EXFUN(mbsnrtowcs, (wchar_t * , const char ** , size_t, size_t, |
mbstate_t *)); |
size_t _EXFUN(_mbsnrtowcs_r, (struct _reent *, wchar_t * , const char ** , |
size_t, size_t, mbstate_t *)); |
size_t _EXFUN(mbsrtowcs, (wchar_t * , const char ** , size_t, mbstate_t *)); |
size_t _EXFUN(_mbsrtowcs_r, (struct _reent *, wchar_t * , const char ** , size_t, mbstate_t *)); |
size_t _EXFUN(wcrtomb, (char * , wchar_t, mbstate_t *)); |
size_t _EXFUN(_wcrtomb_r, (struct _reent *, char * , wchar_t, mbstate_t *)); |
size_t _EXFUN(wcsnrtombs, (char * , const wchar_t ** , size_t, size_t, |
mbstate_t *)); |
size_t _EXFUN(_wcsnrtombs_r, (struct _reent *, char * , const wchar_t ** , |
size_t, size_t, mbstate_t *)); |
size_t _EXFUN(wcsrtombs, (char * , const wchar_t ** , size_t, mbstate_t *)); |
size_t _EXFUN(_wcsrtombs_r, (struct _reent *, char * , const wchar_t ** , |
size_t, mbstate_t *)); |
int _EXFUN(wcscasecmp, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcscat, (wchar_t * , const wchar_t *)); |
wchar_t *_EXFUN(wcschr, (const wchar_t *, wchar_t)); |
int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *)); |
int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcscpy, (wchar_t * , const wchar_t *)); |
wchar_t *_EXFUN(wcpcpy, (wchar_t * , const wchar_t *)); |
wchar_t *_EXFUN(wcsdup, (const wchar_t *)); |
wchar_t *_EXFUN(_wcsdup_r, (struct _reent *, const wchar_t * )); |
size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *)); |
size_t _EXFUN(wcsftime, (wchar_t *, size_t, const wchar_t *, const struct tm *)); |
size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t)); |
size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t)); |
size_t _EXFUN(wcslen, (const wchar_t *)); |
int _EXFUN(wcsncasecmp, (const wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wcsncat, (wchar_t * , const wchar_t * , size_t)); |
int _EXFUN(wcsncmp, (const wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wcsncpy, (wchar_t * , const wchar_t * , size_t)); |
wchar_t *_EXFUN(wcpncpy, (wchar_t * , const wchar_t * , size_t)); |
size_t _EXFUN(wcsnlen, (const wchar_t *, size_t)); |
wchar_t *_EXFUN(wcspbrk, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcsrchr, (const wchar_t *, wchar_t)); |
size_t _EXFUN(wcsspn, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcsstr, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcstok, (wchar_t *, const wchar_t *, wchar_t **)); |
double _EXFUN(wcstod, (const wchar_t *, wchar_t **)); |
double _EXFUN(_wcstod_r, (struct _reent *, const wchar_t *, wchar_t **)); |
float _EXFUN(wcstof, (const wchar_t *, wchar_t **)); |
float _EXFUN(_wcstof_r, (struct _reent *, const wchar_t *, wchar_t **)); |
int _EXFUN(wcswidth, (const wchar_t *, size_t)); |
size_t _EXFUN(wcsxfrm, (wchar_t *, const wchar_t *, size_t)); |
int _EXFUN(wcwidth, (const wchar_t)); |
wchar_t *_EXFUN(wmemchr, (const wchar_t *, wchar_t, size_t)); |
int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wmemcpy, (wchar_t * , const wchar_t * , size_t)); |
wchar_t *_EXFUN(wmemmove, (wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t)); |
long _EXFUN(wcstol, (const wchar_t *, wchar_t **, int)); |
long long _EXFUN(wcstoll, (const wchar_t *, wchar_t **, int)); |
unsigned long _EXFUN(wcstoul, (const wchar_t *, wchar_t **, int)); |
unsigned long long _EXFUN(wcstoull, (const wchar_t *, wchar_t **, int)); |
long _EXFUN(_wcstol_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
long long _EXFUN(_wcstoll_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
wint_t _EXFUN(fgetwc, (__FILE *)); |
wchar_t *_EXFUN(fgetws, (wchar_t *, int, __FILE *)); |
wint_t _EXFUN(fputwc, (wchar_t, __FILE *)); |
int _EXFUN(fputws, (const wchar_t *, __FILE *)); |
int _EXFUN (fwide, (__FILE *, int)); |
wint_t _EXFUN (getwc, (__FILE *)); |
wint_t _EXFUN (getwchar, (void)); |
wint_t _EXFUN(putwc, (wchar_t, __FILE *)); |
wint_t _EXFUN(putwchar, (wchar_t)); |
wint_t _EXFUN (ungetwc, (wint_t wc, __FILE *)); |
wint_t _EXFUN(_fgetwc_r, (struct _reent *, __FILE *)); |
wchar_t *_EXFUN(_fgetws_r, (struct _reent *, wchar_t *, int, __FILE *)); |
wint_t _EXFUN(_fputwc_r, (struct _reent *, wchar_t, __FILE *)); |
int _EXFUN(_fputws_r, (struct _reent *, const wchar_t *, __FILE *)); |
int _EXFUN (_fwide_r, (struct _reent *, __FILE *, int)); |
wint_t _EXFUN (_getwc_r, (struct _reent *, __FILE *)); |
wint_t _EXFUN (_getwchar_r, (struct _reent *ptr)); |
wint_t _EXFUN(_putwc_r, (struct _reent *, wchar_t, __FILE *)); |
wint_t _EXFUN(_putwchar_r, (struct _reent *, wchar_t)); |
wint_t _EXFUN (_ungetwc_r, (struct _reent *, wint_t wc, __FILE *)); |
__FILE *_EXFUN (open_wmemstream, (wchar_t **, size_t *)); |
__FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *)); |
#ifndef __VALIST |
#ifdef __GNUC__ |
#define __VALIST __gnuc_va_list |
#else |
#define __VALIST char* |
#endif |
#endif |
int _EXFUN(fwprintf, (__FILE *, const wchar_t *, ...)); |
int _EXFUN(swprintf, (wchar_t *, size_t, const wchar_t *, ...)); |
int _EXFUN(vfwprintf, (__FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(vswprintf, (wchar_t *, size_t, const wchar_t *, __VALIST)); |
int _EXFUN(vwprintf, (const wchar_t *, __VALIST)); |
int _EXFUN(wprintf, (const wchar_t *, ...)); |
int _EXFUN(_fwprintf_r, (struct _reent *, __FILE *, const wchar_t *, ...)); |
int _EXFUN(_swprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, ...)); |
int _EXFUN(_vfwprintf_r, (struct _reent *, __FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(_vswprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, __VALIST)); |
int _EXFUN(_vwprintf_r, (struct _reent *, const wchar_t *, __VALIST)); |
int _EXFUN(_wprintf_r, (struct _reent *, const wchar_t *, ...)); |
int _EXFUN(fwscanf, (__FILE *, const wchar_t *, ...)); |
int _EXFUN(swscanf, (const wchar_t *, const wchar_t *, ...)); |
int _EXFUN(vfwscanf, (__FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(vswscanf, (const wchar_t *, const wchar_t *, __VALIST)); |
int _EXFUN(vwscanf, (const wchar_t *, __VALIST)); |
int _EXFUN(wscanf, (const wchar_t *, ...)); |
int _EXFUN(_fwscanf_r, (struct _reent *, __FILE *, const wchar_t *, ...)); |
int _EXFUN(_swscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, ...)); |
int _EXFUN(_vfwscanf_r, (struct _reent *, __FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(_vswscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, __VALIST)); |
int _EXFUN(_vwscanf_r, (struct _reent *, const wchar_t *, __VALIST)); |
int _EXFUN(_wscanf_r, (struct _reent *, const wchar_t *, ...)); |
#define getwc(fp) fgetwc(fp) |
#define putwc(wc,fp) fputwc((wc), (fp)) |
#ifndef _REENT_ONLY |
#define getwchar() fgetwc(_REENT->_stdin) |
#define putwchar(wc) fputwc((wc), _REENT->_stdout) |
#else |
#define getwchar() fgetwc(_impure_ptr->_stdin) |
#define putwchar(wc) fputwc((wc), _impure_ptr->_stdout) |
#endif |
_END_STD_C |
#endif /* _WCHAR_H_ */ |
/programs/develop/libraries/newlib/include/wctype.h |
---|
0,0 → 1,47 |
#ifndef _WCTYPE_H_ |
#define _WCTYPE_H_ |
#include <_ansi.h> |
#include <sys/_types.h> |
#define __need_wint_t |
#include <stddef.h> |
#ifndef WEOF |
# define WEOF ((wint_t)-1) |
#endif |
_BEGIN_STD_C |
#ifndef _WCTYPE_T |
#define _WCTYPE_T |
typedef int wctype_t; |
#endif |
#ifndef _WCTRANS_T |
#define _WCTRANS_T |
typedef int wctrans_t; |
#endif |
int _EXFUN(iswalpha, (wint_t)); |
int _EXFUN(iswalnum, (wint_t)); |
int _EXFUN(iswblank, (wint_t)); |
int _EXFUN(iswcntrl, (wint_t)); |
int _EXFUN(iswctype, (wint_t, wctype_t)); |
int _EXFUN(iswdigit, (wint_t)); |
int _EXFUN(iswgraph, (wint_t)); |
int _EXFUN(iswlower, (wint_t)); |
int _EXFUN(iswprint, (wint_t)); |
int _EXFUN(iswpunct, (wint_t)); |
int _EXFUN(iswspace, (wint_t)); |
int _EXFUN(iswupper, (wint_t)); |
int _EXFUN(iswxdigit, (wint_t)); |
wint_t _EXFUN(towctrans, (wint_t, wctrans_t)); |
wint_t _EXFUN(towupper, (wint_t)); |
wint_t _EXFUN(towlower, (wint_t)); |
wctrans_t _EXFUN(wctrans, (const char *)); |
wctype_t _EXFUN(wctype, (const char *)); |
_END_STD_C |
#endif /* _WCTYPE_H_ */ |
/programs/develop/libraries/newlib/include/wordexp.h |
---|
0,0 → 1,53 |
/* Copyright (C) 2002, 2010 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#ifndef _WORDEXP_H_ |
#define _WORDEXP_H_ |
#include <sys/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
struct _wordexp_t |
{ |
size_t we_wordc; /* Count of words matched by words. */ |
char **we_wordv; /* Pointer to list of expanded words. */ |
size_t we_offs; /* Slots to reserve at the beginning of we_wordv. */ |
}; |
typedef struct _wordexp_t wordexp_t; |
#define WRDE_DOOFFS 0x0001 /* Use we_offs. */ |
#define WRDE_APPEND 0x0002 /* Append to output from previous call. */ |
#define WRDE_NOCMD 0x0004 /* Don't perform command substitution. */ |
#define WRDE_REUSE 0x0008 /* pwordexp points to a wordexp_t struct returned from |
a previous successful call to wordexp. */ |
#define WRDE_SHOWERR 0x0010 /* Print error messages to stderr. */ |
#define WRDE_UNDEF 0x0020 /* Report attempt to expand undefined shell variable. */ |
enum { |
WRDE_SUCCESS, |
WRDE_NOSPACE, |
WRDE_BADCHAR, |
WRDE_BADVAL, |
WRDE_CMDSUB, |
WRDE_SYNTAX, |
WRDE_NOSYS |
}; |
/* Note: This implementation of wordexp requires a version of bash |
that supports the --wordexp and --protected arguments to be present |
on the system. It does not support the WRDE_UNDEF flag. */ |
int wordexp(const char *, wordexp_t *, int); |
void wordfree(wordexp_t *); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _WORDEXP_H_ */ |
/programs/develop/libraries/newlib/include |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/locale/lctype.h |
---|
0,0 → 1,47 |
/* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifndef _LCTYPE_H_ |
#define _LCTYPE_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_ctype_T { |
const char *codeset; /* codeset for mbtowc conversion */ |
const char *mb_cur_max; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *outdigits[10]; |
const wchar_t *woutdigits[10]; |
#endif |
}; |
struct lc_ctype_T *__get_current_ctype_locale(void); |
int __ctype_load_locale(const char *, void *, const char *, int); |
__END_DECLS |
#endif /* !_LCTYPE_H_ */ |
/programs/develop/libraries/newlib/locale/ldpart.h |
---|
0,0 → 1,35 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/ldpart.h,v 1.4 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LDPART_H_ |
#define _LDPART_H_ |
int __part_load_locale(const char *, int*, char *, const char *, |
int, int, const char **); |
#endif /* !_LDPART_H_ */ |
/programs/develop/libraries/newlib/locale/lmessages.h |
---|
0,0 → 1,57 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/lmessages.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LMESSAGES_H_ |
#define _LMESSAGES_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_messages_T { |
const char *yesexpr; |
const char *noexpr; |
const char *yesstr; |
const char *nostr; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wyesexpr; |
const wchar_t *wnoexpr; |
const wchar_t *wyesstr; |
const wchar_t *wnostr; |
#endif |
}; |
struct lc_messages_T *__get_current_messages_locale(void); |
int __numeric_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_LMESSAGES_H_ */ |
/programs/develop/libraries/newlib/locale/lmonetary.h |
---|
0,0 → 1,76 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/lmonetary.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LMONETARY_H_ |
#define _LMONETARY_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_monetary_T { |
const char *int_curr_symbol; |
const char *currency_symbol; |
const char *mon_decimal_point; |
const char *mon_thousands_sep; |
const char *mon_grouping; |
const char *positive_sign; |
const char *negative_sign; |
const char *int_frac_digits; |
const char *frac_digits; |
const char *p_cs_precedes; |
const char *p_sep_by_space; |
const char *n_cs_precedes; |
const char *n_sep_by_space; |
const char *p_sign_posn; |
const char *n_sign_posn; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *int_p_cs_precedes; |
const char *int_p_sep_by_space; |
const char *int_n_cs_precedes; |
const char *int_n_sep_by_space; |
const char *int_p_sign_posn; |
const char *int_n_sign_posn; |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wint_curr_symbol; |
const wchar_t *wcurrency_symbol; |
const wchar_t *wmon_decimal_point; |
const wchar_t *wmon_thousands_sep; |
const wchar_t *wpositive_sign; |
const wchar_t *wnegative_sign; |
#endif |
}; |
struct lc_monetary_T *__get_current_monetary_locale(void); |
int __monetary_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_LMONETARY_H_ */ |
/programs/develop/libraries/newlib/locale/lnumeric.h |
---|
0,0 → 1,54 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/lnumeric.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LNUMERIC_H_ |
#define _LNUMERIC_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_numeric_T { |
const char *decimal_point; |
const char *thousands_sep; |
const char *grouping; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wdecimal_point; |
const wchar_t *wthousands_sep; |
#endif |
}; |
struct lc_numeric_T *__get_current_numeric_locale(void); |
int __numeric_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_LNUMERIC_H_ */ |
/programs/develop/libraries/newlib/locale/locale.c |
---|
0,0 → 1,1029 |
/* |
FUNCTION |
<<setlocale>>, <<localeconv>>---select or query locale |
INDEX |
setlocale |
INDEX |
localeconv |
INDEX |
_setlocale_r |
INDEX |
_localeconv_r |
ANSI_SYNOPSIS |
#include <locale.h> |
char *setlocale(int <[category]>, const char *<[locale]>); |
lconv *localeconv(void); |
char *_setlocale_r(void *<[reent]>, |
int <[category]>, const char *<[locale]>); |
lconv *_localeconv_r(void *<[reent]>); |
TRAD_SYNOPSIS |
#include <locale.h> |
char *setlocale(<[category]>, <[locale]>) |
int <[category]>; |
char *<[locale]>; |
lconv *localeconv(); |
char *_setlocale_r(<[reent]>, <[category]>, <[locale]>) |
char *<[reent]>; |
int <[category]>; |
char *<[locale]>; |
lconv *_localeconv_r(<[reent]>); |
char *<[reent]>; |
DESCRIPTION |
<<setlocale>> is the facility defined by ANSI C to condition the |
execution environment for international collating and formatting |
information; <<localeconv>> reports on the settings of the current |
locale. |
This is a minimal implementation, supporting only the required <<"POSIX">> |
and <<"C">> values for <[locale]>; strings representing other locales are not |
honored unless _MB_CAPABLE is defined. |
If _MB_CAPABLE is defined, POSIX locale strings are allowed, following |
the form |
language[_TERRITORY][.charset][@@modifier] |
<<"language">> is a two character string per ISO 639, or, if not available |
for a given language, a three character string per ISO 639-3. |
<<"TERRITORY">> is a country code per ISO 3166. For <<"charset">> and |
<<"modifier">> see below. |
Additionally to the POSIX specifier, the following extension is supported |
for backward compatibility with older implementations using newlib: |
<<"C-charset">>. |
Instead of <<"C-">>, you can also specify <<"C.">>. Both variations allow |
to specify language neutral locales while using other charsets than ASCII, |
for instance <<"C.UTF-8">>, which keeps all settings as in the C locale, |
but uses the UTF-8 charset. |
The following charsets are recognized: |
<<"UTF-8">>, <<"JIS">>, <<"EUCJP">>, <<"SJIS">>, <<"KOI8-R">>, <<"KOI8-U">>, |
<<"GEORGIAN-PS">>, <<"PT154">>, <<"TIS-620">>, <<"ISO-8859-x">> with |
1 <= x <= 16, or <<"CPxxx">> with xxx in [437, 720, 737, 775, 850, 852, 855, |
857, 858, 862, 866, 874, 932, 1125, 1250, 1251, 1252, 1253, 1254, 1255, 1256, |
1257, 1258]. |
Charsets are case insensitive. For instance, <<"EUCJP">> and <<"eucJP">> |
are equivalent. Charset names with dashes can also be written without |
dashes, as in <<"UTF8">>, <<"iso88591">> or <<"koi8r">>. <<"EUCJP">> and |
<<"EUCKR">> are also recognized with dash, <<"EUC-JP">> and <<"EUC-KR">>. |
Full support for all of the above charsets requires that newlib has been |
build with multibyte support and support for all ISO and Windows Codepage. |
Otherwise all singlebyte charsets are simply mapped to ASCII. Right now, |
only newlib for Cygwin is built with full charset support by default. |
Under Cygwin, this implementation additionally supports the charsets |
<<"GBK">>, <<"GB2312">>, <<"eucCN">>, <<"eucKR">>, and <<"Big5">>. Cygwin |
does not support <<"JIS">>. |
Cygwin additionally supports locales from the file |
/usr/share/locale/locale.alias. |
(<<"">> is also accepted; if given, the settings are read from the |
corresponding LC_* environment variables and $LANG according to POSIX rules. |
This implementation also supports a single modifier, <<"cjknarrow">>. |
Any other modifier is ignored. <<"cjknarrow">>, in conjunction with one |
of the language specifiers <<"ja">>, <<"ko">>, and <<"zh">> specifies |
how the functions <<wcwidth>> and <<wcswidth>> handle characters from |
the "CJK Ambiguous Width" character class described in |
http://www.unicode.org/unicode/reports/tr11/. Usually these characters |
have a width of 1, unless you specify one of the aforementioned |
languages, in which case these characters have a width of 2. By |
specifying the <<"cjknarrow">> modifier, these characters will have a |
width of one in the languages <<"ja">>, <<"ko">>, and <<"zh">> as well. |
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns a |
pointer to the string representing the current locale. The acceptable |
values for <[category]> are defined in `<<locale.h>>' as macros |
beginning with <<"LC_">>. |
<<localeconv>> returns a pointer to a structure (also defined in |
`<<locale.h>>') describing the locale-specific conventions currently |
in effect. |
<<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of |
<<localeconv>> and <<setlocale>> respectively. The extra argument |
<[reent]> is a pointer to a reentrancy structure. |
RETURNS |
A successful call to <<setlocale>> returns a pointer to a string |
associated with the specified category for the new locale. The string |
returned by <<setlocale>> is such that a subsequent call using that |
string will restore that category (or all categories in case of LC_ALL), |
to that state. The application shall not modify the string returned |
which may be overwritten by a subsequent call to <<setlocale>>. |
On error, <<setlocale>> returns <<NULL>>. |
<<localeconv>> returns a pointer to a structure of type <<lconv>>, |
which describes the formatting and collating conventions in effect (in |
this implementation, always those of the C locale). |
PORTABILITY |
ANSI C requires <<setlocale>>, but the only locale required across all |
implementations is the C locale. |
NOTES |
There is no ISO-8859-12 codepage. It's also refused by this implementation. |
No supporting OS subroutines are required. |
*/ |
/* Parts of this code are originally taken from FreeBSD. */ |
/* |
* Copyright (c) 1996 - 2002 FreeBSD Project |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Paul Borman at Krystal Technologies. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <newlib.h> |
#include <errno.h> |
#include <locale.h> |
#include <string.h> |
#include <limits.h> |
#include <reent.h> |
#include <stdlib.h> |
#include <wchar.h> |
#include "lmessages.h" |
#include "lmonetary.h" |
#include "lnumeric.h" |
#include "lctype.h" |
#include "../stdlib/local.h" |
#define _LC_LAST 7 |
#define ENCODING_LEN 31 |
int __EXPORT __mb_cur_max = 1; |
int __nlocale_changed = 0; |
int __mlocale_changed = 0; |
char *_PathLocale = NULL; |
static |
struct lconv lconv = |
{ |
".", "", "", "", "", "", "", "", "", "", |
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, |
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, |
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, |
CHAR_MAX, CHAR_MAX |
}; |
#ifdef _MB_CAPABLE |
/* |
* Category names for getenv() |
*/ |
static char *categories[_LC_LAST] = { |
"LC_ALL", |
"LC_COLLATE", |
"LC_CTYPE", |
"LC_MONETARY", |
"LC_NUMERIC", |
"LC_TIME", |
"LC_MESSAGES", |
}; |
/* |
* Default locale per POSIX. Can be overridden on a per-target base. |
*/ |
#ifndef DEFAULT_LOCALE |
#define DEFAULT_LOCALE "C" |
#endif |
/* |
* This variable can be changed by any outside mechanism. This allows, |
* for instance, to load the default locale from a file. |
*/ |
char __default_locale[ENCODING_LEN + 1] = DEFAULT_LOCALE; |
/* |
* Current locales for each category |
*/ |
static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { |
"C", |
"C", |
"C", |
"C", |
"C", |
"C", |
"C", |
}; |
/* |
* The locales we are going to try and load |
*/ |
static char new_categories[_LC_LAST][ENCODING_LEN + 1]; |
static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; |
static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; |
static char *currentlocale(void); |
static char *loadlocale(struct _reent *, int); |
static const char *__get_locale_env(struct _reent *, int); |
#endif /* _MB_CAPABLE */ |
#if 0 /*def __CYGWIN__ TODO: temporarily(?) disable C == UTF-8 */ |
static char lc_ctype_charset[ENCODING_LEN + 1] = "UTF-8"; |
static char lc_message_charset[ENCODING_LEN + 1] = "UTF-8"; |
#else |
static char lc_ctype_charset[ENCODING_LEN + 1] = "ASCII"; |
static char lc_message_charset[ENCODING_LEN + 1] = "ASCII"; |
#endif |
static int lc_ctype_cjk_lang = 0; |
char * |
_DEFUN(_setlocale_r, (p, category, locale), |
struct _reent *p _AND |
int category _AND |
_CONST char *locale) |
{ |
#ifndef _MB_CAPABLE |
if (locale) |
{ |
if (strcmp (locale, "POSIX") && strcmp (locale, "C") |
&& strcmp (locale, "")) |
return NULL; |
} |
return "C"; |
#else /* !_MB_CAPABLE */ |
int i, j, len, saverr; |
const char *env, *r; |
if (category < LC_ALL || category >= _LC_LAST) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
if (locale == NULL) |
return category != LC_ALL ? current_categories[category] : currentlocale(); |
/* |
* Default to the current locale for everything. |
*/ |
for (i = 1; i < _LC_LAST; ++i) |
strcpy (new_categories[i], current_categories[i]); |
/* |
* Now go fill up new_categories from the locale argument |
*/ |
if (!*locale) |
{ |
if (category == LC_ALL) |
{ |
for (i = 1; i < _LC_LAST; ++i) |
{ |
env = __get_locale_env (p, i); |
if (strlen (env) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strcpy (new_categories[i], env); |
} |
} |
else |
{ |
env = __get_locale_env (p, category); |
if (strlen (env) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strcpy (new_categories[category], env); |
} |
} |
else if (category != LC_ALL) |
{ |
if (strlen (locale) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strcpy (new_categories[category], locale); |
} |
else |
{ |
if ((r = strchr (locale, '/')) == NULL) |
{ |
if (strlen (locale) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
for (i = 1; i < _LC_LAST; ++i) |
strcpy (new_categories[i], locale); |
} |
else |
{ |
for (i = 1; r[1] == '/'; ++r) |
; |
if (!r[1]) |
{ |
p->_errno = EINVAL; |
return NULL; /* Hmm, just slashes... */ |
} |
do |
{ |
if (i == _LC_LAST) |
break; /* Too many slashes... */ |
if ((len = r - locale) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strlcpy (new_categories[i], locale, len + 1); |
i++; |
while (*r == '/') |
r++; |
locale = r; |
while (*r && *r != '/') |
r++; |
} |
while (*locale); |
while (i < _LC_LAST) |
{ |
strcpy (new_categories[i], new_categories[i-1]); |
i++; |
} |
} |
} |
if (category != LC_ALL) |
return loadlocale (p, category); |
for (i = 1; i < _LC_LAST; ++i) |
{ |
strcpy (saved_categories[i], current_categories[i]); |
if (loadlocale (p, i) == NULL) |
{ |
saverr = p->_errno; |
for (j = 1; j < i; j++) |
{ |
strcpy (new_categories[j], saved_categories[j]); |
if (loadlocale (p, j) == NULL) |
{ |
strcpy (new_categories[j], "C"); |
loadlocale (p, j); |
} |
} |
p->_errno = saverr; |
return NULL; |
} |
} |
return currentlocale (); |
#endif /* !_MB_CAPABLE */ |
} |
#ifdef _MB_CAPABLE |
static char * |
currentlocale() |
{ |
int i; |
(void)strcpy(current_locale_string, current_categories[1]); |
for (i = 2; i < _LC_LAST; ++i) |
if (strcmp(current_categories[1], current_categories[i])) { |
for (i = 2; i < _LC_LAST; ++i) { |
(void)strcat(current_locale_string, "/"); |
(void)strcat(current_locale_string, |
current_categories[i]); |
} |
break; |
} |
return (current_locale_string); |
} |
#endif /* _MB_CAPABLE */ |
#ifdef _MB_CAPABLE |
#ifdef __CYGWIN__ |
extern void __set_charset_from_locale (const char *locale, char *charset); |
extern int __set_locale_from_locale_alias (const char *, char *); |
extern int __collate_load_locale (const char *, void *, const char *); |
#endif /* __CYGWIN__ */ |
extern void __set_ctype (const char *charset); |
static char * |
loadlocale(struct _reent *p, int category) |
{ |
/* At this point a full-featured system would just load the locale |
specific data from the locale files. |
What we do here for now is to check the incoming string for correctness. |
The string must be in one of the allowed locale strings, either |
one in POSIX-style, or one in the old newlib style to maintain |
backward compatibility. If the local string is correct, the charset |
is extracted and stored in lc_ctype_charset or lc_message_charset |
dependent on the cateogry. */ |
char *locale = NULL; |
char charset[ENCODING_LEN + 1]; |
unsigned long val; |
char *end, *c; |
int mbc_max; |
int (*l_wctomb) (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int cjknarrow = 0; |
/* Avoid doing everything twice if nothing has changed. */ |
if (!strcmp (new_categories[category], current_categories[category])) |
return current_categories[category]; |
#ifdef __CYGWIN__ |
/* This additional code handles the case that the incoming locale string |
is not valid. If so, it calls the function __set_locale_from_locale_alias, |
which is only available on Cygwin right now. The function reads the |
file /usr/share/locale/locale.alias. The file contains locale aliases |
and their replacement locale. For instance, the alias "french" is |
translated to "fr_FR.ISO-8859-1", the alias "thai" is translated to |
"th_TH.TIS-620". If successful, the function returns with a pointer |
to the second argument, which is a buffer in which the replacement locale |
gets stored. Otherwise the function returns NULL. */ |
char tmp_locale[ENCODING_LEN + 1]; |
int ret = 0; |
restart: |
if (!locale) |
locale = new_categories[category]; |
else if (locale != tmp_locale) |
{ |
locale = __set_locale_from_locale_alias (locale, tmp_locale); |
if (!locale) |
return NULL; |
} |
# define FAIL goto restart |
#else |
locale = new_categories[category]; |
# define FAIL return NULL |
#endif |
/* "POSIX" is translated to "C", as on Linux. */ |
if (!strcmp (locale, "POSIX")) |
strcpy (locale, "C"); |
if (!strcmp (locale, "C")) /* Default "C" locale */ |
#if 0 /*def __CYGWIN__ TODO: temporarily(?) disable C == UTF-8 */ |
strcpy (charset, "UTF-8"); |
#else |
strcpy (charset, "ASCII"); |
#endif |
else if (locale[0] == 'C' |
&& (locale[1] == '-' /* Old newlib style */ |
|| locale[1] == '.')) /* Extension for the C locale to allow |
specifying different charsets while |
sticking to the C locale in terms |
of sort order, etc. Proposed in |
the Debian project. */ |
strcpy (charset, locale + 2); |
else /* POSIX style */ |
{ |
c = locale; |
/* Don't use ctype macros here, they might be localized. */ |
/* Language */ |
if (c[0] < 'a' || c[0] > 'z' |
|| c[1] < 'a' || c[1] > 'z') |
FAIL; |
c += 2; |
/* Allow three character Language per ISO 639-3 */ |
if (c[0] >= 'a' && c[0] <= 'z') |
++c; |
if (c[0] == '_') |
{ |
/* Territory */ |
++c; |
if (c[0] < 'A' || c[0] > 'Z' |
|| c[1] < 'A' || c[1] > 'Z') |
FAIL; |
c += 2; |
} |
if (c[0] == '.') |
{ |
/* Charset */ |
char *chp; |
++c; |
strcpy (charset, c); |
if ((chp = strchr (charset, '@'))) |
/* Strip off modifier */ |
*chp = '\0'; |
c += strlen (charset); |
} |
else if (c[0] == '\0' || c[0] == '@') |
/* End of string or just a modifier */ |
#ifdef __CYGWIN__ |
/* The Cygwin-only function __set_charset_from_locale checks |
for the default charset which is connected to the given locale. |
The function uses Windows functions in turn so it can't be easily |
adapted to other targets. However, if any other target provides |
equivalent functionality, preferrably using the same function name |
it would be sufficient to change the guarding #ifdef. */ |
__set_charset_from_locale (locale, charset); |
#else |
strcpy (charset, "ISO-8859-1"); |
#endif |
else |
/* Invalid string */ |
FAIL; |
if (c[0] == '@') |
{ |
/* Modifier */ |
/* Only one modifier is recognized right now. "cjknarrow" is used |
to modify the behaviour of wcwidth() for East Asian languages. |
For details see the comment at the end of this function. */ |
if (!strcmp (c + 1, "cjknarrow")) |
cjknarrow = 1; |
} |
} |
/* We only support this subset of charsets. */ |
switch (charset[0]) |
{ |
case 'U': |
case 'u': |
if (strcasecmp (charset, "UTF-8") && strcasecmp (charset, "UTF8")) |
FAIL; |
strcpy (charset, "UTF-8"); |
mbc_max = 6; |
l_wctomb = __utf8_wctomb; |
l_mbtowc = __utf8_mbtowc; |
break; |
#ifndef __CYGWIN__ |
/* Cygwin does not support JIS at all. */ |
case 'J': |
case 'j': |
if (strcasecmp (charset, "JIS")) |
FAIL; |
strcpy (charset, "JIS"); |
mbc_max = 8; |
l_wctomb = __jis_wctomb; |
l_mbtowc = __jis_mbtowc; |
break; |
#endif /* !__CYGWIN__ */ |
case 'E': |
case 'e': |
if (strncasecmp (charset, "EUC", 3)) |
FAIL; |
c = charset + 3; |
if (*c == '-') |
++c; |
if (!strcasecmp (c, "JP")) |
{ |
strcpy (charset, "EUCJP"); |
mbc_max = 3; |
l_wctomb = __eucjp_wctomb; |
l_mbtowc = __eucjp_mbtowc; |
} |
#ifdef __CYGWIN__ |
/* Newlib does neither provide EUC-KR nor EUC-CN, and Cygwin's |
implementation requires Windows support. */ |
else if (!strcasecmp (c, "KR")) |
{ |
strcpy (charset, "EUCKR"); |
mbc_max = 2; |
l_wctomb = __kr_wctomb; |
l_mbtowc = __kr_mbtowc; |
} |
else if (!strcasecmp (c, "CN")) |
{ |
strcpy (charset, "EUCCN"); |
mbc_max = 2; |
l_wctomb = __gbk_wctomb; |
l_mbtowc = __gbk_mbtowc; |
} |
#endif /* __CYGWIN__ */ |
else |
FAIL; |
break; |
case 'S': |
case 's': |
if (strcasecmp (charset, "SJIS")) |
FAIL; |
strcpy (charset, "SJIS"); |
mbc_max = 2; |
l_wctomb = __sjis_wctomb; |
l_mbtowc = __sjis_mbtowc; |
break; |
case 'I': |
case 'i': |
/* Must be exactly one of ISO-8859-1, [...] ISO-8859-16, except for |
ISO-8859-12. This code also recognizes the aliases without dashes. */ |
if (strncasecmp (charset, "ISO", 3)) |
FAIL; |
c = charset + 3; |
if (*c == '-') |
++c; |
if (strncasecmp (c, "8859", 4)) |
FAIL; |
c += 4; |
if (*c == '-') |
++c; |
val = _strtol_r (p, c, &end, 10); |
if (val < 1 || val > 16 || val == 12 || *end) |
FAIL; |
strcpy (charset, "ISO-8859-"); |
c = charset + 9; |
if (val > 10) |
*c++ = '1'; |
*c++ = val % 10 + '0'; |
*c = '\0'; |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_ISO |
l_wctomb = __iso_wctomb; |
l_mbtowc = __iso_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_ISO */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_ISO */ |
break; |
case 'C': |
case 'c': |
if (charset[1] != 'P' && charset[1] != 'p') |
FAIL; |
strncpy (charset, "CP", 2); |
val = _strtol_r (p, charset + 2, &end, 10); |
if (*end) |
FAIL; |
switch (val) |
{ |
case 437: |
case 720: |
case 737: |
case 775: |
case 850: |
case 852: |
case 855: |
case 857: |
case 858: |
case 862: |
case 866: |
case 874: |
case 1125: |
case 1250: |
case 1251: |
case 1252: |
case 1253: |
case 1254: |
case 1255: |
case 1256: |
case 1257: |
case 1258: |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
case 932: |
mbc_max = 2; |
l_wctomb = __sjis_wctomb; |
l_mbtowc = __sjis_mbtowc; |
break; |
default: |
FAIL; |
} |
break; |
case 'K': |
case 'k': |
/* KOI8-R, KOI8-U and the aliases without dash */ |
if (strncasecmp (charset, "KOI8", 4)) |
FAIL; |
c = charset + 4; |
if (*c == '-') |
++c; |
if (*c == 'R' || *c == 'r') |
strcpy (charset, "CP20866"); |
else if (*c == 'U' || *c == 'u') |
strcpy (charset, "CP21866"); |
else |
FAIL; |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
case 'A': |
case 'a': |
if (strcasecmp (charset, "ASCII")) |
FAIL; |
strcpy (charset, "ASCII"); |
mbc_max = 1; |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
break; |
case 'G': |
case 'g': |
#ifdef __CYGWIN__ |
/* Newlib does not provide GBK/GB2312 and Cygwin's implementation |
requires Windows support. */ |
if (!strcasecmp (charset, "GBK") |
|| !strcasecmp (charset, "GB2312")) |
{ |
strcpy (charset, charset[2] == '2' ? "GB2312" : "GBK"); |
mbc_max = 2; |
l_wctomb = __gbk_wctomb; |
l_mbtowc = __gbk_mbtowc; |
} |
else |
#endif /* __CYGWIN__ */ |
/* GEORGIAN-PS and the alias without dash */ |
if (!strncasecmp (charset, "GEORGIAN", 8)) |
{ |
c = charset + 8; |
if (*c == '-') |
++c; |
if (strcasecmp (c, "PS")) |
FAIL; |
strcpy (charset, "CP101"); |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
} |
else |
FAIL; |
break; |
case 'P': |
case 'p': |
/* PT154 */ |
if (strcasecmp (charset, "PT154")) |
FAIL; |
strcpy (charset, "CP102"); |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
case 'T': |
case 't': |
if (strncasecmp (charset, "TIS", 3)) |
FAIL; |
c = charset + 3; |
if (*c == '-') |
++c; |
if (strcasecmp (c, "620")) |
FAIL; |
strcpy (charset, "CP874"); |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
#ifdef __CYGWIN__ |
/* Newlib does not provide Big5 and Cygwin's implementation |
requires Windows support. */ |
case 'B': |
case 'b': |
if (strcasecmp (charset, "BIG5")) |
FAIL; |
strcpy (charset, "BIG5"); |
mbc_max = 2; |
l_wctomb = __big5_wctomb; |
l_mbtowc = __big5_mbtowc; |
break; |
#endif /* __CYGWIN__ */ |
default: |
FAIL; |
} |
switch (category) |
{ |
case LC_CTYPE: |
strcpy (lc_ctype_charset, charset); |
__mb_cur_max = mbc_max; |
__wctomb = l_wctomb; |
__mbtowc = l_mbtowc; |
__set_ctype (charset); |
/* Check for the language part of the locale specifier. In case |
of "ja", "ko", or "zh", assume the use of CJK fonts, unless the |
"@cjknarrow" modifier has been specifed. |
The result is stored in lc_ctype_cjk_lang and tested in wcwidth() |
to figure out the width to return (1 or 2) for the "CJK Ambiguous |
Width" category of characters. */ |
lc_ctype_cjk_lang = !cjknarrow |
&& ((strncmp (locale, "ja", 2) == 0 |
|| strncmp (locale, "ko", 2) == 0 |
|| strncmp (locale, "zh", 2) == 0)); |
#ifdef __HAVE_LOCALE_INFO__ |
ret = __ctype_load_locale (locale, (void *) l_wctomb, charset, mbc_max); |
#endif /* __HAVE_LOCALE_INFO__ */ |
break; |
case LC_MESSAGES: |
strcpy (lc_message_charset, charset); |
#ifdef __HAVE_LOCALE_INFO__ |
ret = __messages_load_locale (locale, (void *) l_wctomb, charset); |
if (!ret) |
#endif /* __HAVE_LOCALE_INFO__ */ |
break; |
#ifdef __HAVE_LOCALE_INFO__ |
#ifdef __CYGWIN__ |
/* Right now only Cygwin supports a __collate_load_locale function at all. */ |
case LC_COLLATE: |
ret = __collate_load_locale (locale, (void *) l_mbtowc, charset); |
break; |
#endif |
case LC_MONETARY: |
ret = __monetary_load_locale (locale, (void *) l_wctomb, charset); |
break; |
case LC_NUMERIC: |
ret = __numeric_load_locale (locale, (void *) l_wctomb, charset); |
break; |
case LC_TIME: |
ret = __time_load_locale (locale, (void *) l_wctomb, charset); |
break; |
#endif /* __HAVE_LOCALE_INFO__ */ |
default: |
break; |
} |
#ifdef __HAVE_LOCALE_INFO__ |
if (ret) |
FAIL; |
#endif /* __HAVE_LOCALE_INFO__ */ |
return strcpy(current_categories[category], new_categories[category]); |
} |
static const char * |
__get_locale_env(struct _reent *p, int category) |
{ |
const char *env; |
/* 1. check LC_ALL. */ |
env = _getenv_r (p, categories[0]); |
/* 2. check LC_* */ |
if (env == NULL || !*env) |
env = _getenv_r (p, categories[category]); |
/* 3. check LANG */ |
if (env == NULL || !*env) |
env = _getenv_r (p, "LANG"); |
/* 4. if none is set, fall to default locale */ |
if (env == NULL || !*env) |
env = __default_locale; |
return env; |
} |
#endif /* _MB_CAPABLE */ |
char * |
_DEFUN_VOID(__locale_charset) |
{ |
#if 0//def __HAVE_LOCALE_INFO__ |
return __get_current_ctype_locale ()->codeset; |
#else |
return lc_ctype_charset; |
#endif |
} |
int |
_DEFUN_VOID(__locale_mb_cur_max) |
{ |
#if 0//def __HAVE_LOCALE_INFO__ |
return __get_current_ctype_locale ()->mb_cur_max[0]; |
#else |
return __mb_cur_max; |
#endif |
} |
char * |
_DEFUN_VOID(__locale_msgcharset) |
{ |
#ifdef __HAVE_LOCALE_INFO__ |
return __get_current_messages_locale ()->codeset; |
#else |
return lc_message_charset; |
#endif |
} |
int |
_DEFUN_VOID(__locale_cjk_lang) |
{ |
return lc_ctype_cjk_lang; |
} |
struct lconv * |
_DEFUN(_localeconv_r, (data), |
struct _reent *data) |
{ |
#ifdef __HAVE_LOCALE_INFO__ |
if (__nlocale_changed) |
{ |
struct lc_numeric_T *n = __get_current_numeric_locale (); |
lconv.decimal_point = n->decimal_point; |
lconv.thousands_sep = n->thousands_sep; |
lconv.grouping = n->grouping; |
__nlocale_changed = 0; |
} |
if (__mlocale_changed) |
{ |
struct lc_monetary_T *m = __get_current_monetary_locale (); |
lconv.int_curr_symbol = m->int_curr_symbol; |
lconv.currency_symbol = m->currency_symbol; |
lconv.mon_decimal_point = m->mon_decimal_point; |
lconv.mon_thousands_sep = m->mon_thousands_sep; |
lconv.mon_grouping = m->mon_grouping; |
lconv.positive_sign = m->positive_sign; |
lconv.negative_sign = m->negative_sign; |
lconv.int_frac_digits = m->int_frac_digits[0]; |
lconv.frac_digits = m->frac_digits[0]; |
lconv.p_cs_precedes = m->p_cs_precedes[0]; |
lconv.p_sep_by_space = m->p_sep_by_space[0]; |
lconv.n_cs_precedes = m->n_cs_precedes[0]; |
lconv.n_sep_by_space = m->n_sep_by_space[0]; |
lconv.p_sign_posn = m->p_sign_posn[0]; |
lconv.n_sign_posn = m->n_sign_posn[0]; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
lconv.int_p_cs_precedes = m->int_p_cs_precedes[0]; |
lconv.int_p_sep_by_space = m->int_p_sep_by_space[0]; |
lconv.int_n_cs_precedes = m->int_n_cs_precedes[0]; |
lconv.int_n_sep_by_space = m->int_n_sep_by_space[0]; |
lconv.int_n_sign_posn = m->int_n_sign_posn[0]; |
lconv.int_p_sign_posn = m->int_p_sign_posn[0]; |
#else /* !__HAVE_LOCALE_INFO_EXTENDED__ */ |
lconv.int_p_cs_precedes = m->p_cs_precedes[0]; |
lconv.int_p_sep_by_space = m->p_sep_by_space[0]; |
lconv.int_n_cs_precedes = m->n_cs_precedes[0]; |
lconv.int_n_sep_by_space = m->n_sep_by_space[0]; |
lconv.int_n_sign_posn = m->n_sign_posn[0]; |
lconv.int_p_sign_posn = m->p_sign_posn[0]; |
#endif /* !__HAVE_LOCALE_INFO_EXTENDED__ */ |
__mlocale_changed = 0; |
} |
#endif /* __HAVE_LOCALE_INFO__ */ |
return (struct lconv *) &lconv; |
} |
#ifndef _REENT_ONLY |
#ifndef __CYGWIN__ |
/* Cygwin provides its own version of setlocale to perform some more |
initialization work. It calls _setlocale_r, though. */ |
char * |
_DEFUN(setlocale, (category, locale), |
int category _AND |
_CONST char *locale) |
{ |
return _setlocale_r (_REENT, category, locale); |
} |
#endif /* __CYGWIN__ */ |
struct lconv * |
_DEFUN_VOID(localeconv) |
{ |
return _localeconv_r (_REENT); |
} |
#endif |
/programs/develop/libraries/newlib/locale/setlocale.h |
---|
0,0 → 1,37 |
/*- |
* Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/setlocale.h,v 1.4 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _SETLOCALE_H_ |
#define _SETLOCALE_H_ |
#define ENCODING_LEN 31 |
#define CATEGORY_LEN 11 |
extern char *_PathLocale; |
#endif /* !_SETLOCALE_H_ */ |
/programs/develop/libraries/newlib/locale/timelocal.h |
---|
0,0 → 1,85 |
/*- |
* Copyright (c) 1997-2002 FreeBSD Project. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/stdtime/timelocal.h,v 1.11 2002/01/24 15:07:44 phantom Exp $ |
*/ |
#ifndef _TIMELOCAL_H_ |
#define _TIMELOCAL_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
/* |
* Private header file for the strftime and strptime localization |
* stuff. |
*/ |
struct lc_time_T { |
const char *mon[12]; |
const char *month[12]; |
const char *wday[7]; |
const char *weekday[7]; |
const char *X_fmt; |
const char *x_fmt; |
const char *c_fmt; |
const char *am_pm[2]; |
const char *date_fmt; |
const char *alt_month[12]; /* unused */ |
const char *md_order; |
const char *ampm_fmt; |
const char *era; |
const char *era_d_fmt; |
const char *era_d_t_fmt; |
const char *era_t_fmt; |
const char *alt_digits; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wmon[12]; |
const wchar_t *wmonth[12]; |
const wchar_t *wwday[7]; |
const wchar_t *wweekday[7]; |
const wchar_t *wX_fmt; |
const wchar_t *wx_fmt; |
const wchar_t *wc_fmt; |
const wchar_t *wam_pm[2]; |
const wchar_t *wdate_fmt; |
const wchar_t *wampm_fmt; |
const wchar_t *wera; |
const wchar_t *wera_d_fmt; |
const wchar_t *wera_d_t_fmt; |
const wchar_t *wera_t_fmt; |
const wchar_t *walt_digits; |
#endif |
}; |
struct lc_time_T *__get_current_time_locale(void); |
int __time_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_TIMELOCAL_H_ */ |
/programs/develop/libraries/newlib/locale |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/reent/closer.c |
---|
0,0 → 1,85 |
/* Reentrant version of close system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* |
FUNCTION |
<<_close_r>>---Reentrant version of close |
INDEX |
_close_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _close_r(struct _reent *<[ptr]>, int <[fd]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _close_r(<[ptr]>, <[fd]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
DESCRIPTION |
This is a reentrant version of <<close>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
extern unsigned __NFiles; |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF ; \ |
return( __r ); \ |
} |
int |
_DEFUN(_close_r, (ptr, fd), |
struct _reent *ptr _AND |
int fd) |
{ |
int ret; |
int h; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
fh = (__file_handle*) __getOSHandle( fd ); |
_free_r(ptr, fh->name); |
_free_r(ptr, fh); |
__freePOSIXHandle( fd ); |
__SetIOMode_nogrow( fd, 0 ); |
return 0; |
} |
int |
_DEFUN( close,(fd), |
int fd) |
{ |
return _close_r(_REENT, fd); |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/programs/develop/libraries/newlib/reent/fstatr.c |
---|
0,0 → 1,156 |
/* Reentrant versions of fstat system call. This implementation just |
calls the fstat system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <sys/stat.h> |
#include <_syslist.h> |
#include <errno.h> |
#include <string.h> |
/* Some targets provides their own versions of these functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifdef REENTRANT_SYSCALLS_PROVIDED |
int _dummy_fstat_syscalls = 1; |
#else |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_fstat_r>>---Reentrant version of fstat |
INDEX |
_fstat_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _fstat_r(struct _reent *<[ptr]>, |
int <[fd]>, struct stat *<[pstat]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _fstat_r(<[ptr]>, <[fd]>, <[pstat]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
struct stat *<[pstat]>; |
DESCRIPTION |
This is a reentrant version of <<fstat>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
#pragma pack(push, 1) |
typedef struct |
{ |
char sec; |
char min; |
char hour; |
char rsv; |
}detime_t; |
typedef struct |
{ |
char day; |
char month; |
short year; |
}dedate_t; |
typedef struct |
{ |
unsigned attr; |
unsigned flags; |
union |
{ |
detime_t ctime; |
unsigned cr_time; |
}; |
union |
{ |
dedate_t cdate; |
unsigned cr_date; |
}; |
union |
{ |
detime_t atime; |
unsigned acc_time; |
}; |
union |
{ |
dedate_t adate; |
unsigned acc_date; |
}; |
union |
{ |
detime_t mtime; |
unsigned mod_time; |
}; |
union |
{ |
dedate_t mdate; |
unsigned mod_date; |
}; |
unsigned size; |
unsigned size_high; |
} FILEINFO; |
#pragma pack(pop) |
extern unsigned __NFiles; |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF ; \ |
return( __r ); \ |
} |
int |
_fstat_r (ptr, fd, pstat) |
struct _reent *ptr; |
int fd; |
struct stat *pstat; |
{ |
FILEINFO info; |
int ret; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
if (fd < 3) |
{ |
pstat->st_mode = S_IFCHR; |
pstat->st_blksize = 0; |
return 0; |
} |
fh = (__file_handle*) __getOSHandle( fd ); |
get_fileinfo(fh->name, &info); |
memset (pstat, 0, sizeof (* pstat)); |
pstat->st_mode = S_IFREG; |
pstat->st_blksize = 4096; |
pstat->st_size = info.size; |
return 0; |
} |
int |
_DEFUN (fstat, (fd, pstat), |
int fd _AND |
struct stat *pstat) |
{ |
return _fstat_r (_REENT, fd, pstat); |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/programs/develop/libraries/newlib/reent/getreent.c |
---|
0,0 → 1,68 |
/* default reentrant pointer when multithread enabled */ |
#include <_ansi.h> |
#include <string.h> |
#include <reent.h> |
#ifdef __getreent |
#undef __getreent |
#endif |
static inline |
void *user_alloc(int size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=eax"(val) |
:"a"(68),"b"(12),"c"(size)); |
return val; |
} |
void init_reent() |
{ |
struct _reent *ent; |
ent = user_alloc(sizeof(struct _reent)); |
_REENT_INIT_PTR(ent); |
__asm__ __volatile__( |
"movl %0, %%fs:0" |
::"r"(ent)); |
__sinit(ent); |
} |
struct _reent * |
_DEFUN_VOID(__getreent) |
{ |
struct _reent *ent; |
__asm__ __volatile__( |
"movl %%fs:0, %0" |
:"=r"(ent)); |
return ent; |
} |
void __mutex_lock(volatile int *val) |
{ |
int tmp; |
__asm__ __volatile__ ( |
"0:\n\t" |
"mov %0, %1\n\t" |
"testl %1, %1\n\t" |
"jz 1f\n\t" |
"movl $68, %%eax\n\t" |
"movl $1, %%ebx\n\t" |
"int $0x40\n\t" |
"jmp 0b\n\t" |
"1:\n\t" |
"incl %1\n\t" |
"xchgl %0, %1\n\t" |
"testl %1, %1\n\t" |
"jnz 0b\n" |
: "+m" (*val), "=&r"(tmp) |
::"eax","ebx" ); |
} |
/programs/develop/libraries/newlib/reent/hdlman.c |
---|
0,0 → 1,379 |
/**************************************************************************** |
* |
* Open Watcom Project |
* |
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. |
* |
* ======================================================================== |
* |
* This file contains Original Code and/or Modifications of Original |
* Code as defined in and that are subject to the Sybase Open Watcom |
* Public License version 1.0 (the 'License'). You may not use this file |
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO |
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is |
* provided with the Original Code and Modifications, and is also |
* available at www.sybase.com/developer/opensource. |
* |
* 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 SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM |
* 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. |
* |
* ======================================================================== |
* |
* Description: Handle manager routines. |
* |
****************************************************************************/ |
#include <reent.h> |
#include <unistd.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <errno.h> |
#include <fcntl.h> |
#define _NFILES 20 |
#define _DYNAMIC 0x4000 /* FILE is dynamically allocated */ |
#define _READ 0x0001 /* file opened for reading */ |
#define _WRITE 0x0002 /* file opened for writing */ |
#define NULL_HANDLE (int)-1 |
#define DUMMY_HANDLE (int)-2 |
#define INVALID_HANDLE_VALUE (int) -1 |
#define _AccessIOB() |
#define _ReleaseIOB() |
#undef __getOSHandle |
void __ChkTTYIOMode( int handle ); |
void __grow_iomode( int num ); |
int debugwrite(const char *path,const void *buff, |
size_t offset, size_t count, size_t *writes); |
int _fmode; |
#define NUM_STD_STREAMS 3 |
#define _ISTTY 0x2000 /* is console device */ |
unsigned __init_mode[_NFILES] = { /* file mode information (flags) */ |
_READ, /* stdin */ |
_WRITE, /* stdout */ |
_WRITE /* stderr */ |
}; |
unsigned *__io_mode = __init_mode; /* initially points to static array */ |
unsigned __NFiles = _NFILES; /* maximum # of files we can open */ |
unsigned __NHandles = 0; |
int *__OSHandles = NULL; |
static __file_handle |
stdin_handle = { |
NULL, |
0, |
NULL |
}; |
static __file_handle |
stdout_handle = |
{ |
NULL, |
0, |
debugwrite |
}; |
static __file_handle |
stderr_handle = |
{ |
NULL, |
0, |
debugwrite |
}; |
unsigned __growPOSIXHandles( unsigned num ) |
{ |
int *new2; |
unsigned i; |
if( num > __NHandles ) |
{ |
if( __OSHandles == NULL ) |
{ |
new2 = malloc( num * sizeof( int ) ); |
} |
else |
{ |
new2 = realloc( __OSHandles, num * sizeof( int ) ); |
} |
if( new2 == NULL ) |
{ |
// __set_errno( ENOMEM ); |
num = __NHandles; |
} |
else |
{ |
for( i = __NHandles; i < num; i++ ) |
{ |
new2[ i ] = NULL_HANDLE; |
} |
__OSHandles = new2; |
__NHandles = num; |
} |
} |
return( __NHandles ); |
} |
int __allocPOSIXHandle( int hdl ) |
{ |
int i; |
for( i = 0; i < __NHandles; i++ ) |
{ |
if( __OSHandles[i] == NULL_HANDLE ) break; |
} |
if( i >= __NHandles ) |
{ |
// 20 -> (20+10+1) -> 31 |
// 31 -> (31+15+1) -> 47 |
// 47 -> (47+23+1) -> 71 |
__growPOSIXHandles( i + (i >> 1) + 1 ); |
// keep iomode array in sync |
if( __NHandles > __NFiles ) __grow_iomode( __NHandles ); |
for( ; i < __NHandles; i++ ) |
{ |
if( __OSHandles[i] == NULL_HANDLE ) break; |
} |
} |
if( i >= __NHandles ) |
{ |
i = -1; |
} else { |
__OSHandles[i] = hdl; |
} |
return( i ); |
} |
void __freePOSIXHandle( int hid ) |
{ |
__OSHandles[ hid ] = NULL_HANDLE; |
} |
int __getOSHandle( int hid ) |
{ |
return( __OSHandles[ hid ] ); |
} |
int __setOSHandle( unsigned hid, int hdl ) |
{ |
// call the Win32 API for a standard file handle |
switch( hid ) { |
case STDIN_FILENO: |
// SetStdHandle( STD_INPUT_HANDLE, hdl ); |
break; |
case STDOUT_FILENO: |
// SetStdHandle( STD_OUTPUT_HANDLE, hdl ); |
break; |
case STDERR_FILENO: |
// SetStdHandle( STD_ERROR_HANDLE, hdl ); |
break; |
} |
if( hid < __NHandles ) |
{ |
__OSHandles[ hid ] = hdl; |
} |
else |
{ |
hid = (unsigned)-1; // this should never happen |
} |
return( hid ); |
} |
// called from library startup code |
void __initPOSIXHandles( void ) |
{ |
int h; |
_fmode = O_BINARY; |
__growPOSIXHandles( __NFiles ); |
h = (int)&stdin_handle; |
__allocPOSIXHandle( h ); // should return 0==STDIN_FILENO |
h = (int)&stdout_handle; |
__allocPOSIXHandle( h ); // should return 1==STDOUT_FILENO |
h = (int)&stderr_handle; |
__allocPOSIXHandle( h ); // should return 3==STDERR_FILENO |
} |
/* |
static void __finiPOSIXHandles( void ) |
{ |
if( __OSHandles != NULL ) { |
free( __OSHandles ); |
__OSHandles = NULL; |
} |
if( __FakeHandles != NULL ) |
{ |
int i; |
for( i = 0 ; i < __topFakeHandle ; i++ ) |
{ |
// CloseHandle( __FakeHandles[i] ); |
} |
free( __FakeHandles ); |
__FakeHandles = 0; |
} |
} |
*/ |
void __set_handles( int num ) |
{ |
__NHandles = num; |
} |
int _grow_handles( int num ) |
{ |
if( num > __NHandles ) |
{ |
num = __growPOSIXHandles( num ); |
if( num > __NFiles ) { |
__grow_iomode( num ); // sets new __NFiles if successful |
} |
__NHandles = num; |
} |
return( __NHandles ); |
} |
static unsigned _init_NFiles; // original __NFiles value; |
void __grow_iomode( int num ) |
{ |
unsigned *new; |
_AccessIOB(); |
if( __io_mode == __init_mode ) |
{ |
_init_NFiles = __NFiles; |
new = (unsigned *) malloc( num * sizeof( unsigned ) ); |
if( new != NULL ) { |
memcpy( new, __init_mode, __NFiles * sizeof(unsigned) ); |
} |
} |
else |
{ |
new = (unsigned *) realloc( __io_mode, num * sizeof( unsigned ) ); |
} |
if( new == NULL ) |
{ |
// __set_errno( ENOMEM ); |
} |
else |
{ |
memset( &new[__NFiles], 0, (num-__NFiles)*sizeof(unsigned) ); |
__io_mode = new; |
__NFiles = num; |
} |
_ReleaseIOB(); |
} |
void __shrink_iomode( void ) |
{ |
_AccessIOB(); |
// free any malloc'd iomode array |
if( __io_mode != __init_mode ) |
{ |
free( __io_mode ); |
__io_mode = __init_mode; |
__NFiles = _init_NFiles; |
} |
_ReleaseIOB(); |
} |
#define _INITIALIZED _DYNAMIC |
signed __SetIOMode( int handle, unsigned value ) |
{ |
int i; |
if( handle >= __NFiles ) |
{ |
i = __NFiles; // 20 -> (20+10+1) -> 31 |
// 31 -> (31+15+1) -> 47 |
// 47 -> (47+23+1) -> 71 |
__grow_iomode( i + (i > 1) + 1 ); |
} |
if( handle >= __NFiles ) |
{ |
// return an error indication (errno should be set to ENOMEM) |
return( -1 ); |
} |
else |
{ |
if( value != 0 ) |
{ |
__ChkTTYIOMode( handle ); |
__io_mode[handle] = value | _INITIALIZED; |
} |
else |
{ |
__io_mode[handle] = value; /* we're closing it; smite _INITIALIZED */ |
} |
return( handle ); |
} |
} |
int _isatty( int hid ) |
{ |
return( 0 ); |
} |
void __ChkTTYIOMode( int handle ) |
{ |
if( handle < NUM_STD_STREAMS && !(__io_mode[handle] & _INITIALIZED) ) |
{ |
__io_mode[handle] |= _INITIALIZED; |
if( _isatty( handle ) ) |
{ |
__io_mode[handle] |= _ISTTY; |
} |
} |
} |
unsigned __GetIOMode( int handle ) |
{ |
if( handle >= __NFiles ) |
{ |
return( 0 ); |
} |
return( __io_mode[handle] ); |
}; |
void __SetIOMode_nogrow( int handle, unsigned value ) |
{ |
if( handle < __NFiles ) |
{ |
__io_mode[handle] = value; /* we're closing it; smite _INITIALIZED */ |
} |
} |
/programs/develop/libraries/newlib/reent/impure.c |
---|
0,0 → 1,28 |
#include <reent.h> |
/* Note that there is a copy of this in sys/reent.h. */ |
#ifndef __ATTRIBUTE_IMPURE_PTR__ |
#define __ATTRIBUTE_IMPURE_PTR__ |
#endif |
#ifndef __ATTRIBUTE_IMPURE_DATA__ |
#define __ATTRIBUTE_IMPURE_DATA__ |
#endif |
/* Redeclare these symbols locally as weak so that the file containing |
their definitions (along with a lot of other stuff) isn't sucked in |
unless they are actually used by other compilation units. This is |
important to reduce image size for targets with very small amounts |
of memory. */ |
#ifdef _REENT_SMALL |
extern const struct __sFILE_fake __sf_fake_stdin _ATTRIBUTE ((weak)); |
extern const struct __sFILE_fake __sf_fake_stdout _ATTRIBUTE ((weak)); |
extern const struct __sFILE_fake __sf_fake_stderr _ATTRIBUTE ((weak)); |
#endif |
static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data = _REENT_INIT (impure_data); |
#ifdef __CYGWIN__ |
extern struct _reent reent_data __attribute__ ((alias("impure_data"))); |
#endif |
struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &impure_data; |
struct _reent *_CONST __ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr = &impure_data; |
/programs/develop/libraries/newlib/reent/isattyr.c |
---|
0,0 → 1,62 |
/* Reentrant versions of isatty system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of these functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifdef REENTRANT_SYSCALLS_PROVIDED |
int _dummy_isatty_syscalls = 1; |
#else |
/* We use the errno variable used by the system dependent layer. */ |
#undef errno |
extern int errno; |
/* |
FUNCTION |
<<_isatty_r>>---Reentrant version of isatty |
INDEX |
_isatty_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _isatty_r(struct _reent *<[ptr]>, |
int <[fd]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _isatty_r(<[ptr]>, <[fd]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
DESCRIPTION |
This is a reentrant version of <<isatty>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
int |
_isatty_r (ptr, fd) |
struct _reent *ptr; |
int fd; |
{ |
int ret; |
ptr->_errno = ENOTTY ; |
return 0; |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/programs/develop/libraries/newlib/reent/lseekr.c |
---|
0,0 → 1,159 |
/* Reentrant versions of lseek system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#pragma pack(push, 1) |
typedef struct |
{ |
char sec; |
char min; |
char hour; |
char rsv; |
}detime_t; |
typedef struct |
{ |
char day; |
char month; |
short year; |
}dedate_t; |
typedef struct |
{ |
unsigned attr; |
unsigned flags; |
union |
{ |
detime_t ctime; |
unsigned cr_time; |
}; |
union |
{ |
dedate_t cdate; |
unsigned cr_date; |
}; |
union |
{ |
detime_t atime; |
unsigned acc_time; |
}; |
union |
{ |
dedate_t adate; |
unsigned acc_date; |
}; |
union |
{ |
detime_t mtime; |
unsigned mod_time; |
}; |
union |
{ |
dedate_t mdate; |
unsigned mod_date; |
}; |
unsigned size; |
unsigned size_high; |
} FILEINFO; |
#pragma pack(pop) |
extern unsigned __NFiles; |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF ; \ |
return( __r ); \ |
} |
/* |
FUNCTION |
<<_lseek_r>>---Reentrant version of lseek |
INDEX |
_lseek_r |
ANSI_SYNOPSIS |
#include <reent.h> |
off_t _lseek_r(struct _reent *<[ptr]>, |
int <[fd]>, off_t <[pos]>, int <[whence]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
off_t _lseek_r(<[ptr]>, <[fd]>, <[pos]>, <[whence]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
off_t <[pos]>; |
int <[whence]>; |
DESCRIPTION |
This is a reentrant version of <<lseek>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
_off_t |
_DEFUN (_lseek_r, (ptr, fd, pos, whence), |
struct _reent *ptr _AND |
int fd _AND |
_off_t pos _AND |
int whence) |
{ |
_off_t ret; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
fh = (__file_handle*) __getOSHandle( fd ); |
switch(whence) |
{ |
case SEEK_SET: |
ret = pos; |
break; |
case SEEK_CUR: |
ret = fh->offset + pos; |
break; |
case SEEK_END: |
{ |
FILEINFO info; |
get_fileinfo(fh->name, &info); |
ret = pos + info.size; |
break; |
} |
default: |
ptr->_errno = EINVAL; |
return -1; |
}; |
fh->offset = ret; |
return( ret ); |
} |
_off_t |
_DEFUN (lseek, (fd, pos, whence), |
int fd _AND |
_off_t pos _AND |
int whence) |
{ |
return _lseek_r(_REENT, fd, pos, whence); |
}; |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/programs/develop/libraries/newlib/reent/openr.c |
---|
0,0 → 1,396 |
/* Reentrant versions of open system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include <_syslist.h> |
#include <sys/errno.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdarg.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_open_r>>---Reentrant version of open |
INDEX |
_open_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _open_r(struct _reent *<[ptr]>, |
const char *<[file]>, int <[flags]>, int <[mode]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _open_r(<[ptr]>, <[file]>, <[flags]>, <[mode]>) |
struct _reent *<[ptr]>; |
char *<[file]>; |
int <[flags]>; |
int <[mode]>; |
DESCRIPTION |
This is a reentrant version of <<open>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
#pragma pack(push, 1) |
typedef struct |
{ |
char sec; |
char min; |
char hour; |
char rsv; |
}detime_t; |
typedef struct |
{ |
char day; |
char month; |
short year; |
}dedate_t; |
typedef struct |
{ |
unsigned attr; |
unsigned flags; |
union |
{ |
detime_t ctime; |
unsigned cr_time; |
}; |
union |
{ |
dedate_t cdate; |
unsigned cr_date; |
}; |
union |
{ |
detime_t atime; |
unsigned acc_time; |
}; |
union |
{ |
dedate_t adate; |
unsigned acc_date; |
}; |
union |
{ |
detime_t mtime; |
unsigned mod_time; |
}; |
union |
{ |
dedate_t mdate; |
unsigned mod_date; |
}; |
unsigned size; |
unsigned size_high; |
} fileinfo_t; |
#pragma pack(pop) |
#define NULL_HANDLE (int)-1 |
#define DUMMY_HANDLE (int)-2 |
#define _READ 0x0001 /* file opened for reading */ |
#define _WRITE 0x0002 /* file opened for writing */ |
#define _UNGET 0x0004 /* ungetc has been done */ |
#define _BIGBUF 0x0008 /* big buffer allocated */ |
#define _EOF 0x0010 /* EOF has occurred */ |
#define _SFERR 0x0020 /* error has occurred on this file */ |
#define _APPEND 0x0080 /* file opened for append */ |
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */ |
#define _TMPFIL 0x0800 /* this is a temporary file */ |
#define _DIRTY 0x1000 /* buffer has been modified */ |
#define _ISTTY 0x2000 /* is console device */ |
#define _DYNAMIC 0x4000 /* FILE is dynamically allocated */ |
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */ |
#define _COMMIT 0x0001 /* extended flag: commit OS buffers on flush */ |
extern int _fmode; |
int create_file(const char *path) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %0, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $2 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path) |
:"ebx"); |
return retval; |
}; |
int set_file_size(const char *path, unsigned size) |
{ |
int retval; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl %%ebx \n\t" |
"push $4 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a" (path), "b" (size)); |
return retval; |
}; |
int get_fileinfo(const char *path, fileinfo_t *info) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %1, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $5 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path), "b" (info)); |
return retval; |
}; |
int read_file(const char *path, void *buff, |
size_t offset, size_t count, size_t *reads) |
{ |
int retval; |
int d0; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl %%edx \n\t" |
"pushl $0 \n\t" |
"pushl %%ecx \n\t" |
"pushl $0 \n\t" |
"movl %%esp, %%ebx \n\t" |
"mov $70, %%eax \n\t" |
"int $0x40 \n\t" |
"testl %%esi, %%esi \n\t" |
"jz 1f \n\t" |
"movl %%ebx, (%%esi) \n\t" |
"1:" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(reads)); |
return retval; |
}; |
static inline void debug_out(const char val) |
{ |
__asm__ __volatile__( |
"int $0x40 \n\t" |
::"a"(63), "b"(1),"c"(val)); |
} |
int debugwrite(const char *path, const void *buff, |
size_t offset, size_t count, size_t *writes) |
{ |
int ret = count; |
const char *p = buff; |
while (count--) |
{ |
debug_out(*p++); |
}; |
*writes = ret; |
return ret; |
}; |
int write_file(const char *path,const void *buff, |
size_t offset, size_t count, size_t *writes) |
{ |
int retval; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl %%edx \n\t" |
"pushl $0 \n\t" |
"pushl %%ecx \n\t" |
"pushl $3 \n\t" |
"movl %%esp, %%ebx \n\t" |
"mov $70, %%eax \n\t" |
"int $0x40 \n\t" |
"testl %%esi, %%esi \n\t" |
"jz 1f \n\t" |
"movl %%ebx, (%%esi) \n\t" |
"1:" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes)); |
return retval; |
}; |
static int __openFileHandle(const char *path, int mode, int *err) |
{ |
fileinfo_t info; |
__file_handle *handle; |
// path = getfullpath(name); |
*err = get_fileinfo(path, &info); |
if( mode & O_EXCL && mode & O_CREAT ) |
{ |
if( ! *err) |
{ |
*err = EEXIST; |
return -1; |
}; |
} |
if( *err) |
{ |
if(mode & O_CREAT) |
*err=create_file(path); |
if( *err) |
{ |
return -1; |
}; |
}; |
if( mode & O_TRUNC ) |
set_file_size(path, 0); |
if ( !(handle=(__file_handle*)malloc(sizeof( __file_handle) ))) |
{ |
*err = ENOMEM; |
return -1; |
}; |
handle->name = strdup(path); |
handle->offset = 0; |
handle->write = write_file; |
*err = 0; |
return (int)handle; |
}; |
int |
_DEFUN (_open_r, (ptr, file, flags, dmode), |
struct _reent *ptr _AND |
_CONST char *file _AND |
int flags _AND |
int dmode) |
{ |
int hid; |
int handle; |
int err = 0; |
unsigned iomode_flags; |
int rwmode; |
/* |
if (flags & ~(O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_APPEND | O_TRUNC)) |
{ |
ptr->_errno = ENOSYS; |
return -1; |
} |
*/ |
// First try to get the required slot. |
// No point in creating a file only to not use it. JBS 99/10/26 |
hid = __allocPOSIXHandle( DUMMY_HANDLE ); |
if( hid == -1 ) |
{ |
ptr->_errno = EMFILE; |
return( -1 ); |
} |
handle = __openFileHandle( file, flags, &err); |
if( handle == -1 ) |
{ |
__freePOSIXHandle( hid ); |
ptr->_errno = err; |
return( -1 ); |
} |
__setOSHandle( hid, handle ); // JBS 99/11/01 |
rwmode = flags & ( O_RDONLY | O_WRONLY | O_RDWR | O_NOINHERIT ); |
iomode_flags = 0; |
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE; |
else if( rwmode == O_RDONLY) iomode_flags |= _READ; |
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE; |
if( flags & O_APPEND ) iomode_flags |= _APPEND; |
if( flags & (O_BINARY|O_TEXT) ) { |
if( flags & O_BINARY ) iomode_flags |= _BINARY; |
} else { |
if( _fmode == O_BINARY ) iomode_flags |= _BINARY; |
} |
__SetIOMode( hid, iomode_flags ); |
ptr->_errno = 0; |
return (hid); |
} |
int |
_DEFUN (open, (file, flags, ...), |
const char *file _AND |
int flags _DOTS) |
{ |
va_list ap; |
int ret; |
va_start (ap, flags); |
ret = _open_r (_REENT, file, flags, va_arg (ap, int)); |
va_end (ap); |
return ret; |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/programs/develop/libraries/newlib/reent/readr.c |
---|
0,0 → 1,168 |
/* Reentrant versions of read system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_read_r>>---Reentrant version of read |
INDEX |
_read_r |
ANSI_SYNOPSIS |
#include <reent.h> |
_ssize_t _read_r(struct _reent *<[ptr]>, |
int <[fd]>, void *<[buf]>, size_t <[cnt]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
_ssize_t _read_r(<[ptr]>, <[fd]>, <[buf]>, <[cnt]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
char *<[buf]>; |
size_t <[cnt]>; |
DESCRIPTION |
This is a reentrant version of <<read>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
extern unsigned __NFiles; |
#define _READ 0x0001 /* file opened for reading */ |
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */ |
#define _ISTTY 0x2000 /* is console device */ |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF; \ |
return( __r ); \ |
} |
_ssize_t |
_DEFUN (_read, (fd, buf, cnt), |
int fd _AND |
_PTR buf _AND |
size_t cnt) |
{ |
return _read_r( _REENT, fd, buf, cnt); |
} |
_ssize_t |
_DEFUN (_read_r, (ptr, fd, buf, cnt), |
struct _reent *ptr _AND |
int fd _AND |
_PTR buf _AND |
size_t cnt) |
{ |
_ssize_t ret; |
_ssize_t read_len, total_len; |
unsigned reduce_idx, finish_idx; |
unsigned iomode_flags; |
char *buffer = buf; |
int rc; |
int h; |
unsigned amount_read; |
int err; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
__ChkTTYIOMode( fd ); |
iomode_flags = __GetIOMode( fd ); |
if( iomode_flags == 0 ) |
{ |
ptr->_errno = EBADF; |
return( -1 ); |
} |
if( !(iomode_flags & _READ) ) |
{ |
ptr->_errno = EACCES; /* changed from EBADF to EACCES 23-feb-89 */ |
return( -1 ); |
} |
fh = (__file_handle*) __getOSHandle( fd ); |
if( iomode_flags & _BINARY ) /* if binary mode */ |
{ |
err = read_file(fh->name, buffer, fh->offset, cnt, &amount_read); |
fh->offset+= amount_read; |
total_len = amount_read; |
if(err) |
if ( amount_read == 0) |
return (-1); |
} |
else |
{ |
total_len = 0; |
read_len = cnt; |
do |
{ |
err=read_file(fh->name,buffer, fh->offset, cnt, &amount_read); |
fh->offset+=amount_read; |
if( amount_read == 0 ) |
break; /* EOF */ |
reduce_idx = 0; |
finish_idx = reduce_idx; |
for( ; reduce_idx < amount_read; ++reduce_idx ) |
{ |
if( buffer[ reduce_idx ] == 0x1a ) /* EOF */ |
{ |
_lseek_r(ptr, fd, ((long)reduce_idx - (long)amount_read)+1L, |
SEEK_CUR ); |
total_len += finish_idx; |
return( total_len ); |
} |
if( buffer[ reduce_idx ] != '\r' ) |
{ |
buffer[ finish_idx++ ] = buffer[ reduce_idx ]; |
}; |
} |
total_len += finish_idx; |
buffer += finish_idx; |
read_len -= finish_idx; |
if( iomode_flags & _ISTTY ) |
{ |
break; /* 04-feb-88, FWC */ |
} |
} while( read_len != 0 ); |
} |
return( total_len ); |
} |
_ssize_t |
_DEFUN (read, (fd, buf, cnt), |
int fd _AND |
_PTR buf _AND |
size_t cnt) |
{ |
return _read_r(_REENT, fd, buf, cnt); |
}; |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/programs/develop/libraries/newlib/reent/writer.c |
---|
0,0 → 1,257 |
/* Reentrant versions of write system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <alloca.h> |
#include <errno.h> |
#include <string.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_write_r>>---Reentrant version of write |
INDEX |
_write_r |
ANSI_SYNOPSIS |
#include <reent.h> |
_ssize_t _write_r(struct _reent *<[ptr]>, |
int <[fd]>, const void *<[buf]>, size_t <[cnt]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
_ssize_t _write_r(<[ptr]>, <[fd]>, <[buf]>, <[cnt]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
char *<[buf]>; |
size_t <[cnt]>; |
DESCRIPTION |
This is a reentrant version of <<write>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
#define _WRITE 0x0002 /* file opened for writing */ |
#define _APPEND 0x0080 /* file opened for append */ |
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */ |
#define _ISTTY 0x2000 /* is console device */ |
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */ |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF; \ |
return( __r ); \ |
} |
extern unsigned __NFiles; |
#define PAD_SIZE 512 |
static int zero_pad(struct _reent *ptr, int handle ) /* 09-jan-95 */ |
/*******************************/ |
{ |
int rc; |
long curPos, eodPos; |
long bytesToWrite; |
unsigned writeAmt; |
char zeroBuf[PAD_SIZE]; |
// Pad with zeros due to lseek() past EOF (POSIX) |
curPos = _lseek_r( ptr, handle, 0L, SEEK_CUR ); /* current offset */ |
if( curPos == -1 ) |
return( -1 ); |
eodPos = _lseek_r( ptr, handle, 0L, SEEK_END ); /* end of data offset */ |
if( eodPos == -1 ) |
return( -1 ); |
if( curPos > eodPos ) { |
bytesToWrite = curPos - eodPos; /* amount to pad by */ |
if( bytesToWrite > 0 ) { /* only write if needed */ |
memset( zeroBuf, 0x00, PAD_SIZE ); /* zero out a buffer */ |
do { /* loop until done */ |
if( bytesToWrite > PAD_SIZE ) |
writeAmt = 512; |
else |
writeAmt = (unsigned)bytesToWrite; |
rc = _write_r(ptr, handle, zeroBuf, writeAmt ); |
if( rc < 0 ) |
return( rc ); |
bytesToWrite -= writeAmt; /* more bytes written */ |
} while( bytesToWrite != 0 ); |
} |
} else { |
curPos = _lseek_r( ptr, handle, curPos, SEEK_SET ); |
if( curPos == -1 ) { |
return( -1 ); |
} |
} |
return( 0 ); /* return success code */ |
} |
static int os_write(struct _reent *ptr, int handle, |
const void *buffer, unsigned len, unsigned *amt ) |
/********************************************************************************/ |
{ |
__file_handle *fh; |
int rc; |
rc = 0; |
*amt = 0; |
fh = (__file_handle*) __getOSHandle( handle ); |
rc = fh->write(fh->name,buffer,fh->offset,len,amt); |
fh->offset+= *amt; |
if( *amt != len ) |
{ |
rc = ENOSPC; |
ptr->_errno = ENOSPC; |
} |
return( rc ); |
} |
_ssize_t |
_DEFUN (_write_r, (ptr, fd, buffer, cnt), |
struct _reent *ptr _AND |
int fd _AND |
_CONST _PTR buffer _AND |
size_t cnt) |
{ |
_ssize_t ret; |
unsigned int iomode_flags; |
unsigned len_written, i, j; |
int rc2; |
char *buf; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
iomode_flags = __GetIOMode( fd ); |
if( iomode_flags == 0 ) |
{ |
ptr->_errno = EBADF; |
return( -1 ); |
} |
if( !(iomode_flags & _WRITE) ) { |
ptr->_errno = EACCES ; /* changed from EBADF to EACCES 23-feb-89 */ |
return( -1 ); |
} |
if( (iomode_flags & _APPEND) && !(iomode_flags & _ISTTY) ) |
{ |
fh->offset = _lseek_r(ptr, fd, 0L, SEEK_END ); /* end of data offset */ |
} |
len_written = 0; |
rc2 = 0; |
// Pad the file with zeros if necessary |
if( iomode_flags & _FILEEXT ) |
{ |
// turn off file extended flag |
__SetIOMode_nogrow( fd, iomode_flags&(~_FILEEXT) ); |
// It is not required to pad a file with zeroes on an NTFS file system; |
// unfortunately it is required on FAT (and probably FAT32). (JBS) |
rc2 = zero_pad( ptr, fd ); |
} |
if( rc2 == 0 ) |
{ |
if( iomode_flags & _BINARY ) { /* if binary mode */ |
rc2 = os_write(ptr, fd, buffer, cnt, &len_written ); |
/* end of binary mode part */ |
} else { /* text mode */ |
int buf_size = 512; |
buf = (char*)alloca( buf_size ); |
j = 0; |
for( i = 0; i < cnt; ) |
{ |
if( ((const char*)buffer)[i] == '\n' ) |
{ |
buf[j] = '\r'; |
++j; |
if( j == buf_size ) |
{ |
rc2 = os_write(ptr, fd, buf, buf_size, &j ); |
if( rc2 == -1 ) |
break; |
len_written += j; |
if( rc2 == ENOSPC ) |
break; |
len_written = i; |
j = 0; |
} |
} |
buf[j] = ((const char*)buffer)[i]; |
++i; |
++j; |
if( j == buf_size ) { |
rc2 = os_write(ptr, fd, buf, buf_size, &j ); |
if( rc2 == -1 ) |
break; |
len_written += j; |
if( rc2 == ENOSPC ) |
break; |
len_written = i; |
j = 0; |
} |
} |
if( j ) { |
rc2 = os_write(ptr, fd, buf, j, &i ); |
if( rc2 == ENOSPC ) { |
len_written += i; |
} else { |
len_written = cnt; |
} |
} |
/* end of text mode part */ |
} |
} |
if( rc2 == -1 ) { |
return( rc2 ); |
} else { |
return( len_written ); |
} |
} |
_ssize_t |
_DEFUN (write, ( fd, buffer, cnt), |
int fd _AND |
_CONST _PTR buffer _AND |
size_t cnt) |
{ |
return _write_r(_REENT, fd, buffer, cnt); |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/programs/develop/libraries/newlib/reent |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/search/bsearch.c |
---|
0,0 → 1,102 |
/* |
* bsearch.c |
* Original Author: G. Haley |
* Rewritten by: G. Noer |
* |
* Searches an array of nmemb members, the initial member of which is pointed |
* to by base, for a member that matches the object pointed to by key. The |
* contents of the array shall be in ascending order according to a comparison |
* function pointed to by compar. The function shall return an integer less |
* than, equal to or greater than zero if the first argument is considered to be |
* respectively less than, equal to or greater than the second. Returns a |
* pointer to the matching member of the array, or a null pointer if no match |
* is found. |
*/ |
/* |
FUNCTION |
<<bsearch>>---binary search |
INDEX |
bsearch |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void *bsearch(const void *<[key]>, const void *<[base]>, |
size_t <[nmemb]>, size_t <[size]>, |
int (*<[compar]>)(const void *, const void *)); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
char *bsearch(<[key]>, <[base]>, <[nmemb]>, <[size]>, <[compar]>) |
char *<[key]>; |
char *<[base]>; |
size_t <[nmemb]>, <[size]>; |
int (*<[compar]>)(); |
DESCRIPTION |
<<bsearch>> searches an array beginning at <[base]> for any element |
that matches <[key]>, using binary search. <[nmemb]> is the element |
count of the array; <[size]> is the size of each element. |
The array must be sorted in ascending order with respect to the |
comparison function <[compar]> (which you supply as the last argument of |
<<bsearch>>). |
You must define the comparison function <<(*<[compar]>)>> to have two |
arguments; its result must be negative if the first argument is |
less than the second, zero if the two arguments match, and |
positive if the first argument is greater than the second (where |
``less than'' and ``greater than'' refer to whatever arbitrary |
ordering is appropriate). |
RETURNS |
Returns a pointer to an element of <[array]> that matches <[key]>. If |
more than one matching element is available, the result may point to |
any of them. |
PORTABILITY |
<<bsearch>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdlib.h> |
_PTR |
_DEFUN (bsearch, (key, base, nmemb, size, compar), |
_CONST _PTR key _AND |
_CONST _PTR base _AND |
size_t nmemb _AND |
size_t size _AND |
int _EXFNPTR(compar, (const _PTR, const _PTR))) |
{ |
_PTR current; |
size_t lower = 0; |
size_t upper = nmemb; |
size_t index; |
int result; |
if (nmemb == 0 || size == 0) |
return NULL; |
while (lower < upper) |
{ |
index = (lower + upper) / 2; |
current = (_PTR) (((char *) base) + (index * size)); |
result = compar (key, current); |
if (result < 0) |
upper = index; |
else if (result > 0) |
lower = index + 1; |
else |
return current; |
} |
return NULL; |
} |
/programs/develop/libraries/newlib/search/qsort.c |
---|
0,0 → 1,222 |
/* |
FUNCTION |
<<qsort>>---sort an array |
INDEX |
qsort |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void qsort(void *<[base]>, size_t <[nmemb]>, size_t <[size]>, |
int (*<[compar]>)(const void *, const void *) ); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
qsort(<[base]>, <[nmemb]>, <[size]>, <[compar]> ) |
char *<[base]>; |
size_t <[nmemb]>; |
size_t <[size]>; |
int (*<[compar]>)(); |
DESCRIPTION |
<<qsort>> sorts an array (beginning at <[base]>) of <[nmemb]> objects. |
<[size]> describes the size of each element of the array. |
You must supply a pointer to a comparison function, using the argument |
shown as <[compar]>. (This permits sorting objects of unknown |
properties.) Define the comparison function to accept two arguments, |
each a pointer to an element of the array starting at <[base]>. The |
result of <<(*<[compar]>)>> must be negative if the first argument is |
less than the second, zero if the two arguments match, and positive if |
the first argument is greater than the second (where ``less than'' and |
``greater than'' refer to whatever arbitrary ordering is appropriate). |
The array is sorted in place; that is, when <<qsort>> returns, the |
array elements beginning at <[base]> have been reordered. |
RETURNS |
<<qsort>> does not return a result. |
PORTABILITY |
<<qsort>> is required by ANSI (without specifying the sorting algorithm). |
*/ |
/*- |
* Copyright (c) 1992, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <stdlib.h> |
#ifndef __GNUC__ |
#define inline |
#endif |
static inline char *med3 _PARAMS((char *, char *, char *, int (*)())); |
static inline void swapfunc _PARAMS((char *, char *, int, int)); |
#define min(a, b) (a) < (b) ? a : b |
/* |
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". |
*/ |
#define swapcode(TYPE, parmi, parmj, n) { \ |
long i = (n) / sizeof (TYPE); \ |
register TYPE *pi = (TYPE *) (parmi); \ |
register TYPE *pj = (TYPE *) (parmj); \ |
do { \ |
register TYPE t = *pi; \ |
*pi++ = *pj; \ |
*pj++ = t; \ |
} while (--i > 0); \ |
} |
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ |
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; |
static inline void |
_DEFUN(swapfunc, (a, b, n, swaptype), |
char *a _AND |
char *b _AND |
int n _AND |
int swaptype) |
{ |
if(swaptype <= 1) |
swapcode(long, a, b, n) |
else |
swapcode(char, a, b, n) |
} |
#define swap(a, b) \ |
if (swaptype == 0) { \ |
long t = *(long *)(a); \ |
*(long *)(a) = *(long *)(b); \ |
*(long *)(b) = t; \ |
} else \ |
swapfunc(a, b, es, swaptype) |
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) |
static inline char * |
_DEFUN(med3, (a, b, c, cmp), |
char *a _AND |
char *b _AND |
char *c _AND |
int (*cmp)()) |
{ |
return cmp(a, b) < 0 ? |
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a )) |
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c )); |
} |
void |
_DEFUN(qsort, (a, n, es, cmp), |
void *a _AND |
size_t n _AND |
size_t es _AND |
int (*cmp)()) |
{ |
char *pa, *pb, *pc, *pd, *pl, *pm, *pn; |
int d, r, swaptype, swap_cnt; |
loop: SWAPINIT(a, es); |
swap_cnt = 0; |
if (n < 7) { |
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) |
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; |
pl -= es) |
swap(pl, pl - es); |
return; |
} |
pm = (char *) a + (n / 2) * es; |
if (n > 7) { |
pl = a; |
pn = (char *) a + (n - 1) * es; |
if (n > 40) { |
d = (n / 8) * es; |
pl = med3(pl, pl + d, pl + 2 * d, cmp); |
pm = med3(pm - d, pm, pm + d, cmp); |
pn = med3(pn - 2 * d, pn - d, pn, cmp); |
} |
pm = med3(pl, pm, pn, cmp); |
} |
swap(a, pm); |
pa = pb = (char *) a + es; |
pc = pd = (char *) a + (n - 1) * es; |
for (;;) { |
while (pb <= pc && (r = cmp(pb, a)) <= 0) { |
if (r == 0) { |
swap_cnt = 1; |
swap(pa, pb); |
pa += es; |
} |
pb += es; |
} |
while (pb <= pc && (r = cmp(pc, a)) >= 0) { |
if (r == 0) { |
swap_cnt = 1; |
swap(pc, pd); |
pd -= es; |
} |
pc -= es; |
} |
if (pb > pc) |
break; |
swap(pb, pc); |
swap_cnt = 1; |
pb += es; |
pc -= es; |
} |
if (swap_cnt == 0) { /* Switch to insertion sort */ |
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) |
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; |
pl -= es) |
swap(pl, pl - es); |
return; |
} |
pn = (char *) a + n * es; |
r = min(pa - (char *)a, pb - pa); |
vecswap(a, pb - r, r); |
r = min(pd - pc, pn - pd - es); |
vecswap(pb, pn - r, r); |
if ((r = pb - pa) > es) |
qsort(a, r / es, es, cmp); |
if ((r = pd - pc) > es) { |
/* Iterate rather than recurse to save stack space */ |
a = pn - r; |
n = r / es; |
goto loop; |
} |
/* qsort(pn - r, r / es, es, cmp);*/ |
} |
/programs/develop/libraries/newlib/search |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/stdio/fclose.c |
---|
0,0 → 1,121 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fclose>>---close a file |
INDEX |
fclose |
INDEX |
_fclose_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fclose(FILE *<[fp]>); |
int _fclose_r(struct _reent *<[reent]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fclose(<[fp]>) |
FILE *<[fp]>; |
int fclose(<[fp]>) |
struct _reent *<[reent]> |
FILE *<[fp]>; |
DESCRIPTION |
If the file or stream identified by <[fp]> is open, <<fclose>> closes |
it, after first ensuring that any pending data is written (by calling |
<<fflush(<[fp]>)>>). |
The alternate function <<_fclose_r>> is a reentrant version. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<fclose>> returns <<0>> if successful (including when <[fp]> is |
<<NULL>> or not an open file); otherwise, it returns <<EOF>>. |
PORTABILITY |
<<fclose>> is required by ANSI C. |
Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, |
<<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <sys/lock.h> |
#include "local.h" |
int |
_DEFUN(_fclose_r, (rptr, fp), |
struct _reent *rptr _AND |
register FILE * fp) |
{ |
int r; |
if (fp == NULL) |
return (0); /* on NULL */ |
__sfp_lock_acquire (); |
CHECK_INIT (rptr, fp); |
_flockfile (fp); |
if (fp->_flags == 0) /* not open! */ |
{ |
_funlockfile (fp); |
__sfp_lock_release (); |
return (0); |
} |
/* Unconditionally flush to allow special handling for seekable read |
files to reposition file to last byte processed as opposed to |
last byte read ahead into the buffer. */ |
r = _fflush_r (rptr, fp); |
if (fp->_close != NULL && fp->_close (rptr, fp->_cookie) < 0) |
r = EOF; |
if (fp->_flags & __SMBF) |
_free_r (rptr, (char *) fp->_bf._base); |
if (HASUB (fp)) |
FREEUB (rptr, fp); |
if (HASLB (fp)) |
FREELB (rptr, fp); |
fp->_flags = 0; /* release this FILE for reuse */ |
_funlockfile (fp); |
#ifndef __SINGLE_THREAD__ |
__lock_close_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
return (r); |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fclose, (fp), |
register FILE * fp) |
{ |
return _fclose_r(_REENT, fp); |
} |
#endif |
/programs/develop/libraries/newlib/stdio/fflush.c |
---|
0,0 → 1,240 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fflush>>---flush buffered file output |
INDEX |
fflush |
INDEX |
_fflush_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fflush(FILE *<[fp]>); |
int _fflush_r(struct _reent *<[reent]>, FILE *<[fp]>); |
DESCRIPTION |
The <<stdio>> output functions can buffer output before delivering it |
to the host system, in order to minimize the overhead of system calls. |
Use <<fflush>> to deliver any such pending output (for the file |
or stream identified by <[fp]>) to the host system. |
If <[fp]> is <<NULL>>, <<fflush>> delivers pending output from all |
open files. |
Additionally, if <[fp]> is a seekable input stream visiting a file |
descriptor, set the position of the file descriptor to match next |
unread byte, useful for obeying POSIX semantics when ending a process |
without consuming all input from the stream. |
The alternate function <<_fflush_r>> is a reentrant version, where the |
extra argument <[reent]> is a pointer to a reentrancy structure, and |
<[fp]> must not be NULL. |
RETURNS |
<<fflush>> returns <<0>> unless it encounters a write error; in that |
situation, it returns <<EOF>>. |
PORTABILITY |
ANSI C requires <<fflush>>. The behavior on input streams is only |
specified by POSIX, and not all implementations follow POSIX rules. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
/* Flush a single file, or (if fp is NULL) all files. */ |
int |
_DEFUN(_fflush_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE * fp) |
{ |
register unsigned char *p; |
register int n, t; |
#ifdef _REENT_SMALL |
/* For REENT_SMALL platforms, it is possible we are being |
called for the first time on a std stream. This std |
stream can belong to a reentrant struct that is not |
_REENT. If CHECK_INIT gets called below based on _REENT, |
we will end up changing said file pointers to the equivalent |
std stream off of _REENT. This causes unexpected behavior if |
there is any data to flush on the _REENT std stream. There |
are two alternatives to fix this: 1) make a reentrant fflush |
or 2) simply recognize that this file has nothing to flush |
and return immediately before performing a CHECK_INIT. Choice |
2 is implemented here due to its simplicity. */ |
if (fp->_bf._base == NULL) |
return 0; |
#endif /* _REENT_SMALL */ |
CHECK_INIT (ptr, fp); |
if (!fp->_flags) |
return 0; |
_flockfile (fp); |
t = fp->_flags; |
if ((t & __SWR) == 0) |
{ |
/* For a read stream, an fflush causes the next seek to be |
unoptimized (i.e. forces a system-level seek). This conforms |
to the POSIX and SUSv3 standards. */ |
fp->_flags |= __SNPT; |
/* For a seekable stream with buffered read characters, we will attempt |
a seek to the current position now. A subsequent read will then get |
the next byte from the file rather than the buffer. This conforms |
to the POSIX and SUSv3 standards. Note that the standards allow |
this seek to be deferred until necessary, but we choose to do it here |
to make the change simpler, more contained, and less likely |
to miss a code scenario. */ |
if ((fp->_r > 0 || fp->_ur > 0) && fp->_seek != NULL) |
{ |
int tmp_errno; |
#ifdef __LARGE64_FILES |
_fpos64_t curoff; |
#else |
_fpos_t curoff; |
#endif |
/* Save last errno and set errno to 0, so we can check if a device |
returns with a valid position -1. We restore the last errno if |
no other error condition has been encountered. */ |
tmp_errno = ptr->_errno; |
ptr->_errno = 0; |
/* Get the physical position we are at in the file. */ |
if (fp->_flags & __SOFF) |
curoff = fp->_offset; |
else |
{ |
/* We don't know current physical offset, so ask for it. |
Only ESPIPE and EINVAL are ignorable. */ |
#ifdef __LARGE64_FILES |
if (fp->_flags & __SL64) |
curoff = fp->_seek64 (ptr, fp->_cookie, 0, SEEK_CUR); |
else |
#endif |
curoff = fp->_seek (ptr, fp->_cookie, 0, SEEK_CUR); |
if (curoff == -1L && ptr->_errno != 0) |
{ |
int result = EOF; |
if (ptr->_errno == ESPIPE || ptr->_errno == EINVAL) |
{ |
result = 0; |
ptr->_errno = tmp_errno; |
} |
else |
fp->_flags |= __SERR; |
_funlockfile (fp); |
return result; |
} |
} |
if (fp->_flags & __SRD) |
{ |
/* Current offset is at end of buffer. Compensate for |
characters not yet read. */ |
curoff -= fp->_r; |
if (HASUB (fp)) |
curoff -= fp->_ur; |
} |
/* Now physically seek to after byte last read. */ |
#ifdef __LARGE64_FILES |
if (fp->_flags & __SL64) |
curoff = fp->_seek64 (ptr, fp->_cookie, curoff, SEEK_SET); |
else |
#endif |
curoff = fp->_seek (ptr, fp->_cookie, curoff, SEEK_SET); |
if (curoff != -1 || ptr->_errno == 0 |
|| ptr->_errno == ESPIPE || ptr->_errno == EINVAL) |
{ |
/* Seek successful or ignorable error condition. |
We can clear read buffer now. */ |
fp->_flags &= ~__SNPT; |
fp->_r = 0; |
fp->_p = fp->_bf._base; |
if ((fp->_flags & __SOFF) && (curoff != -1 || ptr->_errno == 0)) |
fp->_offset = curoff; |
ptr->_errno = tmp_errno; |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
} |
else |
{ |
fp->_flags |= __SERR; |
_funlockfile (fp); |
return EOF; |
} |
} |
_funlockfile (fp); |
return 0; |
} |
if ((p = fp->_bf._base) == NULL) |
{ |
/* Nothing to flush. */ |
_funlockfile (fp); |
return 0; |
} |
n = fp->_p - p; /* write this much */ |
/* |
* Set these immediately to avoid problems with longjmp |
* and to allow exchange buffering (via setvbuf) in user |
* write function. |
*/ |
fp->_p = p; |
fp->_w = t & (__SLBF | __SNBF) ? 0 : fp->_bf._size; |
while (n > 0) |
{ |
t = fp->_write (ptr, fp->_cookie, (char *) p, n); |
if (t <= 0) |
{ |
fp->_flags |= __SERR; |
_funlockfile (fp); |
return EOF; |
} |
p += t; |
n -= t; |
} |
_funlockfile (fp); |
return 0; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fflush, (fp), |
register FILE * fp) |
{ |
if (fp == NULL) |
return _fwalk_reent (_GLOBAL_REENT, _fflush_r); |
return _fflush_r (_REENT, fp); |
} |
#endif /* _REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/findfp.c |
---|
0,0 → 1,294 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <errno.h> |
#include <string.h> |
#include <fcntl.h> |
#include <sys/lock.h> |
#include "local.h" |
#ifdef _REENT_SMALL |
const struct __sFILE_fake __sf_fake_stdin = |
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}; |
const struct __sFILE_fake __sf_fake_stdout = |
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}; |
const struct __sFILE_fake __sf_fake_stderr = |
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}; |
#endif |
static _VOID |
_DEFUN(std, (ptr, flags, file, data), |
FILE *ptr _AND |
int flags _AND |
int file _AND |
struct _reent *data) |
{ |
ptr->_p = 0; |
ptr->_r = 0; |
ptr->_w = 0; |
ptr->_flags = flags; |
ptr->_flags2 = 0; |
ptr->_file = file; |
ptr->_bf._base = 0; |
ptr->_bf._size = 0; |
ptr->_lbfsize = 0; |
memset (&ptr->_mbstate, 0, sizeof (_mbstate_t)); |
ptr->_cookie = ptr; |
ptr->_read = __sread; |
#ifndef __LARGE64_FILES |
ptr->_write = __swrite; |
#else /* __LARGE64_FILES */ |
ptr->_write = __swrite64; |
ptr->_seek64 = __sseek64; |
ptr->_flags |= __SL64; |
#endif /* __LARGE64_FILES */ |
ptr->_seek = __sseek; |
ptr->_close = __sclose; |
#if !defined(__SINGLE_THREAD__) && !defined(_REENT_SMALL) |
__lock_init_recursive (ptr->_lock); |
/* |
* #else |
* lock is already initialized in __sfp |
*/ |
#endif |
#ifdef __SCLE |
if (__stextmode (ptr->_file)) |
ptr->_flags |= __SCLE; |
#endif |
} |
struct _glue * |
_DEFUN(__sfmoreglue, (d, n), |
struct _reent *d _AND |
register int n) |
{ |
struct _glue *g; |
FILE *p; |
g = (struct _glue *) _malloc_r (d, sizeof (*g) + n * sizeof (FILE)); |
if (g == NULL) |
return NULL; |
p = (FILE *) (g + 1); |
g->_next = NULL; |
g->_niobs = n; |
g->_iobs = p; |
memset (p, 0, n * sizeof (FILE)); |
return g; |
} |
/* |
* Find a free FILE for fopen et al. |
*/ |
FILE * |
_DEFUN(__sfp, (d), |
struct _reent *d) |
{ |
FILE *fp; |
int n; |
struct _glue *g; |
__sfp_lock_acquire (); |
if (!_GLOBAL_REENT->__sdidinit) |
__sinit (_GLOBAL_REENT); |
for (g = &_GLOBAL_REENT->__sglue;; g = g->_next) |
{ |
for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++) |
if (fp->_flags == 0) |
goto found; |
if (g->_next == NULL && |
(g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL) |
break; |
} |
__sfp_lock_release (); |
d->_errno = ENOMEM; |
return NULL; |
found: |
fp->_file = -1; /* no file */ |
fp->_flags = 1; /* reserve this slot; caller sets real flags */ |
fp->_flags2 = 0; |
#ifndef __SINGLE_THREAD__ |
__lock_init_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
fp->_p = NULL; /* no current pointer */ |
fp->_w = 0; /* nothing to read or write */ |
fp->_r = 0; |
fp->_bf._base = NULL; /* no buffer */ |
fp->_bf._size = 0; |
fp->_lbfsize = 0; /* not line buffered */ |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
/* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */ |
fp->_ub._base = NULL; /* no ungetc buffer */ |
fp->_ub._size = 0; |
fp->_lb._base = NULL; /* no line buffer */ |
fp->_lb._size = 0; |
return fp; |
} |
/* |
* exit() calls _cleanup() through *__cleanup, set whenever we |
* open or buffer a file. This chicanery is done so that programs |
* that do not use stdio need not link it all in. |
* |
* The name `_cleanup' is, alas, fairly well known outside stdio. |
*/ |
_VOID |
_DEFUN(_cleanup_r, (ptr), |
struct _reent *ptr) |
{ |
_CAST_VOID _fwalk(ptr, fclose); |
/* _CAST_VOID _fwalk (ptr, fflush); */ /* `cheating' */ |
} |
#ifndef _REENT_ONLY |
_VOID |
_DEFUN_VOID(_cleanup) |
{ |
_cleanup_r (_GLOBAL_REENT); |
} |
#endif |
/* |
* __sinit() is called whenever stdio's internal variables must be set up. |
*/ |
_VOID |
_DEFUN(__sinit, (s), |
struct _reent *s) |
{ |
__sinit_lock_acquire (); |
if (s->__sdidinit) |
{ |
__sinit_lock_release (); |
return; |
} |
/* make sure we clean up on exit */ |
s->__cleanup = _cleanup_r; /* conservative */ |
s->__sdidinit = 1; |
s->__sglue._next = NULL; |
#ifndef _REENT_SMALL |
s->__sglue._niobs = 3; |
s->__sglue._iobs = &s->__sf[0]; |
#else |
s->__sglue._niobs = 0; |
s->__sglue._iobs = NULL; |
s->_stdin = __sfp(s); |
s->_stdout = __sfp(s); |
s->_stderr = __sfp(s); |
#endif |
std (s->_stdin, __SRD, 0, s); |
/* On platforms that have true file system I/O, we can verify |
whether stdout is an interactive terminal or not, as part of |
__smakebuf on first use of the stream. For all other platforms, |
we will default to line buffered mode here. Technically, POSIX |
requires both stdin and stdout to be line-buffered, but tradition |
leaves stdin alone on systems without fcntl. */ |
#ifdef HAVE_FCNTL |
std (s->_stdout, __SWR, 1, s); |
#else |
std (s->_stdout, __SWR | __SLBF, 1, s); |
#endif |
/* POSIX requires stderr to be opened for reading and writing, even |
when the underlying fd 2 is write-only. */ |
std (s->_stderr, __SRW | __SNBF, 2, s); |
__sinit_lock_release (); |
} |
#ifndef __SINGLE_THREAD__ |
__LOCK_INIT_RECURSIVE(static, __sfp_lock); |
__LOCK_INIT_RECURSIVE(static, __sinit_lock); |
_VOID |
_DEFUN_VOID(__sfp_lock_acquire) |
{ |
__lock_acquire_recursive (__sfp_lock); |
} |
_VOID |
_DEFUN_VOID(__sfp_lock_release) |
{ |
__lock_release_recursive (__sfp_lock); |
} |
_VOID |
_DEFUN_VOID(__sinit_lock_acquire) |
{ |
__lock_acquire_recursive (__sinit_lock); |
} |
_VOID |
_DEFUN_VOID(__sinit_lock_release) |
{ |
__lock_release_recursive (__sinit_lock); |
} |
/* Walkable file locking routine. */ |
static int |
_DEFUN(__fp_lock, (ptr), |
FILE * ptr) |
{ |
_flockfile (ptr); |
return 0; |
} |
/* Walkable file unlocking routine. */ |
static int |
_DEFUN(__fp_unlock, (ptr), |
FILE * ptr) |
{ |
_funlockfile (ptr); |
return 0; |
} |
_VOID |
_DEFUN_VOID(__fp_lock_all) |
{ |
__sfp_lock_acquire (); |
_CAST_VOID _fwalk (_REENT, __fp_lock); |
} |
_VOID |
_DEFUN_VOID(__fp_unlock_all) |
{ |
_CAST_VOID _fwalk (_REENT, __fp_unlock); |
__sfp_lock_release (); |
} |
#endif |
/programs/develop/libraries/newlib/stdio/fiprintf.c |
---|
0,0 → 1,55 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in siprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
int |
_DEFUN(_fiprintf_r, (ptr, fp, fmt), |
struct _reent *ptr _AND |
FILE * fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfiprintf_r (ptr, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fiprintf, (fp, fmt), |
FILE * fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfiprintf_r (_REENT, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* ! _REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/flags.c |
---|
0,0 → 1,86 |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92 */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <time.h> |
#include <fcntl.h> |
#include <errno.h> |
#include <sys/types.h> |
/* |
* Return the (stdio) flags for a given mode. Store the flags |
* to be passed to an open() syscall through *optr. |
* Return 0 on error. |
*/ |
int |
_DEFUN(__sflags, (ptr, mode, optr), |
struct _reent *ptr _AND |
register char *mode _AND |
int *optr) |
{ |
register int ret, m, o; |
switch (mode[0]) |
{ |
case 'r': /* open for reading */ |
ret = __SRD; |
m = O_RDONLY; |
o = 0; |
break; |
case 'w': /* open for writing */ |
ret = __SWR; |
m = O_WRONLY; |
o = O_CREAT | O_TRUNC; |
break; |
case 'a': /* open for appending */ |
ret = __SWR | __SAPP; |
m = O_WRONLY; |
o = O_CREAT | O_APPEND; |
break; |
default: /* illegal mode */ |
ptr->_errno = EINVAL; |
return (0); |
} |
if (mode[1] && (mode[1] == '+' || mode[2] == '+')) |
{ |
ret = (ret & ~(__SRD | __SWR)) | __SRW; |
m = O_RDWR; |
} |
if (mode[1] && (mode[1] == 'b' || mode[2] == 'b')) |
{ |
#ifdef O_BINARY |
m |= O_BINARY; |
#endif |
} |
#ifdef __CYGWIN__ |
else if (mode[1] && (mode[1] == 't' || mode[2] == 't')) |
#else |
else |
#endif |
{ |
#ifdef O_TEXT |
m |= O_TEXT; |
#endif |
} |
*optr = m | o; |
return ret; |
} |
/programs/develop/libraries/newlib/stdio/floatio.h |
---|
0,0 → 1,32 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
* |
* %W% (Berkeley) %G% |
*/ |
/* |
* Floating point scanf/printf (input/output) definitions. |
*/ |
#ifdef _NO_LONGDBL |
/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ |
#define MAXEXP 308 |
#else /* !_NO_LONGDBL */ |
/* 15-bit exponent (Intel extended floating point) is 4932 decimal digits */ |
#define MAXEXP 4932 |
#endif /* !_NO_LONGDBL */ |
/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ |
#define MAXFRACT 39 |
/programs/develop/libraries/newlib/stdio/fopen.c |
---|
0,0 → 1,184 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fopen>>---open a file |
INDEX |
fopen |
INDEX |
_fopen_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
FILE *fopen(const char *<[file]>, const char *<[mode]>); |
FILE *_fopen_r(struct _reent *<[reent]>, |
const char *<[file]>, const char *<[mode]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
FILE *fopen(<[file]>, <[mode]>) |
char *<[file]>; |
char *<[mode]>; |
FILE *_fopen_r(<[reent]>, <[file]>, <[mode]>) |
struct _reent *<[reent]>; |
char *<[file]>; |
char *<[mode]>; |
DESCRIPTION |
<<fopen>> initializes the data structures needed to read or write a |
file. Specify the file's name as the string at <[file]>, and the kind |
of access you need to the file with the string at <[mode]>. |
The alternate function <<_fopen_r>> is a reentrant version. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
Three fundamental kinds of access are available: read, write, and append. |
<<*<[mode]>>> must begin with one of the three characters `<<r>>', |
`<<w>>', or `<<a>>', to select one of these: |
o+ |
o r |
Open the file for reading; the operation will fail if the file does |
not exist, or if the host system does not permit you to read it. |
o w |
Open the file for writing @emph{from the beginning} of the file: |
effectively, this always creates a new file. If the file whose name you |
specified already existed, its old contents are discarded. |
o a |
Open the file for appending data, that is writing from the end of |
file. When you open a file this way, all data always goes to the |
current end of file; you cannot change this using <<fseek>>. |
o- |
Some host systems distinguish between ``binary'' and ``text'' files. |
Such systems may perform data transformations on data written to, or |
read from, files opened as ``text''. |
If your system is one of these, then you can append a `<<b>>' to any |
of the three modes above, to specify that you are opening the file as |
a binary file (the default is to open the file as a text file). |
`<<rb>>', then, means ``read binary''; `<<wb>>', ``write binary''; and |
`<<ab>>', ``append binary''. |
To make C programs more portable, the `<<b>>' is accepted on all |
systems, whether or not it makes a difference. |
Finally, you might need to both read and write from the same file. |
You can also append a `<<+>>' to any of the three modes, to permit |
this. (If you want to append both `<<b>>' and `<<+>>', you can do it |
in either order: for example, <<"rb+">> means the same thing as |
<<"r+b">> when used as a mode string.) |
Use <<"r+">> (or <<"rb+">>) to permit reading and writing anywhere in |
an existing file, without discarding any data; <<"w+">> (or <<"wb+">>) |
to create a new file (or begin by discarding all data from an old one) |
that permits reading and writing anywhere in it; and <<"a+">> (or |
<<"ab+">>) to permit reading anywhere in an existing file, but writing |
only at the end. |
RETURNS |
<<fopen>> returns a file pointer which you can use for other file |
operations, unless the file you requested could not be opened; in that |
situation, the result is <<NULL>>. If the reason for failure was an |
invalid string at <[mode]>, <<errno>> is set to <<EINVAL>>. |
PORTABILITY |
<<fopen>> is required by ANSI C. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <errno.h> |
#include <sys/lock.h> |
#ifdef __CYGWIN__ |
#include <fcntl.h> |
#endif |
#include "local.h" |
FILE * |
_DEFUN(_fopen_r, (ptr, file, mode), |
struct _reent *ptr _AND |
_CONST char *file _AND |
_CONST char *mode) |
{ |
register FILE *fp; |
register int f; |
int flags, oflags; |
if ((flags = __sflags (ptr, mode, &oflags)) == 0) |
return NULL; |
if ((fp = __sfp (ptr)) == NULL) |
return NULL; |
if ((f = _open_r (ptr, file, oflags, 0666)) < 0) |
{ |
__sfp_lock_acquire (); |
fp->_flags = 0; /* release */ |
#ifndef __SINGLE_THREAD__ |
__lock_close_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
return NULL; |
} |
_flockfile (fp); |
fp->_file = f; |
fp->_flags = flags; |
fp->_cookie = (_PTR) fp; |
fp->_read = __sread; |
fp->_write = __swrite; |
fp->_seek = __sseek; |
fp->_close = __sclose; |
if (fp->_flags & __SAPP) |
_fseek_r (ptr, fp, 0, SEEK_END); |
#ifdef __SCLE |
if (__stextmode (fp->_file)) |
fp->_flags |= __SCLE; |
#endif |
_funlockfile (fp); |
return fp; |
} |
#ifndef _REENT_ONLY |
FILE * |
_DEFUN(fopen, (file, mode), |
_CONST char *file _AND |
_CONST char *mode) |
{ |
return _fopen_r (_REENT, file, mode); |
} |
#endif |
/programs/develop/libraries/newlib/stdio/fprintf.c |
---|
0,0 → 1,55 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in sprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
int |
_DEFUN(_fprintf_r, (ptr, fp, fmt), |
struct _reent *ptr _AND |
FILE *fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfprintf_r (ptr, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fprintf, (fp, fmt), |
FILE *fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfprintf_r (_REENT, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* ! _REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/fputc.c |
---|
0,0 → 1,109 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fputc>>---write a character on a stream or file |
INDEX |
fputc |
INDEX |
_fputc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fputc(int <[ch]>, FILE *<[fp]>); |
#include <stdio.h> |
int _fputc_r(struct _rent *<[ptr]>, int <[ch]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fputc(<[ch]>, <[fp]>) |
int <[ch]>; |
FILE *<[fp]>; |
#include <stdio.h> |
int _fputc_r(<[ptr]>, <[ch]>, <[fp]>) |
struct _reent *<[ptr]>; |
int <[ch]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fputc>> converts the argument <[ch]> from an <<int>> to an |
<<unsigned char>>, then writes it to the file or stream identified by |
<[fp]>. |
If the file was opened with append mode (or if the stream cannot |
support positioning), then the new character goes at the end of the |
file or stream. Otherwise, the new character is written at the |
current value of the position indicator, and the position indicator |
oadvances by one. |
For a macro version of this function, see <<putc>>. |
The <<_fputc_r>> function is simply a reentrant version of <<fputc>> |
that takes an additional reentrant structure argument: <[ptr]>. |
RETURNS |
If successful, <<fputc>> returns its argument <[ch]>. If an error |
intervenes, the result is <<EOF>>. You can use `<<ferror(<[fp]>)>>' to |
query for errors. |
PORTABILITY |
<<fputc>> is required by ANSI C. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include "local.h" |
int |
_DEFUN(_fputc_r, (ptr, ch, file), |
struct _reent *ptr _AND |
int ch _AND |
FILE * file) |
{ |
int result; |
CHECK_INIT(ptr, file); |
_flockfile (file); |
result = _putc_r (ptr, ch, file); |
_funlockfile (file); |
return result; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fputc, (ch, file), |
int ch _AND |
FILE * file) |
{ |
#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED) |
int result; |
CHECK_INIT(_REENT, file); |
_flockfile (file); |
result = _putc_r (_REENT, ch, file); |
_funlockfile (file); |
return result; |
#else |
return _fputc_r (_REENT, ch, file); |
#endif |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/fputs.c |
---|
0,0 → 1,106 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fputs>>---write a character string in a file or stream |
INDEX |
fputs |
INDEX |
_fputs_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fputs(const char *<[s]>, FILE *<[fp]>); |
#include <stdio.h> |
int _fputs_r(struct _reent *<[ptr]>, const char *<[s]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fputs(<[s]>, <[fp]>) |
char *<[s]>; |
FILE *<[fp]>; |
#include <stdio.h> |
int _fputs_r(<[ptr]>, <[s]>, <[fp]>) |
struct _reent *<[ptr]>; |
char *<[s]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fputs>> writes the string at <[s]> (but without the trailing null) |
to the file or stream identified by <[fp]>. |
<<_fputs_r>> is simply the reentrant version of <<fputs>> that takes |
an additional reentrant struct pointer argument: <[ptr]>. |
RETURNS |
If successful, the result is <<0>>; otherwise, the result is <<EOF>>. |
PORTABILITY |
ANSI C requires <<fputs>>, but does not specify that the result on |
success must be <<0>>; any non-negative value is permitted. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#include "fvwrite.h" |
#include "local.h" |
/* |
* Write the given string to the given file. |
*/ |
int |
_DEFUN(_fputs_r, (ptr, s, fp), |
struct _reent * ptr _AND |
char _CONST * s _AND |
FILE * fp) |
{ |
int result; |
struct __suio uio; |
struct __siov iov; |
iov.iov_base = s; |
iov.iov_len = uio.uio_resid = strlen (s); |
uio.uio_iov = &iov; |
uio.uio_iovcnt = 1; |
CHECK_INIT(ptr, fp); |
_flockfile (fp); |
ORIENT (fp, -1); |
result = __sfvwrite_r (ptr, fp, &uio); |
_funlockfile (fp); |
return result; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fputs, (s, fp), |
char _CONST * s _AND |
FILE * fp) |
{ |
return _fputs_r (_REENT, s, fp); |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/fputwc.c |
---|
0,0 → 1,177 |
/*- |
* Copyright (c) 2002-2004 Tim J. Robbins. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<fputwc>>, <<putwc>>---write a wide character on a stream or file |
INDEX |
fputwc |
INDEX |
_fputwc_r |
INDEX |
putwc |
INDEX |
_putwc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <wchar.h> |
wint_t fputwc(wchar_t <[wc]>, FILE *<[fp]>); |
#include <stdio.h> |
#include <wchar.h> |
wint_t _fputwc_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>); |
#include <stdio.h> |
#include <wchar.h> |
wint_t putwc(wchar_t <[wc]>, FILE *<[fp]>); |
#include <stdio.h> |
#include <wchar.h> |
wint_t _putwc_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
#include <wchar.h> |
wint_t fputwc(<[wc]>, <[fp]>) |
wchar_t <[wc]>; |
FILE *<[fp]>; |
#include <stdio.h> |
#include <wchar.h> |
wint_t _fputwc_r(<[ptr]>, <[wc]>, <[fp]>) |
struct _reent *<[ptr]>; |
wchar_t <[wc]>; |
FILE *<[fp]>; |
#include <stdio.h> |
#include <wchar.h> |
wint_t putwc(<[wc]>, <[fp]>) |
wchar_t <[wc]>; |
FILE *<[fp]>; |
#include <stdio.h> |
#include <wchar.h> |
wint_t _putwc_r(<[ptr]>, <[wc]>, <[fp]>) |
struct _reent *<[ptr]>; |
wchar_t <[wc]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fputwc>> writes the wide character argument <[wc]> to the file or |
stream identified by <[fp]>. |
If the file was opened with append mode (or if the stream cannot |
support positioning), then the new wide character goes at the end of the |
file or stream. Otherwise, the new wide character is written at the |
current value of the position indicator, and the position indicator |
oadvances by one. |
The <<putwc>> function or macro functions identically to <<fputwc>>. It |
may be implemented as a macro, and may evaluate its argument more than |
once. There is no reason ever to use it. |
The <<_fputwc_r>> and <<_putwc_r>> functions are simply reentrant versions |
of <<fputwc>> and <<putwc>> that take an additional reentrant structure |
argument: <[ptr]>. |
RETURNS |
If successful, <<fputwc>> and <<putwc>> return their argument <[wc]>. |
If an error intervenes, the result is <<EOF>>. You can use |
`<<ferror(<[fp]>)>>' to query for errors. |
PORTABILITY |
C99, POSIX.1-2001 |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <errno.h> |
#include <limits.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <wchar.h> |
#include "local.h" |
static wint_t |
_DEFUN(__fputwc, (ptr, wc, fp), |
struct _reent *ptr _AND |
wchar_t wc _AND |
FILE *fp) |
{ |
char buf[MB_LEN_MAX]; |
size_t i, len; |
if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) |
{ |
/* |
* Assume single-byte locale with no special encoding. |
* A more careful test would be to check |
* _CurrentRuneLocale->encoding. |
*/ |
*buf = (unsigned char)wc; |
len = 1; |
} |
else |
{ |
if ((len = _wcrtomb_r (ptr, buf, wc, &fp->_mbstate)) == (size_t) -1) |
{ |
fp->_flags |= __SERR; |
return WEOF; |
} |
} |
for (i = 0; i < len; i++) |
if (__sputc_r (ptr, (unsigned char) buf[i], fp) == EOF) |
return WEOF; |
return (wint_t) wc; |
} |
wint_t |
_DEFUN(_fputwc_r, (ptr, wc, fp), |
struct _reent *ptr _AND |
wchar_t wc _AND |
FILE *fp) |
{ |
wint_t r; |
_flockfile (fp); |
ORIENT(fp, 1); |
r = __fputwc(ptr, wc, fp); |
_funlockfile (fp); |
return r; |
} |
wint_t |
_DEFUN(fputwc, (wc, fp), |
wchar_t wc _AND |
FILE *fp) |
{ |
CHECK_INIT(_REENT, fp); |
return _fputwc_r (_REENT, wc, fp); |
} |
/programs/develop/libraries/newlib/stdio/fseek.c |
---|
0,0 → 1,406 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fseek>>, <<fseeko>>---set file position |
INDEX |
fseek |
INDEX |
fseeko |
INDEX |
_fseek_r |
INDEX |
_fseeko_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fseek(FILE *<[fp]>, long <[offset]>, int <[whence]>) |
int fseeko(FILE *<[fp]>, off_t <[offset]>, int <[whence]>) |
int _fseek_r(struct _reent *<[ptr]>, FILE *<[fp]>, |
long <[offset]>, int <[whence]>) |
int _fseeko_r(struct _reent *<[ptr]>, FILE *<[fp]>, |
off_t <[offset]>, int <[whence]>) |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fseek(<[fp]>, <[offset]>, <[whence]>) |
FILE *<[fp]>; |
long <[offset]>; |
int <[whence]>; |
int fseeko(<[fp]>, <[offset]>, <[whence]>) |
FILE *<[fp]>; |
off_t <[offset]>; |
int <[whence]>; |
int _fseek_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>) |
struct _reent *<[ptr]>; |
FILE *<[fp]>; |
long <[offset]>; |
int <[whence]>; |
int _fseeko_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>) |
struct _reent *<[ptr]>; |
FILE *<[fp]>; |
off_t <[offset]>; |
int <[whence]>; |
DESCRIPTION |
Objects of type <<FILE>> can have a ``position'' that records how much |
of the file your program has already read. Many of the <<stdio>> functions |
depend on this position, and many change it as a side effect. |
You can use <<fseek>>/<<fseeko>> to set the position for the file identified by |
<[fp]>. The value of <[offset]> determines the new position, in one |
of three ways selected by the value of <[whence]> (defined as macros |
in `<<stdio.h>>'): |
<<SEEK_SET>>---<[offset]> is the absolute file position (an offset |
from the beginning of the file) desired. <[offset]> must be positive. |
<<SEEK_CUR>>---<[offset]> is relative to the current file position. |
<[offset]> can meaningfully be either positive or negative. |
<<SEEK_END>>---<[offset]> is relative to the current end of file. |
<[offset]> can meaningfully be either positive (to increase the size |
of the file) or negative. |
See <<ftell>>/<<ftello>> to determine the current file position. |
RETURNS |
<<fseek>>/<<fseeko>> return <<0>> when successful. On failure, the |
result is <<EOF>>. The reason for failure is indicated in <<errno>>: |
either <<ESPIPE>> (the stream identified by <[fp]> doesn't support |
repositioning) or <<EINVAL>> (invalid file position). |
PORTABILITY |
ANSI C requires <<fseek>>. |
<<fseeko>> is defined by the Single Unix specification. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <string.h> |
#include <time.h> |
#include <fcntl.h> |
#include <stdlib.h> |
#include <errno.h> |
#include <sys/stat.h> |
#include "local.h" |
#define POS_ERR (-(_fpos_t)1) |
/* |
* Seek the given file to the given offset. |
* `Whence' must be one of the three SEEK_* macros. |
*/ |
int |
_DEFUN(_fseek_r, (ptr, fp, offset, whence), |
struct _reent *ptr _AND |
register FILE *fp _AND |
long offset _AND |
int whence) |
{ |
_fpos_t _EXFNPTR(seekfn, (struct _reent *, _PTR, _fpos_t, int)); |
_fpos_t target; |
_fpos_t curoff = 0; |
size_t n; |
#ifdef __USE_INTERNAL_STAT64 |
struct stat64 st; |
#else |
struct stat st; |
#endif |
int havepos; |
/* Make sure stdio is set up. */ |
CHECK_INIT (ptr, fp); |
__sfp_lock_acquire (); |
_flockfile (fp); |
/* If we've been doing some writing, and we're in append mode |
then we don't really know where the filepos is. */ |
if (fp->_flags & __SAPP && fp->_flags & __SWR) |
{ |
/* So flush the buffer and seek to the end. */ |
_fflush_r (ptr, fp); |
} |
/* Have to be able to seek. */ |
if ((seekfn = fp->_seek) == NULL) |
{ |
ptr->_errno = ESPIPE; /* ??? */ |
_funlockfile (fp); |
__sfp_lock_release (); |
return EOF; |
} |
/* |
* Change any SEEK_CUR to SEEK_SET, and check `whence' argument. |
* After this, whence is either SEEK_SET or SEEK_END. |
*/ |
switch (whence) |
{ |
case SEEK_CUR: |
/* |
* In order to seek relative to the current stream offset, |
* we have to first find the current stream offset a la |
* ftell (see ftell for details). |
*/ |
_fflush_r (ptr, fp); /* may adjust seek offset on append stream */ |
if (fp->_flags & __SOFF) |
curoff = fp->_offset; |
else |
{ |
curoff = seekfn (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR); |
if (curoff == -1L) |
{ |
_funlockfile (fp); |
__sfp_lock_release (); |
return EOF; |
} |
} |
if (fp->_flags & __SRD) |
{ |
curoff -= fp->_r; |
if (HASUB (fp)) |
curoff -= fp->_ur; |
} |
else if (fp->_flags & __SWR && fp->_p != NULL) |
curoff += fp->_p - fp->_bf._base; |
offset += curoff; |
whence = SEEK_SET; |
havepos = 1; |
break; |
case SEEK_SET: |
case SEEK_END: |
havepos = 0; |
break; |
default: |
ptr->_errno = EINVAL; |
_funlockfile (fp); |
__sfp_lock_release (); |
return (EOF); |
} |
/* |
* Can only optimise if: |
* reading (and not reading-and-writing); |
* not unbuffered; and |
* this is a `regular' Unix file (and hence seekfn==__sseek). |
* We must check __NBF first, because it is possible to have __NBF |
* and __SOPT both set. |
*/ |
if (fp->_bf._base == NULL) |
__smakebuf_r (ptr, fp); |
if (fp->_flags & (__SWR | __SRW | __SNBF | __SNPT)) |
goto dumb; |
if ((fp->_flags & __SOPT) == 0) |
{ |
if (seekfn != __sseek |
|| fp->_file < 0 |
#ifdef __USE_INTERNAL_STAT64 |
|| _fstat64_r (ptr, fp->_file, &st) |
#else |
|| _fstat_r (ptr, fp->_file, &st) |
#endif |
|| (st.st_mode & S_IFMT) != S_IFREG) |
{ |
fp->_flags |= __SNPT; |
goto dumb; |
} |
#ifdef HAVE_BLKSIZE |
fp->_blksize = st.st_blksize; |
#else |
fp->_blksize = 1024; |
#endif |
fp->_flags |= __SOPT; |
} |
/* |
* We are reading; we can try to optimise. |
* Figure out where we are going and where we are now. |
*/ |
if (whence == SEEK_SET) |
target = offset; |
else |
{ |
#ifdef __USE_INTERNAL_STAT64 |
if (_fstat64_r (ptr, fp->_file, &st)) |
#else |
if (_fstat_r (ptr, fp->_file, &st)) |
#endif |
goto dumb; |
target = st.st_size + offset; |
} |
if ((long)target != target) |
{ |
ptr->_errno = EOVERFLOW; |
_funlockfile (fp); |
__sfp_lock_release (); |
return EOF; |
} |
if (!havepos) |
{ |
if (fp->_flags & __SOFF) |
curoff = fp->_offset; |
else |
{ |
curoff = seekfn (ptr, fp->_cookie, 0L, SEEK_CUR); |
if (curoff == POS_ERR) |
goto dumb; |
} |
curoff -= fp->_r; |
if (HASUB (fp)) |
curoff -= fp->_ur; |
} |
/* |
* Compute the number of bytes in the input buffer (pretending |
* that any ungetc() input has been discarded). Adjust current |
* offset backwards by this count so that it represents the |
* file offset for the first byte in the current input buffer. |
*/ |
if (HASUB (fp)) |
{ |
curoff += fp->_r; /* kill off ungetc */ |
n = fp->_up - fp->_bf._base; |
curoff -= n; |
n += fp->_ur; |
} |
else |
{ |
n = fp->_p - fp->_bf._base; |
curoff -= n; |
n += fp->_r; |
} |
/* |
* If the target offset is within the current buffer, |
* simply adjust the pointers, clear EOF, undo ungetc(), |
* and return. |
*/ |
if (target >= curoff && target < curoff + n) |
{ |
register int o = target - curoff; |
fp->_p = fp->_bf._base + o; |
fp->_r = n - o; |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_flags &= ~__SEOF; |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
_funlockfile (fp); |
__sfp_lock_release (); |
return 0; |
} |
/* |
* The place we want to get to is not within the current buffer, |
* but we can still be kind to the kernel copyout mechanism. |
* By aligning the file offset to a block boundary, we can let |
* the kernel use the VM hardware to map pages instead of |
* copying bytes laboriously. Using a block boundary also |
* ensures that we only read one block, rather than two. |
*/ |
curoff = target & ~(fp->_blksize - 1); |
if (seekfn (ptr, fp->_cookie, curoff, SEEK_SET) == POS_ERR) |
goto dumb; |
fp->_r = 0; |
fp->_p = fp->_bf._base; |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_flags &= ~__SEOF; |
n = target - curoff; |
if (n) |
{ |
if (__srefill_r (ptr, fp) || fp->_r < n) |
goto dumb; |
fp->_p += n; |
fp->_r -= n; |
} |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
_funlockfile (fp); |
__sfp_lock_release (); |
return 0; |
/* |
* We get here if we cannot optimise the seek ... just |
* do it. Allow the seek function to change fp->_bf._base. |
*/ |
dumb: |
if (_fflush_r (ptr, fp) |
|| seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR) |
{ |
_funlockfile (fp); |
__sfp_lock_release (); |
return EOF; |
} |
/* success: clear EOF indicator and discard ungetc() data */ |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_p = fp->_bf._base; |
fp->_r = 0; |
/* fp->_w = 0; *//* unnecessary (I think...) */ |
fp->_flags &= ~__SEOF; |
/* Reset no-optimization flag after successful seek. The |
no-optimization flag may be set in the case of a read |
stream that is flushed which by POSIX/SUSv3 standards, |
means that a corresponding seek must not optimize. The |
optimization is then allowed if no subsequent flush |
is performed. */ |
fp->_flags &= ~__SNPT; |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
_funlockfile (fp); |
__sfp_lock_release (); |
return 0; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fseek, (fp, offset, whence), |
register FILE *fp _AND |
long offset _AND |
int whence) |
{ |
return _fseek_r (_REENT, fp, offset, whence); |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/fvwrite.c |
---|
0,0 → 1,271 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#include <stdlib.h> |
#include <errno.h> |
#include "local.h" |
#include "fvwrite.h" |
#define MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define COPY(n) _CAST_VOID memmove ((_PTR) fp->_p, (_PTR) p, (size_t) (n)) |
#define GETIOV(extra_work) \ |
while (len == 0) \ |
{ \ |
extra_work; \ |
p = iov->iov_base; \ |
len = iov->iov_len; \ |
iov++; \ |
} |
/* |
* Write some memory regions. Return zero on success, EOF on error. |
* |
* This routine is large and unsightly, but most of the ugliness due |
* to the three different kinds of output buffering is handled here. |
*/ |
int |
_DEFUN(__sfvwrite_r, (ptr, fp, uio), |
struct _reent *ptr _AND |
register FILE *fp _AND |
register struct __suio *uio) |
{ |
register size_t len; |
register _CONST char *p = NULL; |
register struct __siov *iov; |
register int w, s; |
char *nl; |
int nlknown, nldist; |
if ((len = uio->uio_resid) == 0) |
return 0; |
/* make sure we can write */ |
if (cantwrite (ptr, fp)) |
{ |
fp->_flags |= __SERR; |
ptr->_errno = EBADF; |
return EOF; |
} |
iov = uio->uio_iov; |
len = 0; |
#ifdef __SCLE |
if (fp->_flags & __SCLE) /* text mode */ |
{ |
do |
{ |
GETIOV (;); |
while (len > 0) |
{ |
if (putc (*p, fp) == EOF) |
return EOF; |
p++; |
len--; |
uio->uio_resid--; |
} |
} |
while (uio->uio_resid > 0); |
return 0; |
} |
#endif |
if (fp->_flags & __SNBF) |
{ |
/* |
* Unbuffered: write up to BUFSIZ bytes at a time. |
*/ |
do |
{ |
GETIOV (;); |
w = fp->_write (ptr, fp->_cookie, p, MIN (len, BUFSIZ)); |
if (w <= 0) |
goto err; |
p += w; |
len -= w; |
} |
while ((uio->uio_resid -= w) != 0); |
} |
else if ((fp->_flags & __SLBF) == 0) |
{ |
/* |
* Fully buffered: fill partially full buffer, if any, |
* and then flush. If there is no partial buffer, write |
* one _bf._size byte chunk directly (without copying). |
* |
* String output is a special case: write as many bytes |
* as fit, but pretend we wrote everything. This makes |
* snprintf() return the number of bytes needed, rather |
* than the number used, and avoids its write function |
* (so that the write function can be invalid). If |
* we are dealing with the asprintf routines, we will |
* dynamically increase the buffer size as needed. |
*/ |
do |
{ |
GETIOV (;); |
w = fp->_w; |
if (fp->_flags & __SSTR) |
{ |
if (len >= w && fp->_flags & (__SMBF | __SOPT)) |
{ /* must be asprintf family */ |
unsigned char *str; |
int curpos = (fp->_p - fp->_bf._base); |
/* Choose a geometric growth factor to avoid |
quadratic realloc behavior, but use a rate less |
than (1+sqrt(5))/2 to accomodate malloc |
overhead. asprintf EXPECTS us to overallocate, so |
that it can add a trailing \0 without |
reallocating. The new allocation should thus be |
max(prev_size*1.5, curpos+len+1). */ |
int newsize = fp->_bf._size * 3 / 2; |
if (newsize < curpos + len + 1) |
newsize = curpos + len + 1; |
if (fp->_flags & __SOPT) |
{ |
/* asnprintf leaves original buffer alone. */ |
str = (unsigned char *)_malloc_r (ptr, newsize); |
if (!str) |
{ |
ptr->_errno = ENOMEM; |
goto err; |
} |
memcpy (str, fp->_bf._base, curpos); |
fp->_flags = (fp->_flags & ~__SOPT) | __SMBF; |
} |
else |
{ |
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base, |
newsize); |
if (!str) |
{ |
/* Free buffer which is no longer used. */ |
_free_r (ptr, fp->_bf._base); |
/* Ensure correct errno, even if free changed it. */ |
ptr->_errno = ENOMEM; |
goto err; |
} |
} |
fp->_bf._base = str; |
fp->_p = str + curpos; |
fp->_bf._size = newsize; |
w = len; |
fp->_w = newsize - curpos; |
} |
if (len < w) |
w = len; |
COPY (w); /* copy MIN(fp->_w,len), */ |
fp->_w -= w; |
fp->_p += w; |
w = len; /* but pretend copied all */ |
} |
else if (fp->_p > fp->_bf._base && len > w) |
{ |
/* fill and flush */ |
COPY (w); |
/* fp->_w -= w; *//* unneeded */ |
fp->_p += w; |
if (_fflush_r (ptr, fp)) |
goto err; |
} |
else if (len >= (w = fp->_bf._size)) |
{ |
/* write directly */ |
w = fp->_write (ptr, fp->_cookie, p, w); |
if (w <= 0) |
goto err; |
} |
else |
{ |
/* fill and done */ |
w = len; |
COPY (w); |
fp->_w -= w; |
fp->_p += w; |
} |
p += w; |
len -= w; |
} |
while ((uio->uio_resid -= w) != 0); |
} |
else |
{ |
/* |
* Line buffered: like fully buffered, but we |
* must check for newlines. Compute the distance |
* to the first newline (including the newline), |
* or `infinity' if there is none, then pretend |
* that the amount to write is MIN(len,nldist). |
*/ |
nlknown = 0; |
nldist = 0; |
do |
{ |
GETIOV (nlknown = 0); |
if (!nlknown) |
{ |
nl = memchr ((_PTR) p, '\n', len); |
nldist = nl ? nl + 1 - p : len + 1; |
nlknown = 1; |
} |
s = MIN (len, nldist); |
w = fp->_w + fp->_bf._size; |
if (fp->_p > fp->_bf._base && s > w) |
{ |
COPY (w); |
/* fp->_w -= w; */ |
fp->_p += w; |
if (_fflush_r (ptr, fp)) |
goto err; |
} |
else if (s >= (w = fp->_bf._size)) |
{ |
w = fp->_write (ptr, fp->_cookie, p, w); |
if (w <= 0) |
goto err; |
} |
else |
{ |
w = s; |
COPY (w); |
fp->_w -= w; |
fp->_p += w; |
} |
if ((nldist -= w) == 0) |
{ |
/* copied the newline: flush and forget */ |
if (_fflush_r (ptr, fp)) |
goto err; |
nlknown = 0; |
} |
p += w; |
len -= w; |
} |
while ((uio->uio_resid -= w) != 0); |
} |
return 0; |
err: |
fp->_flags |= __SERR; |
return EOF; |
} |
/programs/develop/libraries/newlib/stdio/fvwrite.h |
---|
0,0 → 1,36 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* %W% (Berkeley) %G% */ |
#include <_ansi.h> |
/* |
* I/O descriptors for __sfvwrite_r(). |
*/ |
struct __siov { |
_CONST _PTR iov_base; |
size_t iov_len; |
}; |
struct __suio { |
struct __siov *uio_iov; |
int uio_iovcnt; |
int uio_resid; |
}; |
extern int _EXFUN(__sfvwrite_r,(struct _reent *, FILE *, struct __suio *)); |
extern int _EXFUN(__swsetup_r,(struct _reent *, FILE *)); |
/programs/develop/libraries/newlib/stdio/fwalk.c |
---|
0,0 → 1,108 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <errno.h> |
#include "local.h" |
static int |
_DEFUN(__fwalk, (ptr, function), |
struct _reent *ptr _AND |
register int (*function) (FILE *)) |
{ |
register FILE *fp; |
register int n, ret = 0; |
register struct _glue *g; |
for (g = &ptr->__sglue; g != NULL; g = g->_next) |
for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++) |
if (fp->_flags != 0) |
{ |
if (fp->_flags != 0 && fp->_file != -1) |
ret |= (*function) (fp); |
} |
return ret; |
} |
/* Special version of __fwalk where the function pointer is a reentrant |
I/O function (e.g. _fclose_r). */ |
static int |
_DEFUN(__fwalk_reent, (ptr, reent_function), |
struct _reent *ptr _AND |
register int (*reent_function) (struct _reent *, FILE *)) |
{ |
register FILE *fp; |
register int n, ret = 0; |
register struct _glue *g; |
for (g = &ptr->__sglue; g != NULL; g = g->_next) |
for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++) |
if (fp->_flags != 0) |
{ |
if (fp->_flags != 0 && fp->_file != -1) |
ret |= (*reent_function) (ptr, fp); |
} |
return ret; |
} |
int |
_DEFUN(_fwalk, (ptr, function), |
struct _reent *ptr _AND |
register int (*function)(FILE *)) |
{ |
register int ret = 0; |
__sfp_lock_acquire (); |
/* Must traverse given list for streams. Note that _GLOBAL_REENT |
only walked once in exit(). */ |
ret |= __fwalk (ptr, function); |
__sfp_lock_release (); |
return ret; |
} |
/* Special version of _fwalk which handles a function pointer to a |
reentrant I/O function (e.g. _fclose_r). */ |
int |
_DEFUN(_fwalk_reent, (ptr, reent_function), |
struct _reent *ptr _AND |
register int (*reent_function) (struct _reent *, FILE *)) |
{ |
register int ret = 0; |
__sfp_lock_acquire (); |
/* Must traverse given list for streams. Note that _GLOBAL_REENT |
only walked once in exit(). */ |
ret |= __fwalk_reent (ptr, reent_function); |
__sfp_lock_release (); |
return ret; |
} |
/programs/develop/libraries/newlib/stdio/fwrite.c |
---|
0,0 → 1,143 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fwrite>>---write array elements |
INDEX |
fwrite |
INDEX |
_fwrite_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
size_t fwrite(const void *<[buf]>, size_t <[size]>, |
size_t <[count]>, FILE *<[fp]>); |
#include <stdio.h> |
size_t _fwrite_r(struct _reent *<[ptr]>, const void *<[buf]>, size_t <[size]>, |
size_t <[count]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
size_t fwrite(<[buf]>, <[size]>, <[count]>, <[fp]>) |
char *<[buf]>; |
size_t <[size]>; |
size_t <[count]>; |
FILE *<[fp]>; |
#include <stdio.h> |
size_t _fwrite_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>) |
struct _reent *<[ptr]>; |
char *<[buf]>; |
size_t <[size]>; |
size_t <[count]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fwrite>> attempts to copy, starting from the memory location |
<[buf]>, <[count]> elements (each of size <[size]>) into the file or |
stream identified by <[fp]>. <<fwrite>> may copy fewer elements than |
<[count]> if an error intervenes. |
<<fwrite>> also advances the file position indicator (if any) for |
<[fp]> by the number of @emph{characters} actually written. |
<<_fwrite_r>> is simply the reentrant version of <<fwrite>> that |
takes an additional reentrant structure argument: <[ptr]>. |
RETURNS |
If <<fwrite>> succeeds in writing all the elements you specify, the |
result is the same as the argument <[count]>. In any event, the |
result is the number of complete elements that <<fwrite>> copied to |
the file. |
PORTABILITY |
ANSI C requires <<fwrite>>. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#if 0 |
#include <sys/stdc.h> |
#endif |
#include "local.h" |
#if 1 |
#include "fvwrite.h" |
#endif |
/* |
* Write `count' objects (each size `size') from memory to the given file. |
* Return the number of whole objects written. |
*/ |
size_t |
_DEFUN(_fwrite_r, (ptr, buf, size, count, fp), |
struct _reent * ptr _AND |
_CONST _PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
size_t n; |
struct __suio uio; |
struct __siov iov; |
iov.iov_base = buf; |
uio.uio_resid = iov.iov_len = n = count * size; |
uio.uio_iov = &iov; |
uio.uio_iovcnt = 1; |
/* |
* The usual case is success (__sfvwrite_r returns 0); |
* skip the divide if this happens, since divides are |
* generally slow and since this occurs whenever size==0. |
*/ |
CHECK_INIT(ptr, fp); |
_flockfile (fp); |
ORIENT (fp, -1); |
if (__sfvwrite_r (ptr, fp, &uio) == 0) |
{ |
_funlockfile (fp); |
return count; |
} |
_funlockfile (fp); |
return (n - uio.uio_resid) / size; |
} |
#ifndef _REENT_ONLY |
size_t |
_DEFUN(fwrite, (buf, size, count, fp), |
_CONST _PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
return _fwrite_r (_REENT, buf, size, count, fp); |
} |
#endif |
/programs/develop/libraries/newlib/stdio/local.h |
---|
0,0 → 1,227 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
* |
* %W% (UofMD/Berkeley) %G% |
*/ |
/* |
* Information local to this implementation of stdio, |
* in particular, macros and private variables. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdarg.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <stdio.h> |
#ifdef __SCLE |
# include <io.h> |
#endif |
extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); |
extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
extern int _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
extern int _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
extern int _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *, |
va_list) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *, |
va_list) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
va_list)); |
int _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
va_list)); |
extern FILE *_EXFUN(__sfp,(struct _reent *)); |
extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*)); |
extern int _EXFUN(__srefill_r,(struct _reent *,FILE *)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *, |
int)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *, |
char *, int)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *, |
const char *, int)); |
extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int)); |
extern int _EXFUN(__sclose,(struct _reent *, void *)); |
extern int _EXFUN(__stextmode,(int)); |
extern _VOID _EXFUN(__sinit,(struct _reent *)); |
extern _VOID _EXFUN(_cleanup_r,(struct _reent *)); |
extern _VOID _EXFUN(__smakebuf_r,(struct _reent *, FILE *)); |
extern int _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *))); |
extern int _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *))); |
struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n)); |
extern int _EXFUN(__submore, (struct _reent *, FILE *)); |
#ifdef __LARGE64_FILES |
extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *, |
const char *, int)); |
#endif |
/* Called by the main entry point fns to ensure stdio has been initialized. */ |
#ifdef _REENT_SMALL |
#define CHECK_INIT(ptr, fp) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
if ((fp) == (FILE *)&__sf_fake_stdin) \ |
(fp) = _stdin_r(ptr); \ |
else if ((fp) == (FILE *)&__sf_fake_stdout) \ |
(fp) = _stdout_r(ptr); \ |
else if ((fp) == (FILE *)&__sf_fake_stderr) \ |
(fp) = _stderr_r(ptr); \ |
} \ |
while (0) |
#else /* !_REENT_SMALL */ |
#define CHECK_INIT(ptr, fp) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
} \ |
while (0) |
#endif /* !_REENT_SMALL */ |
#define CHECK_STD_INIT(ptr) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
} \ |
while (0) |
/* Return true iff the given FILE cannot be written now. */ |
#define cantwrite(ptr, fp) \ |
((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ |
__swsetup_r(ptr, fp)) |
/* Test whether the given stdio file has an active ungetc buffer; |
release such a buffer, without restoring ordinary unread data. */ |
#define HASUB(fp) ((fp)->_ub._base != NULL) |
#define FREEUB(ptr, fp) { \ |
if ((fp)->_ub._base != (fp)->_ubuf) \ |
_free_r(ptr, (char *)(fp)->_ub._base); \ |
(fp)->_ub._base = NULL; \ |
} |
/* Test for an fgetline() buffer. */ |
#define HASLB(fp) ((fp)->_lb._base != NULL) |
#define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \ |
(fp)->_lb._base = NULL; } |
/* |
* Set the orientation for a stream. If o > 0, the stream has wide- |
* orientation. If o < 0, the stream has byte-orientation. |
*/ |
#define ORIENT(fp,ori) \ |
do \ |
{ \ |
if (!((fp)->_flags & __SORD)) \ |
{ \ |
(fp)->_flags |= __SORD; \ |
if (ori > 0) \ |
(fp)->_flags2 |= __SWID; \ |
else \ |
(fp)->_flags2 &= ~__SWID; \ |
} \ |
} \ |
while (0) |
/* WARNING: _dcvt is defined in the stdlib directory, not here! */ |
char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int)); |
char *_EXFUN(_sicvt,(char *, short, char)); |
char *_EXFUN(_icvt,(char *, int, char)); |
char *_EXFUN(_licvt,(char *, long, char)); |
#ifdef __GNUC__ |
char *_EXFUN(_llicvt,(char *, long long, char)); |
#endif |
#define CVT_BUF_SIZE 128 |
#define NDYNAMIC 4 /* add four more whenever necessary */ |
#ifdef __SINGLE_THREAD__ |
#define __sfp_lock_acquire() |
#define __sfp_lock_release() |
#define __sinit_lock_acquire() |
#define __sinit_lock_release() |
#else |
_VOID _EXFUN(__sfp_lock_acquire,(_VOID)); |
_VOID _EXFUN(__sfp_lock_release,(_VOID)); |
_VOID _EXFUN(__sinit_lock_acquire,(_VOID)); |
_VOID _EXFUN(__sinit_lock_release,(_VOID)); |
#endif |
/* Types used in positional argument support in vfprinf/vfwprintf. |
The implementation is char/wchar_t dependent but the class and state |
tables are only defined once in vfprintf.c. */ |
typedef enum { |
ZERO, /* '0' */ |
DIGIT, /* '1-9' */ |
DOLLAR, /* '$' */ |
MODFR, /* spec modifier */ |
SPEC, /* format specifier */ |
DOT, /* '.' */ |
STAR, /* '*' */ |
FLAG, /* format flag */ |
OTHER, /* all other chars */ |
MAX_CH_CLASS /* place-holder */ |
} __CH_CLASS; |
typedef enum { |
START, /* start */ |
SFLAG, /* seen a flag */ |
WDIG, /* seen digits in width area */ |
WIDTH, /* processed width */ |
SMOD, /* seen spec modifier */ |
SDOT, /* seen dot */ |
VARW, /* have variable width specifier */ |
VARP, /* have variable precision specifier */ |
PREC, /* processed precision */ |
VWDIG, /* have digits in variable width specification */ |
VPDIG, /* have digits in variable precision specification */ |
DONE, /* done */ |
MAX_STATE, /* place-holder */ |
} __STATE; |
typedef enum { |
NOOP, /* do nothing */ |
NUMBER, /* build a number from digits */ |
SKIPNUM, /* skip over digits */ |
GETMOD, /* get and process format modifier */ |
GETARG, /* get and process argument */ |
GETPW, /* get variable precision or width */ |
GETPWB, /* get variable precision or width and pushback fmt char */ |
GETPOS, /* get positional parameter value */ |
PWPOS, /* get positional parameter value for variable width or precision */ |
} __ACTION; |
extern _CONST __CH_CLASS __chclass[256]; |
extern _CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS]; |
extern _CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS]; |
/programs/develop/libraries/newlib/stdio/makebuf.c |
---|
0,0 → 1,113 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <sys/stat.h> |
#include <sys/types.h> |
#include <sys/unistd.h> |
#include "local.h" |
#define _DEFAULT_ASPRINTF_BUFSIZE 64 |
/* |
* Allocate a file buffer, or switch to unbuffered I/O. |
* Per the ANSI C standard, ALL tty devices default to line buffered. |
* |
* As a side effect, we set __SOPT or __SNPT (en/dis-able fseek |
* optimization) right after the _fstat() that finds the buffer size. |
*/ |
_VOID |
_DEFUN(__smakebuf_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE *fp) |
{ |
register size_t size, couldbetty; |
register _PTR p; |
#ifdef __USE_INTERNAL_STAT64 |
struct stat64 st; |
#else |
struct stat st; |
#endif |
if (fp->_flags & __SNBF) |
{ |
fp->_bf._base = fp->_p = fp->_nbuf; |
fp->_bf._size = 1; |
return; |
} |
#ifdef __USE_INTERNAL_STAT64 |
if (fp->_file < 0 || _fstat64_r (ptr, fp->_file, &st) < 0) |
#else |
if (fp->_file < 0 || _fstat_r (ptr, fp->_file, &st) < 0) |
#endif |
{ |
couldbetty = 0; |
/* Check if we are be called by asprintf family for initial buffer. */ |
if (fp->_flags & __SMBF) |
size = _DEFAULT_ASPRINTF_BUFSIZE; |
else |
size = BUFSIZ; |
/* do not try to optimise fseek() */ |
fp->_flags |= __SNPT; |
} |
else |
{ |
couldbetty = (st.st_mode & S_IFMT) == S_IFCHR; |
#ifdef HAVE_BLKSIZE |
size = st.st_blksize <= 0 ? BUFSIZ : st.st_blksize; |
#else |
size = BUFSIZ; |
#endif |
/* |
* Optimize fseek() only if it is a regular file. |
* (The test for __sseek is mainly paranoia.) |
*/ |
if ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek) |
{ |
fp->_flags |= __SOPT; |
#ifdef HAVE_BLKSIZE |
fp->_blksize = st.st_blksize; |
#else |
fp->_blksize = 1024; |
#endif |
} |
else |
fp->_flags |= __SNPT; |
} |
if ((p = _malloc_r (ptr, size)) == NULL) |
{ |
if (!(fp->_flags & __SSTR)) |
{ |
fp->_flags |= __SNBF; |
fp->_bf._base = fp->_p = fp->_nbuf; |
fp->_bf._size = 1; |
} |
} |
else |
{ |
ptr->__cleanup = _cleanup_r; |
fp->_flags |= __SMBF; |
fp->_bf._base = fp->_p = (unsigned char *) p; |
fp->_bf._size = size; |
if (couldbetty && _isatty_r (ptr, fp->_file)) |
fp->_flags |= __SLBF; |
} |
} |
/programs/develop/libraries/newlib/stdio/printf.c |
---|
0,0 → 1,57 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in sprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
#include "local.h" |
int |
_DEFUN(_printf_r, (ptr, fmt), |
struct _reent *ptr _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
_REENT_SMALL_CHECK_INIT (ptr); |
va_start (ap, fmt); |
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap); |
va_end (ap); |
return ret; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(printf, (fmt), |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
struct _reent *ptr = _REENT; |
_REENT_SMALL_CHECK_INIT (ptr); |
va_start (ap, fmt); |
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* ! _REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/putc.c |
---|
0,0 → 1,124 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<putc>>---write a character (macro) |
INDEX |
putc |
INDEX |
_putc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int putc(int <[ch]>, FILE *<[fp]>); |
#include <stdio.h> |
int _putc_r(struct _reent *<[ptr]>, int <[ch]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int putc(<[ch]>, <[fp]>) |
int <[ch]>; |
FILE *<[fp]>; |
#include <stdio.h> |
int _putc_r(<[ptr]>, <[ch]>, <[fp]>) |
struct _reent *<[ptr]>; |
int <[ch]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<putc>> is a macro, defined in <<stdio.h>>. <<putc>> |
writes the argument <[ch]> to the file or stream identified by |
<[fp]>, after converting it from an <<int>> to an <<unsigned char>>. |
If the file was opened with append mode (or if the stream cannot |
support positioning), then the new character goes at the end of the |
file or stream. Otherwise, the new character is written at the |
current value of the position indicator, and the position indicator |
advances by one. |
For a subroutine version of this macro, see <<fputc>>. |
The <<_putc_r>> function is simply the reentrant version of |
<<putc>> that takes an additional reentrant structure argument: <[ptr]>. |
RETURNS |
If successful, <<putc>> returns its argument <[ch]>. If an error |
intervenes, the result is <<EOF>>. You can use `<<ferror(<[fp]>)>>' to |
query for errors. |
PORTABILITY |
ANSI C requires <<putc>>; it suggests, but does not require, that |
<<putc>> be implemented as a macro. The standard explicitly permits |
macro implementations of <<putc>> to use the <[fp]> argument more than once; |
therefore, in a portable program, you should not use an expression |
with side effects as this argument. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <stdio.h> |
#include "local.h" |
/* |
* A subroutine version of the macro putc. |
*/ |
#undef putc |
int |
_DEFUN(_putc_r, (ptr, c, fp), |
struct _reent *ptr _AND |
int c _AND |
register FILE *fp) |
{ |
int result; |
CHECK_INIT (ptr, fp); |
_flockfile (fp); |
result = __sputc_r (ptr, c, fp); |
_funlockfile (fp); |
return result; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(putc, (c, fp), |
int c _AND |
register FILE *fp) |
{ |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
int result; |
CHECK_INIT (_REENT, fp); |
_flockfile (fp); |
result = __sputc_r (_REENT, c, fp); |
_funlockfile (fp); |
return result; |
#else |
return _putc_r (_REENT, c, fp); |
#endif |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/puts.c |
---|
0,0 → 1,106 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<puts>>---write a character string |
INDEX |
puts |
INDEX |
_puts_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int puts(const char *<[s]>); |
int _puts_r(struct _reent *<[reent]>, const char *<[s]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int puts(<[s]>) |
char *<[s]>; |
int _puts_r(<[reent]>, <[s]>) |
struct _reent *<[reent]>; |
char *<[s]>; |
DESCRIPTION |
<<puts>> writes the string at <[s]> (followed by a newline, instead of |
the trailing null) to the standard output stream. |
The alternate function <<_puts_r>> is a reentrant version. The extra |
argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
If successful, the result is a nonnegative integer; otherwise, the |
result is <<EOF>>. |
PORTABILITY |
ANSI C requires <<puts>>, but does not specify that the result on |
success must be <<0>>; any non-negative value is permitted. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <string.h> |
#include "fvwrite.h" |
#include "local.h" |
/* |
* Write the given string to stdout, appending a newline. |
*/ |
int |
_DEFUN(_puts_r, (ptr, s), |
struct _reent *ptr _AND |
_CONST char * s) |
{ |
size_t c = strlen (s); |
struct __suio uio; |
struct __siov iov[2]; |
iov[0].iov_base = s; |
iov[0].iov_len = c; |
iov[1].iov_base = "\n"; |
iov[1].iov_len = 1; |
uio.uio_resid = c + 1; |
uio.uio_iov = &iov[0]; |
uio.uio_iovcnt = 2; |
_REENT_SMALL_CHECK_INIT (ptr); |
ORIENT (stdout, -1); |
return (__sfvwrite_r (ptr, _stdout_r (ptr), &uio) ? EOF : '\n'); |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(puts, (s), |
char _CONST * s) |
{ |
return _puts_r (_REENT, s); |
} |
#endif |
/programs/develop/libraries/newlib/stdio/refill.c |
---|
0,0 → 1,128 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <errno.h> |
#include "local.h" |
static int |
_DEFUN(lflush, (fp), |
FILE *fp) |
{ |
if ((fp->_flags & (__SLBF | __SWR)) == (__SLBF | __SWR)) |
return fflush (fp); |
return 0; |
} |
/* |
* Refill a stdio buffer. |
* Return EOF on eof or error, 0 otherwise. |
*/ |
int |
_DEFUN(__srefill_r, (ptr, fp), |
struct _reent * ptr _AND |
register FILE * fp) |
{ |
/* make sure stdio is set up */ |
CHECK_INIT (ptr, fp); |
ORIENT (fp, -1); |
fp->_r = 0; /* largely a convenience for callers */ |
#ifndef __CYGWIN__ |
/* SysV does not make this test; take it out for compatibility */ |
if (fp->_flags & __SEOF) |
return EOF; |
#endif |
/* if not already reading, have to be reading and writing */ |
if ((fp->_flags & __SRD) == 0) |
{ |
if ((fp->_flags & __SRW) == 0) |
{ |
ptr->_errno = EBADF; |
fp->_flags |= __SERR; |
return EOF; |
} |
/* switch to reading */ |
if (fp->_flags & __SWR) |
{ |
if (_fflush_r (ptr, fp)) |
return EOF; |
fp->_flags &= ~__SWR; |
fp->_w = 0; |
fp->_lbfsize = 0; |
} |
fp->_flags |= __SRD; |
} |
else |
{ |
/* |
* We were reading. If there is an ungetc buffer, |
* we must have been reading from that. Drop it, |
* restoring the previous buffer (if any). If there |
* is anything in that buffer, return. |
*/ |
if (HASUB (fp)) |
{ |
FREEUB (ptr, fp); |
if ((fp->_r = fp->_ur) != 0) |
{ |
fp->_p = fp->_up; |
return 0; |
} |
} |
} |
if (fp->_bf._base == NULL) |
__smakebuf_r (ptr, fp); |
/* |
* Before reading from a line buffered or unbuffered file, |
* flush all line buffered output files, per the ANSI C |
* standard. |
*/ |
if (fp->_flags & (__SLBF | __SNBF)) |
_CAST_VOID _fwalk (_GLOBAL_REENT, lflush); |
fp->_p = fp->_bf._base; |
fp->_r = fp->_read (ptr, fp->_cookie, (char *) fp->_p, fp->_bf._size); |
#ifndef __CYGWIN__ |
if (fp->_r <= 0) |
#else |
if (fp->_r > 0) |
fp->_flags &= ~__SEOF; |
else |
#endif |
{ |
if (fp->_r == 0) |
fp->_flags |= __SEOF; |
else |
{ |
fp->_r = 0; |
fp->_flags |= __SERR; |
} |
return EOF; |
} |
return 0; |
} |
/programs/develop/libraries/newlib/stdio/sccl.c |
---|
0,0 → 1,127 |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* Split from vfscanf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <newlib.h> |
#include <stdio.h> |
#include "local.h" |
/* |
* Fill in the given table from the scanset at the given format |
* (just after `['). Return a pointer to the character past the |
* closing `]'. The table has a 1 wherever characters should be |
* considered part of the scanset. |
*/ |
u_char * |
_DEFUN(__sccl, (tab, fmt), |
register char *tab _AND |
register u_char *fmt) |
{ |
register int c, n, v; |
/* first `clear' the whole table */ |
c = *fmt++; /* first char hat => negated scanset */ |
if (c == '^') |
{ |
v = 1; /* default => accept */ |
c = *fmt++; /* get new first char */ |
} |
else |
v = 0; /* default => reject */ |
/* should probably use memset here */ |
for (n = 0; n < 256; n++) |
tab[n] = v; |
if (c == 0) |
return fmt - 1; /* format ended before closing ] */ |
/* |
* Now set the entries corresponding to the actual scanset to the |
* opposite of the above. |
* |
* The first character may be ']' (or '-') without being special; the |
* last character may be '-'. |
*/ |
v = 1 - v; |
for (;;) |
{ |
tab[c] = v; /* take character c */ |
doswitch: |
n = *fmt++; /* and examine the next */ |
switch (n) |
{ |
case 0: /* format ended too soon */ |
return fmt - 1; |
case '-': |
/* |
* A scanset of the form [01+-] is defined as `the digit 0, the |
* digit 1, the character +, the character -', but the effect of a |
* scanset such as [a-zA-Z0-9] is implementation defined. The V7 |
* Unix scanf treats `a-z' as `the letters a through z', but treats |
* `a-a' as `the letter a, the character -, and the letter a'. |
* |
* For compatibility, the `-' is not considerd to define a range if |
* the character following it is either a close bracket (required by |
* ANSI) or is not numerically greater than the character we just |
* stored in the table (c). |
*/ |
n = *fmt; |
if (n == ']' || n < c) |
{ |
c = '-'; |
break; /* resume the for(;;) */ |
} |
fmt++; |
do |
{ /* fill in the range */ |
tab[++c] = v; |
} |
while (c < n); |
#if 1 /* XXX another disgusting compatibility hack */ |
/* |
* Alas, the V7 Unix scanf also treats formats such |
* as [a-c-e] as `the letters a through e'. This too |
* is permitted by the standard.... |
*/ |
goto doswitch; |
#else |
c = *fmt++; |
if (c == 0) |
return fmt - 1; |
if (c == ']') |
return fmt; |
#endif |
break; |
case ']': /* end of scanset */ |
return fmt; |
default: /* just another character */ |
c = n; |
break; |
} |
} |
/* NOTREACHED */ |
} |
/programs/develop/libraries/newlib/stdio/snprintf.c |
---|
0,0 → 1,119 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in sprintf.c */ |
/* This code created by modifying sprintf.c so copyright inherited. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include <limits.h> |
#include <errno.h> |
#include "local.h" |
int |
#ifdef _HAVE_STDC |
_DEFUN(_snprintf_r, (ptr, str, size, fmt), |
struct _reent *ptr _AND |
char *str _AND |
size_t size _AND |
_CONST char *fmt _DOTS) |
#else |
_snprintf_r(ptr, str, size, fmt, va_alist) |
struct _reent *ptr; |
char *str; |
size_t size; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return (ret); |
} |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
_DEFUN(snprintf, (str, size, fmt), |
char *str _AND |
size_t size _AND |
_CONST char *fmt _DOTS) |
#else |
snprintf(str, size, fmt, va_alist) |
char *str; |
size_t size; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
struct _reent *ptr = _REENT; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return (ret); |
} |
#endif |
/programs/develop/libraries/newlib/stdio/sprintf.c |
---|
0,0 → 1,640 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<sprintf>>, <<fprintf>>, <<printf>>, <<snprintf>>, <<asprintf>>, <<asnprintf>>---format output |
INDEX |
fprintf |
INDEX |
_fprintf_r |
INDEX |
printf |
INDEX |
_printf_r |
INDEX |
asprintf |
INDEX |
_asprintf_r |
INDEX |
sprintf |
INDEX |
_sprintf_r |
INDEX |
snprintf |
INDEX |
_snprintf_r |
INDEX |
asnprintf |
INDEX |
_asnprintf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int printf(const char *<[format]>, ...); |
int fprintf(FILE *<[fd]>, const char *<[format]>, ...); |
int sprintf(char *<[str]>, const char *<[format]>, ...); |
int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]>, |
...); |
int asprintf(char **<[strp]>, const char *<[format]>, ...); |
char *asnprintf(char *<[str]>, size_t *<[size]>, const char *<[format]>, |
...); |
int _printf_r(struct _reent *<[ptr]>, const char *<[format]>, ...); |
int _fprintf_r(struct _reent *<[ptr]>, FILE *<[fd]>, |
const char *<[format]>, ...); |
int _sprintf_r(struct _reent *<[ptr]>, char *<[str]>, |
const char *<[format]>, ...); |
int _snprintf_r(struct _reent *<[ptr]>, char *<[str]>, size_t <[size]>, |
const char *<[format]>, ...); |
int _asprintf_r(struct _reent *<[ptr]>, char **<[strp]>, |
const char *<[format]>, ...); |
char *_asnprintf_r(struct _reent *<[ptr]>, char *<[str]>, |
size_t *<[size]>, const char *<[format]>, ...); |
DESCRIPTION |
<<printf>> accepts a series of arguments, applies to each a |
format specifier from <<*<[format]>>>, and writes the |
formatted data to <<stdout>>, without a terminating NUL |
character. The behavior of <<printf>> is undefined if there |
are not enough arguments for the format. <<printf>> returns |
when it reaches the end of the format string. If there are |
more arguments than the format requires, excess arguments are |
ignored. |
<<fprintf>> is like <<printf>>, except that output is directed |
to the stream <[fd]> rather than <<stdout>>. |
<<sprintf>> is like <<printf>>, except that output is directed |
to the buffer <[str]>, and a terminating NUL is output. |
Behavior is undefined if more output is generated than the |
buffer can hold. |
<<snprintf>> is like <<sprintf>>, except that output is |
limited to at most <[size]> bytes, including the terminating |
<<NUL>>. As a special case, if <[size]> is 0, <[str]> can be |
NULL, and <<snprintf>> merely calculates how many bytes would |
be printed. |
<<asprintf>> is like <<sprintf>>, except that the output is |
stored in a dynamically allocated buffer, <[pstr]>, which |
should be freed later with <<free>>. |
<<asnprintf>> is like <<sprintf>>, except that the return type |
is either the original <[str]> if it was large enough, or a |
dynamically allocated string if the output exceeds *<[size]>; |
the length of the result is returned in *<[size]>. When |
dynamic allocation occurs, the contents of the original |
<[str]> may have been modified. |
For <<sprintf>>, <<snprintf>>, and <<asnprintf>>, the behavior |
is undefined if the output <<*<[str]>>> overlaps with one of |
the arguments. Behavior is also undefined if the argument for |
<<%n>> within <<*<[format]>>> overlaps another argument. |
<[format]> is a pointer to a character string containing two |
types of objects: ordinary characters (other than <<%>>), |
which are copied unchanged to the output, and conversion |
specifications, each of which is introduced by <<%>>. (To |
include <<%>> in the output, use <<%%>> in the format string.) |
A conversion specification has the following form: |
. %[<[pos]>][<[flags]>][<[width]>][.<[prec]>][<[size]>]<[type]> |
The fields of the conversion specification have the following |
meanings: |
O+ |
o <[pos]> |
Conversions normally consume arguments in the order that they |
are presented. However, it is possible to consume arguments |
out of order, and reuse an argument for more than one |
conversion specification (although the behavior is undefined |
if the same argument is requested with different types), by |
specifying <[pos]>, which is a decimal integer followed by |
'$'. The integer must be between 1 and <NL_ARGMAX> from |
limits.h, and if argument <<%n$>> is requested, all earlier |
arguments must be requested somewhere within <[format]>. If |
positional parameters are used, then all conversion |
specifications except for <<%%>> must specify a position. |
This positional parameters method is a POSIX extension to the C |
standard definition for the functions. |
o <[flags]> |
<[flags]> is an optional sequence of characters which control |
output justification, numeric signs, decimal points, trailing |
zeros, and octal and hex prefixes. The flag characters are |
minus (<<->>), plus (<<+>>), space ( ), zero (<<0>>), sharp |
(<<#>>), and quote (<<'>>). They can appear in any |
combination, although not all flags can be used for all |
conversion specification types. |
o+ |
o ' |
A POSIX extension to the C standard. However, this |
implementation presently treats it as a no-op, which |
is the default behavior for the C locale, anyway. (If |
it did what it is supposed to, when <[type]> were <<i>>, |
<<d>>, <<u>>, <<f>>, <<F>>, <<g>>, or <<G>>, the |
integer portion of the conversion would be formatted |
with thousands' grouping wide characters.) |
o - |
The result of the conversion is left |
justified, and the right is padded with |
blanks. If you do not use this flag, the |
result is right justified, and padded on the |
left. |
o + |
The result of a signed conversion (as |
determined by <[type]> of <<d>>, <<i>>, <<a>>, |
<<A>>, <<e>>, <<E>>, <<f>>, <<F>>, <<g>>, or |
<<G>>) will always begin with a plus or minus |
sign. (If you do not use this flag, positive |
values do not begin with a plus sign.) |
o " " (space) |
If the first character of a signed conversion |
specification is not a sign, or if a signed |
conversion results in no characters, the |
result will begin with a space. If the space |
( ) flag and the plus (<<+>>) flag both |
appear, the space flag is ignored. |
o 0 |
If the <[type]> character is <<d>>, <<i>>, |
<<o>>, <<u>>, <<x>>, <<X>>, <<a>>, <<A>>, |
<<e>>, <<E>>, <<f>>, <<F>>, <<g>>, or <<G>>: leading |
zeros are used to pad the field width |
(following any indication of sign or base); no |
spaces are used for padding. If the zero |
(<<0>>) and minus (<<->>) flags both appear, |
the zero (<<0>>) flag will be ignored. For |
<<d>>, <<i>>, <<o>>, <<u>>, <<x>>, and <<X>> |
conversions, if a precision <[prec]> is |
specified, the zero (<<0>>) flag is ignored. |
Note that <<0>> is interpreted as a flag, not |
as the beginning of a field width. |
o # |
The result is to be converted to an |
alternative form, according to the <[type]> |
character: |
o+ |
o o |
Increases precision to force the first |
digit of the result to be a zero. |
o x |
A non-zero result will have a <<0x>> |
prefix. |
o X |
A non-zero result will have a <<0X>> |
prefix. |
o a, A, e, E, f, or F |
The result will always contain a |
decimal point even if no digits follow |
the point. (Normally, a decimal point |
appears only if a digit follows it.) |
Trailing zeros are removed. |
o g or G |
The result will always contain a |
decimal point even if no digits follow |
the point. Trailing zeros are not |
removed. |
o all others |
Undefined. |
o- |
o- |
o <[width]> |
<[width]> is an optional minimum field width. You can |
either specify it directly as a decimal integer, or |
indirectly by using instead an asterisk (<<*>>), in |
which case an <<int>> argument is used as the field |
width. If positional arguments are used, then the |
width must also be specified positionally as <<*m$>>, |
with m as a decimal integer. Negative field widths |
are treated as specifying the minus (<<->>) flag for |
left justfication, along with a positive field width. |
The resulting format may be wider than the specified |
width. |
o <[prec]> |
<[prec]> is an optional field; if present, it is |
introduced with `<<.>>' (a period). You can specify |
the precision either directly as a decimal integer or |
indirectly by using an asterisk (<<*>>), in which case |
an <<int>> argument is used as the precision. If |
positional arguments are used, then the precision must |
also be specified positionally as <<*m$>>, with m as a |
decimal integer. Supplying a negative precision is |
equivalent to omitting the precision. If only a |
period is specified the precision is zero. The effect |
depends on the conversion <[type]>. |
o+ |
o d, i, o, u, x, or X |
Minimum number of digits to appear. If no |
precision is given, defaults to 1. |
o a or A |
Number of digits to appear after the decimal |
point. If no precision is given, the |
precision defaults to the minimum needed for |
an exact representation. |
o e, E, f or F |
Number of digits to appear after the decimal |
point. If no precision is given, the |
precision defaults to 6. |
o g or G |
Maximum number of significant digits. A |
precision of 0 is treated the same as a |
precision of 1. If no precision is given, the |
precision defaults to 6. |
o s or S |
Maximum number of characters to print from the |
string. If no precision is given, the entire |
string is printed. |
o all others |
undefined. |
o- |
o <[size]> |
<[size]> is an optional modifier that changes the data |
type that the corresponding argument has. Behavior is |
unspecified if a size is given that does not match the |
<[type]>. |
o+ |
o hh |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument should be |
converted to a <<signed char>> or <<unsigned |
char>> before printing. |
With <<n>>, specifies that the argument is a |
pointer to a <<signed char>>. |
o h |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument should be |
converted to a <<short>> or <<unsigned short>> |
before printing. |
With <<n>>, specifies that the argument is a |
pointer to a <<short>>. |
o l |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a |
<<long>> or <<unsigned long>>. |
With <<c>>, specifies that the argument has |
type <<wint_t>>. |
With <<s>>, specifies that the argument is a |
pointer to <<wchar_t>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<long>>. |
With <<a>>, <<A>>, <<e>>, <<E>>, <<f>>, <<F>>, |
<<g>>, or <<G>>, has no effect (because of |
vararg promotion rules, there is no need to |
distinguish between <<float>> and <<double>>). |
o ll |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a |
<<long long>> or <<unsigned long long>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<long long>>. |
o j |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is an |
<<intmax_t>> or <<uintmax_t>>. |
With <<n>>, specifies that the argument is a |
pointer to an <<intmax_t>>. |
o z |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a <<size_t>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<size_t>>. |
o t |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a |
<<ptrdiff_t>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<ptrdiff_t>>. |
o L |
With <<a>>, <<A>>, <<e>>, <<E>>, <<f>>, <<F>>, |
<<g>>, or <<G>>, specifies that the argument |
is a <<long double>>. |
o- |
o <[type]> |
<[type]> specifies what kind of conversion <<printf>> |
performs. Here is a table of these: |
o+ |
o % |
Prints the percent character (<<%>>). |
o c |
Prints <[arg]> as single character. If the |
<<l>> size specifier is in effect, a multibyte |
character is printed. |
o C |
Short for <<%lc>>. A POSIX extension to the C standard. |
o s |
Prints the elements of a pointer to <<char>> |
until the precision or a null character is |
reached. If the <<l>> size specifier is in |
effect, the pointer is to an array of |
<<wchar_t>>, and the string is converted to |
multibyte characters before printing. |
o S |
Short for <<%ls>>. A POSIX extension to the C standard. |
o d or i |
Prints a signed decimal integer; takes an |
<<int>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o D |
Newlib extension, short for <<%ld>>. |
o o |
Prints an unsigned octal integer; takes an |
<<unsigned>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o O |
Newlib extension, short for <<%lo>>. |
o u |
Prints an unsigned decimal integer; takes an |
<<unsigned>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o U |
Newlib extension, short for <<%lu>>. |
o x |
Prints an unsigned hexadecimal integer (using |
<<abcdef>> as digits beyond <<9>>); takes an |
<<unsigned>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o X |
Like <<x>>, but uses <<ABCDEF>> as digits |
beyond <<9>>. |
o f |
Prints a signed value of the form |
<<[-]9999.9999>>, with the precision |
determining how many digits follow the decimal |
point; takes a <<double>> (remember that |
<<float>> promotes to <<double>> as a vararg). |
The low order digit is rounded to even. If |
the precision results in at most DECIMAL_DIG |
digits, the result is rounded correctly; if |
more than DECIMAL_DIG digits are printed, the |
result is only guaranteed to round back to the |
original value. |
If the value is infinite, the result is |
<<inf>>, and no zero padding is performed. If |
the value is not a number, the result is |
<<nan>>, and no zero padding is performed. |
o F |
Like <<f>>, but uses <<INF>> and <<NAN>> for |
non-finite numbers. |
o e |
Prints a signed value of the form |
<<[-]9.9999e[+|-]999>>; takes a <<double>>. |
The digit before the decimal point is non-zero |
if the value is non-zero. The precision |
determines how many digits appear between |
<<.>> and <<e>>, and the exponent always |
contains at least two digits. The value zero |
has an exponent of zero. If the value is not |
finite, it is printed like <<f>>. |
o E |
Like <<e>>, but using <<E>> to introduce the |
exponent, and like <<F>> for non-finite |
values. |
o g |
Prints a signed value in either <<f>> or <<e>> |
form, based on the given value and |
precision---an exponent less than -4 or |
greater than the precision selects the <<e>> |
form. Trailing zeros and the decimal point |
are printed only if necessary; takes a |
<<double>>. |
o G |
Like <<g>>, except use <<F>> or <<E>> form. |
o a |
Prints a signed value of the form |
<<[-]0x1.ffffp[+|-]9>>; takes a <<double>>. |
The letters <<abcdef>> are used for digits |
beyond <<9>>. The precision determines how |
many digits appear after the decimal point. |
The exponent contains at least one digit, and |
is a decimal value representing the power of |
2; a value of 0 has an exponent of 0. |
Non-finite values are printed like <<f>>. |
o A |
Like <<a>>, except uses <<X>>, <<P>>, and |
<<ABCDEF>> instead of lower case. |
o n |
Takes a pointer to <<int>>, and stores a count |
of the number of bytes written so far. No |
output is created. |
o p |
Takes a pointer to <<void>>, and prints it in |
an implementation-defined format. This |
implementation is similar to <<%#tx>>), except |
that <<0x>> appears even for the NULL pointer. |
o- |
O- |
<<_printf_r>>, <<_fprintf_r>>, <<_asprintf_r>>, |
<<_sprintf_r>>, <<_snprintf_r>>, <<_asnprintf_r>> are simply |
reentrant versions of the functions above. |
RETURNS |
On success, <<sprintf>> and <<asprintf>> return the number of bytes in |
the output string, except the concluding <<NUL>> is not counted. |
<<snprintf>> returns the number of bytes that would be in the output |
string, except the concluding <<NUL>> is not counted. <<printf>> and |
<<fprintf>> return the number of characters transmitted. |
<<asnprintf>> returns the original <[str]> if there was enough room, |
otherwise it returns an allocated string. |
If an error occurs, the result of <<printf>>, <<fprintf>>, |
<<snprintf>>, and <<asprintf>> is a negative value, and the result of |
<<asnprintf>> is NULL. No error returns occur for <<sprintf>>. For |
<<printf>> and <<fprintf>>, <<errno>> may be set according to |
<<fputc>>. For <<asprintf>> and <<asnprintf>>, <<errno>> may be set |
to ENOMEM if allocation fails, and for <<snprintf>>, <<errno>> may be |
set to EOVERFLOW if <[size]> or the output length exceeds INT_MAX. |
BUGS |
The ``''' (quote) flag does not work when locale's thousands_sep is not empty. |
PORTABILITY |
ANSI C requires <<printf>>, <<fprintf>>, <<sprintf>>, and |
<<snprintf>>. <<asprintf>> and <<asnprintf>> are newlib extensions. |
The ANSI C standard specifies that implementations must support at |
least formatted output of up to 509 characters. This implementation |
has no inherent limit. |
Depending on how newlib was configured, not all format specifiers are |
supported. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include <limits.h> |
#include "local.h" |
int |
#ifdef _HAVE_STDC |
_DEFUN(_sprintf_r, (ptr, str, fmt), |
struct _reent *ptr _AND |
char *str _AND |
_CONST char *fmt _DOTS) |
#else |
_sprintf_r(ptr, str, fmt, va_alist) |
struct _reent *ptr; |
char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
*f._p = '\0'; /* terminate the string */ |
return (ret); |
} |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
_DEFUN(sprintf, (str, fmt), |
char *str _AND |
_CONST char *fmt _DOTS) |
#else |
sprintf(str, fmt, va_alist) |
char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (_REENT, &f, fmt, ap); |
va_end (ap); |
*f._p = '\0'; /* terminate the string */ |
return (ret); |
} |
#endif |
/programs/develop/libraries/newlib/stdio/sscanf.c |
---|
0,0 → 1,469 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<sscanf>>, <<fscanf>>, <<scanf>>---scan and format input |
INDEX |
scanf |
INDEX |
_scanf_r |
INDEX |
fscanf |
INDEX |
_fscanf_r |
INDEX |
sscanf |
INDEX |
_sscanf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int scanf(const char *<[format]>, ...); |
int fscanf(FILE *<[fd]>, const char *<[format]>, ...); |
int sscanf(const char *<[str]>, const char *<[format]>, ...); |
int _scanf_r(struct _reent *<[ptr]>, const char *<[format]>, ...); |
int _fscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, |
const char *<[format]>, ...); |
int _sscanf_r(struct _reent *<[ptr]>, const char *<[str]>, |
const char *<[format]>, ...); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int scanf(<[format]> [, <[arg]>, ...]) |
char *<[format]>; |
int fscanf(<[fd]>, <[format]> [, <[arg]>, ...]); |
FILE *<[fd]>; |
char *<[format]>; |
int sscanf(<[str]>, <[format]> [, <[arg]>, ...]); |
char *<[str]>; |
char *<[format]>; |
int _scanf_r(<[ptr]>, <[format]> [, <[arg]>, ...]) |
struct _reent *<[ptr]>; |
char *<[format]>; |
int _fscanf_r(<[ptr]>, <[fd]>, <[format]> [, <[arg]>, ...]); |
struct _reent *<[ptr]>; |
FILE *<[fd]>; |
char *<[format]>; |
int _sscanf_r(<[ptr]>, <[str]>, <[format]> [, <[arg]>, ...]); |
struct _reent *<[ptr]>; |
char *<[str]>; |
char *<[format]>; |
DESCRIPTION |
<<scanf>> scans a series of input fields from standard input, |
one character at a time. Each field is interpreted according to |
a format specifier passed to <<scanf>> in the format string at |
<<*<[format]>>>. <<scanf>> stores the interpreted input from |
each field at the address passed to it as the corresponding argument |
following <[format]>. You must supply the same number of |
format specifiers and address arguments as there are input fields. |
There must be sufficient address arguments for the given format |
specifiers; if not the results are unpredictable and likely |
disasterous. Excess address arguments are merely ignored. |
<<scanf>> often produces unexpected results if the input diverges from |
an expected pattern. Since the combination of <<gets>> or <<fgets>> |
followed by <<sscanf>> is safe and easy, that is the preferred way |
to be certain that a program is synchronized with input at the end |
of a line. |
<<fscanf>> and <<sscanf>> are identical to <<scanf>>, other than the |
source of input: <<fscanf>> reads from a file, and <<sscanf>> |
from a string. |
The routines <<_scanf_r>>, <<_fscanf_r>>, and <<_sscanf_r>> are reentrant |
versions of <<scanf>>, <<fscanf>>, and <<sscanf>> that take an additional |
first argument pointing to a reentrancy structure. |
The string at <<*<[format]>>> is a character sequence composed |
of zero or more directives. Directives are composed of |
one or more whitespace characters, non-whitespace characters, |
and format specifications. |
Whitespace characters are blank (<< >>), tab (<<\t>>), or |
newline (<<\n>>). |
When <<scanf>> encounters a whitespace character in the format string |
it will read (but not store) all consecutive whitespace characters |
up to the next non-whitespace character in the input. |
Non-whitespace characters are all other ASCII characters except the |
percent sign (<<%>>). When <<scanf>> encounters a non-whitespace |
character in the format string it will read, but not store |
a matching non-whitespace character. |
Format specifications tell <<scanf>> to read and convert characters |
from the input field into specific types of values, and store then |
in the locations specified by the address arguments. |
Trailing whitespace is left unread unless explicitly |
matched in the format string. |
The format specifiers must begin with a percent sign (<<%>>) |
and have the following form: |
. %[*][<[width]>][<[size]>]<[type]> |
Each format specification begins with the percent character (<<%>>). |
The other fields are: |
o+ |
o * |
an optional marker; if present, it suppresses interpretation and |
assignment of this input field. |
o <[width]> |
an optional maximum field width: a decimal integer, |
which controls the maximum number of characters that |
will be read before converting the current input field. If the |
input field has fewer than <[width]> characters, <<scanf>> |
reads all the characters in the field, and then |
proceeds with the next field and its format specification. |
If a whitespace or a non-convertable character occurs |
before <[width]> character are read, the characters up |
to that character are read, converted, and stored. |
Then <<scanf>> proceeds to the next format specification. |
o size |
<<h>>, <<j>>, <<l>>, <<L>>, <<t>>, and <<z>> are optional size |
characters which override the default way that <<scanf>> |
interprets the data type of the corresponding argument. |
.Modifier Type(s) |
. hh d, i, o, u, x, n convert input to char, |
. store in char object |
. |
. h d, i, o, u, x, n convert input to short, |
. store in short object |
. |
. h D, I, O, U, X no effect |
. e, f, c, s, p |
. |
. j d, i, o, u, x, n convert input to intmax_t, |
. store in intmax_t object |
. |
. j all others no effect |
. |
. l d, i, o, u, x, n convert input to long, |
. store in long object |
. |
. l e, f, g convert input to double |
. store in a double object |
. |
. l D, I, O, U, X no effect |
. c, s, p |
. |
. ll d, i, o, u, x, n convert to long long, |
. store in long long |
. |
. L d, i, o, u, x, n convert to long long, |
. store in long long |
. |
. L e, f, g, E, G convert to long double, |
. store in long double |
. |
. L all others no effect |
. |
. t d, i, o, u, x, n convert input to ptrdiff_t, |
. store in ptrdiff_t object |
. |
. t all others no effect |
. |
. z d, i, o, u, x, n convert input to size_t, |
. store in size_t object |
. |
. z all others no effect |
. |
o <[type]> |
A character to specify what kind of conversion |
<<scanf>> performs. Here is a table of the conversion |
characters: |
o+ |
o % |
No conversion is done; the percent character (<<%>>) is stored. |
o c |
Scans one character. Corresponding <[arg]>: <<(char *arg)>>. |
o s |
Reads a character string into the array supplied. |
Corresponding <[arg]>: <<(char arg[])>>. |
o [<[pattern]>] |
Reads a non-empty character string into memory |
starting at <[arg]>. This area must be large |
enough to accept the sequence and a |
terminating null character which will be added |
automatically. (<[pattern]> is discussed in the paragraph following |
this table). Corresponding <[arg]>: <<(char *arg)>>. |
o d |
Reads a decimal integer into the corresponding <[arg]>: <<(int *arg)>>. |
o D |
Reads a decimal integer into the corresponding |
<[arg]>: <<(long *arg)>>. |
o o |
Reads an octal integer into the corresponding <[arg]>: <<(int *arg)>>. |
o O |
Reads an octal integer into the corresponding <[arg]>: <<(long *arg)>>. |
o u |
Reads an unsigned decimal integer into the corresponding |
<[arg]>: <<(unsigned int *arg)>>. |
o U |
Reads an unsigned decimal integer into the corresponding <[arg]>: |
<<(unsigned long *arg)>>. |
o x,X |
Read a hexadecimal integer into the corresponding <[arg]>: |
<<(int *arg)>>. |
o e, f, g |
Read a floating-point number into the corresponding <[arg]>: |
<<(float *arg)>>. |
o E, F, G |
Read a floating-point number into the corresponding <[arg]>: |
<<(double *arg)>>. |
o i |
Reads a decimal, octal or hexadecimal integer into the |
corresponding <[arg]>: <<(int *arg)>>. |
o I |
Reads a decimal, octal or hexadecimal integer into the |
corresponding <[arg]>: <<(long *arg)>>. |
o n |
Stores the number of characters read in the corresponding |
<[arg]>: <<(int *arg)>>. |
o p |
Stores a scanned pointer. ANSI C leaves the details |
to each implementation; this implementation treats |
<<%p>> exactly the same as <<%U>>. Corresponding |
<[arg]>: <<(void **arg)>>. |
o- |
A <[pattern]> of characters surrounded by square brackets can be used |
instead of the <<s>> type character. <[pattern]> is a set of |
characters which define a search set of possible characters making up |
the <<scanf>> input field. If the first character in the brackets is a |
caret (<<^>>), the search set is inverted to include all ASCII characters |
except those between the brackets. There is also a range facility |
which you can use as a shortcut. <<%[0-9] >> matches all decimal digits. |
The hyphen must not be the first or last character in the set. |
The character prior to the hyphen must be lexically less than the |
character after it. |
Here are some <[pattern]> examples: |
o+ |
o %[abcd] |
matches strings containing only <<a>>, <<b>>, <<c>>, and <<d>>. |
o %[^abcd] |
matches strings containing any characters except <<a>>, <<b>>, |
<<c>>, or <<d>> |
o %[A-DW-Z] |
matches strings containing <<A>>, <<B>>, <<C>>, <<D>>, <<W>>, |
<<X>>, <<Y>>, <<Z>> |
o %[z-a] |
matches the characters <<z>>, <<->>, and <<a>> |
o- |
Floating point numbers (for field types <<e>>, <<f>>, <<g>>, <<E>>, |
<<F>>, <<G>>) must correspond to the following general form: |
. [+/-] ddddd[.]ddd [E|e[+|-]ddd] |
where objects inclosed in square brackets are optional, and <<ddd>> |
represents decimal, octal, or hexadecimal digits. |
o- |
RETURNS |
<<scanf>> returns the number of input fields successfully |
scanned, converted and stored; the return value does |
not include scanned fields which were not stored. |
If <<scanf>> attempts to read at end-of-file, the return |
value is <<EOF>>. |
If no fields were stored, the return value is <<0>>. |
<<scanf>> might stop scanning a particular field before |
reaching the normal field end character, or may |
terminate entirely. |
<<scanf>> stops scanning and storing the current field |
and moves to the next input field (if any) |
in any of the following situations: |
O+ |
o The assignment suppressing character (<<*>>) appears |
after the <<%>> in the format specification; the current |
input field is scanned but not stored. |
o <[width]> characters have been read (<[width]> is a |
width specification, a positive decimal integer). |
o The next character read cannot be converted |
under the the current format (for example, |
if a <<Z>> is read when the format is decimal). |
o The next character in the input field does not appear |
in the search set (or does appear in the inverted search set). |
O- |
When <<scanf>> stops scanning the current input field for one of |
these reasons, the next character is considered unread and |
used as the first character of the following input field, or the |
first character in a subsequent read operation on the input. |
<<scanf>> will terminate under the following circumstances: |
O+ |
o The next character in the input field conflicts |
with a corresponding non-whitespace character in the |
format string. |
o The next character in the input field is <<EOF>>. |
o The format string has been exhausted. |
O- |
When the format string contains a character sequence that is |
not part of a format specification, the same character |
sequence must appear in the input; <<scanf>> will |
scan but not store the matched characters. If a |
conflict occurs, the first conflicting character remains in the input |
as if it had never been read. |
PORTABILITY |
<<scanf>> is ANSI C. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <string.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include "local.h" |
#ifndef _REENT_ONLY |
#ifdef _HAVE_STDC |
int |
_DEFUN(sscanf, (str, fmt), |
_CONST char *str _AND |
_CONST char *fmt _DOTS) |
#else |
int |
sscanf(str, fmt, va_alist) |
_CONST char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SRD | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._r = strlen (str); |
f._read = __seofread; |
f._ub._base = NULL; |
f._lb._base = NULL; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = __ssvfscanf_r (_REENT, &f, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* !_REENT_ONLY */ |
#ifdef _HAVE_STDC |
int |
_DEFUN(_sscanf_r, (ptr, str, fmt), |
struct _reent *ptr _AND |
_CONST char *str _AND |
_CONST char *fmt _DOTS) |
#else |
int |
_sscanf_r(ptr, str, fmt, va_alist) |
struct _reent *ptr; |
_CONST char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SRD | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._r = strlen (str); |
f._read = __seofread; |
f._ub._base = NULL; |
f._lb._base = NULL; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = __ssvfscanf_r (ptr, &f, fmt, ap); |
va_end (ap); |
return ret; |
} |
/programs/develop/libraries/newlib/stdio/stdio.c |
---|
0,0 → 1,150 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <fcntl.h> |
#include <sys/unistd.h> |
#include "local.h" |
/* |
* Small standard I/O/seek/close functions. |
* These maintain the `known seek offset' for seek optimisation. |
*/ |
_READ_WRITE_RETURN_TYPE |
_DEFUN(__sread, (ptr, cookie, buf, n), |
struct _reent *ptr _AND |
void *cookie _AND |
char *buf _AND |
int n) |
{ |
register FILE *fp = (FILE *) cookie; |
register int ret; |
#ifdef __SCLE |
int oldmode = 0; |
if (fp->_flags & __SCLE) |
oldmode = setmode (fp->_file, O_BINARY); |
#endif |
ret = _read_r (ptr, fp->_file, buf, n); |
#ifdef __SCLE |
if (oldmode) |
setmode (fp->_file, oldmode); |
#endif |
/* If the read succeeded, update the current offset. */ |
if (ret >= 0) |
fp->_offset += ret; |
else |
fp->_flags &= ~__SOFF; /* paranoia */ |
return ret; |
} |
/* Dummy function used in sscanf/swscanf. */ |
_READ_WRITE_RETURN_TYPE |
_DEFUN(__seofread, (ptr, cookie, buf, len), |
struct _reent *_ptr _AND |
_PTR cookie _AND |
char *buf _AND |
int len) |
{ |
return 0; |
} |
_READ_WRITE_RETURN_TYPE |
_DEFUN(__swrite, (ptr, cookie, buf, n), |
struct _reent *ptr _AND |
void *cookie _AND |
char const *buf _AND |
int n) |
{ |
register FILE *fp = (FILE *) cookie; |
int w; |
#ifdef __SCLE |
int oldmode=0; |
#endif |
if (fp->_flags & __SAPP) |
_lseek_r (ptr, fp->_file, (_off_t) 0, SEEK_END); |
fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */ |
#ifdef __SCLE |
if (fp->_flags & __SCLE) |
oldmode = setmode (fp->_file, O_BINARY); |
#endif |
w = _write_r (ptr, fp->_file, buf, n); |
#ifdef __SCLE |
if (oldmode) |
setmode (fp->_file, oldmode); |
#endif |
return w; |
} |
_fpos_t |
_DEFUN(__sseek, (ptr, cookie, offset, whence), |
struct _reent *ptr _AND |
void *cookie _AND |
_fpos_t offset _AND |
int whence) |
{ |
register FILE *fp = (FILE *) cookie; |
register _off_t ret; |
ret = _lseek_r (ptr, fp->_file, (_off_t) offset, whence); |
if (ret == -1L) |
fp->_flags &= ~__SOFF; |
else |
{ |
fp->_flags |= __SOFF; |
fp->_offset = ret; |
} |
return ret; |
} |
int |
_DEFUN(__sclose, (ptr, cookie), |
struct _reent *ptr _AND |
void *cookie) |
{ |
FILE *fp = (FILE *) cookie; |
return _close_r (ptr, fp->_file); |
} |
#ifdef __SCLE |
int |
_DEFUN(__stextmode, (fd), |
int fd) |
{ |
#ifdef __CYGWIN__ |
extern int _cygwin_istext_for_stdio (int); |
return _cygwin_istext_for_stdio (fd); |
#else |
return 0; |
#endif |
} |
#endif |
/programs/develop/libraries/newlib/stdio/ungetc.c |
---|
0,0 → 1,217 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<ungetc>>---push data back into a stream |
INDEX |
ungetc |
INDEX |
_ungetc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int ungetc(int <[c]>, FILE *<[stream]>); |
int _ungetc_r(struct _reent *<[reent]>, int <[c]>, FILE *<[stream]>); |
DESCRIPTION |
<<ungetc>> is used to return bytes back to <[stream]> to be read again. |
If <[c]> is EOF, the stream is unchanged. Otherwise, the unsigned |
char <[c]> is put back on the stream, and subsequent reads will see |
the bytes pushed back in reverse order. Pushed byes are lost if the |
stream is repositioned, such as by <<fseek>>, <<fsetpos>>, or |
<<rewind>>. |
The underlying file is not changed, but it is possible to push back |
something different than what was originally read. Ungetting a |
character will clear the end-of-stream marker, and decrement the file |
position indicator. Pushing back beyond the beginning of a file gives |
unspecified behavior. |
The alternate function <<_ungetc_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
The character pushed back, or <<EOF>> on error. |
PORTABILITY |
ANSI C requires <<ungetc>>, but only requires a pushback buffer of one |
byte; although this implementation can handle multiple bytes, not all |
can. Pushing back a signed char is a common application bug. |
Supporting OS subroutines required: <<sbrk>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include "local.h" |
/* |
* Expand the ungetc buffer `in place'. That is, adjust fp->_p when |
* the buffer moves, so that it points the same distance from the end, |
* and move the bytes in the buffer around as necessary so that they |
* are all at the end (stack-style). |
*/ |
/*static*/ |
int |
_DEFUN(__submore, (rptr, fp), |
struct _reent *rptr _AND |
register FILE *fp) |
{ |
register int i; |
register unsigned char *p; |
if (fp->_ub._base == fp->_ubuf) |
{ |
/* |
* Get a new buffer (rather than expanding the old one). |
*/ |
if ((p = (unsigned char *) _malloc_r (rptr, (size_t) BUFSIZ)) == NULL) |
return EOF; |
fp->_ub._base = p; |
fp->_ub._size = BUFSIZ; |
p += BUFSIZ - sizeof (fp->_ubuf); |
for (i = sizeof (fp->_ubuf); --i >= 0;) |
p[i] = fp->_ubuf[i]; |
fp->_p = p; |
return 0; |
} |
i = fp->_ub._size; |
p = (unsigned char *) _realloc_r (rptr, (_PTR) (fp->_ub._base), i << 1); |
if (p == NULL) |
return EOF; |
_CAST_VOID memcpy ((_PTR) (p + i), (_PTR) p, (size_t) i); |
fp->_p = p + i; |
fp->_ub._base = p; |
fp->_ub._size = i << 1; |
return 0; |
} |
int |
_DEFUN(_ungetc_r, (rptr, c, fp), |
struct _reent *rptr _AND |
int c _AND |
register FILE *fp) |
{ |
if (c == EOF) |
return (EOF); |
/* Ensure stdio has been initialized. |
??? Might be able to remove this as some other stdio routine should |
have already been called to get the char we are un-getting. */ |
CHECK_INIT (rptr, fp); |
_flockfile (fp); |
ORIENT (fp, -1); |
/* After ungetc, we won't be at eof anymore */ |
fp->_flags &= ~__SEOF; |
if ((fp->_flags & __SRD) == 0) |
{ |
/* |
* Not already reading: no good unless reading-and-writing. |
* Otherwise, flush any current write stuff. |
*/ |
if ((fp->_flags & __SRW) == 0) |
{ |
_funlockfile (fp); |
return EOF; |
} |
if (fp->_flags & __SWR) |
{ |
if (_fflush_r (rptr, fp)) |
{ |
_funlockfile (fp); |
return EOF; |
} |
fp->_flags &= ~__SWR; |
fp->_w = 0; |
fp->_lbfsize = 0; |
} |
fp->_flags |= __SRD; |
} |
c = (unsigned char) c; |
/* |
* If we are in the middle of ungetc'ing, just continue. |
* This may require expanding the current ungetc buffer. |
*/ |
if (HASUB (fp)) |
{ |
if (fp->_r >= fp->_ub._size && __submore (rptr, fp)) |
{ |
_funlockfile (fp); |
return EOF; |
} |
*--fp->_p = c; |
fp->_r++; |
_funlockfile (fp); |
return c; |
} |
/* |
* If we can handle this by simply backing up, do so, |
* but never replace the original character. |
* (This makes sscanf() work when scanning `const' data.) |
*/ |
if (fp->_bf._base != NULL && fp->_p > fp->_bf._base && fp->_p[-1] == c) |
{ |
fp->_p--; |
fp->_r++; |
_funlockfile (fp); |
return c; |
} |
/* |
* Create an ungetc buffer. |
* Initially, we will use the `reserve' buffer. |
*/ |
fp->_ur = fp->_r; |
fp->_up = fp->_p; |
fp->_ub._base = fp->_ubuf; |
fp->_ub._size = sizeof (fp->_ubuf); |
fp->_ubuf[sizeof (fp->_ubuf) - 1] = c; |
fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1]; |
fp->_r = 1; |
_funlockfile (fp); |
return c; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(ungetc, (c, fp), |
int c _AND |
register FILE *fp) |
{ |
return _ungetc_r (_REENT, c, fp); |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdio/vfieeefp.h |
---|
0,0 → 1,283 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
/* This header file is a modification of mprec.h that only contains floating |
point union code. */ |
#include <newlib.h> |
#include <ieeefp.h> |
#include <math.h> |
#include <float.h> |
#include <errno.h> |
#include <sys/config.h> |
#ifdef __IEEE_LITTLE_ENDIAN |
#define IEEE_8087 |
#endif |
#ifdef __IEEE_BIG_ENDIAN |
#define IEEE_MC68k |
#endif |
#ifdef __Z8000__ |
#define Just_16 |
#endif |
#ifdef Unsigned_Shifts |
#define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000; |
#else |
#define Sign_Extend(a,b) /*no-op*/ |
#endif |
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 |
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. |
#endif |
#ifdef _WANT_IO_LONG_DOUBLE |
/* If we are going to examine or modify specific bits in a long double using |
the lword0 or lwordx macros, then we must wrap the long double inside |
a union. This is necessary to avoid undefined behavior according to |
the ANSI C spec. */ |
#ifdef IEEE_8087 |
#if LDBL_MANT_DIG == 24 |
struct ldieee |
{ |
unsigned manh:23; |
unsigned exp:8; |
unsigned sign:1; |
}; |
#elif LDBL_MANT_DIG == 53 |
struct ldieee |
{ |
unsigned manl:20; |
unsigned manh:32; |
unsigned exp:11; |
unsigned sign:1; |
}; |
#elif LDBL_MANT_DIG == 64 |
struct ldieee |
{ |
unsigned manl:32; |
unsigned manh:32; |
unsigned exp:15; |
unsigned sign:1; |
}; |
#elif LDBL_MANT_DIG > 64 |
struct ldieee |
{ |
unsigned manl3:16; |
unsigned manl2:32; |
unsigned manl:32; |
unsigned manh:32; |
unsigned exp:15; |
unsigned sign:1; |
}; |
#endif /* LDBL_MANT_DIG */ |
#else /* !IEEE_8087 */ |
#if LDBL_MANT_DIG == 24 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:8; |
unsigned manh:23; |
}; |
#elif LDBL_MANT_DIG == 53 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:11; |
unsigned manh:32; |
unsigned manl:20; |
}; |
#elif LDBL_MANT_DIG == 64 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:15; |
unsigned manh:32; |
unsigned manl:32; |
}; |
#elif LDBL_MANT_DIG > 64 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:15; |
unsigned manh:32; |
unsigned manl:32; |
unsigned manl2:32; |
unsigned manl3;16; |
}; |
#endif /* LDBL_MANT_DIG */ |
#endif /* !IEEE_8087 */ |
#endif /* _WANT_IO_LONG_DOUBLE */ |
/* If we are going to examine or modify specific bits in a double using |
the word0 and/or word1 macros, then we must wrap the double inside |
a union. This is necessary to avoid undefined behavior according to |
the ANSI C spec. */ |
union double_union |
{ |
double d; |
__uint32_t i[2]; |
}; |
#ifdef IEEE_8087 |
#define word0(x) (x.i[1]) |
#define word1(x) (x.i[0]) |
#else |
#define word0(x) (x.i[0]) |
#define word1(x) (x.i[1]) |
#endif |
/* #define P DBL_MANT_DIG */ |
/* Ten_pmax = floor(P*log(2)/log(5)) */ |
/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ |
/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ |
/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ |
#if defined(IEEE_8087) + defined(IEEE_MC68k) |
#if defined (_DOUBLE_IS_32BITS) |
#define Exp_shift 23 |
#define Exp_shift1 23 |
#define Exp_msk1 ((__uint32_t)0x00800000L) |
#define Exp_msk11 ((__uint32_t)0x00800000L) |
#define Exp_mask ((__uint32_t)0x7f800000L) |
#define P 24 |
#define Bias 127 |
#define IEEE_Arith |
#define Emin (-126) |
#define Exp_1 ((__uint32_t)0x3f800000L) |
#define Exp_11 ((__uint32_t)0x3f800000L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x007fffffL) |
#define Frac_mask1 ((__uint32_t)0x007fffffL) |
#define Ten_pmax 10 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Ten_pmax 10 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0x007fffffL) |
#define Bndry_mask1 ((__uint32_t)0x007fffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 5 |
#define Int_max 6 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L)) |
#undef word0 |
#undef word1 |
#define word0(x) (x.i[0]) |
#define word1(x) 0 |
#else |
#define Exp_shift 20 |
#define Exp_shift1 20 |
#define Exp_msk1 ((__uint32_t)0x100000L) |
#define Exp_msk11 ((__uint32_t)0x100000L) |
#define Exp_mask ((__uint32_t)0x7ff00000L) |
#define P 53 |
#define Bias 1023 |
#define IEEE_Arith |
#define Emin (-1022) |
#define Exp_1 ((__uint32_t)0x3ff00000L) |
#define Exp_11 ((__uint32_t)0x3ff00000L) |
#define Ebits 11 |
#define Frac_mask ((__uint32_t)0xfffffL) |
#define Frac_mask1 ((__uint32_t)0xfffffL) |
#define Ten_pmax 22 |
#define Bletch 0x10 |
#define Bndry_mask ((__uint32_t)0xfffffL) |
#define Bndry_mask1 ((__uint32_t)0xfffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 14 |
#define Int_max 14 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */ |
#endif |
#else |
#undef Sudden_Underflow |
#define Sudden_Underflow |
#ifdef IBM |
#define Exp_shift 24 |
#define Exp_shift1 24 |
#define Exp_msk1 ((__uint32_t)0x1000000L) |
#define Exp_msk11 ((__uint32_t)0x1000000L) |
#define Exp_mask ((__uint32_t)0x7f000000L) |
#define P 14 |
#define Bias 65 |
#define Exp_1 ((__uint32_t)0x41000000L) |
#define Exp_11 ((__uint32_t)0x41000000L) |
#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ |
#define Frac_mask ((__uint32_t)0xffffffL) |
#define Frac_mask1 ((__uint32_t)0xffffffL) |
#define Bletch 4 |
#define Ten_pmax 22 |
#define Bndry_mask ((__uint32_t)0xefffffL) |
#define Bndry_mask1 ((__uint32_t)0xffffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 4 |
#define Tiny0 ((__uint32_t)0x100000L) |
#define Tiny1 0 |
#define Quick_max 14 |
#define Int_max 15 |
#else /* VAX */ |
#define Exp_shift 23 |
#define Exp_shift1 7 |
#define Exp_msk1 0x80 |
#define Exp_msk11 ((__uint32_t)0x800000L) |
#define Exp_mask ((__uint32_t)0x7f80L) |
#define P 56 |
#define Bias 129 |
#define Exp_1 ((__uint32_t)0x40800000L) |
#define Exp_11 ((__uint32_t)0x4080L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x7fffffL) |
#define Frac_mask1 ((__uint32_t)0xffff007fL) |
#define Ten_pmax 24 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0xffff007fL) |
#define Bndry_mask1 ((__uint32_t)0xffff007fL) |
#define LSB ((__uint32_t)0x10000L) |
#define Sign_bit ((__uint32_t)0x8000L) |
#define Log2P 1 |
#define Tiny0 0x80 |
#define Tiny1 0 |
#define Quick_max 15 |
#define Int_max 15 |
#endif |
#endif |
/programs/develop/libraries/newlib/stdio/vfprintf.c |
---|
0,0 → 1,2190 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Chris Torek. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<vfprintf>>, <<vprintf>>, <<vsprintf>>, <<vsnprintf>>, <<vasprintf>>, <<vasnprintf>>---format argument list |
INDEX |
vfprintf |
INDEX |
_vfprintf_r |
INDEX |
vprintf |
INDEX |
_vprintf_r |
INDEX |
vsprintf |
INDEX |
_vsprintf_r |
INDEX |
vsnprintf |
INDEX |
_vsnprintf_r |
INDEX |
vasprintf |
INDEX |
_vasprintf_r |
INDEX |
vasnprintf |
INDEX |
_vasnprintf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <stdarg.h> |
int vprintf(const char *<[fmt]>, va_list <[list]>); |
int vfprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); |
int vsprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>); |
int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, |
va_list <[list]>); |
int vasprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>); |
char *vasnprintf(char *<[str]>, size_t *<[size]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vprintf_r(struct _reent *<[reent]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vfprintf_r(struct _reent *<[reent]>, FILE *<[fp]>, |
const char *<[fmt]>, va_list <[list]>); |
int _vsprintf_r(struct _reent *<[reent]>, char *<[str]>, |
const char *<[fmt]>, va_list <[list]>); |
int _vasprintf_r(struct _reent *<[reent]>, char **<[str]>, |
const char *<[fmt]>, va_list <[list]>); |
int _vsnprintf_r(struct _reent *<[reent]>, char *<[str]>, |
size_t <[size]>, const char *<[fmt]>, va_list <[list]>); |
char *_vasnprintf_r(struct _reent *<[reent]>, char *<[str]>, |
size_t *<[size]>, const char *<[fmt]>, va_list <[list]>); |
DESCRIPTION |
<<vprintf>>, <<vfprintf>>, <<vasprintf>>, <<vsprintf>>, <<vsnprintf>>, |
and <<vasnprintf>> are (respectively) variants of <<printf>>, |
<<fprintf>>, <<asprintf>>, <<sprintf>>, <<snprintf>>, and |
<<asnprintf>>. They differ only in allowing their caller to pass the |
variable argument list as a <<va_list>> object (initialized by |
<<va_start>>) rather than directly accepting a variable number of |
arguments. The caller is responsible for calling <<va_end>>. |
<<_vprintf_r>>, <<_vfprintf_r>>, <<_vasprintf_r>>, <<_vsprintf_r>>, |
<<_vsnprintf_r>>, and <<_vasnprintf_r>> are reentrant versions of the |
above. |
RETURNS |
The return values are consistent with the corresponding functions. |
PORTABILITY |
ANSI C requires <<vprintf>>, <<vfprintf>>, <<vsprintf>>, and |
<<vsnprintf>>. The remaining functions are newlib extensions. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
/*static char *sccsid = "from: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";*/ |
static char *rcsid = "$Id: vfprintf.c,v 1.43 2002/08/13 02:40:06 fitzsim Exp $"; |
#endif /* LIBC_SCCS and not lint */ |
/* |
* Actual printf innards. |
* |
* This code is large and complicated... |
*/ |
#include <newlib.h> |
#ifdef INTEGER_ONLY |
# define VFPRINTF vfiprintf |
# ifdef STRING_ONLY |
# define _VFPRINTF_R _svfiprintf_r |
# else |
# define _VFPRINTF_R _vfiprintf_r |
# endif |
#else |
# define VFPRINTF vfprintf |
# ifdef STRING_ONLY |
# define _VFPRINTF_R _svfprintf_r |
# else |
# define _VFPRINTF_R _vfprintf_r |
# endif |
# ifndef NO_FLOATING_POINT |
# define FLOATING_POINT |
# endif |
#endif |
#define _NO_POS_ARGS |
#ifdef _WANT_IO_POS_ARGS |
# undef _NO_POS_ARGS |
#endif |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <limits.h> |
#include <stdint.h> |
#include <wchar.h> |
#include <sys/lock.h> |
#include <stdarg.h> |
#include "local.h" |
#include "../stdlib/local.h" |
#include "fvwrite.h" |
#include "vfieeefp.h" |
/* Currently a test is made to see if long double processing is warranted. |
This could be changed in the future should the _ldtoa_r code be |
preferred over _dtoa_r. */ |
#define _NO_LONGDBL |
#if defined _WANT_IO_LONG_DOUBLE && (LDBL_MANT_DIG > DBL_MANT_DIG) |
#undef _NO_LONGDBL |
#endif |
#define _NO_LONGLONG |
#if defined _WANT_IO_LONG_LONG \ |
&& (defined __GNUC__ || __STDC_VERSION__ >= 199901L) |
# undef _NO_LONGLONG |
#endif |
#ifdef STRING_ONLY |
#define __SPRINT __ssprint_r |
#else |
#define __SPRINT __sprint_r |
#endif |
/* The __sprint_r/__ssprint_r functions are shared between all versions of |
vfprintf and vfwprintf. They must only be defined once, which we do in |
the INTEGER_ONLY versions here. */ |
#ifdef STRING_ONLY |
#ifdef INTEGER_ONLY |
int |
_DEFUN(__ssprint_r, (ptr, fp, uio), |
struct _reent *ptr _AND |
FILE *fp _AND |
register struct __suio *uio) |
{ |
register size_t len; |
register int w; |
register struct __siov *iov; |
register _CONST char *p = NULL; |
iov = uio->uio_iov; |
len = 0; |
if (uio->uio_resid == 0) { |
uio->uio_iovcnt = 0; |
return (0); |
} |
do { |
while (len == 0) { |
p = iov->iov_base; |
len = iov->iov_len; |
iov++; |
} |
w = fp->_w; |
if (len >= w && fp->_flags & (__SMBF | __SOPT)) { |
/* must be asprintf family */ |
unsigned char *str; |
int curpos = (fp->_p - fp->_bf._base); |
/* Choose a geometric growth factor to avoid |
* quadratic realloc behavior, but use a rate less |
* than (1+sqrt(5))/2 to accomodate malloc |
* overhead. asprintf EXPECTS us to overallocate, so |
* that it can add a trailing \0 without |
* reallocating. The new allocation should thus be |
* max(prev_size*1.5, curpos+len+1). */ |
int newsize = fp->_bf._size * 3 / 2; |
if (newsize < curpos + len + 1) |
newsize = curpos + len + 1; |
if (fp->_flags & __SOPT) |
{ |
/* asnprintf leaves original buffer alone. */ |
str = (unsigned char *)_malloc_r (ptr, newsize); |
if (!str) |
{ |
ptr->_errno = ENOMEM; |
goto err; |
} |
memcpy (str, fp->_bf._base, curpos); |
fp->_flags = (fp->_flags & ~__SOPT) | __SMBF; |
} |
else |
{ |
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base, |
newsize); |
if (!str) { |
/* Free unneeded buffer. */ |
_free_r (ptr, fp->_bf._base); |
/* Ensure correct errno, even if free |
* changed it. */ |
ptr->_errno = ENOMEM; |
goto err; |
} |
} |
fp->_bf._base = str; |
fp->_p = str + curpos; |
fp->_bf._size = newsize; |
w = len; |
fp->_w = newsize - curpos; |
} |
if (len < w) |
w = len; |
(void)memmove ((_PTR) fp->_p, (_PTR) p, (size_t) (w)); |
fp->_w -= w; |
fp->_p += w; |
w = len; /* pretend we copied all */ |
p += w; |
len -= w; |
} while ((uio->uio_resid -= w) != 0); |
uio->uio_resid = 0; |
uio->uio_iovcnt = 0; |
return 0; |
err: |
fp->_flags |= __SERR; |
uio->uio_resid = 0; |
uio->uio_iovcnt = 0; |
return EOF; |
} |
#else /* !INTEGER_ONLY */ |
int __ssprint_r (struct _reent *, FILE *, register struct __suio *); |
#endif /* !INTEGER_ONLY */ |
#else /* !STRING_ONLY */ |
#ifdef INTEGER_ONLY |
/* |
* Flush out all the vectors defined by the given uio, |
* then reset it so that it can be reused. |
*/ |
int |
_DEFUN(__sprint_r, (ptr, fp, uio), |
struct _reent *ptr _AND |
FILE *fp _AND |
register struct __suio *uio) |
{ |
register int err = 0; |
if (uio->uio_resid == 0) { |
uio->uio_iovcnt = 0; |
return (0); |
} |
if (fp->_flags2 & __SWID) { |
struct __siov *iov; |
wchar_t *p; |
int i, len; |
iov = uio->uio_iov; |
for (; uio->uio_resid != 0; |
uio->uio_resid -= len * sizeof (wchar_t), iov++) { |
p = (wchar_t *) iov->iov_base; |
len = iov->iov_len / sizeof (wchar_t); |
for (i = 0; i < len; i++) { |
if (_fputwc_r (ptr, p[i], fp) == WEOF) { |
err = -1; |
goto out; |
} |
} |
} |
} else |
err = __sfvwrite_r(ptr, fp, uio); |
out: |
uio->uio_resid = 0; |
uio->uio_iovcnt = 0; |
return (err); |
} |
#else /* !INTEGER_ONLY */ |
int __sprint_r (struct _reent *, FILE *, register struct __suio *); |
#endif /* !INTEGER_ONLY */ |
/* |
* Helper function for `fprintf to unbuffered unix file': creates a |
* temporary buffer. We only work on write-only files; this avoids |
* worries about ungetc buffers and so forth. |
*/ |
static int |
_DEFUN(__sbprintf, (rptr, fp, fmt, ap), |
struct _reent *rptr _AND |
register FILE *fp _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE fake; |
unsigned char buf[BUFSIZ]; |
/* copy the important variables */ |
fake._flags = fp->_flags & ~__SNBF; |
fake._flags2 = fp->_flags2; |
fake._file = fp->_file; |
fake._cookie = fp->_cookie; |
fake._write = fp->_write; |
/* set up the buffer */ |
fake._bf._base = fake._p = buf; |
fake._bf._size = fake._w = sizeof (buf); |
fake._lbfsize = 0; /* not actually used, but Just In Case */ |
#ifndef __SINGLE_THREAD__ |
__lock_init_recursive (fake._lock); |
#endif |
/* do the work, then copy any error status */ |
ret = _VFPRINTF_R (rptr, &fake, fmt, ap); |
if (ret >= 0 && _fflush_r (rptr, &fake)) |
ret = EOF; |
if (fake._flags & __SERR) |
fp->_flags |= __SERR; |
#ifndef __SINGLE_THREAD__ |
__lock_close_recursive (fake._lock); |
#endif |
return (ret); |
} |
#endif /* !STRING_ONLY */ |
#if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) |
# include <locale.h> |
#endif |
#ifdef FLOATING_POINT |
# include <math.h> |
/* For %La, an exponent of 15 bits occupies the exponent character, a |
sign, and up to 5 digits. */ |
# define MAXEXPLEN 7 |
# define DEFPREC 6 |
# ifdef _NO_LONGDBL |
extern char *_dtoa_r _PARAMS((struct _reent *, double, int, |
int, int *, int *, char **)); |
# define _PRINTF_FLOAT_TYPE double |
# define _DTOA_R _dtoa_r |
# define FREXP frexp |
# else /* !_NO_LONGDBL */ |
extern char *_ldtoa_r _PARAMS((struct _reent *, _LONG_DOUBLE, int, |
int, int *, int *, char **)); |
extern int _EXFUN(_ldcheck,(_LONG_DOUBLE *)); |
# define _PRINTF_FLOAT_TYPE _LONG_DOUBLE |
# define _DTOA_R _ldtoa_r |
/* FIXME - frexpl is not yet supported; and cvt infloops if (double)f |
converts a finite value into infinity. */ |
/* # define FREXP frexpl */ |
# define FREXP(f,e) ((_LONG_DOUBLE) frexp ((double)f, e)) |
# endif /* !_NO_LONGDBL */ |
static char *cvt(struct _reent *, _PRINTF_FLOAT_TYPE, int, int, char *, int *, |
int, int *, char *); |
static int exponent(char *, int, int); |
#endif /* FLOATING_POINT */ |
/* BUF must be big enough for the maximum %#llo (assuming long long is |
at most 64 bits, this would be 23 characters), the maximum |
multibyte character %C, and the maximum default precision of %La |
(assuming long double is at most 128 bits with 113 bits of |
mantissa, this would be 29 characters). %e, %f, and %g use |
reentrant storage shared with mprec. All other formats that use |
buf get by with fewer characters. Making BUF slightly bigger |
reduces the need for malloc in %.*a and %S, when large precision or |
long strings are processed. |
The bigger size of 100 bytes is used on systems which allow number |
strings using the locale's grouping character. Since that's a multibyte |
value, we should use a conservative value. |
*/ |
#ifdef _WANT_IO_C99_FORMATS |
#define BUF 100 |
#else |
#define BUF 40 |
#endif |
#if defined _MB_CAPABLE && MB_LEN_MAX > BUF |
# undef BUF |
# define BUF MB_LEN_MAX |
#endif |
#ifndef _NO_LONGLONG |
# define quad_t long long |
# define u_quad_t unsigned long long |
#else |
# define quad_t long |
# define u_quad_t unsigned long |
#endif |
typedef quad_t * quad_ptr_t; |
typedef _PTR void_ptr_t; |
typedef char * char_ptr_t; |
typedef long * long_ptr_t; |
typedef int * int_ptr_t; |
typedef short * short_ptr_t; |
#ifndef _NO_POS_ARGS |
# ifdef NL_ARGMAX |
# define MAX_POS_ARGS NL_ARGMAX |
# else |
# define MAX_POS_ARGS 32 |
# endif |
union arg_val |
{ |
int val_int; |
u_int val_u_int; |
long val_long; |
u_long val_u_long; |
float val_float; |
double val_double; |
_LONG_DOUBLE val__LONG_DOUBLE; |
int_ptr_t val_int_ptr_t; |
short_ptr_t val_short_ptr_t; |
long_ptr_t val_long_ptr_t; |
char_ptr_t val_char_ptr_t; |
quad_ptr_t val_quad_ptr_t; |
void_ptr_t val_void_ptr_t; |
quad_t val_quad_t; |
u_quad_t val_u_quad_t; |
wint_t val_wint_t; |
}; |
static union arg_val * |
_EXFUN(get_arg, (struct _reent *data, int n, char *fmt, |
va_list *ap, int *numargs, union arg_val *args, |
int *arg_type, char **last_fmt)); |
#endif /* !_NO_POS_ARGS */ |
/* |
* Macros for converting digits to letters and vice versa |
*/ |
#define to_digit(c) ((c) - '0') |
#define is_digit(c) ((unsigned)to_digit (c) <= 9) |
#define to_char(n) ((n) + '0') |
/* |
* Flags used during conversion. |
*/ |
#define ALT 0x001 /* alternate form */ |
#define HEXPREFIX 0x002 /* add 0x or 0X prefix */ |
#define LADJUST 0x004 /* left adjustment */ |
#define LONGDBL 0x008 /* long double */ |
#define LONGINT 0x010 /* long integer */ |
#ifndef _NO_LONGLONG |
# define QUADINT 0x020 /* quad integer */ |
#else /* ifdef _NO_LONGLONG, make QUADINT equivalent to LONGINT, so |
that %lld behaves the same as %ld, not as %d, as expected if: |
sizeof (long long) = sizeof long > sizeof int */ |
# define QUADINT LONGINT |
#endif |
#define SHORTINT 0x040 /* short integer */ |
#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ |
#define FPT 0x100 /* Floating point number */ |
#ifdef _WANT_IO_C99_FORMATS |
# define CHARINT 0x200 /* char as integer */ |
#else /* define as 0, to make SARG and UARG occupy fewer instructions */ |
# define CHARINT 0 |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
# define GROUPING 0x400 /* use grouping ("'" flag) */ |
#endif |
int _EXFUN(_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list)); |
#ifndef STRING_ONLY |
int |
_DEFUN(VFPRINTF, (fp, fmt0, ap), |
FILE * fp _AND |
_CONST char *fmt0 _AND |
va_list ap) |
{ |
int result; |
result = _VFPRINTF_R (_REENT, fp, fmt0, ap); |
return result; |
} |
#endif /* STRING_ONLY */ |
int |
_DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), |
struct _reent *data _AND |
FILE * fp _AND |
_CONST char *fmt0 _AND |
va_list ap) |
{ |
register char *fmt; /* format string */ |
register int ch; /* character from fmt */ |
register int n, m; /* handy integers (short term usage) */ |
register char *cp; /* handy char pointer (short term usage) */ |
register struct __siov *iovp;/* for PRINT macro */ |
register int flags; /* flags as above */ |
char *fmt_anchor; /* current format spec being processed */ |
#ifndef _NO_POS_ARGS |
int N; /* arg number */ |
int arg_index; /* index into args processed directly */ |
int numargs; /* number of varargs read */ |
char *saved_fmt; /* saved fmt pointer */ |
union arg_val args[MAX_POS_ARGS]; |
int arg_type[MAX_POS_ARGS]; |
int is_pos_arg; /* is current format positional? */ |
int old_is_pos_arg; /* is current format positional? */ |
#endif |
int ret; /* return value accumulator */ |
int width; /* width from format (%8d), or 0 */ |
int prec; /* precision from format (%.3d), or -1 */ |
char sign; /* sign prefix (' ', '+', '-', or \0) */ |
#ifdef _WANT_IO_C99_FORMATS |
/* locale specific numeric grouping */ |
char *thousands_sep; |
size_t thsnd_len; |
const char *grouping; |
#endif |
#ifdef FLOATING_POINT |
char *decimal_point = _localeconv_r (data)->decimal_point; |
size_t decp_len = strlen (decimal_point); |
char softsign; /* temporary negative sign for floats */ |
union { int i; _PRINTF_FLOAT_TYPE fp; } _double_ = {0}; |
# define _fpvalue (_double_.fp) |
int expt; /* integer value of exponent */ |
int expsize = 0; /* character count for expstr */ |
char expstr[MAXEXPLEN]; /* buffer for exponent string */ |
int lead; /* sig figs before decimal or group sep */ |
#endif /* FLOATING_POINT */ |
#if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) |
int ndig = 0; /* actual number of digits returned by cvt */ |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
int nseps; /* number of group separators with ' */ |
int nrepeats; /* number of repeats of the last group */ |
#endif |
u_quad_t _uquad; /* integer arguments %[diouxX] */ |
enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ |
int dprec; /* a copy of prec if [diouxX], 0 otherwise */ |
int realsz; /* field size expanded by dprec */ |
int size; /* size of converted field or string */ |
char *xdigs = NULL; /* digits for [xX] conversion */ |
#define NIOV 8 |
struct __suio uio; /* output information: summary */ |
struct __siov iov[NIOV];/* ... and individual io vectors */ |
char buf[BUF]; /* space for %c, %S, %[diouxX], %[aA] */ |
char ox[2]; /* space for 0x hex-prefix */ |
#ifdef _MB_CAPABLE |
wchar_t wc; |
mbstate_t state; /* mbtowc calls from library must not change state */ |
#endif |
char *malloc_buf = NULL;/* handy pointer for malloced buffers */ |
/* |
* Choose PADSIZE to trade efficiency vs. size. If larger printf |
* fields occur frequently, increase PADSIZE and make the initialisers |
* below longer. |
*/ |
#define PADSIZE 16 /* pad chunk size */ |
static _CONST char blanks[PADSIZE] = |
{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; |
static _CONST char zeroes[PADSIZE] = |
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; |
#ifdef _MB_CAPABLE |
memset (&state, '\0', sizeof (state)); |
#endif |
/* |
* BEWARE, these `goto error' on error, and PAD uses `n'. |
*/ |
#define PRINT(ptr, len) { \ |
iovp->iov_base = (ptr); \ |
iovp->iov_len = (len); \ |
uio.uio_resid += (len); \ |
iovp++; \ |
if (++uio.uio_iovcnt >= NIOV) { \ |
if (__SPRINT(data, fp, &uio)) \ |
goto error; \ |
iovp = iov; \ |
} \ |
} |
#define PAD(howmany, with) { \ |
if ((n = (howmany)) > 0) { \ |
while (n > PADSIZE) { \ |
PRINT (with, PADSIZE); \ |
n -= PADSIZE; \ |
} \ |
PRINT (with, n); \ |
} \ |
} |
#define PRINTANDPAD(p, ep, len, with) { \ |
int n = (ep) - (p); \ |
if (n > (len)) \ |
n = (len); \ |
if (n > 0) \ |
PRINT((p), n); \ |
PAD((len) - (n > 0 ? n : 0), (with)); \ |
} |
#define FLUSH() { \ |
if (uio.uio_resid && __SPRINT(data, fp, &uio)) \ |
goto error; \ |
uio.uio_iovcnt = 0; \ |
iovp = iov; \ |
} |
/* Macros to support positional arguments */ |
#ifndef _NO_POS_ARGS |
# define GET_ARG(n, ap, type) \ |
(is_pos_arg \ |
? (n < numargs \ |
? args[n].val_##type \ |
: get_arg (data, n, fmt_anchor, &ap, &numargs, args, \ |
arg_type, &saved_fmt)->val_##type) \ |
: (arg_index++ < numargs \ |
? args[n].val_##type \ |
: (numargs < MAX_POS_ARGS \ |
? args[numargs++].val_##type = va_arg (ap, type) \ |
: va_arg (ap, type)))) |
#else |
# define GET_ARG(n, ap, type) (va_arg (ap, type)) |
#endif |
/* |
* To extend shorts properly, we need both signed and unsigned |
* argument extraction methods. |
*/ |
#ifndef _NO_LONGLONG |
#define SARG() \ |
(flags&QUADINT ? GET_ARG (N, ap, quad_t) : \ |
flags&LONGINT ? GET_ARG (N, ap, long) : \ |
flags&SHORTINT ? (long)(short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (long)(signed char)GET_ARG (N, ap, int) : \ |
(long)GET_ARG (N, ap, int)) |
#define UARG() \ |
(flags&QUADINT ? GET_ARG (N, ap, u_quad_t) : \ |
flags&LONGINT ? GET_ARG (N, ap, u_long) : \ |
flags&SHORTINT ? (u_long)(u_short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (u_long)(unsigned char)GET_ARG (N, ap, int) : \ |
(u_long)GET_ARG (N, ap, u_int)) |
#else |
#define SARG() \ |
(flags&LONGINT ? GET_ARG (N, ap, long) : \ |
flags&SHORTINT ? (long)(short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (long)(signed char)GET_ARG (N, ap, int) : \ |
(long)GET_ARG (N, ap, int)) |
#define UARG() \ |
(flags&LONGINT ? GET_ARG (N, ap, u_long) : \ |
flags&SHORTINT ? (u_long)(u_short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (u_long)(unsigned char)GET_ARG (N, ap, int) : \ |
(u_long)GET_ARG (N, ap, u_int)) |
#endif |
#ifndef STRING_ONLY |
/* Initialize std streams if not dealing with sprintf family. */ |
CHECK_INIT (data, fp); |
_flockfile (fp); |
ORIENT(fp, -1); |
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ |
if (cantwrite (data, fp)) { |
_funlockfile (fp); |
return (EOF); |
} |
/* optimise fprintf(stderr) (and other unbuffered Unix files) */ |
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && |
fp->_file >= 0) { |
_funlockfile (fp); |
return (__sbprintf (data, fp, fmt0, ap)); |
} |
#else /* STRING_ONLY */ |
/* Create initial buffer if we are called by asprintf family. */ |
if (fp->_flags & __SMBF && !fp->_bf._base) |
{ |
fp->_bf._base = fp->_p = _malloc_r (data, 64); |
if (!fp->_p) |
{ |
data->_errno = ENOMEM; |
return EOF; |
} |
fp->_bf._size = 64; |
} |
#endif /* STRING_ONLY */ |
fmt = (char *)fmt0; |
uio.uio_iov = iovp = iov; |
uio.uio_resid = 0; |
uio.uio_iovcnt = 0; |
ret = 0; |
#ifndef _NO_POS_ARGS |
arg_index = 0; |
saved_fmt = NULL; |
arg_type[0] = -1; |
numargs = 0; |
is_pos_arg = 0; |
#endif |
/* |
* Scan the format for conversions (`%' character). |
*/ |
for (;;) { |
cp = fmt; |
#ifdef _MB_CAPABLE |
while ((n = __mbtowc (data, &wc, fmt, MB_CUR_MAX, |
__locale_charset (), &state)) != 0) { |
if (n < 0) { |
/* Wave invalid chars through. */ |
memset (&state, 0, sizeof state); |
n = 1; |
} |
else if (wc == '%') |
break; |
fmt += n; |
} |
#else |
while (*fmt != '\0' && *fmt != '%') |
fmt += 1; |
#endif |
if ((m = fmt - cp) != 0) { |
PRINT (cp, m); |
ret += m; |
} |
#ifdef _MB_CAPABLE |
if (n <= 0) |
goto done; |
#else |
if (*fmt == '\0') |
goto done; |
#endif |
fmt_anchor = fmt; |
fmt++; /* skip over '%' */ |
flags = 0; |
dprec = 0; |
width = 0; |
prec = -1; |
sign = '\0'; |
#ifdef FLOATING_POINT |
lead = 0; |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
nseps = nrepeats = 0; |
#endif |
#ifndef _NO_POS_ARGS |
N = arg_index; |
is_pos_arg = 0; |
#endif |
rflag: ch = *fmt++; |
reswitch: switch (ch) { |
#ifdef _WANT_IO_C99_FORMATS |
case '\'': |
thousands_sep = _localeconv_r (data)->thousands_sep; |
thsnd_len = strlen (thousands_sep); |
grouping = _localeconv_r (data)->grouping; |
if (thsnd_len > 0 && grouping && *grouping) |
flags |= GROUPING; |
goto rflag; |
#endif |
case ' ': |
/* |
* ``If the space and + flags both appear, the space |
* flag will be ignored.'' |
* -- ANSI X3J11 |
*/ |
if (!sign) |
sign = ' '; |
goto rflag; |
case '#': |
flags |= ALT; |
goto rflag; |
case '*': |
#ifndef _NO_POS_ARGS |
/* we must check for positional arg used for dynamic width */ |
n = N; |
old_is_pos_arg = is_pos_arg; |
is_pos_arg = 0; |
if (is_digit (*fmt)) { |
char *old_fmt = fmt; |
n = 0; |
ch = *fmt++; |
do { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} while (is_digit (ch)); |
if (ch == '$') { |
if (n <= MAX_POS_ARGS) { |
n -= 1; |
is_pos_arg = 1; |
} |
else |
goto error; |
} |
else { |
fmt = old_fmt; |
goto rflag; |
} |
} |
#endif /* !_NO_POS_ARGS */ |
/* |
* ``A negative field width argument is taken as a |
* - flag followed by a positive field width.'' |
* -- ANSI X3J11 |
* They don't exclude field widths read from args. |
*/ |
width = GET_ARG (n, ap, int); |
#ifndef _NO_POS_ARGS |
is_pos_arg = old_is_pos_arg; |
#endif |
if (width >= 0) |
goto rflag; |
width = -width; |
/* FALLTHROUGH */ |
case '-': |
flags |= LADJUST; |
goto rflag; |
case '+': |
sign = '+'; |
goto rflag; |
case '.': |
if ((ch = *fmt++) == '*') { |
#ifndef _NO_POS_ARGS |
/* we must check for positional arg used for dynamic width */ |
n = N; |
old_is_pos_arg = is_pos_arg; |
is_pos_arg = 0; |
if (is_digit (*fmt)) { |
char *old_fmt = fmt; |
n = 0; |
ch = *fmt++; |
do { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} while (is_digit (ch)); |
if (ch == '$') { |
if (n <= MAX_POS_ARGS) { |
n -= 1; |
is_pos_arg = 1; |
} |
else |
goto error; |
} |
else { |
fmt = old_fmt; |
goto rflag; |
} |
} |
#endif /* !_NO_POS_ARGS */ |
prec = GET_ARG (n, ap, int); |
#ifndef _NO_POS_ARGS |
is_pos_arg = old_is_pos_arg; |
#endif |
if (prec < 0) |
prec = -1; |
goto rflag; |
} |
n = 0; |
while (is_digit (ch)) { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} |
prec = n < 0 ? -1 : n; |
goto reswitch; |
case '0': |
/* |
* ``Note that 0 is taken as a flag, not as the |
* beginning of a field width.'' |
* -- ANSI X3J11 |
*/ |
flags |= ZEROPAD; |
goto rflag; |
case '1': case '2': case '3': case '4': |
case '5': case '6': case '7': case '8': case '9': |
n = 0; |
do { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} while (is_digit (ch)); |
#ifndef _NO_POS_ARGS |
if (ch == '$') { |
if (n <= MAX_POS_ARGS) { |
N = n - 1; |
is_pos_arg = 1; |
goto rflag; |
} |
else |
goto error; |
} |
#endif /* !_NO_POS_ARGS */ |
width = n; |
goto reswitch; |
#ifdef FLOATING_POINT |
case 'L': |
flags |= LONGDBL; |
goto rflag; |
#endif |
case 'h': |
#ifdef _WANT_IO_C99_FORMATS |
if (*fmt == 'h') { |
fmt++; |
flags |= CHARINT; |
} else |
#endif |
flags |= SHORTINT; |
goto rflag; |
case 'l': |
#if defined _WANT_IO_C99_FORMATS || !defined _NO_LONGLONG |
if (*fmt == 'l') { |
fmt++; |
flags |= QUADINT; |
} else |
#endif |
flags |= LONGINT; |
goto rflag; |
case 'q': /* extension */ |
flags |= QUADINT; |
goto rflag; |
#ifdef _WANT_IO_C99_FORMATS |
case 'j': |
if (sizeof (intmax_t) == sizeof (long)) |
flags |= LONGINT; |
else |
flags |= QUADINT; |
goto rflag; |
case 'z': |
if (sizeof (size_t) < sizeof (int)) |
/* POSIX states size_t is 16 or more bits, as is short. */ |
flags |= SHORTINT; |
else if (sizeof (size_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (size_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support size_t no wider than |
long, but that means other environments can |
have size_t as wide as long long. */ |
flags |= QUADINT; |
goto rflag; |
case 't': |
if (sizeof (ptrdiff_t) < sizeof (int)) |
/* POSIX states ptrdiff_t is 16 or more bits, as |
is short. */ |
flags |= SHORTINT; |
else if (sizeof (ptrdiff_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (ptrdiff_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support ptrdiff_t no wider than |
long, but that means other environments can |
have ptrdiff_t as wide as long long. */ |
flags |= QUADINT; |
goto rflag; |
case 'C': |
#endif /* _WANT_IO_C99_FORMATS */ |
case 'c': |
cp = buf; |
#ifdef _MB_CAPABLE |
if (ch == 'C' || (flags & LONGINT)) { |
mbstate_t ps; |
memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); |
if ((size = (int)_wcrtomb_r (data, cp, |
(wchar_t)GET_ARG (N, ap, wint_t), |
&ps)) == -1) { |
fp->_flags |= __SERR; |
goto error; |
} |
} |
else |
#endif /* _MB_CAPABLE */ |
{ |
*cp = GET_ARG (N, ap, int); |
size = 1; |
} |
sign = '\0'; |
break; |
case 'D': /* extension */ |
flags |= LONGINT; |
/*FALLTHROUGH*/ |
case 'd': |
case 'i': |
_uquad = SARG (); |
#ifndef _NO_LONGLONG |
if ((quad_t)_uquad < 0) |
#else |
if ((long) _uquad < 0) |
#endif |
{ |
_uquad = -_uquad; |
sign = '-'; |
} |
base = DEC; |
goto number; |
#ifdef FLOATING_POINT |
# ifdef _WANT_IO_C99_FORMATS |
case 'a': |
case 'A': |
case 'F': |
# endif |
case 'e': |
case 'E': |
case 'f': |
case 'g': |
case 'G': |
# ifdef _NO_LONGDBL |
if (flags & LONGDBL) { |
_fpvalue = (double) GET_ARG (N, ap, _LONG_DOUBLE); |
} else { |
_fpvalue = GET_ARG (N, ap, double); |
} |
/* do this before tricky precision changes |
If the output is infinite or NaN, leading |
zeros are not permitted. Otherwise, scanf |
could not read what printf wrote. |
*/ |
if (isinf (_fpvalue)) { |
if (_fpvalue < 0) |
sign = '-'; |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "INF"; |
else |
cp = "inf"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
if (isnan (_fpvalue)) { |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "NAN"; |
else |
cp = "nan"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
# else /* !_NO_LONGDBL */ |
if (flags & LONGDBL) { |
_fpvalue = GET_ARG (N, ap, _LONG_DOUBLE); |
} else { |
_fpvalue = (_LONG_DOUBLE)GET_ARG (N, ap, double); |
} |
/* do this before tricky precision changes */ |
expt = _ldcheck (&_fpvalue); |
if (expt == 2) { |
if (_fpvalue < 0) |
sign = '-'; |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "INF"; |
else |
cp = "inf"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
if (expt == 1) { |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "NAN"; |
else |
cp = "nan"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
# endif /* !_NO_LONGDBL */ |
# ifdef _WANT_IO_C99_FORMATS |
if (ch == 'a' || ch == 'A') { |
ox[0] = '0'; |
ox[1] = ch == 'a' ? 'x' : 'X'; |
flags |= HEXPREFIX; |
if (prec >= BUF) |
{ |
if ((malloc_buf = |
(char *)_malloc_r (data, prec + 1)) |
== NULL) |
{ |
fp->_flags |= __SERR; |
goto error; |
} |
cp = malloc_buf; |
} |
else |
cp = buf; |
} else |
# endif /* _WANT_IO_C99_FORMATS */ |
if (prec == -1) { |
prec = DEFPREC; |
} else if ((ch == 'g' || ch == 'G') && prec == 0) { |
prec = 1; |
} |
flags |= FPT; |
cp = cvt (data, _fpvalue, prec, flags, &softsign, |
&expt, ch, &ndig, cp); |
if (ch == 'g' || ch == 'G') { |
if (expt <= -4 || expt > prec) |
ch -= 2; /* 'e' or 'E' */ |
else |
ch = 'g'; |
} |
# ifdef _WANT_IO_C99_FORMATS |
else if (ch == 'F') |
ch = 'f'; |
# endif |
if (ch <= 'e') { /* 'a', 'A', 'e', or 'E' fmt */ |
--expt; |
expsize = exponent (expstr, expt, ch); |
size = expsize + ndig; |
if (ndig > 1 || flags & ALT) |
++size; |
# ifdef _WANT_IO_C99_FORMATS |
flags &= ~GROUPING; |
# endif |
} else { |
if (ch == 'f') { /* f fmt */ |
if (expt > 0) { |
size = expt; |
if (prec || flags & ALT) |
size += prec + 1; |
} else /* "0.X" */ |
size = (prec || flags & ALT) |
? prec + 2 |
: 1; |
} else if (expt >= ndig) { /* fixed g fmt */ |
size = expt; |
if (flags & ALT) |
++size; |
} else |
size = ndig + (expt > 0 ? |
1 : 2 - expt); |
# ifdef _WANT_IO_C99_FORMATS |
if ((flags & GROUPING) && expt > 0) { |
/* space for thousands' grouping */ |
nseps = nrepeats = 0; |
lead = expt; |
while (*grouping != CHAR_MAX) { |
if (lead <= *grouping) |
break; |
lead -= *grouping; |
if (grouping[1]) { |
nseps++; |
grouping++; |
} else |
nrepeats++; |
} |
size += (nseps + nrepeats) * thsnd_len; |
} else |
# endif |
lead = expt; |
} |
if (softsign) |
sign = '-'; |
break; |
#endif /* FLOATING_POINT */ |
case 'n': |
#ifndef _NO_LONGLONG |
if (flags & QUADINT) |
*GET_ARG (N, ap, quad_ptr_t) = ret; |
else |
#endif |
if (flags & LONGINT) |
*GET_ARG (N, ap, long_ptr_t) = ret; |
else if (flags & SHORTINT) |
*GET_ARG (N, ap, short_ptr_t) = ret; |
#ifdef _WANT_IO_C99_FORMATS |
else if (flags & CHARINT) |
*GET_ARG (N, ap, char_ptr_t) = ret; |
#endif |
else |
*GET_ARG (N, ap, int_ptr_t) = ret; |
continue; /* no output */ |
case 'O': /* extension */ |
flags |= LONGINT; |
/*FALLTHROUGH*/ |
case 'o': |
_uquad = UARG (); |
base = OCT; |
#ifdef _WANT_IO_C99_FORMATS |
flags &= ~GROUPING; |
#endif |
goto nosign; |
case 'p': |
/* |
* ``The argument shall be a pointer to void. The |
* value of the pointer is converted to a sequence |
* of printable characters, in an implementation- |
* defined manner.'' |
* -- ANSI X3J11 |
*/ |
/* NOSTRICT */ |
_uquad = (uintptr_t) GET_ARG (N, ap, void_ptr_t); |
base = HEX; |
xdigs = "0123456789abcdef"; |
flags |= HEXPREFIX; |
ox[0] = '0'; |
ox[1] = ch = 'x'; |
goto nosign; |
case 's': |
#ifdef _WANT_IO_C99_FORMATS |
case 'S': |
#endif |
sign = '\0'; |
cp = GET_ARG (N, ap, char_ptr_t); |
#ifndef __OPTIMIZE_SIZE__ |
/* Behavior is undefined if the user passed a |
NULL string when precision is not 0. |
However, if we are not optimizing for size, |
we might as well mirror glibc behavior. */ |
if (cp == NULL) { |
cp = "(null)"; |
size = ((unsigned) prec > 6U) ? 6 : prec; |
} |
else |
#endif /* __OPTIMIZE_SIZE__ */ |
#ifdef _MB_CAPABLE |
if (ch == 'S' || (flags & LONGINT)) { |
mbstate_t ps; |
_CONST wchar_t *wcp; |
wcp = (_CONST wchar_t *)cp; |
size = m = 0; |
memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); |
/* Count number of bytes needed for multibyte |
string that will be produced from widechar |
string. */ |
if (prec >= 0) { |
while (1) { |
if (wcp[m] == L'\0') |
break; |
if ((n = (int)_wcrtomb_r (data, |
buf, wcp[m], &ps)) == -1) { |
fp->_flags |= __SERR; |
goto error; |
} |
if (n + size > prec) |
break; |
m += 1; |
size += n; |
if (size == prec) |
break; |
} |
} |
else { |
if ((size = (int)_wcsrtombs_r (data, |
NULL, &wcp, 0, &ps)) == -1) { |
fp->_flags |= __SERR; |
goto error; |
} |
wcp = (_CONST wchar_t *)cp; |
} |
if (size == 0) |
break; |
if (size >= BUF) { |
if ((malloc_buf = |
(char *)_malloc_r (data, size + 1)) |
== NULL) { |
fp->_flags |= __SERR; |
goto error; |
} |
cp = malloc_buf; |
} else |
cp = buf; |
/* Convert widechar string to multibyte string. */ |
memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); |
if (_wcsrtombs_r (data, cp, &wcp, size, &ps) |
!= size) { |
fp->_flags |= __SERR; |
goto error; |
} |
cp[size] = '\0'; |
} |
else |
#endif /* _MB_CAPABLE */ |
if (prec >= 0) { |
/* |
* can't use strlen; can only look for the |
* NUL in the first `prec' characters, and |
* strlen () will go further. |
*/ |
char *p = memchr (cp, 0, prec); |
if (p != NULL) { |
size = p - cp; |
if (size > prec) |
size = prec; |
} else |
size = prec; |
} else |
size = strlen (cp); |
break; |
case 'U': /* extension */ |
flags |= LONGINT; |
/*FALLTHROUGH*/ |
case 'u': |
_uquad = UARG (); |
base = DEC; |
goto nosign; |
case 'X': |
xdigs = "0123456789ABCDEF"; |
goto hex; |
case 'x': |
xdigs = "0123456789abcdef"; |
hex: _uquad = UARG (); |
base = HEX; |
/* leading 0x/X only if non-zero */ |
if (flags & ALT && _uquad != 0) { |
ox[0] = '0'; |
ox[1] = ch; |
flags |= HEXPREFIX; |
} |
#ifdef _WANT_IO_C99_FORMATS |
flags &= ~GROUPING; |
#endif |
/* unsigned conversions */ |
nosign: sign = '\0'; |
/* |
* ``... diouXx conversions ... if a precision is |
* specified, the 0 flag will be ignored.'' |
* -- ANSI X3J11 |
*/ |
number: if ((dprec = prec) >= 0) |
flags &= ~ZEROPAD; |
/* |
* ``The result of converting a zero value with an |
* explicit precision of zero is no characters.'' |
* -- ANSI X3J11 |
*/ |
cp = buf + BUF; |
if (_uquad != 0 || prec != 0) { |
/* |
* Unsigned mod is hard, and unsigned mod |
* by a constant is easier than that by |
* a variable; hence this switch. |
*/ |
switch (base) { |
case OCT: |
do { |
*--cp = to_char (_uquad & 7); |
_uquad >>= 3; |
} while (_uquad); |
/* handle octal leading 0 */ |
if (flags & ALT && *cp != '0') |
*--cp = '0'; |
break; |
case DEC: |
/* many numbers are 1 digit */ |
if (_uquad < 10) { |
*--cp = to_char(_uquad); |
break; |
} |
#ifdef _WANT_IO_C99_FORMATS |
ndig = 0; |
#endif |
do { |
*--cp = to_char (_uquad % 10); |
#ifdef _WANT_IO_C99_FORMATS |
ndig++; |
/* If (*grouping == CHAR_MAX) then no |
more grouping */ |
if ((flags & GROUPING) |
&& ndig == *grouping |
&& *grouping != CHAR_MAX |
&& _uquad > 9) { |
cp -= thsnd_len; |
strncpy (cp, thousands_sep, |
thsnd_len); |
ndig = 0; |
/* If (grouping[1] == '\0') then we |
have to use *grouping character |
(last grouping rule) for all |
next cases. */ |
if (grouping[1] != '\0') |
grouping++; |
} |
#endif |
_uquad /= 10; |
} while (_uquad != 0); |
break; |
case HEX: |
do { |
*--cp = xdigs[_uquad & 15]; |
_uquad >>= 4; |
} while (_uquad); |
break; |
default: |
cp = "bug in vfprintf: bad base"; |
size = strlen (cp); |
goto skipsize; |
} |
} |
/* |
* ...result is to be converted to an 'alternate form'. |
* For o conversion, it increases the precision to force |
* the first digit of the result to be a zero." |
* -- ANSI X3J11 |
* |
* To demonstrate this case, compile and run: |
* printf ("%#.0o",0); |
*/ |
else if (base == OCT && (flags & ALT)) |
*--cp = '0'; |
size = buf + BUF - cp; |
skipsize: |
break; |
default: /* "%?" prints ?, unless ? is NUL */ |
if (ch == '\0') |
goto done; |
/* pretend it was %c with argument ch */ |
cp = buf; |
*cp = ch; |
size = 1; |
sign = '\0'; |
break; |
} |
/* |
* All reasonable formats wind up here. At this point, `cp' |
* points to a string which (if not flags&LADJUST) should be |
* padded out to `width' places. If flags&ZEROPAD, it should |
* first be prefixed by any sign or other prefix; otherwise, |
* it should be blank padded before the prefix is emitted. |
* After any left-hand padding and prefixing, emit zeroes |
* required by a decimal [diouxX] precision, then print the |
* string proper, then emit zeroes required by any leftover |
* floating precision; finally, if LADJUST, pad with blanks. |
* If flags&FPT, ch must be in [aAeEfg]. |
* |
* Compute actual size, so we know how much to pad. |
* size excludes decimal prec; realsz includes it. |
*/ |
realsz = dprec > size ? dprec : size; |
if (sign) |
realsz++; |
if (flags & HEXPREFIX) |
realsz+= 2; |
/* right-adjusting blank padding */ |
if ((flags & (LADJUST|ZEROPAD)) == 0) |
PAD (width - realsz, blanks); |
/* prefix */ |
if (sign) |
PRINT (&sign, 1); |
if (flags & HEXPREFIX) |
PRINT (ox, 2); |
/* right-adjusting zero padding */ |
if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) |
PAD (width - realsz, zeroes); |
/* leading zeroes from decimal precision */ |
PAD (dprec - size, zeroes); |
/* the string or number proper */ |
#ifdef FLOATING_POINT |
if ((flags & FPT) == 0) { |
PRINT (cp, size); |
} else { /* glue together f_p fragments */ |
if (ch >= 'f') { /* 'f' or 'g' */ |
if (_fpvalue == 0) { |
/* kludge for __dtoa irregularity */ |
PRINT ("0", 1); |
if (expt < ndig || flags & ALT) { |
PRINT (decimal_point, decp_len); |
PAD (ndig - 1, zeroes); |
} |
} else if (expt <= 0) { |
PRINT ("0", 1); |
if (expt || ndig || flags & ALT) { |
PRINT (decimal_point, decp_len); |
PAD (-expt, zeroes); |
PRINT (cp, ndig); |
} |
} else { |
char *convbuf = cp; |
PRINTANDPAD(cp, convbuf + ndig, |
lead, zeroes); |
cp += lead; |
#ifdef _WANT_IO_C99_FORMATS |
if (flags & GROUPING) { |
while (nseps > 0 || nrepeats > 0) { |
if (nrepeats > 0) |
nrepeats--; |
else { |
grouping--; |
nseps--; |
} |
PRINT(thousands_sep, thsnd_len); |
PRINTANDPAD (cp, convbuf + ndig, |
*grouping, zeroes); |
cp += *grouping; |
} |
if (cp > convbuf + ndig) |
cp = convbuf + ndig; |
} |
#endif |
if (expt < ndig || flags & ALT) |
PRINT (decimal_point, decp_len); |
PRINTANDPAD (cp, convbuf + ndig, |
ndig - expt, zeroes); |
} |
} else { /* 'a', 'A', 'e', or 'E' */ |
if (ndig > 1 || flags & ALT) { |
PRINT (cp, 1); |
cp++; |
PRINT (decimal_point, decp_len); |
if (_fpvalue) { |
PRINT (cp, ndig - 1); |
} else /* 0.[0..] */ |
/* __dtoa irregularity */ |
PAD (ndig - 1, zeroes); |
} else /* XeYYY */ |
PRINT (cp, 1); |
PRINT (expstr, expsize); |
} |
} |
#else /* !FLOATING_POINT */ |
PRINT (cp, size); |
#endif |
/* left-adjusting padding (always blank) */ |
if (flags & LADJUST) |
PAD (width - realsz, blanks); |
/* finally, adjust ret */ |
ret += width > realsz ? width : realsz; |
FLUSH (); /* copy out the I/O vectors */ |
if (malloc_buf != NULL) { |
_free_r (data, malloc_buf); |
malloc_buf = NULL; |
} |
} |
done: |
FLUSH (); |
error: |
if (malloc_buf != NULL) |
_free_r (data, malloc_buf); |
#ifndef STRING_ONLY |
_funlockfile (fp); |
#endif |
return (__sferror (fp) ? EOF : ret); |
/* NOTREACHED */ |
} |
#ifdef FLOATING_POINT |
/* Using reentrant DATA, convert finite VALUE into a string of digits |
with no decimal point, using NDIGITS precision and FLAGS as guides |
to whether trailing zeros must be included. Set *SIGN to nonzero |
if VALUE was negative. Set *DECPT to the exponent plus one. Set |
*LENGTH to the length of the returned string. CH must be one of |
[aAeEfFgG]; if it is [aA], then the return string lives in BUF, |
otherwise the return value shares the mprec reentrant storage. */ |
static char * |
cvt(struct _reent *data, _PRINTF_FLOAT_TYPE value, int ndigits, int flags, |
char *sign, int *decpt, int ch, int *length, char *buf) |
{ |
int mode, dsgn; |
char *digits, *bp, *rve; |
# ifdef _NO_LONGDBL |
union double_union tmp; |
tmp.d = value; |
if (word0 (tmp) & Sign_bit) { /* this will check for < 0 and -0.0 */ |
value = -value; |
*sign = '-'; |
} else |
*sign = '\000'; |
# else /* !_NO_LONGDBL */ |
union |
{ |
struct ldieee ieee; |
_LONG_DOUBLE val; |
} ld; |
ld.val = value; |
if (ld.ieee.sign) { /* this will check for < 0 and -0.0 */ |
value = -value; |
*sign = '-'; |
} else |
*sign = '\000'; |
# endif /* !_NO_LONGDBL */ |
# ifdef _WANT_IO_C99_FORMATS |
if (ch == 'a' || ch == 'A') { |
/* This code assumes FLT_RADIX is a power of 2. The initial |
division ensures the digit before the decimal will be less |
than FLT_RADIX (unless it is rounded later). There is no |
loss of precision in these calculations. */ |
value = FREXP (value, decpt) / 8; |
if (!value) |
*decpt = 1; |
digits = ch == 'a' ? "0123456789abcdef" : "0123456789ABCDEF"; |
bp = buf; |
do { |
value *= 16; |
mode = (int) value; |
value -= mode; |
*bp++ = digits[mode]; |
} while (ndigits-- && value); |
if (value > 0.5 || (value == 0.5 && mode & 1)) { |
/* round to even */ |
rve = bp; |
while (*--rve == digits[0xf]) { |
*rve = '0'; |
} |
*rve = *rve == '9' ? digits[0xa] : *rve + 1; |
} else { |
while (ndigits-- >= 0) { |
*bp++ = '0'; |
} |
} |
*length = bp - buf; |
return buf; |
} |
# endif /* _WANT_IO_C99_FORMATS */ |
if (ch == 'f' || ch == 'F') { |
mode = 3; /* ndigits after the decimal point */ |
} else { |
/* To obtain ndigits after the decimal point for the 'e' |
* and 'E' formats, round to ndigits + 1 significant |
* figures. |
*/ |
if (ch == 'e' || ch == 'E') { |
ndigits++; |
} |
mode = 2; /* ndigits significant digits */ |
} |
digits = _DTOA_R (data, value, mode, ndigits, decpt, &dsgn, &rve); |
if ((ch != 'g' && ch != 'G') || flags & ALT) { /* Print trailing zeros */ |
bp = digits + ndigits; |
if (ch == 'f' || ch == 'F') { |
if (*digits == '0' && value) |
*decpt = -ndigits + 1; |
bp += *decpt; |
} |
if (value == 0) /* kludge for __dtoa irregularity */ |
rve = bp; |
while (rve < bp) |
*rve++ = '0'; |
} |
*length = rve - digits; |
return (digits); |
} |
static int |
exponent(char *p0, int exp, int fmtch) |
{ |
register char *p, *t; |
char expbuf[MAXEXPLEN]; |
# ifdef _WANT_IO_C99_FORMATS |
int isa = fmtch == 'a' || fmtch == 'A'; |
# else |
# define isa 0 |
# endif |
p = p0; |
*p++ = isa ? 'p' - 'a' + fmtch : fmtch; |
if (exp < 0) { |
exp = -exp; |
*p++ = '-'; |
} |
else |
*p++ = '+'; |
t = expbuf + MAXEXPLEN; |
if (exp > 9) { |
do { |
*--t = to_char (exp % 10); |
} while ((exp /= 10) > 9); |
*--t = to_char (exp); |
for (; t < expbuf + MAXEXPLEN; *p++ = *t++); |
} |
else { |
if (!isa) |
*p++ = '0'; |
*p++ = to_char (exp); |
} |
return (p - p0); |
} |
#endif /* FLOATING_POINT */ |
#ifndef _NO_POS_ARGS |
/* Positional argument support. |
Written by Jeff Johnston |
Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ |
/* The below constant state tables are shared between all versions of |
vfprintf and vfwprintf. They must only be defined once, which we do in |
the STRING_ONLY/INTEGER_ONLY versions here. */ |
#if defined (STRING_ONLY) && defined(INTEGER_ONLY) |
_CONST __CH_CLASS __chclass[256] = { |
/* 00-07 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 08-0f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 10-17 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 18-1f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 20-27 */ FLAG, OTHER, OTHER, FLAG, DOLLAR, OTHER, OTHER, FLAG, |
/* 28-2f */ OTHER, OTHER, STAR, FLAG, OTHER, FLAG, DOT, OTHER, |
/* 30-37 */ ZERO, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, |
/* 38-3f */ DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 40-47 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC, |
/* 48-4f */ OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC, |
/* 50-57 */ OTHER, OTHER, OTHER, SPEC, OTHER, SPEC, OTHER, OTHER, |
/* 58-5f */ SPEC, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 60-67 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC, |
/* 68-6f */ MODFR, SPEC, MODFR, OTHER, MODFR, OTHER, SPEC, SPEC, |
/* 70-77 */ SPEC, MODFR, OTHER, SPEC, MODFR, SPEC, OTHER, OTHER, |
/* 78-7f */ SPEC, OTHER, MODFR, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 80-87 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 88-8f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 90-97 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 98-9f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* a0-a7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* a8-af */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* b0-b7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* b8-bf */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* c0-c7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* c8-cf */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* d0-d7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* d8-df */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* e0-e7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* e8-ef */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* f0-f7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* f8-ff */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
}; |
_CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS] = { |
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ |
/* START */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, |
/* SFLAG */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, |
/* WDIG */ { DONE, DONE, WIDTH, SMOD, DONE, SDOT, DONE, DONE, DONE }, |
/* WIDTH */ { DONE, DONE, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE }, |
/* SMOD */ { DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE }, |
/* SDOT */ { SDOT, PREC, DONE, SMOD, DONE, DONE, VARP, DONE, DONE }, |
/* VARW */ { DONE, VWDIG, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE }, |
/* VARP */ { DONE, VPDIG, DONE, SMOD, DONE, DONE, DONE, DONE, DONE }, |
/* PREC */ { DONE, DONE, DONE, SMOD, DONE, DONE, DONE, DONE, DONE }, |
/* VWDIG */ { DONE, DONE, WIDTH, DONE, DONE, DONE, DONE, DONE, DONE }, |
/* VPDIG */ { DONE, DONE, PREC, DONE, DONE, DONE, DONE, DONE, DONE }, |
}; |
_CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS] = { |
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ |
/* START */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* SFLAG */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* WDIG */ { NOOP, NOOP, GETPOS, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* WIDTH */ { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* SMOD */ { NOOP, NOOP, NOOP, NOOP, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* SDOT */ { NOOP, SKIPNUM, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* VARW */ { NOOP, NUMBER, NOOP, GETPW, GETPWB, GETPW, NOOP, NOOP, NOOP }, |
/* VARP */ { NOOP, NUMBER, NOOP, GETPW, GETPWB, NOOP, NOOP, NOOP, NOOP }, |
/* PREC */ { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* VWDIG */ { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP }, |
/* VPDIG */ { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP }, |
}; |
#endif /* STRING_ONLY && INTEGER_ONLY */ |
/* function to get positional parameter N where n = N - 1 */ |
static union arg_val * |
_DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt), |
struct _reent *data _AND |
int n _AND |
char *fmt _AND |
va_list *ap _AND |
int *numargs_p _AND |
union arg_val *args _AND |
int *arg_type _AND |
char **last_fmt) |
{ |
int ch; |
int number, flags; |
int spec_type; |
int numargs = *numargs_p; |
__CH_CLASS chtype; |
__STATE state, next_state; |
__ACTION action; |
int pos, last_arg; |
int max_pos_arg = n; |
/* Only need types that can be reached via vararg promotions. */ |
enum types { INT, LONG_INT, QUAD_INT, CHAR_PTR, DOUBLE, LONG_DOUBLE, WIDE_CHAR }; |
# ifdef _MB_CAPABLE |
wchar_t wc; |
mbstate_t wc_state; |
int nbytes; |
# endif |
/* if this isn't the first call, pick up where we left off last time */ |
if (*last_fmt != NULL) |
fmt = *last_fmt; |
# ifdef _MB_CAPABLE |
memset (&wc_state, '\0', sizeof (wc_state)); |
# endif |
/* we need to process either to end of fmt string or until we have actually |
read the desired parameter from the vararg list. */ |
while (*fmt && n >= numargs) |
{ |
# ifdef _MB_CAPABLE |
while ((nbytes = __mbtowc (data, &wc, fmt, MB_CUR_MAX, |
__locale_charset (), &wc_state)) > 0) |
{ |
fmt += nbytes; |
if (wc == '%') |
break; |
} |
if (nbytes <= 0) |
break; |
# else |
while (*fmt != '\0' && *fmt != '%') |
fmt += 1; |
if (*fmt == '\0') |
break; |
# endif /* ! _MB_CAPABLE */ |
state = START; |
flags = 0; |
pos = -1; |
number = 0; |
spec_type = INT; |
/* Use state/action table to process format specifiers. We ignore invalid |
formats and we are only interested in information that tells us how to |
read the vararg list. */ |
while (state != DONE) |
{ |
ch = *fmt++; |
chtype = __chclass[ch]; |
next_state = __state_table[state][chtype]; |
action = __action_table[state][chtype]; |
state = next_state; |
switch (action) |
{ |
case GETMOD: /* we have format modifier */ |
switch (ch) |
{ |
case 'h': |
/* No flag needed, since short and char promote to int. */ |
break; |
case 'L': |
flags |= LONGDBL; |
break; |
case 'q': |
flags |= QUADINT; |
break; |
# ifdef _WANT_IO_C99_FORMATS |
case 'j': |
if (sizeof (intmax_t) == sizeof (long)) |
flags |= LONGINT; |
else |
flags |= QUADINT; |
break; |
case 'z': |
if (sizeof (size_t) <= sizeof (int)) |
/* no flag needed */; |
else if (sizeof (size_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support size_t no wider than |
long, but that means other environments can |
have size_t as wide as long long. */ |
flags |= QUADINT; |
break; |
case 't': |
if (sizeof (ptrdiff_t) <= sizeof (int)) |
/* no flag needed */; |
else if (sizeof (ptrdiff_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support ptrdiff_t no wider than |
long, but that means other environments can |
have ptrdiff_t as wide as long long. */ |
flags |= QUADINT; |
break; |
# endif /* _WANT_IO_C99_FORMATS */ |
case 'l': |
default: |
# if defined _WANT_IO_C99_FORMATS || !defined _NO_LONGLONG |
if (*fmt == 'l') |
{ |
flags |= QUADINT; |
++fmt; |
} |
else |
# endif |
flags |= LONGINT; |
break; |
} |
break; |
case GETARG: /* we have format specifier */ |
{ |
numargs &= (MAX_POS_ARGS - 1); |
/* process the specifier and translate it to a type to fetch from varargs */ |
switch (ch) |
{ |
case 'd': |
case 'i': |
case 'o': |
case 'x': |
case 'X': |
case 'u': |
if (flags & LONGINT) |
spec_type = LONG_INT; |
# ifndef _NO_LONGLONG |
else if (flags & QUADINT) |
spec_type = QUAD_INT; |
# endif |
else |
spec_type = INT; |
break; |
case 'D': |
case 'U': |
case 'O': |
spec_type = LONG_INT; |
break; |
# ifdef _WANT_IO_C99_FORMATS |
case 'a': |
case 'A': |
case 'F': |
# endif |
case 'f': |
case 'g': |
case 'G': |
case 'E': |
case 'e': |
# ifndef _NO_LONGDBL |
if (flags & LONGDBL) |
spec_type = LONG_DOUBLE; |
else |
# endif |
spec_type = DOUBLE; |
break; |
case 's': |
# ifdef _WANT_IO_C99_FORMATS |
case 'S': |
# endif |
case 'p': |
case 'n': |
spec_type = CHAR_PTR; |
break; |
case 'c': |
# ifdef _WANT_IO_C99_FORMATS |
if (flags & LONGINT) |
spec_type = WIDE_CHAR; |
else |
# endif |
spec_type = INT; |
break; |
# ifdef _WANT_IO_C99_FORMATS |
case 'C': |
spec_type = WIDE_CHAR; |
break; |
# endif |
} |
/* if we have a positional parameter, just store the type, otherwise |
fetch the parameter from the vararg list */ |
if (pos != -1) |
arg_type[pos] = spec_type; |
else |
{ |
switch (spec_type) |
{ |
case LONG_INT: |
args[numargs++].val_long = va_arg (*ap, long); |
break; |
case QUAD_INT: |
args[numargs++].val_quad_t = va_arg (*ap, quad_t); |
break; |
case WIDE_CHAR: |
args[numargs++].val_wint_t = va_arg (*ap, wint_t); |
break; |
case INT: |
args[numargs++].val_int = va_arg (*ap, int); |
break; |
case CHAR_PTR: |
args[numargs++].val_char_ptr_t = va_arg (*ap, char *); |
break; |
case DOUBLE: |
args[numargs++].val_double = va_arg (*ap, double); |
break; |
case LONG_DOUBLE: |
args[numargs++].val__LONG_DOUBLE = va_arg (*ap, _LONG_DOUBLE); |
break; |
} |
} |
} |
break; |
case GETPOS: /* we have positional specifier */ |
if (arg_type[0] == -1) |
memset (arg_type, 0, sizeof (int) * MAX_POS_ARGS); |
pos = number - 1; |
max_pos_arg = (max_pos_arg > pos ? max_pos_arg : pos); |
break; |
case PWPOS: /* we have positional specifier for width or precision */ |
if (arg_type[0] == -1) |
memset (arg_type, 0, sizeof (int) * MAX_POS_ARGS); |
number -= 1; |
arg_type[number] = INT; |
max_pos_arg = (max_pos_arg > number ? max_pos_arg : number); |
break; |
case GETPWB: /* we require format pushback */ |
--fmt; |
/* fallthrough */ |
case GETPW: /* we have a variable precision or width to acquire */ |
args[numargs++].val_int = va_arg (*ap, int); |
break; |
case NUMBER: /* we have a number to process */ |
number = (ch - '0'); |
while ((ch = *fmt) != '\0' && is_digit (ch)) |
{ |
number = number * 10 + (ch - '0'); |
++fmt; |
} |
break; |
case SKIPNUM: /* we have a number to skip */ |
while ((ch = *fmt) != '\0' && is_digit (ch)) |
++fmt; |
break; |
case NOOP: |
default: |
break; /* do nothing */ |
} |
} |
} |
/* process all arguments up to at least the one we are looking for and if we |
have seen the end of the string, then process up to the max argument needed */ |
if (*fmt == '\0') |
last_arg = max_pos_arg; |
else |
last_arg = n; |
while (numargs <= last_arg) |
{ |
switch (arg_type[numargs]) |
{ |
case LONG_INT: |
args[numargs++].val_long = va_arg (*ap, long); |
break; |
case QUAD_INT: |
args[numargs++].val_quad_t = va_arg (*ap, quad_t); |
break; |
case CHAR_PTR: |
args[numargs++].val_char_ptr_t = va_arg (*ap, char *); |
break; |
case DOUBLE: |
args[numargs++].val_double = va_arg (*ap, double); |
break; |
case LONG_DOUBLE: |
args[numargs++].val__LONG_DOUBLE = va_arg (*ap, _LONG_DOUBLE); |
break; |
case WIDE_CHAR: |
args[numargs++].val_wint_t = va_arg (*ap, wint_t); |
break; |
case INT: |
default: |
args[numargs++].val_int = va_arg (*ap, int); |
break; |
} |
} |
/* alter the global numargs value and keep a reference to the last bit of the fmt |
string we processed here because the caller will continue processing where we started */ |
*numargs_p = numargs; |
*last_fmt = fmt; |
return &args[n]; |
} |
#endif /* !_NO_POS_ARGS */ |
/programs/develop/libraries/newlib/stdio/vfscanf.c |
---|
0,0 → 1,1622 |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<vfscanf>>, <<vscanf>>, <<vsscanf>>---format argument list |
INDEX |
vfscanf |
INDEX |
_vfscanf_r |
INDEX |
vscanf |
INDEX |
_vscanf_r |
INDEX |
vsscanf |
INDEX |
_vsscanf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <stdarg.h> |
int vscanf(const char *<[fmt]>, va_list <[list]>); |
int vfscanf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); |
int vsscanf(const char *<[str]>, const char *<[fmt]>, va_list <[list]>); |
int _vscanf_r(struct _reent *<[reent]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vfscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vsscanf_r(struct _reent *<[reent]>, const char *<[str]>, |
const char *<[fmt]>, va_list <[list]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
#include <varargs.h> |
int vscanf( <[fmt]>, <[ist]>) |
char *<[fmt]>; |
va_list <[list]>; |
int vfscanf( <[fp]>, <[fmt]>, <[list]>) |
FILE *<[fp]>; |
char *<[fmt]>; |
va_list <[list]>; |
int vsscanf( <[str]>, <[fmt]>, <[list]>) |
char *<[str]>; |
char *<[fmt]>; |
va_list <[list]>; |
int _vscanf_r( <[reent]>, <[fmt]>, <[ist]>) |
struct _reent *<[reent]>; |
char *<[fmt]>; |
va_list <[list]>; |
int _vfscanf_r( <[reent]>, <[fp]>, <[fmt]>, <[list]>) |
struct _reent *<[reent]>; |
FILE *<[fp]>; |
char *<[fmt]>; |
va_list <[list]>; |
int _vsscanf_r( <[reent]>, <[str]>, <[fmt]>, <[list]>) |
struct _reent *<[reent]>; |
char *<[str]>; |
char *<[fmt]>; |
va_list <[list]>; |
DESCRIPTION |
<<vscanf>>, <<vfscanf>>, and <<vsscanf>> are (respectively) variants |
of <<scanf>>, <<fscanf>>, and <<sscanf>>. They differ only in |
allowing their caller to pass the variable argument list as a |
<<va_list>> object (initialized by <<va_start>>) rather than |
directly accepting a variable number of arguments. |
RETURNS |
The return values are consistent with the corresponding functions: |
<<vscanf>> returns the number of input fields successfully scanned, |
converted, and stored; the return value does not include scanned |
fields which were not stored. |
If <<vscanf>> attempts to read at end-of-file, the return value |
is <<EOF>>. |
If no fields were stored, the return value is <<0>>. |
The routines <<_vscanf_r>>, <<_vfscanf_f>>, and <<_vsscanf_r>> are |
reentrant versions which take an additional first parameter which points to the |
reentrancy structure. |
PORTABILITY |
These are GNU extensions. |
Supporting OS subroutines required: |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <newlib.h> |
#include <ctype.h> |
#include <wctype.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdint.h> |
#include <limits.h> |
#include <wchar.h> |
#include <string.h> |
#include <stdarg.h> |
#include <errno.h> |
#include "local.h" |
#include "../stdlib/local.h" |
#ifdef INTEGER_ONLY |
#define VFSCANF vfiscanf |
#define _VFSCANF_R _vfiscanf_r |
#define __SVFSCANF __svfiscanf |
#ifdef STRING_ONLY |
# define __SVFSCANF_R __ssvfiscanf_r |
#else |
# define __SVFSCANF_R __svfiscanf_r |
#endif |
#else |
#define VFSCANF vfscanf |
#define _VFSCANF_R _vfscanf_r |
#define __SVFSCANF __svfscanf |
#ifdef STRING_ONLY |
# define __SVFSCANF_R __ssvfscanf_r |
#else |
# define __SVFSCANF_R __svfscanf_r |
#endif |
#ifndef NO_FLOATING_POINT |
#define FLOATING_POINT |
#endif |
#endif |
#ifdef STRING_ONLY |
#undef _flockfile |
#undef _funlockfile |
#define _flockfile(x) {} |
#define _funlockfile(x) {} |
#define _ungetc_r _sungetc_r |
#define __srefill_r __ssrefill_r |
#define _fread_r _sfread_r |
#endif |
#ifdef FLOATING_POINT |
#include <math.h> |
#include <float.h> |
/* Currently a test is made to see if long double processing is warranted. |
This could be changed in the future should the _ldtoa_r code be |
preferred over _dtoa_r. */ |
#define _NO_LONGDBL |
#if defined _WANT_IO_LONG_DOUBLE && (LDBL_MANT_DIG > DBL_MANT_DIG) |
#undef _NO_LONGDBL |
extern _LONG_DOUBLE _strtold _PARAMS((char *s, char **sptr)); |
#endif |
#include "floatio.h" |
#if ((MAXEXP+MAXFRACT+3) > MB_LEN_MAX) |
# define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */ |
#else |
# define BUF MB_LEN_MAX |
#endif |
/* An upper bound for how long a long prints in decimal. 4 / 13 approximates |
log (2). Add one char for roundoff compensation and one for the sign. */ |
#define MAX_LONG_LEN ((CHAR_BIT * sizeof (long) - 1) * 4 / 13 + 2) |
#else |
#define BUF 40 |
#endif |
#define _NO_LONGLONG |
#if defined _WANT_IO_LONG_LONG \ |
&& (defined __GNUC__ || __STDC_VERSION__ >= 199901L) |
# undef _NO_LONGLONG |
#endif |
#define _NO_POS_ARGS |
#ifdef _WANT_IO_POS_ARGS |
# undef _NO_POS_ARGS |
# ifdef NL_ARGMAX |
# define MAX_POS_ARGS NL_ARGMAX |
# else |
# define MAX_POS_ARGS 32 |
# endif |
static void * get_arg (int, va_list *, int *, void **); |
#endif /* _WANT_IO_POS_ARGS */ |
/* |
* Flags used during conversion. |
*/ |
#define LONG 0x01 /* l: long or double */ |
#define LONGDBL 0x02 /* L/ll: long double or long long */ |
#define SHORT 0x04 /* h: short */ |
#define CHAR 0x08 /* hh: 8 bit integer */ |
#define SUPPRESS 0x10 /* suppress assignment */ |
#define POINTER 0x20 /* weird %p pointer (`fake hex') */ |
#define NOSKIP 0x40 /* do not skip blanks */ |
/* |
* The following are used in numeric conversions only: |
* SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point; |
* SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. |
*/ |
#define SIGNOK 0x80 /* +/- is (still) legal */ |
#define NDIGITS 0x100 /* no digits detected */ |
#define DPTOK 0x200 /* (float) decimal point is still legal */ |
#define EXPOK 0x400 /* (float) exponent (e+3, etc) still legal */ |
#define PFXOK 0x200 /* 0x prefix is (still) legal */ |
#define NZDIGITS 0x400 /* no zero digits detected */ |
#define NNZDIGITS 0x800 /* no non-zero digits detected */ |
/* |
* Conversion types. |
*/ |
#define CT_CHAR 0 /* %c conversion */ |
#define CT_CCL 1 /* %[...] conversion */ |
#define CT_STRING 2 /* %s conversion */ |
#define CT_INT 3 /* integer, i.e., strtol or strtoul */ |
#define CT_FLOAT 4 /* floating, i.e., strtod */ |
#if 0 |
#define u_char unsigned char |
#endif |
#define u_char char |
#define u_long unsigned long |
#ifndef _NO_LONGLONG |
typedef unsigned long long u_long_long; |
#endif |
/* |
* vfscanf |
*/ |
#define BufferEmpty (fp->_r <= 0 && __srefill_r(rptr, fp)) |
#ifndef STRING_ONLY |
#ifndef _REENT_ONLY |
int |
_DEFUN(VFSCANF, (fp, fmt, ap), |
register FILE *fp _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
CHECK_INIT(_REENT, fp); |
return __SVFSCANF_R (_REENT, fp, fmt, ap); |
} |
int |
_DEFUN(__SVFSCANF, (fp, fmt0, ap), |
register FILE *fp _AND |
char _CONST *fmt0 _AND |
va_list ap) |
{ |
return __SVFSCANF_R (_REENT, fp, fmt0, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_VFSCANF_R, (data, fp, fmt, ap), |
struct _reent *data _AND |
register FILE *fp _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
CHECK_INIT(data, fp); |
return __SVFSCANF_R (data, fp, fmt, ap); |
} |
#endif /* !STRING_ONLY */ |
#if defined (STRING_ONLY) && defined (INTEGER_ONLY) |
/* When dealing with the sscanf family, we don't want to use the |
* regular ungetc which will drag in file I/O items we don't need. |
* So, we create our own trimmed-down version. */ |
int |
_DEFUN(_sungetc_r, (data, fp, ch), |
struct _reent *data _AND |
int c _AND |
register FILE *fp) |
{ |
if (c == EOF) |
return (EOF); |
/* After ungetc, we won't be at eof anymore */ |
fp->_flags &= ~__SEOF; |
c = (unsigned char) c; |
/* |
* If we are in the middle of ungetc'ing, just continue. |
* This may require expanding the current ungetc buffer. |
*/ |
if (HASUB (fp)) |
{ |
if (fp->_r >= fp->_ub._size && __submore (data, fp)) |
{ |
return EOF; |
} |
*--fp->_p = c; |
fp->_r++; |
return c; |
} |
/* |
* If we can handle this by simply backing up, do so, |
* but never replace the original character. |
* (This makes sscanf() work when scanning `const' data.) |
*/ |
if (fp->_bf._base != NULL && fp->_p > fp->_bf._base && fp->_p[-1] == c) |
{ |
fp->_p--; |
fp->_r++; |
return c; |
} |
/* |
* Create an ungetc buffer. |
* Initially, we will use the `reserve' buffer. |
*/ |
fp->_ur = fp->_r; |
fp->_up = fp->_p; |
fp->_ub._base = fp->_ubuf; |
fp->_ub._size = sizeof (fp->_ubuf); |
fp->_ubuf[sizeof (fp->_ubuf) - 1] = c; |
fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1]; |
fp->_r = 1; |
return c; |
} |
/* String only version of __srefill_r for sscanf family. */ |
int |
_DEFUN(__ssrefill_r, (ptr, fp), |
struct _reent * ptr _AND |
register FILE * fp) |
{ |
/* |
* Our only hope of further input is the ungetc buffer. |
* If there is anything in that buffer to read, return. |
*/ |
if (HASUB (fp)) |
{ |
FREEUB (ptr, fp); |
if ((fp->_r = fp->_ur) != 0) |
{ |
fp->_p = fp->_up; |
return 0; |
} |
} |
/* Otherwise we are out of character input. */ |
fp->_p = fp->_bf._base; |
fp->_r = 0; |
fp->_flags |= __SEOF; |
return EOF; |
} |
size_t |
_DEFUN(_sfread_r, (ptr, buf, size, count, fp), |
struct _reent * ptr _AND |
_PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
register size_t resid; |
register char *p; |
register int r; |
size_t total; |
if ((resid = count * size) == 0) |
return 0; |
total = resid; |
p = buf; |
while (resid > (r = fp->_r)) |
{ |
_CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, (size_t) r); |
fp->_p += r; |
fp->_r = 0; |
p += r; |
resid -= r; |
if (__ssrefill_r (ptr, fp)) |
{ |
/* no more input: return partial result */ |
return (total - resid) / size; |
} |
} |
_CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, resid); |
fp->_r -= resid; |
fp->_p += resid; |
return count; |
} |
#else /* !STRING_ONLY || !INTEGER_ONLY */ |
int _EXFUN (_sungetc_r, (struct _reent *, int, register FILE *)); |
int _EXFUN (__ssrefill_r, (struct _reent *, register FILE *)); |
size_t _EXFUN (_sfread_r, (struct _reent *, _PTR buf, size_t, size_t, FILE *)); |
#endif /* !STRING_ONLY || !INTEGER_ONLY */ |
int |
_DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), |
struct _reent *rptr _AND |
register FILE *fp _AND |
char _CONST *fmt0 _AND |
va_list ap) |
{ |
register u_char *fmt = (u_char *) fmt0; |
register int c; /* character from format, or conversion */ |
register size_t width; /* field width, or 0 */ |
register char *p; /* points into all kinds of strings */ |
register int n; /* handy integer */ |
register int flags; /* flags as defined above */ |
register char *p0; /* saves original value of p when necessary */ |
int nassigned; /* number of fields assigned */ |
int nread; /* number of characters consumed from fp */ |
#ifndef _NO_POS_ARGS |
int N; /* arg number */ |
int arg_index = 0; /* index into args processed directly */ |
int numargs = 0; /* number of varargs read */ |
void *args[MAX_POS_ARGS]; /* positional args read */ |
int is_pos_arg; /* is current format positional? */ |
#endif |
int base = 0; /* base argument to strtol/strtoul */ |
int nbytes = 1; /* number of bytes read from fmt string */ |
wchar_t wc; /* wchar to use to read format string */ |
wchar_t *wcp; /* handy wide character pointer */ |
size_t mbslen; /* length of converted multibyte sequence */ |
mbstate_t state; /* value to keep track of multibyte state */ |
#define CCFN_PARAMS _PARAMS((struct _reent *, const char *, char **, int)) |
u_long (*ccfn)CCFN_PARAMS=0; /* conversion function (strtol/strtoul) */ |
char ccltab[256]; /* character class table for %[...] */ |
char buf[BUF]; /* buffer for numeric conversions */ |
unsigned char *lptr; /* literal pointer */ |
char *cp; |
short *sp; |
int *ip; |
#ifdef FLOATING_POINT |
float *flp; |
_LONG_DOUBLE *ldp; |
double *dp; |
#endif |
long *lp; |
#ifndef _NO_LONGLONG |
long long *llp; |
#endif |
/* `basefix' is used to avoid `if' tests in the integer scanner */ |
static _CONST short basefix[17] = |
{10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; |
/* Macro to support positional arguments */ |
#ifndef _NO_POS_ARGS |
# define GET_ARG(n, ap, type) \ |
((type) (is_pos_arg \ |
? (n < numargs \ |
? args[n] \ |
: get_arg (n, &ap, &numargs, args)) \ |
: (arg_index++ < numargs \ |
? args[n] \ |
: (numargs < MAX_POS_ARGS \ |
? args[numargs++] = va_arg (ap, void *) \ |
: va_arg (ap, void *))))) |
#else |
# define GET_ARG(n, ap, type) (va_arg (ap, type)) |
#endif |
__sfp_lock_acquire (); |
_flockfile (fp); |
ORIENT (fp, -1); |
nassigned = 0; |
nread = 0; |
#ifdef _MB_CAPABLE |
memset (&state, 0, sizeof (state)); |
#endif |
for (;;) |
{ |
#ifndef _MB_CAPABLE |
wc = *fmt; |
#else |
nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (), |
&state); |
if (nbytes < 0) { |
wc = 0xFFFD; /* Unicode replacement character */ |
nbytes = 1; |
memset (&state, 0, sizeof (state)); |
} |
#endif |
fmt += nbytes; |
if (wc == 0) |
goto all_done; |
if (nbytes == 1 && isspace (wc)) |
{ |
for (;;) |
{ |
if (BufferEmpty || !isspace (*fp->_p)) |
break; |
nread++, fp->_r--, fp->_p++; |
} |
continue; |
} |
if (wc != '%') |
goto literal; |
width = 0; |
flags = 0; |
#ifndef _NO_POS_ARGS |
N = arg_index; |
is_pos_arg = 0; |
#endif |
/* |
* switch on the format. continue if done; break once format |
* type is derived. |
*/ |
again: |
c = *fmt++; |
switch (c) |
{ |
case '%': |
literal: |
lptr = fmt - nbytes; |
for (n = 0; n < nbytes; ++n) |
{ |
if (BufferEmpty) |
goto input_failure; |
if (*fp->_p != *lptr) |
goto match_failure; |
fp->_r--, fp->_p++; |
nread++; |
++lptr; |
} |
continue; |
case '*': |
flags |= SUPPRESS; |
goto again; |
case 'l': |
#if defined _WANT_IO_C99_FORMATS || !defined _NO_LONGLONG |
if (*fmt == 'l') /* Check for 'll' = long long (SUSv3) */ |
{ |
++fmt; |
flags |= LONGDBL; |
} |
else |
#endif |
flags |= LONG; |
goto again; |
case 'L': |
flags |= LONGDBL; |
goto again; |
case 'h': |
#ifdef _WANT_IO_C99_FORMATS |
if (*fmt == 'h') /* Check for 'hh' = char int (SUSv3) */ |
{ |
++fmt; |
flags |= CHAR; |
} |
else |
#endif |
flags |= SHORT; |
goto again; |
#ifdef _WANT_IO_C99_FORMATS |
case 'j': /* intmax_t */ |
if (sizeof (intmax_t) == sizeof (long)) |
flags |= LONG; |
else |
flags |= LONGDBL; |
goto again; |
case 't': /* ptrdiff_t */ |
if (sizeof (ptrdiff_t) < sizeof (int)) |
/* POSIX states ptrdiff_t is 16 or more bits, as |
is short. */ |
flags |= SHORT; |
else if (sizeof (ptrdiff_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (ptrdiff_t) <= sizeof (long)) |
flags |= LONG; |
else |
/* POSIX states that at least one programming |
environment must support ptrdiff_t no wider than |
long, but that means other environments can |
have ptrdiff_t as wide as long long. */ |
flags |= LONGDBL; |
goto again; |
case 'z': /* size_t */ |
if (sizeof (size_t) < sizeof (int)) |
/* POSIX states size_t is 16 or more bits, as is short. */ |
flags |= SHORT; |
else if (sizeof (size_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (size_t) <= sizeof (long)) |
flags |= LONG; |
else |
/* POSIX states that at least one programming |
environment must support size_t no wider than |
long, but that means other environments can |
have size_t as wide as long long. */ |
flags |= LONGDBL; |
goto again; |
#endif /* _WANT_IO_C99_FORMATS */ |
case '0': |
case '1': |
case '2': |
case '3': |
case '4': |
case '5': |
case '6': |
case '7': |
case '8': |
case '9': |
width = width * 10 + c - '0'; |
goto again; |
#ifndef _NO_POS_ARGS |
case '$': |
if (width <= MAX_POS_ARGS) |
{ |
N = width - 1; |
is_pos_arg = 1; |
width = 0; |
goto again; |
} |
rptr->_errno = EINVAL; |
goto input_failure; |
#endif /* !_NO_POS_ARGS */ |
/* |
* Conversions. Those marked `compat' are for |
* 4.[123]BSD compatibility. |
* |
* (According to ANSI, E and X formats are supposed to |
* the same as e and x. Sorry about that.) |
*/ |
case 'D': /* compat */ |
flags |= LONG; |
/* FALLTHROUGH */ |
case 'd': |
c = CT_INT; |
ccfn = (u_long (*)CCFN_PARAMS)_strtol_r; |
base = 10; |
break; |
case 'i': |
c = CT_INT; |
ccfn = (u_long (*)CCFN_PARAMS)_strtol_r; |
base = 0; |
break; |
case 'O': /* compat */ |
flags |= LONG; |
/* FALLTHROUGH */ |
case 'o': |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 8; |
break; |
case 'u': |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 10; |
break; |
case 'X': |
case 'x': |
flags |= PFXOK; /* enable 0x prefixing */ |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 16; |
break; |
#ifdef FLOATING_POINT |
# ifdef _WANT_IO_C99_FORMATS |
case 'a': |
case 'A': |
case 'F': |
# endif |
case 'E': |
case 'G': |
case 'e': |
case 'f': |
case 'g': |
c = CT_FLOAT; |
break; |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
case 'S': |
flags |= LONG; |
/* FALLTHROUGH */ |
#endif |
case 's': |
c = CT_STRING; |
break; |
case '[': |
fmt = (u_char *) __sccl (ccltab, (unsigned char *) fmt); |
flags |= NOSKIP; |
c = CT_CCL; |
break; |
#ifdef _WANT_IO_C99_FORMATS |
case 'C': |
flags |= LONG; |
/* FALLTHROUGH */ |
#endif |
case 'c': |
flags |= NOSKIP; |
c = CT_CHAR; |
break; |
case 'p': /* pointer format is like hex */ |
flags |= POINTER | PFXOK; |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 16; |
break; |
case 'n': |
if (flags & SUPPRESS) /* ??? */ |
continue; |
#ifdef _WANT_IO_C99_FORMATS |
if (flags & CHAR) |
{ |
cp = GET_ARG (N, ap, char *); |
*cp = nread; |
} |
else |
#endif |
if (flags & SHORT) |
{ |
sp = GET_ARG (N, ap, short *); |
*sp = nread; |
} |
else if (flags & LONG) |
{ |
lp = GET_ARG (N, ap, long *); |
*lp = nread; |
} |
#ifndef _NO_LONGLONG |
else if (flags & LONGDBL) |
{ |
llp = GET_ARG (N, ap, long long*); |
*llp = nread; |
} |
#endif |
else |
{ |
ip = GET_ARG (N, ap, int *); |
*ip = nread; |
} |
continue; |
/* |
* Disgusting backwards compatibility hacks. XXX |
*/ |
case '\0': /* compat */ |
_funlockfile (fp); |
__sfp_lock_release (); |
return EOF; |
default: /* compat */ |
if (isupper (c)) |
flags |= LONG; |
c = CT_INT; |
ccfn = (u_long (*)CCFN_PARAMS)_strtol_r; |
base = 10; |
break; |
} |
/* |
* We have a conversion that requires input. |
*/ |
if (BufferEmpty) |
goto input_failure; |
/* |
* Consume leading white space, except for formats that |
* suppress this. |
*/ |
if ((flags & NOSKIP) == 0) |
{ |
while (isspace (*fp->_p)) |
{ |
nread++; |
if (--fp->_r > 0) |
fp->_p++; |
else |
if (__srefill_r (rptr, fp)) |
goto input_failure; |
} |
/* |
* Note that there is at least one character in the |
* buffer, so conversions that do not set NOSKIP ca |
* no longer result in an input failure. |
*/ |
} |
/* |
* Do the conversion. |
*/ |
switch (c) |
{ |
case CT_CHAR: |
/* scan arbitrary characters (sets NOSKIP) */ |
if (width == 0) |
width = 1; |
#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 2 |
if (flags & LONG) |
{ |
mbstate_t state; |
memset (&state, 0, sizeof (mbstate_t)); |
if ((flags & SUPPRESS) == 0) |
wcp = GET_ARG (N, ap, wchar_t *); |
else |
wcp = NULL; |
n = 0; |
while (width != 0) |
{ |
if (n == MB_CUR_MAX) |
goto input_failure; |
buf[n++] = *fp->_p; |
fp->_r -= 1; |
fp->_p += 1; |
if ((mbslen = _mbrtowc_r (rptr, wcp, buf, n, &state)) |
== (size_t)-1) |
goto input_failure; /* Invalid sequence */ |
if (mbslen == 0 && !(flags & SUPPRESS)) |
*wcp = L'\0'; |
if (mbslen != (size_t)-2) /* Incomplete sequence */ |
{ |
nread += n; |
width -= 1; |
if (!(flags & SUPPRESS)) |
wcp += 1; |
n = 0; |
} |
if (BufferEmpty) |
{ |
if (n != 0) |
goto input_failure; |
break; |
} |
} |
if (!(flags & SUPPRESS)) |
nassigned++; |
} |
else |
#endif |
if (flags & SUPPRESS) |
{ |
size_t sum = 0; |
for (;;) |
{ |
if ((n = fp->_r) < (int)width) |
{ |
sum += n; |
width -= n; |
fp->_p += n; |
if (__srefill_r (rptr, fp)) |
{ |
if (sum == 0) |
goto input_failure; |
break; |
} |
} |
else |
{ |
sum += width; |
fp->_r -= width; |
fp->_p += width; |
break; |
} |
} |
nread += sum; |
} |
else |
{ |
size_t r = _fread_r (rptr, (_PTR) GET_ARG (N, ap, char *), 1, width, fp); |
if (r == 0) |
goto input_failure; |
nread += r; |
nassigned++; |
} |
break; |
case CT_CCL: |
/* scan a (nonempty) character class (sets NOSKIP) */ |
if (width == 0) |
width = ~0; /* `infinity' */ |
/* take only those things in the class */ |
if (flags & SUPPRESS) |
{ |
n = 0; |
while (ccltab[*fp->_p]) |
{ |
n++, fp->_r--, fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
{ |
if (n == 0) |
goto input_failure; |
break; |
} |
} |
if (n == 0) |
goto match_failure; |
} |
else |
{ |
p0 = p = GET_ARG (N, ap, char *); |
while (ccltab[*fp->_p]) |
{ |
fp->_r--; |
*p++ = *fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
{ |
if (p == p0) |
goto input_failure; |
break; |
} |
} |
n = p - p0; |
if (n == 0) |
goto match_failure; |
*p = 0; |
nassigned++; |
} |
nread += n; |
break; |
case CT_STRING: |
/* like CCL, but zero-length string OK, & no NOSKIP */ |
if (width == 0) |
width = (size_t)~0; |
#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 2 |
if (flags & LONG) |
{ |
/* Process %S and %ls placeholders */ |
mbstate_t state; |
memset (&state, 0, sizeof (mbstate_t)); |
if ((flags & SUPPRESS) == 0) |
wcp = GET_ARG (N, ap, wchar_t *); |
else |
wcp = &wc; |
n = 0; |
while (!isspace (*fp->_p) && width != 0) |
{ |
if (n == MB_CUR_MAX) |
goto input_failure; |
buf[n++] = *fp->_p; |
fp->_r -= 1; |
fp->_p += 1; |
if ((mbslen = _mbrtowc_r (rptr, wcp, buf, n, &state)) |
== (size_t)-1) |
goto input_failure; |
if (mbslen == 0) |
*wcp = L'\0'; |
if (mbslen != (size_t)-2) /* Incomplete sequence */ |
{ |
if (iswspace(*wcp)) |
{ |
while (n != 0) |
_ungetc_r (rptr, (unsigned char) buf[--n], fp); |
break; |
} |
nread += n; |
width -= 1; |
if ((flags & SUPPRESS) == 0) |
wcp += 1; |
n = 0; |
} |
if (BufferEmpty) |
{ |
if (n != 0) |
goto input_failure; |
break; |
} |
} |
if (!(flags & SUPPRESS)) |
{ |
*wcp = L'\0'; |
nassigned++; |
} |
} |
else |
#endif |
if (flags & SUPPRESS) |
{ |
n = 0; |
while (!isspace (*fp->_p)) |
{ |
n++, fp->_r--, fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
break; |
} |
nread += n; |
} |
else |
{ |
p0 = p = GET_ARG (N, ap, char *); |
while (!isspace (*fp->_p)) |
{ |
fp->_r--; |
*p++ = *fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
break; |
} |
*p = 0; |
nread += p - p0; |
nassigned++; |
} |
continue; |
case CT_INT: |
{ |
/* scan an integer as if by strtol/strtoul */ |
unsigned width_left = 0; |
int skips = 0; |
#ifdef hardway |
if (width == 0 || width > sizeof (buf) - 1) |
#else |
/* size_t is unsigned, hence this optimisation */ |
if (width - 1 > sizeof (buf) - 2) |
#endif |
{ |
width_left = width - (sizeof (buf) - 1); |
width = sizeof (buf) - 1; |
} |
flags |= SIGNOK | NDIGITS | NZDIGITS | NNZDIGITS; |
for (p = buf; width; width--) |
{ |
c = *fp->_p; |
/* |
* Switch on the character; `goto ok' if we |
* accept it as a part of number. |
*/ |
switch (c) |
{ |
/* |
* The digit 0 is always legal, but is special. |
* For %i conversions, if no digits (zero or nonzero) |
* have been scanned (only signs), we will have base==0. |
* In that case, we should set it to 8 and enable 0x |
* prefixing. Also, if we have not scanned zero digits |
* before this, do not turn off prefixing (someone else |
* will turn it off if we have scanned any nonzero digits). |
*/ |
case '0': |
if (! (flags & NNZDIGITS)) |
goto ok; |
if (base == 0) |
{ |
base = 8; |
flags |= PFXOK; |
} |
if (flags & NZDIGITS) |
{ |
flags &= ~(SIGNOK | NZDIGITS | NDIGITS); |
goto ok; |
} |
flags &= ~(SIGNOK | PFXOK | NDIGITS); |
if (width_left) |
{ |
width_left--; |
width++; |
} |
++skips; |
goto skip; |
/* 1 through 7 always legal */ |
case '1': |
case '2': |
case '3': |
case '4': |
case '5': |
case '6': |
case '7': |
base = basefix[base]; |
flags &= ~(SIGNOK | PFXOK | NDIGITS | NNZDIGITS); |
goto ok; |
/* digits 8 and 9 ok iff decimal or hex */ |
case '8': |
case '9': |
base = basefix[base]; |
if (base <= 8) |
break; /* not legal here */ |
flags &= ~(SIGNOK | PFXOK | NDIGITS | NNZDIGITS); |
goto ok; |
/* letters ok iff hex */ |
case 'A': |
case 'B': |
case 'C': |
case 'D': |
case 'E': |
case 'F': |
case 'a': |
case 'b': |
case 'c': |
case 'd': |
case 'e': |
case 'f': |
/* no need to fix base here */ |
if (base <= 10) |
break; /* not legal here */ |
flags &= ~(SIGNOK | PFXOK | NDIGITS | NNZDIGITS); |
goto ok; |
/* sign ok only as first character */ |
case '+': |
case '-': |
if (flags & SIGNOK) |
{ |
flags &= ~SIGNOK; |
goto ok; |
} |
break; |
/* x ok iff flag still set & single 0 seen */ |
case 'x': |
case 'X': |
if ((flags & (PFXOK | NZDIGITS)) == PFXOK) |
{ |
base = 16;/* if %i */ |
flags &= ~PFXOK; |
/* We must reset the NZDIGITS and NDIGITS |
flags that would have been unset by seeing |
the zero that preceded the X or x. */ |
flags |= NZDIGITS | NDIGITS; |
goto ok; |
} |
break; |
} |
/* |
* If we got here, c is not a legal character |
* for a number. Stop accumulating digits. |
*/ |
break; |
ok: |
/* |
* c is legal: store it and look at the next. |
*/ |
*p++ = c; |
skip: |
if (--fp->_r > 0) |
fp->_p++; |
else |
if (__srefill_r (rptr, fp)) |
break; /* EOF */ |
} |
/* |
* If we had only a sign, it is no good; push back the sign. |
* If the number ends in `x', it was [sign] '0' 'x', so push back |
* the x and treat it as [sign] '0'. |
* Use of ungetc here and below assumes ASCII encoding; we are only |
* pushing back 7-bit characters, so casting to unsigned char is |
* not necessary. |
*/ |
if (flags & NDIGITS) |
{ |
if (p > buf) |
_ungetc_r (rptr, *--p, fp); /* [-+xX] */ |
if (p == buf) |
goto match_failure; |
} |
if ((flags & SUPPRESS) == 0) |
{ |
u_long res; |
*p = 0; |
res = (*ccfn) (rptr, buf, (char **) NULL, base); |
if (flags & POINTER) |
{ |
void **vp = GET_ARG (N, ap, void **); |
#ifndef _NO_LONGLONG |
if (sizeof (uintptr_t) > sizeof (u_long)) |
{ |
u_long_long resll; |
resll = _strtoull_r (rptr, buf, (char **) NULL, base); |
*vp = (void *) (uintptr_t) resll; |
} |
else |
#endif /* !_NO_LONGLONG */ |
*vp = (void *) (uintptr_t) res; |
} |
#ifdef _WANT_IO_C99_FORMATS |
else if (flags & CHAR) |
{ |
cp = GET_ARG (N, ap, char *); |
*cp = res; |
} |
#endif |
else if (flags & SHORT) |
{ |
sp = GET_ARG (N, ap, short *); |
*sp = res; |
} |
else if (flags & LONG) |
{ |
lp = GET_ARG (N, ap, long *); |
*lp = res; |
} |
#ifndef _NO_LONGLONG |
else if (flags & LONGDBL) |
{ |
u_long_long resll; |
if (ccfn == _strtoul_r) |
resll = _strtoull_r (rptr, buf, (char **) NULL, base); |
else |
resll = _strtoll_r (rptr, buf, (char **) NULL, base); |
llp = GET_ARG (N, ap, long long*); |
*llp = resll; |
} |
#endif |
else |
{ |
ip = GET_ARG (N, ap, int *); |
*ip = res; |
} |
nassigned++; |
} |
nread += p - buf + skips; |
break; |
} |
#ifdef FLOATING_POINT |
case CT_FLOAT: |
{ |
/* scan a floating point number as if by strtod */ |
/* This code used to assume that the number of digits is reasonable. |
However, ANSI / ISO C makes no such stipulation; we have to get |
exact results even when there is an unreasonable amount of |
leading zeroes. */ |
long leading_zeroes = 0; |
long zeroes, exp_adjust; |
char *exp_start = NULL; |
unsigned width_left = 0; |
char nancount = 0; |
char infcount = 0; |
#ifdef hardway |
if (width == 0 || width > sizeof (buf) - 1) |
#else |
/* size_t is unsigned, hence this optimisation */ |
if (width - 1 > sizeof (buf) - 2) |
#endif |
{ |
width_left = width - (sizeof (buf) - 1); |
width = sizeof (buf) - 1; |
} |
flags |= SIGNOK | NDIGITS | DPTOK | EXPOK; |
zeroes = 0; |
exp_adjust = 0; |
for (p = buf; width; ) |
{ |
c = *fp->_p; |
/* |
* This code mimicks the integer conversion |
* code, but is much simpler. |
*/ |
switch (c) |
{ |
case '0': |
if (flags & NDIGITS) |
{ |
flags &= ~SIGNOK; |
zeroes++; |
if (width_left) |
{ |
width_left--; |
width++; |
} |
goto fskip; |
} |
/* Fall through. */ |
case '1': |
case '2': |
case '3': |
case '4': |
case '5': |
case '6': |
case '7': |
case '8': |
case '9': |
if (nancount + infcount == 0) |
{ |
flags &= ~(SIGNOK | NDIGITS); |
goto fok; |
} |
break; |
case '+': |
case '-': |
if (flags & SIGNOK) |
{ |
flags &= ~SIGNOK; |
goto fok; |
} |
break; |
case 'n': |
case 'N': |
if (nancount == 0 && zeroes == 0 |
&& (flags & (NDIGITS | DPTOK | EXPOK)) == |
(NDIGITS | DPTOK | EXPOK)) |
{ |
flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS); |
nancount = 1; |
goto fok; |
} |
if (nancount == 2) |
{ |
nancount = 3; |
goto fok; |
} |
if (infcount == 1 || infcount == 4) |
{ |
infcount++; |
goto fok; |
} |
break; |
case 'a': |
case 'A': |
if (nancount == 1) |
{ |
nancount = 2; |
goto fok; |
} |
break; |
case 'i': |
case 'I': |
if (infcount == 0 && zeroes == 0 |
&& (flags & (NDIGITS | DPTOK | EXPOK)) == |
(NDIGITS | DPTOK | EXPOK)) |
{ |
flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS); |
infcount = 1; |
goto fok; |
} |
if (infcount == 3 || infcount == 5) |
{ |
infcount++; |
goto fok; |
} |
break; |
case 'f': |
case 'F': |
if (infcount == 2) |
{ |
infcount = 3; |
goto fok; |
} |
break; |
case 't': |
case 'T': |
if (infcount == 6) |
{ |
infcount = 7; |
goto fok; |
} |
break; |
case 'y': |
case 'Y': |
if (infcount == 7) |
{ |
infcount = 8; |
goto fok; |
} |
break; |
case '.': |
if (flags & DPTOK) |
{ |
flags &= ~(SIGNOK | DPTOK); |
leading_zeroes = zeroes; |
goto fok; |
} |
break; |
case 'e': |
case 'E': |
/* no exponent without some digits */ |
if ((flags & (NDIGITS | EXPOK)) == EXPOK |
|| ((flags & EXPOK) && zeroes)) |
{ |
if (! (flags & DPTOK)) |
{ |
exp_adjust = zeroes - leading_zeroes; |
exp_start = p; |
} |
flags = |
(flags & ~(EXPOK | DPTOK)) | |
SIGNOK | NDIGITS; |
zeroes = 0; |
goto fok; |
} |
break; |
} |
break; |
fok: |
*p++ = c; |
fskip: |
width--; |
++nread; |
if (--fp->_r > 0) |
fp->_p++; |
else |
if (__srefill_r (rptr, fp)) |
break; /* EOF */ |
} |
if (zeroes) |
flags &= ~NDIGITS; |
/* We may have a 'N' or possibly even [sign] 'N' 'a' as the |
start of 'NaN', only to run out of chars before it was |
complete (or having encountered a non-matching char). So |
check here if we have an outstanding nancount, and if so |
put back the chars we did swallow and treat as a failed |
match. |
FIXME - we still don't handle NAN([0xdigits]). */ |
if (nancount - 1U < 2U) /* nancount && nancount < 3 */ |
{ |
/* Newlib's ungetc works even if we called __srefill in |
the middle of a partial parse, but POSIX does not |
guarantee that in all implementations of ungetc. */ |
while (p > buf) |
{ |
_ungetc_r (rptr, *--p, fp); /* [-+nNaA] */ |
--nread; |
} |
goto match_failure; |
} |
/* Likewise for 'inf' and 'infinity'. But be careful that |
'infinite' consumes only 3 characters, leaving the stream |
at the second 'i'. */ |
if (infcount - 1U < 7U) /* infcount && infcount < 8 */ |
{ |
if (infcount >= 3) /* valid 'inf', but short of 'infinity' */ |
while (infcount-- > 3) |
{ |
_ungetc_r (rptr, *--p, fp); /* [iInNtT] */ |
--nread; |
} |
else |
{ |
while (p > buf) |
{ |
_ungetc_r (rptr, *--p, fp); /* [-+iInN] */ |
--nread; |
} |
goto match_failure; |
} |
} |
/* |
* If no digits, might be missing exponent digits |
* (just give back the exponent) or might be missing |
* regular digits, but had sign and/or decimal point. |
*/ |
if (flags & NDIGITS) |
{ |
if (flags & EXPOK) |
{ |
/* no digits at all */ |
while (p > buf) |
{ |
_ungetc_r (rptr, *--p, fp); /* [-+.] */ |
--nread; |
} |
goto match_failure; |
} |
/* just a bad exponent (e and maybe sign) */ |
c = *--p; |
--nread; |
if (c != 'e' && c != 'E') |
{ |
_ungetc_r (rptr, c, fp); /* [-+] */ |
c = *--p; |
--nread; |
} |
_ungetc_r (rptr, c, fp); /* [eE] */ |
} |
if ((flags & SUPPRESS) == 0) |
{ |
double res = 0; |
#ifdef _NO_LONGDBL |
#define QUAD_RES res; |
#else /* !_NO_LONG_DBL */ |
long double qres = 0; |
#define QUAD_RES qres; |
#endif /* !_NO_LONG_DBL */ |
long new_exp = 0; |
*p = 0; |
if ((flags & (DPTOK | EXPOK)) == EXPOK) |
{ |
exp_adjust = zeroes - leading_zeroes; |
new_exp = -exp_adjust; |
exp_start = p; |
} |
else if (exp_adjust) |
new_exp = _strtol_r (rptr, (exp_start + 1), NULL, 10) - exp_adjust; |
if (exp_adjust) |
{ |
/* If there might not be enough space for the new exponent, |
truncate some trailing digits to make room. */ |
if (exp_start >= buf + sizeof (buf) - MAX_LONG_LEN) |
exp_start = buf + sizeof (buf) - MAX_LONG_LEN - 1; |
sprintf (exp_start, "e%ld", new_exp); |
} |
/* Current _strtold routine is markedly slower than |
_strtod_r. Only use it if we have a long double |
result. */ |
#ifndef _NO_LONGDBL /* !_NO_LONGDBL */ |
if (flags & LONGDBL) |
qres = _strtold (buf, NULL); |
else |
#endif |
res = _strtod_r (rptr, buf, NULL); |
if (flags & LONG) |
{ |
dp = GET_ARG (N, ap, double *); |
*dp = res; |
} |
else if (flags & LONGDBL) |
{ |
ldp = GET_ARG (N, ap, _LONG_DOUBLE *); |
*ldp = QUAD_RES; |
} |
else |
{ |
flp = GET_ARG (N, ap, float *); |
if (isnan (res)) |
*flp = nanf (NULL); |
else |
*flp = res; |
} |
nassigned++; |
} |
break; |
} |
#endif /* FLOATING_POINT */ |
} |
} |
input_failure: |
/* On read failure, return EOF failure regardless of matches; errno |
should have been set prior to here. On EOF failure (including |
invalid format string), return EOF if no matches yet, else number |
of matches made prior to failure. */ |
_funlockfile (fp); |
__sfp_lock_release (); |
return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF; |
match_failure: |
all_done: |
/* Return number of matches, which can be 0 on match failure. */ |
_funlockfile (fp); |
__sfp_lock_release (); |
return nassigned; |
} |
#ifndef _NO_POS_ARGS |
/* Process all intermediate arguments. Fortunately, with scanf, all |
intermediate arguments are sizeof(void*), so we don't need to scan |
ahead in the format string. */ |
static void * |
get_arg (int n, va_list *ap, int *numargs_p, void **args) |
{ |
int numargs = *numargs_p; |
while (n >= numargs) |
args[numargs++] = va_arg (*ap, void *); |
*numargs_p = numargs; |
return args[n]; |
} |
#endif /* !_NO_POS_ARGS */ |
/programs/develop/libraries/newlib/stdio/vsnprintf.c |
---|
0,0 → 1,70 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in vfprintf.c */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <limits.h> |
#include <stdarg.h> |
#include <errno.h> |
#ifndef _REENT_ONLY |
int |
_DEFUN(vsnprintf, (str, size, fmt, ap), |
char *str _AND |
size_t size _AND |
const char *fmt _AND |
va_list ap) |
{ |
return _vsnprintf_r (_REENT, str, size, fmt, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap), |
struct _reent *ptr _AND |
char *str _AND |
size_t size _AND |
const char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE f; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return ret; |
} |
/programs/develop/libraries/newlib/stdio/vsprintf.c |
---|
0,0 → 1,59 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in vfprintf.c */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <limits.h> |
#include <stdarg.h> |
#ifndef _REENT_ONLY |
int |
_DEFUN(vsprintf, (str, fmt, ap), |
char *str _AND |
const char *fmt _AND |
va_list ap) |
{ |
return _vsprintf_r (_REENT, str, fmt, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_vsprintf_r, (ptr, str, fmt, ap), |
struct _reent *ptr _AND |
char *str _AND |
const char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
*f._p = 0; |
return ret; |
} |
/programs/develop/libraries/newlib/stdio/wbuf.c |
---|
0,0 → 1,100 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
#include "fvwrite.h" |
/* |
* Write the given character into the (probably full) buffer for |
* the given file. Flush the buffer out if it is or becomes full, |
* or if c=='\n' and the file is line buffered. |
*/ |
int |
_DEFUN(__swbuf_r, (ptr, c, fp), |
struct _reent *ptr _AND |
register int c _AND |
register FILE *fp) |
{ |
register int n; |
/* Ensure stdio has been initialized. */ |
CHECK_INIT (ptr, fp); |
/* |
* In case we cannot write, or longjmp takes us out early, |
* make sure _w is 0 (if fully- or un-buffered) or -_bf._size |
* (if line buffered) so that we will get called again. |
* If we did not do this, a sufficient number of putc() |
* calls might wrap _w from negative to positive. |
*/ |
fp->_w = fp->_lbfsize; |
if (cantwrite (ptr, fp)) |
{ |
fp->_flags |= __SERR; |
ptr->_errno = EBADF; |
return EOF; |
} |
c = (unsigned char) c; |
ORIENT (fp, -1); |
/* |
* If it is completely full, flush it out. Then, in any case, |
* stuff c into the buffer. If this causes the buffer to fill |
* completely, or if c is '\n' and the file is line buffered, |
* flush it (perhaps a second time). The second flush will always |
* happen on unbuffered streams, where _bf._size==1; fflush() |
* guarantees that putc() will always call wbuf() by setting _w |
* to 0, so we need not do anything else. |
*/ |
n = fp->_p - fp->_bf._base; |
if (n >= fp->_bf._size) |
{ |
if (_fflush_r (ptr, fp)) |
return EOF; |
n = 0; |
} |
fp->_w--; |
*fp->_p++ = c; |
if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) |
if (_fflush_r (ptr, fp)) |
return EOF; |
return c; |
} |
/* This function isn't any longer declared in stdio.h, but it's |
required for backward compatibility with applications built against |
earlier dynamically built newlib libraries. */ |
int |
_DEFUN(__swbuf, (c, fp), |
register int c _AND |
register FILE *fp) |
{ |
return __swbuf_r (_REENT, c, fp); |
} |
/programs/develop/libraries/newlib/stdio/wsetup.c |
---|
0,0 → 1,83 |
/* No user fns here. Pesch 15apr92. */ |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include "local.h" |
/* |
* Various output routines call wsetup to be sure it is safe to write, |
* because either _flags does not include __SWR, or _buf is NULL. |
* _wsetup returns 0 if OK to write, nonzero otherwise. |
*/ |
int |
_DEFUN(__swsetup_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE * fp) |
{ |
/* Make sure stdio is set up. */ |
CHECK_INIT (_REENT, fp); |
/* |
* If we are not writing, we had better be reading and writing. |
*/ |
if ((fp->_flags & __SWR) == 0) |
{ |
if ((fp->_flags & __SRW) == 0) |
return EOF; |
if (fp->_flags & __SRD) |
{ |
/* clobber any ungetc data */ |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_flags &= ~(__SRD | __SEOF); |
fp->_r = 0; |
fp->_p = fp->_bf._base; |
} |
fp->_flags |= __SWR; |
} |
/* |
* Make a buffer if necessary, then set _w. |
* A string I/O file should not explicitly allocate a buffer |
* unless asprintf is being used. |
*/ |
if (fp->_bf._base == NULL |
&& (!(fp->_flags & __SSTR) || (fp->_flags & __SMBF))) |
__smakebuf_r (ptr, fp); |
if (fp->_flags & __SLBF) |
{ |
/* |
* It is line buffered, so make _lbfsize be -_bufsize |
* for the putc() macro. We will change _lbfsize back |
* to 0 whenever we turn off __SWR. |
*/ |
fp->_w = 0; |
fp->_lbfsize = -fp->_bf._size; |
} |
else |
fp->_w = fp->_flags & __SNBF ? 0 : fp->_bf._size; |
return (!fp->_bf._base && (fp->_flags & __SMBF)) ? EOF : 0; |
} |
/programs/develop/libraries/newlib/stdio |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/stdlib/abort.c |
---|
0,0 → 1,67 |
/* NetWare can not use this implementation of abort. It provides its |
own version of abort in clib.nlm. If we can not use clib.nlm, then |
we must write abort in sys/netware. */ |
#ifdef ABORT_PROVIDED |
int _dummy_abort = 1; |
#else |
/* |
FUNCTION |
<<abort>>---abnormal termination of a program |
INDEX |
abort |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void abort(void); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
void abort(); |
DESCRIPTION |
Use <<abort>> to signal that your program has detected a condition it |
cannot deal with. Normally, <<abort>> ends your program's execution. |
Before terminating your program, <<abort>> raises the exception <<SIGABRT>> |
(using `<<raise(SIGABRT)>>'). If you have used <<signal>> to register |
an exception handler for this condition, that handler has the |
opportunity to retain control, thereby avoiding program termination. |
In this implementation, <<abort>> does not perform any stream- or |
file-related cleanup (the host environment may do so; if not, you can |
arrange for your program to do its own cleanup with a <<SIGABRT>> |
exception handler). |
RETURNS |
<<abort>> does not return to its caller. |
PORTABILITY |
ANSI C requires <<abort>>. |
Supporting OS subroutines required: <<_exit>> and optionally, <<write>>. |
*/ |
#include <stdlib.h> |
#include <unistd.h> |
#include <signal.h> |
_VOID |
_DEFUN_VOID (abort) |
{ |
#ifdef ABORT_MESSAGE |
write (2, "Abort called\n", sizeof ("Abort called\n")-1); |
#endif |
while (1) |
{ |
// raise (SIGABRT); |
_exit (1); |
} |
} |
#endif |
/programs/develop/libraries/newlib/stdlib/abs.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<abs>>---integer absolute value (magnitude) |
INDEX |
abs |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int abs(int <[i]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int abs(<[i]>) |
int <[i]>; |
DESCRIPTION |
<<abs>> returns |
@tex |
$|x|$, |
@end tex |
the absolute value of <[i]> (also called the magnitude |
of <[i]>). That is, if <[i]> is negative, the result is the opposite |
of <[i]>, but if <[i]> is nonnegative the result is <[i]>. |
The similar function <<labs>> uses and returns <<long>> rather than <<int>> values. |
RETURNS |
The result is a nonnegative integer. |
PORTABILITY |
<<abs>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
#include <stdlib.h> |
int |
_DEFUN (abs, (i), int i) |
{ |
return (i < 0) ? -i : i; |
} |
/programs/develop/libraries/newlib/stdlib/atexit.h |
---|
0,0 → 1,14 |
/* |
* Common definitions for atexit-like routines |
*/ |
enum __atexit_types |
{ |
__et_atexit, |
__et_onexit, |
__et_cxa |
}; |
void __call_exitprocs _PARAMS ((int, _PTR)); |
int __register_exitproc _PARAMS ((int, void (*fn) (void), _PTR, _PTR)); |
/programs/develop/libraries/newlib/stdlib/atoi.c |
---|
0,0 → 1,81 |
/* |
FUNCTION |
<<atoi>>, <<atol>>---string to integer |
INDEX |
atoi |
INDEX |
atol |
INDEX |
_atoi_r |
INDEX |
_atol_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int atoi(const char *<[s]>); |
long atol(const char *<[s]>); |
int _atoi_r(struct _reent *<[ptr]>, const char *<[s]>); |
long _atol_r(struct _reent *<[ptr]>, const char *<[s]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int atoi(<[s]>) |
char *<[s]>; |
long atol(<[s]>) |
char *<[s]>; |
int _atoi_r(<[ptr]>, <[s]>) |
struct _reent *<[ptr]>; |
char *<[s]>; |
long _atol_r(<[ptr]>, <[s]>) |
struct _reent *<[ptr]>; |
char *<[s]>; |
DESCRIPTION |
<<atoi>> converts the initial portion of a string to an <<int>>. |
<<atol>> converts the initial portion of a string to a <<long>>. |
<<atoi(s)>> is implemented as <<(int)strtol(s, NULL, 10).>> |
<<atol(s)>> is implemented as <<strtol(s, NULL, 10).>> |
<<_atoi_r>> and <<_atol_r>> are reentrant versions of <<atoi>> and |
<<atol>> respectively, passing the reentrancy struct pointer. |
RETURNS |
The functions return the converted value, if any. If no conversion was |
made, <<0>> is returned. |
PORTABILITY |
<<atoi>>, <<atol>> are ANSI. |
No supporting OS subroutines are required. |
*/ |
/* |
* Andy Wilson, 2-Oct-89. |
*/ |
#include <stdlib.h> |
#include <_ansi.h> |
#ifndef _REENT_ONLY |
int |
_DEFUN (atoi, (s), |
_CONST char *s) |
{ |
return (int) strtol (s, NULL, 10); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN (_atoi_r, (s), |
struct _reent *ptr _AND |
_CONST char *s) |
{ |
return (int) _strtol_r (ptr, s, NULL, 10); |
} |
/programs/develop/libraries/newlib/stdlib/calloc.c |
---|
0,0 → 1,69 |
#ifdef MALLOC_PROVIDED |
int _dummy_calloc = 1; |
#else |
/* |
FUNCTION |
<<calloc>>---allocate space for arrays |
INDEX |
calloc |
INDEX |
_calloc_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void *calloc(size_t <[n]>, size_t <[s]>); |
void *_calloc_r(void *<[reent]>, size_t <[n]>, size_t <[s]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
char *calloc(<[n]>, <[s]>) |
size_t <[n]>, <[s]>; |
char *_calloc_r(<[reent]>, <[n]>, <[s]>) |
char *<[reent]>; |
size_t <[n]>; |
size_t <[s]>; |
DESCRIPTION |
Use <<calloc>> to request a block of memory sufficient to hold an |
array of <[n]> elements, each of which has size <[s]>. |
The memory allocated by <<calloc>> comes out of the same memory pool |
used by <<malloc>>, but the memory block is initialized to all zero |
bytes. (To avoid the overhead of initializing the space, use |
<<malloc>> instead.) |
The alternate function <<_calloc_r>> is reentrant. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
If successful, a pointer to the newly allocated space. |
If unsuccessful, <<NULL>>. |
PORTABILITY |
<<calloc>> is ANSI. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <string.h> |
#include <stdlib.h> |
#ifndef _REENT_ONLY |
_PTR |
_DEFUN (calloc, (n, size), |
size_t n _AND |
size_t size) |
{ |
return _calloc_r (_REENT, n, size); |
} |
#endif |
#endif /* MALLOC_PROVIDED */ |
/programs/develop/libraries/newlib/stdlib/dtoa.c |
---|
0,0 → 1,862 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
#include <_ansi.h> |
#include <stdlib.h> |
#include <reent.h> |
#include <string.h> |
#include "mprec.h" |
static int |
_DEFUN (quorem, |
(b, S), |
_Bigint * b _AND _Bigint * S) |
{ |
int n; |
__Long borrow, y; |
__ULong carry, q, ys; |
__ULong *bx, *bxe, *sx, *sxe; |
#ifdef Pack_32 |
__Long z; |
__ULong si, zs; |
#endif |
n = S->_wds; |
#ifdef DEBUG |
/*debug*/ if (b->_wds > n) |
/*debug*/ Bug ("oversize b in quorem"); |
#endif |
if (b->_wds < n) |
return 0; |
sx = S->_x; |
sxe = sx + --n; |
bx = b->_x; |
bxe = bx + n; |
q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ |
#ifdef DEBUG |
/*debug*/ if (q > 9) |
/*debug*/ Bug ("oversized quotient in quorem"); |
#endif |
if (q) |
{ |
borrow = 0; |
carry = 0; |
do |
{ |
#ifdef Pack_32 |
si = *sx++; |
ys = (si & 0xffff) * q + carry; |
zs = (si >> 16) * q + (ys >> 16); |
carry = zs >> 16; |
y = (*bx & 0xffff) - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*bx >> 16) - (zs & 0xffff) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (bx, z, y); |
#else |
ys = *sx++ * q + carry; |
carry = ys >> 16; |
y = *bx - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*bx++ = y & 0xffff; |
#endif |
} |
while (sx <= sxe); |
if (!*bxe) |
{ |
bx = b->_x; |
while (--bxe > bx && !*bxe) |
--n; |
b->_wds = n; |
} |
} |
if (cmp (b, S) >= 0) |
{ |
q++; |
borrow = 0; |
carry = 0; |
bx = b->_x; |
sx = S->_x; |
do |
{ |
#ifdef Pack_32 |
si = *sx++; |
ys = (si & 0xffff) + carry; |
zs = (si >> 16) + (ys >> 16); |
carry = zs >> 16; |
y = (*bx & 0xffff) - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*bx >> 16) - (zs & 0xffff) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (bx, z, y); |
#else |
ys = *sx++ + carry; |
carry = ys >> 16; |
y = *bx - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*bx++ = y & 0xffff; |
#endif |
} |
while (sx <= sxe); |
bx = b->_x; |
bxe = bx + n; |
if (!*bxe) |
{ |
while (--bxe > bx && !*bxe) |
--n; |
b->_wds = n; |
} |
} |
return q; |
} |
/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. |
* |
* Inspired by "How to Print Floating-Point Numbers Accurately" by |
* Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. |
* |
* Modifications: |
* 1. Rather than iterating, we use a simple numeric overestimate |
* to determine k = floor(log10(d)). We scale relevant |
* quantities using O(log2(k)) rather than O(k) multiplications. |
* 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't |
* try to generate digits strictly left to right. Instead, we |
* compute with fewer bits and propagate the carry if necessary |
* when rounding the final digit up. This is often faster. |
* 3. Under the assumption that input will be rounded nearest, |
* mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. |
* That is, we allow equality in stopping tests when the |
* round-nearest rule will give the same floating-point value |
* as would satisfaction of the stopping test with strict |
* inequality. |
* 4. We remove common factors of powers of 2 from relevant |
* quantities. |
* 5. When converting floating-point integers less than 1e16, |
* we use floating-point arithmetic rather than resorting |
* to multiple-precision integers. |
* 6. When asked to produce fewer than 15 digits, we first try |
* to get by with floating-point arithmetic; we resort to |
* multiple-precision integer arithmetic only if we cannot |
* guarantee that the floating-point calculation has given |
* the correctly rounded result. For k requested digits and |
* "uniformly" distributed input, the probability is |
* something like 10^(k-15) that we must resort to the long |
* calculation. |
*/ |
char * |
_DEFUN (_dtoa_r, |
(ptr, _d, mode, ndigits, decpt, sign, rve), |
struct _reent *ptr _AND |
double _d _AND |
int mode _AND |
int ndigits _AND |
int *decpt _AND |
int *sign _AND |
char **rve) |
{ |
/* Arguments ndigits, decpt, sign are similar to those |
of ecvt and fcvt; trailing zeros are suppressed from |
the returned string. If not null, *rve is set to point |
to the end of the return value. If d is +-Infinity or NaN, |
then *decpt is set to 9999. |
mode: |
0 ==> shortest string that yields d when read in |
and rounded to nearest. |
1 ==> like 0, but with Steele & White stopping rule; |
e.g. with IEEE P754 arithmetic , mode 0 gives |
1e23 whereas mode 1 gives 9.999999999999999e22. |
2 ==> max(1,ndigits) significant digits. This gives a |
return value similar to that of ecvt, except |
that trailing zeros are suppressed. |
3 ==> through ndigits past the decimal point. This |
gives a return value similar to that from fcvt, |
except that trailing zeros are suppressed, and |
ndigits can be negative. |
4-9 should give the same return values as 2-3, i.e., |
4 <= mode <= 9 ==> same return as mode |
2 + (mode & 1). These modes are mainly for |
debugging; often they run slower but sometimes |
faster than modes 2-3. |
4,5,8,9 ==> left-to-right digit generation. |
6-9 ==> don't try fast floating-point estimate |
(if applicable). |
Values of mode other than 0-9 are treated as mode 0. |
Sufficient space is allocated to the return value |
to hold the suppressed trailing zeros. |
*/ |
int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0, |
k_check, leftright, m2, m5, s2, s5, spec_case, try_quick; |
union double_union d, d2, eps; |
__Long L; |
#ifndef Sudden_Underflow |
int denorm; |
__ULong x; |
#endif |
_Bigint *b, *b1, *delta, *mlo = NULL, *mhi, *S; |
double ds; |
char *s, *s0; |
d.d = _d; |
_REENT_CHECK_MP(ptr); |
if (_REENT_MP_RESULT(ptr)) |
{ |
_REENT_MP_RESULT(ptr)->_k = _REENT_MP_RESULT_K(ptr); |
_REENT_MP_RESULT(ptr)->_maxwds = 1 << _REENT_MP_RESULT_K(ptr); |
Bfree (ptr, _REENT_MP_RESULT(ptr)); |
_REENT_MP_RESULT(ptr) = 0; |
} |
if (word0 (d) & Sign_bit) |
{ |
/* set sign for everything, including 0's and NaNs */ |
*sign = 1; |
word0 (d) &= ~Sign_bit; /* clear sign bit */ |
} |
else |
*sign = 0; |
#if defined(IEEE_Arith) + defined(VAX) |
#ifdef IEEE_Arith |
if ((word0 (d) & Exp_mask) == Exp_mask) |
#else |
if (word0 (d) == 0x8000) |
#endif |
{ |
/* Infinity or NaN */ |
*decpt = 9999; |
s = |
#ifdef IEEE_Arith |
!word1 (d) && !(word0 (d) & 0xfffff) ? "Infinity" : |
#endif |
"NaN"; |
if (rve) |
*rve = |
#ifdef IEEE_Arith |
s[3] ? s + 8 : |
#endif |
s + 3; |
return s; |
} |
#endif |
#ifdef IBM |
d.d += 0; /* normalize */ |
#endif |
if (!d.d) |
{ |
*decpt = 1; |
s = "0"; |
if (rve) |
*rve = s + 1; |
return s; |
} |
b = d2b (ptr, d.d, &be, &bbits); |
#ifdef Sudden_Underflow |
i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1)); |
#else |
if ((i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1))) != 0) |
{ |
#endif |
d2.d = d.d; |
word0 (d2) &= Frac_mask1; |
word0 (d2) |= Exp_11; |
#ifdef IBM |
if (j = 11 - hi0bits (word0 (d2) & Frac_mask)) |
d2.d /= 1 << j; |
#endif |
/* log(x) ~=~ log(1.5) + (x-1.5)/1.5 |
* log10(x) = log(x) / log(10) |
* ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) |
* log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) |
* |
* This suggests computing an approximation k to log10(d) by |
* |
* k = (i - Bias)*0.301029995663981 |
* + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); |
* |
* We want k to be too large rather than too small. |
* The error in the first-order Taylor series approximation |
* is in our favor, so we just round up the constant enough |
* to compensate for any error in the multiplication of |
* (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, |
* and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, |
* adding 1e-13 to the constant term more than suffices. |
* Hence we adjust the constant term to 0.1760912590558. |
* (We could get a more accurate k by invoking log10, |
* but this is probably not worthwhile.) |
*/ |
i -= Bias; |
#ifdef IBM |
i <<= 2; |
i += j; |
#endif |
#ifndef Sudden_Underflow |
denorm = 0; |
} |
else |
{ |
/* d is denormalized */ |
i = bbits + be + (Bias + (P - 1) - 1); |
#if defined (_DOUBLE_IS_32BITS) |
x = word0 (d) << (32 - i); |
#else |
x = (i > 32) ? (word0 (d) << (64 - i)) | (word1 (d) >> (i - 32)) |
: (word1 (d) << (32 - i)); |
#endif |
d2.d = x; |
word0 (d2) -= 31 * Exp_msk1; /* adjust exponent */ |
i -= (Bias + (P - 1) - 1) + 1; |
denorm = 1; |
} |
#endif |
#if defined (_DOUBLE_IS_32BITS) |
ds = (d2.d - 1.5) * 0.289529651 + 0.176091269 + i * 0.30103001; |
#else |
ds = (d2.d - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981; |
#endif |
k = (int) ds; |
if (ds < 0. && ds != k) |
k--; /* want k = floor(ds) */ |
k_check = 1; |
if (k >= 0 && k <= Ten_pmax) |
{ |
if (d.d < tens[k]) |
k--; |
k_check = 0; |
} |
j = bbits - i - 1; |
if (j >= 0) |
{ |
b2 = 0; |
s2 = j; |
} |
else |
{ |
b2 = -j; |
s2 = 0; |
} |
if (k >= 0) |
{ |
b5 = 0; |
s5 = k; |
s2 += k; |
} |
else |
{ |
b2 -= k; |
b5 = -k; |
s5 = 0; |
} |
if (mode < 0 || mode > 9) |
mode = 0; |
try_quick = 1; |
if (mode > 5) |
{ |
mode -= 4; |
try_quick = 0; |
} |
leftright = 1; |
ilim = ilim1 = -1; |
switch (mode) |
{ |
case 0: |
case 1: |
i = 18; |
ndigits = 0; |
break; |
case 2: |
leftright = 0; |
/* no break */ |
case 4: |
if (ndigits <= 0) |
ndigits = 1; |
ilim = ilim1 = i = ndigits; |
break; |
case 3: |
leftright = 0; |
/* no break */ |
case 5: |
i = ndigits + k + 1; |
ilim = i; |
ilim1 = i - 1; |
if (i <= 0) |
i = 1; |
} |
j = sizeof (__ULong); |
for (_REENT_MP_RESULT_K(ptr) = 0; sizeof (_Bigint) - sizeof (__ULong) + j <= i; |
j <<= 1) |
_REENT_MP_RESULT_K(ptr)++; |
_REENT_MP_RESULT(ptr) = Balloc (ptr, _REENT_MP_RESULT_K(ptr)); |
s = s0 = (char *) _REENT_MP_RESULT(ptr); |
if (ilim >= 0 && ilim <= Quick_max && try_quick) |
{ |
/* Try to get by with floating-point arithmetic. */ |
i = 0; |
d2.d = d.d; |
k0 = k; |
ilim0 = ilim; |
ieps = 2; /* conservative */ |
if (k > 0) |
{ |
ds = tens[k & 0xf]; |
j = k >> 4; |
if (j & Bletch) |
{ |
/* prevent overflows */ |
j &= Bletch - 1; |
d.d /= bigtens[n_bigtens - 1]; |
ieps++; |
} |
for (; j; j >>= 1, i++) |
if (j & 1) |
{ |
ieps++; |
ds *= bigtens[i]; |
} |
d.d /= ds; |
} |
else if ((j1 = -k) != 0) |
{ |
d.d *= tens[j1 & 0xf]; |
for (j = j1 >> 4; j; j >>= 1, i++) |
if (j & 1) |
{ |
ieps++; |
d.d *= bigtens[i]; |
} |
} |
if (k_check && d.d < 1. && ilim > 0) |
{ |
if (ilim1 <= 0) |
goto fast_failed; |
ilim = ilim1; |
k--; |
d.d *= 10.; |
ieps++; |
} |
eps.d = ieps * d.d + 7.; |
word0 (eps) -= (P - 1) * Exp_msk1; |
if (ilim == 0) |
{ |
S = mhi = 0; |
d.d -= 5.; |
if (d.d > eps.d) |
goto one_digit; |
if (d.d < -eps.d) |
goto no_digits; |
goto fast_failed; |
} |
#ifndef No_leftright |
if (leftright) |
{ |
/* Use Steele & White method of only |
* generating digits needed. |
*/ |
eps.d = 0.5 / tens[ilim - 1] - eps.d; |
for (i = 0;;) |
{ |
L = d.d; |
d.d -= L; |
*s++ = '0' + (int) L; |
if (d.d < eps.d) |
goto ret1; |
if (1. - d.d < eps.d) |
goto bump_up; |
if (++i >= ilim) |
break; |
eps.d *= 10.; |
d.d *= 10.; |
} |
} |
else |
{ |
#endif |
/* Generate ilim digits, then fix them up. */ |
eps.d *= tens[ilim - 1]; |
for (i = 1;; i++, d.d *= 10.) |
{ |
L = d.d; |
d.d -= L; |
*s++ = '0' + (int) L; |
if (i == ilim) |
{ |
if (d.d > 0.5 + eps.d) |
goto bump_up; |
else if (d.d < 0.5 - eps.d) |
{ |
while (*--s == '0'); |
s++; |
goto ret1; |
} |
break; |
} |
} |
#ifndef No_leftright |
} |
#endif |
fast_failed: |
s = s0; |
d.d = d2.d; |
k = k0; |
ilim = ilim0; |
} |
/* Do we have a "small" integer? */ |
if (be >= 0 && k <= Int_max) |
{ |
/* Yes. */ |
ds = tens[k]; |
if (ndigits < 0 && ilim <= 0) |
{ |
S = mhi = 0; |
if (ilim < 0 || d.d <= 5 * ds) |
goto no_digits; |
goto one_digit; |
} |
for (i = 1;; i++) |
{ |
L = d.d / ds; |
d.d -= L * ds; |
#ifdef Check_FLT_ROUNDS |
/* If FLT_ROUNDS == 2, L will usually be high by 1 */ |
if (d.d < 0) |
{ |
L--; |
d.d += ds; |
} |
#endif |
*s++ = '0' + (int) L; |
if (i == ilim) |
{ |
d.d += d.d; |
if ((d.d > ds) || ((d.d == ds) && (L & 1))) |
{ |
bump_up: |
while (*--s == '9') |
if (s == s0) |
{ |
k++; |
*s = '0'; |
break; |
} |
++*s++; |
} |
break; |
} |
if (!(d.d *= 10.)) |
break; |
} |
goto ret1; |
} |
m2 = b2; |
m5 = b5; |
mhi = mlo = 0; |
if (leftright) |
{ |
if (mode < 2) |
{ |
i = |
#ifndef Sudden_Underflow |
denorm ? be + (Bias + (P - 1) - 1 + 1) : |
#endif |
#ifdef IBM |
1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3); |
#else |
1 + P - bbits; |
#endif |
} |
else |
{ |
j = ilim - 1; |
if (m5 >= j) |
m5 -= j; |
else |
{ |
s5 += j -= m5; |
b5 += j; |
m5 = 0; |
} |
if ((i = ilim) < 0) |
{ |
m2 -= i; |
i = 0; |
} |
} |
b2 += i; |
s2 += i; |
mhi = i2b (ptr, 1); |
} |
if (m2 > 0 && s2 > 0) |
{ |
i = m2 < s2 ? m2 : s2; |
b2 -= i; |
m2 -= i; |
s2 -= i; |
} |
if (b5 > 0) |
{ |
if (leftright) |
{ |
if (m5 > 0) |
{ |
mhi = pow5mult (ptr, mhi, m5); |
b1 = mult (ptr, mhi, b); |
Bfree (ptr, b); |
b = b1; |
} |
if ((j = b5 - m5) != 0) |
b = pow5mult (ptr, b, j); |
} |
else |
b = pow5mult (ptr, b, b5); |
} |
S = i2b (ptr, 1); |
if (s5 > 0) |
S = pow5mult (ptr, S, s5); |
/* Check for special case that d is a normalized power of 2. */ |
spec_case = 0; |
if (mode < 2) |
{ |
if (!word1 (d) && !(word0 (d) & Bndry_mask) |
#ifndef Sudden_Underflow |
&& word0 (d) & Exp_mask |
#endif |
) |
{ |
/* The special case */ |
b2 += Log2P; |
s2 += Log2P; |
spec_case = 1; |
} |
} |
/* Arrange for convenient computation of quotients: |
* shift left if necessary so divisor has 4 leading 0 bits. |
* |
* Perhaps we should just compute leading 28 bits of S once |
* and for all and pass them and a shift to quorem, so it |
* can do shifts and ors to compute the numerator for q. |
*/ |
#ifdef Pack_32 |
if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0x1f) != 0) |
i = 32 - i; |
#else |
if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0xf) != 0) |
i = 16 - i; |
#endif |
if (i > 4) |
{ |
i -= 4; |
b2 += i; |
m2 += i; |
s2 += i; |
} |
else if (i < 4) |
{ |
i += 28; |
b2 += i; |
m2 += i; |
s2 += i; |
} |
if (b2 > 0) |
b = lshift (ptr, b, b2); |
if (s2 > 0) |
S = lshift (ptr, S, s2); |
if (k_check) |
{ |
if (cmp (b, S) < 0) |
{ |
k--; |
b = multadd (ptr, b, 10, 0); /* we botched the k estimate */ |
if (leftright) |
mhi = multadd (ptr, mhi, 10, 0); |
ilim = ilim1; |
} |
} |
if (ilim <= 0 && mode > 2) |
{ |
if (ilim < 0 || cmp (b, S = multadd (ptr, S, 5, 0)) <= 0) |
{ |
/* no digits, fcvt style */ |
no_digits: |
k = -1 - ndigits; |
goto ret; |
} |
one_digit: |
*s++ = '1'; |
k++; |
goto ret; |
} |
if (leftright) |
{ |
if (m2 > 0) |
mhi = lshift (ptr, mhi, m2); |
/* Compute mlo -- check for special case |
* that d is a normalized power of 2. |
*/ |
mlo = mhi; |
if (spec_case) |
{ |
mhi = Balloc (ptr, mhi->_k); |
Bcopy (mhi, mlo); |
mhi = lshift (ptr, mhi, Log2P); |
} |
for (i = 1;; i++) |
{ |
dig = quorem (b, S) + '0'; |
/* Do we yet have the shortest decimal string |
* that will round to d? |
*/ |
j = cmp (b, mlo); |
delta = diff (ptr, S, mhi); |
j1 = delta->_sign ? 1 : cmp (b, delta); |
Bfree (ptr, delta); |
#ifndef ROUND_BIASED |
if (j1 == 0 && !mode && !(word1 (d) & 1)) |
{ |
if (dig == '9') |
goto round_9_up; |
if (j > 0) |
dig++; |
*s++ = dig; |
goto ret; |
} |
#endif |
if ((j < 0) || ((j == 0) && !mode |
#ifndef ROUND_BIASED |
&& !(word1 (d) & 1) |
#endif |
)) |
{ |
if (j1 > 0) |
{ |
b = lshift (ptr, b, 1); |
j1 = cmp (b, S); |
if (((j1 > 0) || ((j1 == 0) && (dig & 1))) |
&& dig++ == '9') |
goto round_9_up; |
} |
*s++ = dig; |
goto ret; |
} |
if (j1 > 0) |
{ |
if (dig == '9') |
{ /* possible if i == 1 */ |
round_9_up: |
*s++ = '9'; |
goto roundoff; |
} |
*s++ = dig + 1; |
goto ret; |
} |
*s++ = dig; |
if (i == ilim) |
break; |
b = multadd (ptr, b, 10, 0); |
if (mlo == mhi) |
mlo = mhi = multadd (ptr, mhi, 10, 0); |
else |
{ |
mlo = multadd (ptr, mlo, 10, 0); |
mhi = multadd (ptr, mhi, 10, 0); |
} |
} |
} |
else |
for (i = 1;; i++) |
{ |
*s++ = dig = quorem (b, S) + '0'; |
if (i >= ilim) |
break; |
b = multadd (ptr, b, 10, 0); |
} |
/* Round off last digit */ |
b = lshift (ptr, b, 1); |
j = cmp (b, S); |
if ((j > 0) || ((j == 0) && (dig & 1))) |
{ |
roundoff: |
while (*--s == '9') |
if (s == s0) |
{ |
k++; |
*s++ = '1'; |
goto ret; |
} |
++*s++; |
} |
else |
{ |
while (*--s == '0'); |
s++; |
} |
ret: |
Bfree (ptr, S); |
if (mhi) |
{ |
if (mlo && mlo != mhi) |
Bfree (ptr, mlo); |
Bfree (ptr, mhi); |
} |
ret1: |
Bfree (ptr, b); |
*s = 0; |
*decpt = k + 1; |
if (rve) |
*rve = s; |
return s0; |
} |
/programs/develop/libraries/newlib/stdlib/dtoastub.c |
---|
0,0 → 1,23 |
#include <_ansi.h> |
#include <stdlib.h> |
#include <reent.h> |
#include <string.h> |
/* Nothing in newlib actually *calls* dtoa, they all call _dtoa_r, so this |
is a safe way of providing it to the user. */ |
#ifndef _REENT_ONLY |
char * |
_DEFUN (__dtoa, |
(d, mode, ndigits, decpt, sign, rve), |
double d _AND |
int mode _AND |
int ndigits _AND |
int *decpt _AND |
int *sign _AND |
char **rve) |
{ |
return _dtoa_r (_REENT, d, mode, ndigits, decpt, sign, rve); |
} |
#endif |
/programs/develop/libraries/newlib/stdlib/gd_qnan.h |
---|
0,0 → 1,33 |
#ifdef __IEEE_BIG_ENDIAN |
#define f_QNAN 0x7fc00000 |
#define d_QNAN0 0x7ff80000 |
#define d_QNAN1 0x0 |
#define ld_QNAN0 0x7ff80000 |
#define ld_QNAN1 0x0 |
#define ld_QNAN2 0x0 |
#define ld_QNAN3 0x0 |
#define ldus_QNAN0 0x7ff8 |
#define ldus_QNAN1 0x0 |
#define ldus_QNAN2 0x0 |
#define ldus_QNAN3 0x0 |
#define ldus_QNAN4 0x0 |
#elif defined(__IEEE_LITTLE_ENDIAN) |
#define f_QNAN 0xffc00000 |
#define d_QNAN0 0x0 |
#define d_QNAN1 0xfff80000 |
#define ld_QNAN0 0x0 |
#define ld_QNAN1 0xc0000000 |
#define ld_QNAN2 0xffff |
#define ld_QNAN3 0x0 |
#define ldus_QNAN0 0x0 |
#define ldus_QNAN1 0x0 |
#define ldus_QNAN2 0x0 |
#define ldus_QNAN3 0xc000 |
#define ldus_QNAN4 0xffff |
#else |
#error IEEE endian not defined |
#endif |
/programs/develop/libraries/newlib/stdlib/gdtoa-gethex.c |
---|
0,0 → 1,354 |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 1998 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to David M. Gay (dmg at acm dot org, |
* with " at " changed at "@" and " dot " changed to "."). */ |
#include <_ansi.h> |
#include <reent.h> |
#include <string.h> |
#include "mprec.h" |
#include "gdtoa.h" |
#include "gd_qnan.h" |
#include "locale.h" |
unsigned char hexdig[256]; |
static void |
_DEFUN (htinit, (h, s, inc), |
unsigned char *h _AND |
unsigned char *s _AND |
int inc) |
{ |
int i, j; |
for(i = 0; (j = s[i]) !=0; i++) |
h[j] = i + inc; |
} |
void |
_DEFUN_VOID (hexdig_init) |
{ |
#define USC (unsigned char *) |
htinit(hexdig, USC "0123456789", 0x10); |
htinit(hexdig, USC "abcdef", 0x10 + 10); |
htinit(hexdig, USC "ABCDEF", 0x10 + 10); |
} |
static void |
_DEFUN(rshift, (b, k), |
_Bigint *b _AND |
int k) |
{ |
__ULong *x, *x1, *xe, y; |
int n; |
x = x1 = b->_x; |
n = k >> kshift; |
if (n < b->_wds) { |
xe = x + b->_wds; |
x += n; |
if (k &= kmask) { |
n = ULbits - k; |
y = *x++ >> k; |
while(x < xe) { |
*x1++ = (y | (*x << n)) & ALL_ON; |
y = *x++ >> k; |
} |
if ((*x1 = y) !=0) |
x1++; |
} |
else |
while(x < xe) |
*x1++ = *x++; |
} |
if ((b->_wds = x1 - b->_x) == 0) |
b->_x[0] = 0; |
} |
static _Bigint * |
_DEFUN (increment, (ptr, b), |
struct _reent *ptr _AND |
_Bigint *b) |
{ |
__ULong *x, *xe; |
_Bigint *b1; |
#ifdef Pack_16 |
__ULong carry = 1, y; |
#endif |
x = b->_x; |
xe = x + b->_wds; |
#ifdef Pack_32 |
do { |
if (*x < (__ULong)0xffffffffL) { |
++*x; |
return b; |
} |
*x++ = 0; |
} while(x < xe); |
#else |
do { |
y = *x + carry; |
carry = y >> 16; |
*x++ = y & 0xffff; |
if (!carry) |
return b; |
} while(x < xe); |
if (carry) |
#endif |
{ |
if (b->_wds >= b->_maxwds) { |
b1 = Balloc(ptr, b->_k+1); |
Bcopy(b1, b); |
Bfree(ptr, b); |
b = b1; |
} |
b->_x[b->_wds++] = 1; |
} |
return b; |
} |
int |
_DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), |
struct _reent *ptr _AND |
_CONST char **sp _AND |
FPI *fpi _AND |
Long *exp _AND |
_Bigint **bp _AND |
int sign) |
{ |
_Bigint *b; |
_CONST unsigned char *decpt, *s0, *s, *s1; |
int esign, havedig, irv, k, n, nbits, up, zret; |
__ULong L, lostbits, *x; |
Long e, e1; |
unsigned char *decimalpoint = (unsigned char *) |
_localeconv_r (ptr)->decimal_point; |
size_t decp_len = strlen ((const char *) decimalpoint); |
unsigned char decp_end = decimalpoint[decp_len - 1]; |
if (!hexdig['0']) |
hexdig_init(); |
havedig = 0; |
s0 = *(_CONST unsigned char **)sp + 2; |
while(s0[havedig] == '0') |
havedig++; |
s0 += havedig; |
s = s0; |
decpt = 0; |
zret = 0; |
e = 0; |
if (!hexdig[*s]) { |
zret = 1; |
if (strncmp ((const char *) s, (const char *) decimalpoint, |
decp_len) != 0) |
goto pcheck; |
decpt = (s += decp_len); |
if (!hexdig[*s]) |
goto pcheck; |
while(*s == '0') |
s++; |
if (hexdig[*s]) |
zret = 0; |
havedig = 1; |
s0 = s; |
} |
while(hexdig[*s]) |
s++; |
if (strncmp ((const char *) s, (const char *) decimalpoint, |
decp_len) == 0 |
&& !decpt) { |
decpt = (s += decp_len); |
while(hexdig[*s]) |
s++; |
} |
if (decpt) |
e = -(((Long)(s-decpt)) << 2); |
pcheck: |
s1 = s; |
switch(*s) { |
case 'p': |
case 'P': |
esign = 0; |
switch(*++s) { |
case '-': |
esign = 1; |
/* no break */ |
case '+': |
s++; |
} |
if ((n = hexdig[*s]) == 0 || n > 0x19) { |
s = s1; |
break; |
} |
e1 = n - 0x10; |
while((n = hexdig[*++s]) !=0 && n <= 0x19) |
e1 = 10*e1 + n - 0x10; |
if (esign) |
e1 = -e1; |
e += e1; |
} |
*sp = (char*)s; |
if (zret) |
return havedig ? STRTOG_Zero : STRTOG_NoNumber; |
n = s1 - s0 - 1; |
for(k = 0; n > 7; n >>= 1) |
k++; |
b = Balloc(ptr, k); |
x = b->_x; |
n = 0; |
L = 0; |
while(s1 > s0) { |
if (*--s1 == decp_end && s1 - decp_len + 1 >= s0 |
&& strncmp ((const char *) s1 - decp_len + 1, |
(const char *) decimalpoint, decp_len) == 0) { |
s1 -= decp_len - 1; /* Note the --s1 above! */ |
continue; |
} |
if (n == 32) { |
*x++ = L; |
L = 0; |
n = 0; |
} |
L |= (hexdig[*s1] & 0x0f) << n; |
n += 4; |
} |
*x++ = L; |
b->_wds = n = x - b->_x; |
n = 32*n - hi0bits(L); |
nbits = fpi->nbits; |
lostbits = 0; |
x = b->_x; |
if (n > nbits) { |
n -= nbits; |
if (any_on(b,n)) { |
lostbits = 1; |
k = n - 1; |
if (x[k>>kshift] & 1 << (k & kmask)) { |
lostbits = 2; |
if (k > 1 && any_on(b,k-1)) |
lostbits = 3; |
} |
} |
rshift(b, n); |
e += n; |
} |
else if (n < nbits) { |
n = nbits - n; |
b = lshift(ptr, b, n); |
e -= n; |
x = b->_x; |
} |
if (e > fpi->emax) { |
ovfl: |
Bfree(ptr, b); |
*bp = 0; |
return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; |
} |
irv = STRTOG_Normal; |
if (e < fpi->emin) { |
irv = STRTOG_Denormal; |
n = fpi->emin - e; |
if (n >= nbits) { |
switch (fpi->rounding) { |
case FPI_Round_near: |
if (n == nbits && (n < 2 || any_on(b,n-1))) |
goto one_bit; |
break; |
case FPI_Round_up: |
if (!sign) |
goto one_bit; |
break; |
case FPI_Round_down: |
if (sign) { |
one_bit: |
*exp = fpi->emin; |
x[0] = b->_wds = 1; |
*bp = b; |
return STRTOG_Denormal | STRTOG_Inexhi |
| STRTOG_Underflow; |
} |
} |
Bfree(ptr, b); |
*bp = 0; |
return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow; |
} |
k = n - 1; |
if (lostbits) |
lostbits = 1; |
else if (k > 0) |
lostbits = any_on(b,k); |
if (x[k>>kshift] & 1 << (k & kmask)) |
lostbits |= 2; |
nbits -= n; |
rshift(b,n); |
e = fpi->emin; |
} |
if (lostbits) { |
up = 0; |
switch(fpi->rounding) { |
case FPI_Round_zero: |
break; |
case FPI_Round_near: |
if ((lostbits & 2) |
&& ((lostbits & 1) | (x[0] & 1))) |
up = 1; |
break; |
case FPI_Round_up: |
up = 1 - sign; |
break; |
case FPI_Round_down: |
up = sign; |
} |
if (up) { |
k = b->_wds; |
b = increment(ptr, b); |
x = b->_x; |
if (irv == STRTOG_Denormal) { |
if (nbits == fpi->nbits - 1 |
&& x[nbits >> kshift] & 1 << (nbits & kmask)) |
irv = STRTOG_Normal; |
} |
else if ((b->_wds > k) |
|| ((n = nbits & kmask) !=0 |
&& (hi0bits(x[k-1]) < 32-n))) { |
rshift(b,1); |
if (++e > fpi->emax) |
goto ovfl; |
} |
irv |= STRTOG_Inexhi; |
} |
else |
irv |= STRTOG_Inexlo; |
} |
*bp = b; |
*exp = e; |
return irv; |
} |
/programs/develop/libraries/newlib/stdlib/gdtoa-hexnan.c |
---|
0,0 → 1,142 |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 2000 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to |
David M. Gay |
Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-0636 |
U.S.A. |
dmg@bell-labs.com |
*/ |
/* Modified 06-21-2006 by Jeff Johnston to work with newlib. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <string.h> |
#include "mprec.h" |
#include "gdtoa.h" |
#ifdef INFNAN_CHECK |
static void |
_DEFUN (L_shift, (x, x1, i), |
__ULong *x _AND |
__ULong *x1 _AND |
int i) |
{ |
int j; |
i = 8 - i; |
i <<= 2; |
j = ULbits - i; |
do { |
*x |= x[1] << j; |
x[1] >>= i; |
} while(++x < x1); |
} |
int |
_DEFUN (hexnan, (sp, fpi, x0), |
_CONST char **sp _AND |
FPI *fpi _AND |
__ULong *x0) |
{ |
__ULong c, h, *x, *x1, *xe; |
_CONST char *s; |
int havedig, hd0, i, nbits; |
if (!hexdig['0']) |
hexdig_init(); |
nbits = fpi->nbits; |
x = x0 + (nbits >> kshift); |
if (nbits & kmask) |
x++; |
*--x = 0; |
x1 = xe = x; |
havedig = hd0 = i = 0; |
s = *sp; |
while((c = *(_CONST unsigned char*)++s)) { |
if (!(h = hexdig[c])) { |
if (c <= ' ') { |
if (hd0 < havedig) { |
if (x < x1 && i < 8) |
L_shift(x, x1, i); |
if (x <= x0) { |
i = 8; |
continue; |
} |
hd0 = havedig; |
*--x = 0; |
x1 = x; |
i = 0; |
} |
continue; |
} |
if (/*(*/ c == ')') { |
*sp = s + 1; |
break; |
} |
return STRTOG_NaN; |
} |
havedig++; |
if (++i > 8) { |
if (x <= x0) |
continue; |
i = 1; |
*--x = 0; |
} |
*x = ((*x << 4) | (h & 0xf)); |
} |
if (!havedig) |
return STRTOG_NaN; |
if (x < x1 && i < 8) |
L_shift(x, x1, i); |
if (x > x0) { |
x1 = x0; |
do *x1++ = *x++; |
while(x <= xe); |
do *x1++ = 0; |
while(x1 <= xe); |
} |
else { |
/* truncate high-order word if necessary */ |
if ( (i = nbits & (ULbits-1)) !=0) |
*xe &= ((__ULong)0xffffffff) >> (ULbits - i); |
} |
for(x1 = xe;; --x1) { |
if (*x1 != 0) |
break; |
if (x1 == x0) { |
*x1 = 1; |
break; |
} |
} |
return STRTOG_NaNbits; |
} |
#endif /* INFNAN_CHECK */ |
/programs/develop/libraries/newlib/stdlib/gdtoa.h |
---|
0,0 → 1,72 |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 1998 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to David M. Gay (dmg at acm dot org, |
* with " at " changed at "@" and " dot " changed to "."). */ |
#ifndef GDTOA_H_INCLUDED |
#define GDTOA_H_INCLUDED |
enum { /* return values from strtodg */ |
STRTOG_Zero = 0, |
STRTOG_Normal = 1, |
STRTOG_Denormal = 2, |
STRTOG_Infinite = 3, |
STRTOG_NaN = 4, |
STRTOG_NaNbits = 5, |
STRTOG_NoNumber = 6, |
STRTOG_Retmask = 7, |
/* The following may be or-ed into one of the above values. */ |
STRTOG_Neg = 0x08, |
STRTOG_Inexlo = 0x10, |
STRTOG_Inexhi = 0x20, |
STRTOG_Inexact = 0x30, |
STRTOG_Underflow= 0x40, |
STRTOG_Overflow = 0x80 |
}; |
typedef struct |
FPI { |
int nbits; |
int emin; |
int emax; |
int rounding; |
int sudden_underflow; |
} FPI; |
enum { /* FPI.rounding values: same as FLT_ROUNDS */ |
FPI_Round_zero = 0, |
FPI_Round_near = 1, |
FPI_Round_up = 2, |
FPI_Round_down = 3 |
}; |
#endif /* GDTOA_H_INCLUDED */ |
/programs/develop/libraries/newlib/stdlib/local.h |
---|
0,0 → 1,66 |
/* Misc. local definitions for libc/stdlib */ |
#ifndef _LOCAL_H_ |
#define _LOCAL_H_ |
char * _EXFUN(_gcvt,(struct _reent *, double , int , char *, char, int)); |
char *__locale_charset(_NOARGS); |
#ifndef __mbstate_t_defined |
#include <wchar.h> |
#endif |
extern int (*__wctomb) (struct _reent *, char *, wchar_t, const char *, |
mbstate_t *); |
int __ascii_wctomb (struct _reent *, char *, wchar_t, const char *, |
mbstate_t *); |
#ifdef _MB_CAPABLE |
int __utf8_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __sjis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __eucjp_wctomb (struct _reent *, char *, wchar_t, const char *, |
mbstate_t *); |
int __jis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __iso_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __cp_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
#ifdef __CYGWIN__ |
int __gbk_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __kr_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __big5_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
#endif |
#endif |
extern int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __ascii_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
#ifdef _MB_CAPABLE |
int __utf8_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __sjis_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __eucjp_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __jis_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __iso_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __cp_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
#ifdef __CYGWIN__ |
int __gbk_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __kr_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __big5_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
#endif |
#endif |
extern wchar_t __iso_8859_conv[14][0x60]; |
int __iso_8859_index (const char *); |
extern wchar_t __cp_conv[][0x80]; |
int __cp_index (const char *); |
#endif |
/programs/develop/libraries/newlib/stdlib/malloc.c |
---|
0,0 → 1,227 |
/* VxWorks provides its own version of malloc, and we can't use this |
one because VxWorks does not provide sbrk. So we have a hook to |
not compile this code. */ |
/* The routines here are simple cover fns to the routines that do the real |
work (the reentrant versions). */ |
/* FIXME: Does the warning below (see WARNINGS) about non-reentrancy still |
apply? A first guess would be "no", but how about reentrancy in the *same* |
thread? */ |
#ifdef MALLOC_PROVIDED |
int _dummy_malloc = 1; |
#else |
/* |
FUNCTION |
<<malloc>>, <<realloc>>, <<free>>---manage memory |
INDEX |
malloc |
INDEX |
realloc |
INDEX |
reallocf |
INDEX |
free |
INDEX |
memalign |
INDEX |
malloc_usable_size |
INDEX |
_malloc_r |
INDEX |
_realloc_r |
INDEX |
_reallocf_r |
INDEX |
_free_r |
INDEX |
_memalign_r |
INDEX |
_malloc_usable_size_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void *malloc(size_t <[nbytes]>); |
void *realloc(void *<[aptr]>, size_t <[nbytes]>); |
void *reallocf(void *<[aptr]>, size_t <[nbytes]>); |
void free(void *<[aptr]>); |
void *memalign(size_t <[align]>, size_t <[nbytes]>); |
size_t malloc_usable_size(void *<[aptr]>); |
void *_malloc_r(void *<[reent]>, size_t <[nbytes]>); |
void *_realloc_r(void *<[reent]>, |
void *<[aptr]>, size_t <[nbytes]>); |
void *_reallocf_r(void *<[reent]>, |
void *<[aptr]>, size_t <[nbytes]>); |
void _free_r(void *<[reent]>, void *<[aptr]>); |
void *_memalign_r(void *<[reent]>, |
size_t <[align]>, size_t <[nbytes]>); |
size_t _malloc_usable_size_r(void *<[reent]>, void *<[aptr]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
char *malloc(<[nbytes]>) |
size_t <[nbytes]>; |
char *realloc(<[aptr]>, <[nbytes]>) |
char *<[aptr]>; |
size_t <[nbytes]>; |
char *reallocf(<[aptr]>, <[nbytes]>) |
char *<[aptr]>; |
size_t <[nbytes]>; |
void free(<[aptr]>) |
char *<[aptr]>; |
char *memalign(<[align]>, <[nbytes]>) |
size_t <[align]>; |
size_t <[nbytes]>; |
size_t malloc_usable_size(<[aptr]>) |
char *<[aptr]>; |
char *_malloc_r(<[reent]>,<[nbytes]>) |
char *<[reent]>; |
size_t <[nbytes]>; |
char *_realloc_r(<[reent]>, <[aptr]>, <[nbytes]>) |
char *<[reent]>; |
char *<[aptr]>; |
size_t <[nbytes]>; |
char *_reallocf_r(<[reent]>, <[aptr]>, <[nbytes]>) |
char *<[reent]>; |
char *<[aptr]>; |
size_t <[nbytes]>; |
void _free_r(<[reent]>, <[aptr]>) |
char *<[reent]>; |
char *<[aptr]>; |
char *_memalign_r(<[reent]>, <[align]>, <[nbytes]>) |
char *<[reent]>; |
size_t <[align]>; |
size_t <[nbytes]>; |
size_t malloc_usable_size(<[reent]>, <[aptr]>) |
char *<[reent]>; |
char *<[aptr]>; |
DESCRIPTION |
These functions manage a pool of system memory. |
Use <<malloc>> to request allocation of an object with at least |
<[nbytes]> bytes of storage available. If the space is available, |
<<malloc>> returns a pointer to a newly allocated block as its result. |
If you already have a block of storage allocated by <<malloc>>, but |
you no longer need all the space allocated to it, you can make it |
smaller by calling <<realloc>> with both the object pointer and the |
new desired size as arguments. <<realloc>> guarantees that the |
contents of the smaller object match the beginning of the original object. |
Similarly, if you need more space for an object, use <<realloc>> to |
request the larger size; again, <<realloc>> guarantees that the |
beginning of the new, larger object matches the contents of the |
original object. |
When you no longer need an object originally allocated by <<malloc>> |
or <<realloc>> (or the related function <<calloc>>), return it to the |
memory storage pool by calling <<free>> with the address of the object |
as the argument. You can also use <<realloc>> for this purpose by |
calling it with <<0>> as the <[nbytes]> argument. |
The <<reallocf>> function behaves just like <<realloc>> except if the |
function is required to allocate new storage and this fails. In this |
case <<reallocf>> will free the original object passed in whereas |
<<realloc>> will not. |
The <<memalign>> function returns a block of size <[nbytes]> aligned |
to a <[align]> boundary. The <[align]> argument must be a power of |
two. |
The <<malloc_usable_size>> function takes a pointer to a block |
allocated by <<malloc>>. It returns the amount of space that is |
available in the block. This may or may not be more than the size |
requested from <<malloc>>, due to alignment or minimum size |
constraints. |
The alternate functions <<_malloc_r>>, <<_realloc_r>>, <<_reallocf_r>>, |
<<_free_r>>, <<_memalign_r>>, and <<_malloc_usable_size_r>> are reentrant |
versions. The extra argument <[reent]> is a pointer to a reentrancy structure. |
If you have multiple threads of execution which may call any of these |
routines, or if any of these routines may be called reentrantly, then |
you must provide implementations of the <<__malloc_lock>> and |
<<__malloc_unlock>> functions for your system. See the documentation |
for those functions. |
These functions operate by calling the function <<_sbrk_r>> or |
<<sbrk>>, which allocates space. You may need to provide one of these |
functions for your system. <<_sbrk_r>> is called with a positive |
value to allocate more space, and with a negative value to release |
previously allocated space if it is no longer required. |
@xref{Stubs}. |
RETURNS |
<<malloc>> returns a pointer to the newly allocated space, if |
successful; otherwise it returns <<NULL>>. If your application needs |
to generate empty objects, you may use <<malloc(0)>> for this purpose. |
<<realloc>> returns a pointer to the new block of memory, or <<NULL>> |
if a new block could not be allocated. <<NULL>> is also the result |
when you use `<<realloc(<[aptr]>,0)>>' (which has the same effect as |
`<<free(<[aptr]>)>>'). You should always check the result of |
<<realloc>>; successful reallocation is not guaranteed even when |
you request a smaller object. |
<<free>> does not return a result. |
<<memalign>> returns a pointer to the newly allocated space. |
<<malloc_usable_size>> returns the usable size. |
PORTABILITY |
<<malloc>>, <<realloc>>, and <<free>> are specified by the ANSI C |
standard, but other conforming implementations of <<malloc>> may |
behave differently when <[nbytes]> is zero. |
<<memalign>> is part of SVR4. |
<<malloc_usable_size>> is not portable. |
Supporting OS subroutines required: <<sbrk>>. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdlib.h> |
#include <malloc.h> |
#ifndef _REENT_ONLY |
_PTR |
_DEFUN (malloc, (nbytes), |
size_t nbytes) /* get a block */ |
{ |
return _malloc_r (_REENT, nbytes); |
} |
void |
_DEFUN (free, (aptr), |
_PTR aptr) |
{ |
_free_r (_REENT, aptr); |
} |
#endif |
#endif /* ! defined (MALLOC_PROVIDED) */ |
/programs/develop/libraries/newlib/stdlib/mallocr.c |
---|
0,0 → 1,2171 |
/* |
This is a version (aka dlmalloc) of malloc/free/realloc written by |
Doug Lea and released to the public domain, as explained at |
http://creativecommons.org/licenses/publicdomain. Send questions, |
comments, complaints, performance data, etc to dl@cs.oswego.edu |
* Version 2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) |
Note: There may be an updated version of this malloc obtainable at |
ftp://gee.cs.oswego.edu/pub/misc/malloc.c |
Check before installing! |
* Quickstart |
This library is all in one file to simplify the most common usage: |
ftp it, compile it (-O3), and link it into another program. All of |
the compile-time options default to reasonable values for use on |
most platforms. You might later want to step through various |
compile-time and dynamic tuning options. |
For convenience, an include file for code using this malloc is at: |
ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.4.h |
You don't really need this .h file unless you call functions not |
defined in your system include files. The .h file contains only the |
excerpts from this file needed for using this malloc on ANSI C/C++ |
systems, so long as you haven't changed compile-time options about |
naming and tuning parameters. If you do, then you can create your |
own malloc.h that does include all settings by cutting at the point |
indicated below. Note that you may already by default be using a C |
library containing a malloc that is based on some version of this |
malloc (for example in linux). You might still want to use the one |
in this file to customize settings or to avoid overheads associated |
with library versions. |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
struct malloc_chunk { |
size_t prev_foot; /* Size of previous chunk (if free). */ |
size_t head; /* Size and inuse bits. */ |
struct malloc_chunk* fd; /* double links -- used only if free. */ |
struct malloc_chunk* bk; |
}; |
typedef struct malloc_chunk mchunk; |
typedef struct malloc_chunk* mchunkptr; |
typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ |
typedef unsigned int bindex_t; /* Described below */ |
typedef unsigned int binmap_t; /* Described below */ |
typedef unsigned int flag_t; /* The type of various bit flag sets */ |
/* ------------------- size_t and alignment properties -------------------- */ |
/* The maximum possible size_t value has all bits set */ |
#define MAX_SIZE_T (~(size_t)0) |
void *user_alloc(size_t size) |
{ |
void *val; |
// __asm__("int3"); |
__asm__ __volatile__( |
"int $0x40" |
:"=eax"(val) |
:"a"(68),"b"(12),"c"(size)); |
return val; |
} |
static inline |
int user_free(void *mem) |
{ |
int val; |
// __asm__("int3"); |
__asm__ __volatile__( |
"int $0x40" |
:"=eax"(val) |
:"a"(68),"b"(13),"c"(mem)); |
return val; |
} |
/* ------------------- size_t and alignment properties -------------------- */ |
/* The byte and bit size of a size_t */ |
#define SIZE_T_SIZE (sizeof(size_t)) |
#define SIZE_T_BITSIZE (sizeof(size_t) << 3) |
/* Some constants coerced to size_t */ |
/* Annoying but necessary to avoid errors on some platforms */ |
#define SIZE_T_ZERO ((size_t)0) |
#define SIZE_T_ONE ((size_t)1) |
#define SIZE_T_TWO ((size_t)2) |
#define SIZE_T_FOUR ((size_t)4) |
#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) |
#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) |
#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) |
#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) |
#define USE_LOCK_BIT (2U) |
#define USE_MMAP_BIT (SIZE_T_ONE) |
#define USE_NONCONTIGUOUS_BIT (4U) |
/* segment bit set in create_mspace_with_base */ |
#define EXTERN_BIT (8U) |
#define HAVE_MMAP 1 |
#define CALL_MMAP(s) MMAP_DEFAULT(s) |
#define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) |
#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL |
#define calloc_must_clear(p) (!is_mmapped(p)) |
#define MALLOC_FAILURE_ACTION |
#define MAX_RELEASE_CHECK_RATE 4095 |
#define NO_SEGMENT_TRAVERSAL 1 |
#define MALLOC_ALIGNMENT ((size_t)8U) |
#define CHUNK_OVERHEAD (SIZE_T_SIZE) |
#define DEFAULT_GRANULARITY ((size_t)512U * (size_t)1024U) |
#define DEFAULT_MMAP_THRESHOLD ((size_t)1024U * (size_t)1024U) |
#define DEFAULT_TRIM_THRESHOLD ((size_t)2048U * (size_t)1024U) |
/* The bit mask value corresponding to MALLOC_ALIGNMENT */ |
#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) |
/* True if address a has acceptable alignment */ |
#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) |
/* the number of bytes to offset an address to align it */ |
#define align_offset(A)\ |
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ |
((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) |
#define MFAIL ((void*)(MAX_SIZE_T)) |
#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ |
/* For sys_alloc, enough padding to ensure can malloc request on success */ |
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) |
/* |
TOP_FOOT_SIZE is padding at the end of a segment, including space |
that may be needed to place segment records and fenceposts when new |
noncontiguous segments are added. |
*/ |
#define TOP_FOOT_SIZE\ |
(align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) |
/* ------------------- Chunks sizes and alignments ----------------------- */ |
#define MCHUNK_SIZE (sizeof(mchunk)) |
/* MMapped chunks need a second word of overhead ... */ |
#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) |
/* ... and additional padding for fake next-chunk at foot */ |
#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) |
/* The smallest size we can malloc is an aligned minimal chunk */ |
#define MIN_CHUNK_SIZE\ |
((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
/* conversion from malloc headers to user pointers, and back */ |
#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) |
#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) |
/* chunk associated with aligned address A */ |
#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) |
/* Bounds on request (not chunk) sizes. */ |
#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) |
#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) |
/* pad request bytes into a usable size */ |
#define pad_request(req) \ |
(((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
/* pad request, checking for minimum (but not maximum) */ |
#define request2size(req) \ |
(((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) |
/* ------------------ Operations on head and foot fields ----------------- */ |
/* |
The head field of a chunk is or'ed with PINUSE_BIT when previous |
adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in |
use, unless mmapped, in which case both bits are cleared. |
FLAG4_BIT is not used by this malloc, but might be useful in extensions. |
*/ |
#define PINUSE_BIT (SIZE_T_ONE) |
#define CINUSE_BIT (SIZE_T_TWO) |
#define FLAG4_BIT (SIZE_T_FOUR) |
#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) |
#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) |
/* Head value for fenceposts */ |
#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) |
/* extraction of fields from head words */ |
#define cinuse(p) ((p)->head & CINUSE_BIT) |
#define pinuse(p) ((p)->head & PINUSE_BIT) |
#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) |
#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) |
#define chunksize(p) ((p)->head & ~(FLAG_BITS)) |
#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) |
/* Treat space at ptr +/- offset as a chunk */ |
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) |
#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) |
/* Ptr to next or previous physical malloc_chunk. */ |
#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) |
#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) |
/* extract next chunk's pinuse bit */ |
#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) |
/* Set size, pinuse bit, and foot */ |
#define set_size_and_pinuse_of_free_chunk(p, s)\ |
((p)->head = (s|PINUSE_BIT), set_foot(p, s)) |
/* Set size, pinuse bit, foot, and clear next pinuse */ |
#define set_free_with_pinuse(p, s, n)\ |
(clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) |
/* Get the internal overhead associated with chunk p */ |
#define overhead_for(p)\ |
(is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) |
struct malloc_tree_chunk { |
/* The first four fields must be compatible with malloc_chunk */ |
size_t prev_foot; |
size_t head; |
struct malloc_tree_chunk* fd; |
struct malloc_tree_chunk* bk; |
struct malloc_tree_chunk* child[2]; |
struct malloc_tree_chunk* parent; |
bindex_t index; |
}; |
typedef struct malloc_tree_chunk tchunk; |
typedef struct malloc_tree_chunk* tchunkptr; |
typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ |
/* A little helper macro for trees */ |
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) |
struct malloc_segment { |
char* base; /* base address */ |
size_t size; /* allocated size */ |
struct malloc_segment* next; /* ptr to next segment */ |
flag_t sflags; /* mmap and extern flag */ |
}; |
#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) |
#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) |
typedef struct malloc_segment msegment; |
typedef struct malloc_segment* msegmentptr; |
/* ---------------------------- malloc_state ----------------------------- */ |
/* |
A malloc_state holds all of the bookkeeping for a space. |
The main fields are: |
Top |
The topmost chunk of the currently active segment. Its size is |
cached in topsize. The actual size of topmost space is |
topsize+TOP_FOOT_SIZE, which includes space reserved for adding |
fenceposts and segment records if necessary when getting more |
space from the system. The size at which to autotrim top is |
cached from mparams in trim_check, except that it is disabled if |
an autotrim fails. |
Designated victim (dv) |
This is the preferred chunk for servicing small requests that |
don't have exact fits. It is normally the chunk split off most |
recently to service another small request. Its size is cached in |
dvsize. The link fields of this chunk are not maintained since it |
is not kept in a bin. |
SmallBins |
An array of bin headers for free chunks. These bins hold chunks |
with sizes less than MIN_LARGE_SIZE bytes. Each bin contains |
chunks of all the same size, spaced 8 bytes apart. To simplify |
use in double-linked lists, each bin header acts as a malloc_chunk |
pointing to the real first node, if it exists (else pointing to |
itself). This avoids special-casing for headers. But to avoid |
waste, we allocate only the fd/bk pointers of bins, and then use |
repositioning tricks to treat these as the fields of a chunk. |
TreeBins |
Treebins are pointers to the roots of trees holding a range of |
sizes. There are 2 equally spaced treebins for each power of two |
from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything |
larger. |
Bin maps |
There is one bit map for small bins ("smallmap") and one for |
treebins ("treemap). Each bin sets its bit when non-empty, and |
clears the bit when empty. Bit operations are then used to avoid |
bin-by-bin searching -- nearly all "search" is done without ever |
looking at bins that won't be selected. The bit maps |
conservatively use 32 bits per map word, even if on 64bit system. |
For a good description of some of the bit-based techniques used |
here, see Henry S. Warren Jr's book "Hacker's Delight" (and |
supplement at http://hackersdelight.org/). Many of these are |
intended to reduce the branchiness of paths through malloc etc, as |
well as to reduce the number of memory locations read or written. |
Segments |
A list of segments headed by an embedded malloc_segment record |
representing the initial space. |
Address check support |
The least_addr field is the least address ever obtained from |
MORECORE or MMAP. Attempted frees and reallocs of any address less |
than this are trapped (unless INSECURE is defined). |
Magic tag |
A cross-check field that should always hold same value as mparams.magic. |
Flags |
Bits recording whether to use MMAP, locks, or contiguous MORECORE |
Statistics |
Each space keeps track of current and maximum system memory |
obtained via MORECORE or MMAP. |
Trim support |
Fields holding the amount of unused topmost memory that should trigger |
timming, and a counter to force periodic scanning to release unused |
non-topmost segments. |
Locking |
If USE_LOCKS is defined, the "mutex" lock is acquired and released |
around every public call using this mspace. |
Extension support |
A void* pointer and a size_t field that can be used to help implement |
extensions to this malloc. |
*/ |
/* Bin types, widths and sizes */ |
#define NSMALLBINS (32U) |
#define NTREEBINS (32U) |
#define SMALLBIN_SHIFT (3U) |
#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) |
#define TREEBIN_SHIFT (8U) |
#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) |
#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) |
#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) |
struct malloc_state { |
binmap_t smallmap; |
binmap_t treemap; |
size_t dvsize; |
size_t topsize; |
char* least_addr; |
mchunkptr dv; |
mchunkptr top; |
size_t trim_check; |
size_t release_checks; |
size_t magic; |
mchunkptr smallbins[(NSMALLBINS+1)*2]; |
tbinptr treebins[NTREEBINS]; |
size_t footprint; |
size_t max_footprint; |
flag_t mflags; |
__libc_lock_recursive_t lock; /* locate lock among fields that rarely change */ |
msegment seg; |
void* extp; /* Unused but available for extensions */ |
size_t exts; |
}; |
typedef struct malloc_state* mstate; |
/* ------------- Global malloc_state and malloc_params ------------------- */ |
/* |
malloc_params holds global properties, including those that can be |
dynamically set using mallopt. There is a single instance, mparams, |
initialized in init_mparams. Note that the non-zeroness of "magic" |
also serves as an initialization flag. |
*/ |
struct malloc_params |
{ |
volatile size_t magic; |
size_t page_size; |
size_t granularity; |
size_t mmap_threshold; |
size_t trim_threshold; |
flag_t default_mflags; |
}; |
static struct malloc_params mparams; |
/* Ensure mparams initialized */ |
#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) |
static struct malloc_state _gm_; |
#define gm (&_gm_) |
#define is_global(M) ((M) == &_gm_) |
#define is_initialized(M) ((M)->top != 0) |
__LOCK_INIT_RECURSIVE(static, malloc_global_mutex); |
#define ACQUIRE_MALLOC_GLOBAL_LOCK() __libc_lock_lock_recursive(malloc_global_mutex); |
#define RELEASE_MALLOC_GLOBAL_LOCK() __libc_lock_unlock_recursive(malloc_global_mutex); |
#define PREACTION(M) ( __libc_lock_lock_recursive((M)->lock)) |
#define POSTACTION(M) { __libc_lock_unlock_recursive((M)->lock); } |
/* ---------------------------- Indexing Bins ---------------------------- */ |
#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) |
#define small_index(s) ((s) >> SMALLBIN_SHIFT) |
#define small_index2size(i) ((i) << SMALLBIN_SHIFT) |
#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) |
/* addressing by index. See above about smallbin repositioning */ |
#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) |
#define treebin_at(M,i) (&((M)->treebins[i])) |
#define compute_tree_index(S, I)\ |
{\ |
unsigned int X = S >> TREEBIN_SHIFT;\ |
if (X == 0)\ |
I = 0;\ |
else if (X > 0xFFFF)\ |
I = NTREEBINS-1;\ |
else {\ |
unsigned int K;\ |
__asm__("bsrl\t%1, %0\n\t" : "=r" (K) : "g" (X));\ |
I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ |
}\ |
} |
/* Bit representing maximum resolved size in a treebin at i */ |
#define bit_for_tree_index(i) \ |
(i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) |
/* Shift placing maximum resolved bit in a treebin at i as sign bit */ |
#define leftshift_for_tree_index(i) \ |
((i == NTREEBINS-1)? 0 : \ |
((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) |
/* The size of the smallest chunk held in bin with index i */ |
#define minsize_for_tree_index(i) \ |
((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ |
(((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) |
/* ------------------------ Operations on bin maps ----------------------- */ |
/* bit corresponding to given index */ |
#define idx2bit(i) ((binmap_t)(1) << (i)) |
/* Mark/Clear bits with given index */ |
#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) |
#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) |
#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) |
#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) |
#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) |
#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) |
/* isolate the least set bit of a bitmap */ |
#define least_bit(x) ((x) & -(x)) |
/* mask with all bits to left of least bit of x on */ |
#define left_bits(x) ((x<<1) | -(x<<1)) |
/* mask with all bits to left of or equal to least bit of x on */ |
#define same_or_left_bits(x) ((x) | -(x)) |
/* index corresponding to given bit. Use x86 asm if possible */ |
#define compute_bit2idx(X, I)\ |
{\ |
unsigned int J;\ |
__asm__("bsfl\t%1, %0\n\t" : "=r" (J) : "g" (X));\ |
I = (bindex_t)J;\ |
} |
#define mark_inuse_foot(M,p,s) |
/* Get/set size at footer */ |
#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) |
#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) |
/* Macros for setting head/foot of non-mmapped chunks */ |
/* Set cinuse bit and pinuse bit of next chunk */ |
#define set_inuse(M,p,s)\ |
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ |
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) |
/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ |
#define set_inuse_and_pinuse(M,p,s)\ |
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ |
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) |
/* Set size, cinuse and pinuse bit of this chunk */ |
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ |
((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) |
#define assert(x) |
#define RTCHECK(e) __builtin_expect(e, 1) |
#define check_free_chunk(M,P) |
#define check_inuse_chunk(M,P) |
#define check_malloced_chunk(M,P,N) |
#define check_mmapped_chunk(M,P) |
#define check_malloc_state(M) |
#define check_top_chunk(M,P) |
/* Check if address a is at least as high as any from MORECORE or MMAP */ |
#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) |
/* Check if address of next chunk n is higher than base chunk p */ |
#define ok_next(p, n) ((char*)(p) < (char*)(n)) |
/* Check if p has inuse status */ |
#define ok_inuse(p) is_inuse(p) |
/* Check if p has its pinuse bit on */ |
#define ok_pinuse(p) pinuse(p) |
#define CORRUPTION_ERROR_ACTION(m) \ |
do { \ |
printf("%s malloc heap corrupted\n",__FUNCTION__); \ |
__asm__("int3"); \ |
}while(0) \ |
#define USAGE_ERROR_ACTION(m, p) \ |
do { \ |
printf("%s malloc heap corrupted\n",__FUNCTION__); \ |
__asm__("int3"); \ |
}while(0) \ |
/* ----------------------- Operations on smallbins ----------------------- */ |
/* |
Various forms of linking and unlinking are defined as macros. Even |
the ones for trees, which are very long but have very short typical |
paths. This is ugly but reduces reliance on inlining support of |
compilers. |
*/ |
/* Link a free chunk into a smallbin */ |
#define insert_small_chunk(M, P, S) {\ |
bindex_t I = small_index(S);\ |
mchunkptr B = smallbin_at(M, I);\ |
mchunkptr F = B;\ |
assert(S >= MIN_CHUNK_SIZE);\ |
if (!smallmap_is_marked(M, I))\ |
mark_smallmap(M, I);\ |
else if (RTCHECK(ok_address(M, B->fd)))\ |
F = B->fd;\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
B->fd = P;\ |
F->bk = P;\ |
P->fd = F;\ |
P->bk = B;\ |
} |
/* Unlink a chunk from a smallbin */ |
#define unlink_small_chunk(M, P, S) {\ |
mchunkptr F = P->fd;\ |
mchunkptr B = P->bk;\ |
bindex_t I = small_index(S);\ |
assert(P != B);\ |
assert(P != F);\ |
assert(chunksize(P) == small_index2size(I));\ |
if (F == B)\ |
clear_smallmap(M, I);\ |
else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\ |
(B == smallbin_at(M,I) || ok_address(M, B)))) {\ |
F->bk = B;\ |
B->fd = F;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
} |
/* Unlink the first chunk from a smallbin */ |
#define unlink_first_small_chunk(M, B, P, I) {\ |
mchunkptr F = P->fd;\ |
assert(P != B);\ |
assert(P != F);\ |
assert(chunksize(P) == small_index2size(I));\ |
if (B == F)\ |
clear_smallmap(M, I);\ |
else if (RTCHECK(ok_address(M, F))) {\ |
B->fd = F;\ |
F->bk = B;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
} |
/* Replace dv node, binning the old one */ |
/* Used only when dvsize known to be small */ |
#define replace_dv(M, P, S) {\ |
size_t DVS = M->dvsize;\ |
if (DVS != 0) {\ |
mchunkptr DV = M->dv;\ |
assert(is_small(DVS));\ |
insert_small_chunk(M, DV, DVS);\ |
}\ |
M->dvsize = S;\ |
M->dv = P;\ |
} |
/* ------------------------- Operations on trees ------------------------- */ |
/* Insert chunk into tree */ |
#define insert_large_chunk(M, X, S) {\ |
tbinptr* H;\ |
bindex_t I;\ |
compute_tree_index(S, I);\ |
H = treebin_at(M, I);\ |
X->index = I;\ |
X->child[0] = X->child[1] = 0;\ |
if (!treemap_is_marked(M, I)) {\ |
mark_treemap(M, I);\ |
*H = X;\ |
X->parent = (tchunkptr)H;\ |
X->fd = X->bk = X;\ |
}\ |
else {\ |
tchunkptr T = *H;\ |
size_t K = S << leftshift_for_tree_index(I);\ |
for (;;) {\ |
if (chunksize(T) != S) {\ |
tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ |
K <<= 1;\ |
if (*C != 0)\ |
T = *C;\ |
else if (RTCHECK(ok_address(M, C))) {\ |
*C = X;\ |
X->parent = T;\ |
X->fd = X->bk = X;\ |
break;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
break;\ |
}\ |
}\ |
else {\ |
tchunkptr F = T->fd;\ |
if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ |
T->fd = F->bk = X;\ |
X->fd = F;\ |
X->bk = T;\ |
X->parent = 0;\ |
break;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
break;\ |
}\ |
}\ |
}\ |
}\ |
} |
/* |
Unlink steps: |
1. If x is a chained node, unlink it from its same-sized fd/bk links |
and choose its bk node as its replacement. |
2. If x was the last node of its size, but not a leaf node, it must |
be replaced with a leaf node (not merely one with an open left or |
right), to make sure that lefts and rights of descendents |
correspond properly to bit masks. We use the rightmost descendent |
of x. We could use any other leaf, but this is easy to locate and |
tends to counteract removal of leftmosts elsewhere, and so keeps |
paths shorter than minimally guaranteed. This doesn't loop much |
because on average a node in a tree is near the bottom. |
3. If x is the base of a chain (i.e., has parent links) relink |
x's parent and children to x's replacement (or null if none). |
*/ |
#define unlink_large_chunk(M, X) {\ |
tchunkptr XP = X->parent;\ |
tchunkptr R;\ |
if (X->bk != X) {\ |
tchunkptr F = X->fd;\ |
R = X->bk;\ |
if (RTCHECK(ok_address(M, F))) {\ |
F->bk = R;\ |
R->fd = F;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
else {\ |
tchunkptr* RP;\ |
if (((R = *(RP = &(X->child[1]))) != 0) ||\ |
((R = *(RP = &(X->child[0]))) != 0)) {\ |
tchunkptr* CP;\ |
while ((*(CP = &(R->child[1])) != 0) ||\ |
(*(CP = &(R->child[0])) != 0)) {\ |
R = *(RP = CP);\ |
}\ |
if (RTCHECK(ok_address(M, RP)))\ |
*RP = 0;\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
}\ |
if (XP != 0) {\ |
tbinptr* H = treebin_at(M, X->index);\ |
if (X == *H) {\ |
if ((*H = R) == 0) \ |
clear_treemap(M, X->index);\ |
}\ |
else if (RTCHECK(ok_address(M, XP))) {\ |
if (XP->child[0] == X) \ |
XP->child[0] = R;\ |
else \ |
XP->child[1] = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
if (R != 0) {\ |
if (RTCHECK(ok_address(M, R))) {\ |
tchunkptr C0, C1;\ |
R->parent = XP;\ |
if ((C0 = X->child[0]) != 0) {\ |
if (RTCHECK(ok_address(M, C0))) {\ |
R->child[0] = C0;\ |
C0->parent = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
if ((C1 = X->child[1]) != 0) {\ |
if (RTCHECK(ok_address(M, C1))) {\ |
R->child[1] = C1;\ |
C1->parent = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
} |
/* Relays to large vs small bin operations */ |
#define insert_chunk(M, P, S)\ |
if (is_small(S)) insert_small_chunk(M, P, S)\ |
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } |
#define unlink_chunk(M, P, S)\ |
if (is_small(S)) unlink_small_chunk(M, P, S)\ |
else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } |
/* -------------------------- system alloc setup ------------------------- */ |
/* Operations on mflags */ |
#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) |
#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) |
#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) |
#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) |
#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) |
#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) |
#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) |
#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) |
#define set_lock(M,L)\ |
((M)->mflags = (L)?\ |
((M)->mflags | USE_LOCK_BIT) :\ |
((M)->mflags & ~USE_LOCK_BIT)) |
/* page-align a size */ |
#define page_align(S)\ |
(((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) |
/* granularity-align a size */ |
#define granularity_align(S)\ |
(((S) + (mparams.granularity - SIZE_T_ONE))\ |
& ~(mparams.granularity - SIZE_T_ONE)) |
/* For mmap, use granularity alignment */ |
#define mmap_align(S) granularity_align(S) |
/* For sys_alloc, enough padding to ensure can malloc request on success */ |
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) |
#define is_page_aligned(S)\ |
(((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) |
#define is_granularity_aligned(S)\ |
(((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) |
/* True if segment S holds address A */ |
#define segment_holds(S, A)\ |
((char*)(A) >= S->base && (char*)(A) < S->base + S->size) |
/* Return segment holding given address */ |
static msegmentptr segment_holding(mstate m, char* addr) |
{ |
msegmentptr sp = &m->seg; |
for (;;) { |
if (addr >= sp->base && addr < sp->base + sp->size) |
return sp; |
if ((sp = sp->next) == 0) |
return 0; |
} |
} |
/* Return true if segment contains a segment link */ |
static int has_segment_link(mstate m, msegmentptr ss) |
{ |
msegmentptr sp = &m->seg; |
for (;;) { |
if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) |
return 1; |
if ((sp = sp->next) == 0) |
return 0; |
} |
} |
static inline void* os_mmap(size_t size) |
{ |
void* ptr = user_alloc(size); |
return (ptr != 0)? ptr: MFAIL; |
} |
static inline int os_munmap(void* ptr, size_t size) |
{ |
return (user_free(ptr) != 0) ? 0 : -1; |
} |
#define should_trim(M,s) ((s) > (M)->trim_check) |
#define MMAP_DEFAULT(s) os_mmap(s) |
#define MUNMAP_DEFAULT(a, s) os_munmap((a), (s)) |
#define DIRECT_MMAP_DEFAULT(s) os_mmap(s) |
#define internal_malloc(m, b) malloc(b) |
#define internal_free(m, mem) free(mem) |
/* ----------------------- Direct-mmapping chunks ----------------------- */ |
/* |
Directly mmapped chunks are set up with an offset to the start of |
the mmapped region stored in the prev_foot field of the chunk. This |
allows reconstruction of the required argument to MUNMAP when freed, |
and also allows adjustment of the returned chunk to meet alignment |
requirements (especially in memalign). |
*/ |
/* Malloc using mmap */ |
static void* mmap_alloc(mstate m, size_t nb) |
{ |
size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
if (mmsize > nb) /* Check for wrap around 0 */ |
{ |
char* mm = (char*)(os_mmap(mmsize)); |
if (mm != CMFAIL) |
{ |
size_t offset = align_offset(chunk2mem(mm)); |
size_t psize = mmsize - offset - MMAP_FOOT_PAD; |
mchunkptr p = (mchunkptr)(mm + offset); |
p->prev_foot = offset; |
p->head = psize; |
mark_inuse_foot(m, p, psize); |
chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; |
chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; |
if (m->least_addr == 0 || mm < m->least_addr) |
m->least_addr = mm; |
if ((m->footprint += mmsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
assert(is_aligned(chunk2mem(p))); |
check_mmapped_chunk(m, p); |
return chunk2mem(p); |
} |
} |
return 0; |
} |
/* Realloc using mmap */ |
static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) |
{ |
size_t oldsize = chunksize(oldp); |
if (is_small(nb)) /* Can't shrink mmap regions below small size */ |
return 0; |
/* Keep old chunk if big enough but not too big */ |
if (oldsize >= nb + SIZE_T_SIZE && |
(oldsize - nb) <= (mparams.granularity << 1)) |
return oldp; |
else |
{ |
size_t offset = oldp->prev_foot; |
size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; |
size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
char* cp = (char*)CALL_MREMAP((char*)oldp - offset, |
oldmmsize, newmmsize, 1); |
if (cp != CMFAIL) |
{ |
mchunkptr newp = (mchunkptr)(cp + offset); |
size_t psize = newmmsize - offset - MMAP_FOOT_PAD; |
newp->head = psize; |
mark_inuse_foot(m, newp, psize); |
chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; |
chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; |
if (cp < m->least_addr) |
m->least_addr = cp; |
if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
check_mmapped_chunk(m, newp); |
return newp; |
} |
} |
return 0; |
} |
/* ---------------------------- setting mparams -------------------------- */ |
/* Initialize mparams */ |
static int init_mparams(void) { |
ACQUIRE_MALLOC_GLOBAL_LOCK(); |
if (mparams.magic == 0) |
{ |
size_t magic; |
size_t psize; |
size_t gsize; |
psize = 4096; |
gsize = DEFAULT_GRANULARITY; |
/* Sanity-check configuration: |
size_t must be unsigned and as wide as pointer type. |
ints must be at least 4 bytes. |
alignment must be at least 8. |
Alignment, min chunk size, and page size must all be powers of 2. |
*/ |
mparams.granularity = gsize; |
mparams.page_size = psize; |
mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; |
mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; |
mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; |
/* Set up lock for main malloc area */ |
gm->mflags = mparams.default_mflags; |
__libc_lock_init_recursive(gm->lock); |
magic = (size_t)(0x12345678 ^ (size_t)0x55555555U); |
magic |= (size_t)8U; /* ensure nonzero */ |
magic &= ~(size_t)7U; /* improve chances of fault for bad values */ |
mparams.magic = magic; |
} |
RELEASE_MALLOC_GLOBAL_LOCK(); |
return 1; |
} |
/* -------------------------- mspace management -------------------------- */ |
/* Initialize top chunk and its size */ |
static void init_top(mstate m, mchunkptr p, size_t psize) |
{ |
/* Ensure alignment */ |
size_t offset = align_offset(chunk2mem(p)); |
p = (mchunkptr)((char*)p + offset); |
psize -= offset; |
m->top = p; |
m->topsize = psize; |
p->head = psize | PINUSE_BIT; |
/* set size of fake trailing chunk holding overhead space only once */ |
chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; |
m->trim_check = mparams.trim_threshold; /* reset on each update */ |
} |
/* Initialize bins for a new mstate that is otherwise zeroed out */ |
static void init_bins(mstate m) |
{ |
/* Establish circular links for smallbins */ |
bindex_t i; |
for (i = 0; i < NSMALLBINS; ++i) { |
sbinptr bin = smallbin_at(m,i); |
bin->fd = bin->bk = bin; |
} |
} |
/* Allocate chunk and prepend remainder with chunk in successor base. */ |
static void* prepend_alloc(mstate m, char* newbase, char* oldbase, |
size_t nb) |
{ |
mchunkptr p = align_as_chunk(newbase); |
mchunkptr oldfirst = align_as_chunk(oldbase); |
size_t psize = (char*)oldfirst - (char*)p; |
mchunkptr q = chunk_plus_offset(p, nb); |
size_t qsize = psize - nb; |
set_size_and_pinuse_of_inuse_chunk(m, p, nb); |
assert((char*)oldfirst > (char*)q); |
assert(pinuse(oldfirst)); |
assert(qsize >= MIN_CHUNK_SIZE); |
/* consolidate remainder with first chunk of old base */ |
if (oldfirst == m->top) { |
size_t tsize = m->topsize += qsize; |
m->top = q; |
q->head = tsize | PINUSE_BIT; |
check_top_chunk(m, q); |
} |
else if (oldfirst == m->dv) { |
size_t dsize = m->dvsize += qsize; |
m->dv = q; |
set_size_and_pinuse_of_free_chunk(q, dsize); |
} |
else { |
if (!is_inuse(oldfirst)) { |
size_t nsize = chunksize(oldfirst); |
unlink_chunk(m, oldfirst, nsize); |
oldfirst = chunk_plus_offset(oldfirst, nsize); |
qsize += nsize; |
} |
set_free_with_pinuse(q, qsize, oldfirst); |
insert_chunk(m, q, qsize); |
check_free_chunk(m, q); |
} |
check_malloced_chunk(m, chunk2mem(p), nb); |
return chunk2mem(p); |
} |
/* Add a segment to hold a new noncontiguous region */ |
static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) |
{ |
/* Determine locations and sizes of segment, fenceposts, old top */ |
char* old_top = (char*)m->top; |
msegmentptr oldsp = segment_holding(m, old_top); |
char* old_end = oldsp->base + oldsp->size; |
size_t ssize = pad_request(sizeof(struct malloc_segment)); |
char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
size_t offset = align_offset(chunk2mem(rawsp)); |
char* asp = rawsp + offset; |
char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; |
mchunkptr sp = (mchunkptr)csp; |
msegmentptr ss = (msegmentptr)(chunk2mem(sp)); |
mchunkptr tnext = chunk_plus_offset(sp, ssize); |
mchunkptr p = tnext; |
int nfences = 0; |
/* reset top to new space */ |
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); |
/* Set up segment record */ |
assert(is_aligned(ss)); |
set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); |
*ss = m->seg; /* Push current record */ |
m->seg.base = tbase; |
m->seg.size = tsize; |
m->seg.sflags = mmapped; |
m->seg.next = ss; |
/* Insert trailing fenceposts */ |
for (;;) { |
mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); |
p->head = FENCEPOST_HEAD; |
++nfences; |
if ((char*)(&(nextp->head)) < old_end) |
p = nextp; |
else |
break; |
} |
assert(nfences >= 2); |
/* Insert the rest of old top into a bin as an ordinary free chunk */ |
if (csp != old_top) { |
mchunkptr q = (mchunkptr)old_top; |
size_t psize = csp - old_top; |
mchunkptr tn = chunk_plus_offset(q, psize); |
set_free_with_pinuse(q, psize, tn); |
insert_chunk(m, q, psize); |
} |
check_top_chunk(m, m->top); |
} |
/* -------------------------- System allocation -------------------------- */ |
/* Get memory from system using MORECORE or MMAP */ |
static void* sys_alloc(mstate m, size_t nb) |
{ |
char* tbase = CMFAIL; |
size_t tsize = 0; |
flag_t mmap_flag = 0; |
ensure_initialization(); |
/* Directly map large chunks, but only if already initialized */ |
if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) |
{ |
void* mem = mmap_alloc(m, nb); |
if (mem != 0) |
return mem; |
} |
/* |
Try getting memory in any of three ways (in most-preferred to |
least-preferred order): |
1. A call to MORECORE that can normally contiguously extend memory. |
(disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or |
or main space is mmapped or a previous contiguous call failed) |
2. A call to MMAP new space (disabled if not HAVE_MMAP). |
Note that under the default settings, if MORECORE is unable to |
fulfill a request, and HAVE_MMAP is true, then mmap is |
used as a noncontiguous system allocator. This is a useful backup |
strategy for systems with holes in address spaces -- in this case |
sbrk cannot contiguously expand the heap, but mmap may be able to |
find space. |
3. A call to MORECORE that cannot usually contiguously extend memory. |
(disabled if not HAVE_MORECORE) |
In all cases, we need to request enough bytes from system to ensure |
we can malloc nb bytes upon success, so pad with enough space for |
top_foot, plus alignment-pad to make sure we don't lose bytes if |
not on boundary, and round this up to a granularity unit. |
*/ |
if (HAVE_MMAP && tbase == CMFAIL) /* Try MMAP */ |
{ |
size_t rsize = granularity_align(nb + SYS_ALLOC_PADDING); |
if (rsize > nb) /* Fail if wraps around zero */ |
{ |
char* mp = (char*)(CALL_MMAP(rsize)); |
if (mp != CMFAIL) |
{ |
tbase = mp; |
tsize = rsize; |
mmap_flag = USE_MMAP_BIT; |
} |
} |
} |
if (tbase != CMFAIL) |
{ |
if ((m->footprint += tsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
if (!is_initialized(m)) /* first-time initialization */ |
{ |
if (m->least_addr == 0 || tbase < m->least_addr) |
m->least_addr = tbase; |
m->seg.base = tbase; |
m->seg.size = tsize; |
m->seg.sflags = mmap_flag; |
m->magic = mparams.magic; |
m->release_checks = MAX_RELEASE_CHECK_RATE; |
init_bins(m); |
if (is_global(m)) |
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); |
else |
{ |
/* Offset top by embedded malloc_state */ |
mchunkptr mn = next_chunk(mem2chunk(m)); |
init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); |
} |
} |
else |
{ |
/* Try to merge with an existing segment */ |
msegmentptr sp = &m->seg; |
/* Only consider most recent segment if traversal suppressed */ |
while (sp != 0 && tbase != sp->base + sp->size) |
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; |
if (sp != 0 && !is_extern_segment(sp) && |
(sp->sflags & USE_MMAP_BIT) == mmap_flag && |
segment_holds(sp, m->top)) /* append */ |
{ |
sp->size += tsize; |
init_top(m, m->top, m->topsize + tsize); |
} |
else |
{ |
if (tbase < m->least_addr) |
m->least_addr = tbase; |
sp = &m->seg; |
while (sp != 0 && sp->base != tbase + tsize) |
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; |
if (sp != 0 && !is_extern_segment(sp) && |
(sp->sflags & USE_MMAP_BIT) == mmap_flag) |
{ |
char* oldbase = sp->base; |
sp->base = tbase; |
sp->size += tsize; |
return prepend_alloc(m, tbase, oldbase, nb); |
} |
else |
add_segment(m, tbase, tsize, mmap_flag); |
} |
} |
if (nb < m->topsize) /* Allocate from new or extended top space */ |
{ |
size_t rsize = m->topsize -= nb; |
mchunkptr p = m->top; |
mchunkptr r = m->top = chunk_plus_offset(p, nb); |
r->head = rsize | PINUSE_BIT; |
set_size_and_pinuse_of_inuse_chunk(m, p, nb); |
check_top_chunk(m, m->top); |
check_malloced_chunk(m, chunk2mem(p), nb); |
return chunk2mem(p); |
} |
} |
MALLOC_FAILURE_ACTION; |
return 0; |
} |
/* ----------------------- system deallocation -------------------------- */ |
/* Unmap and unlink any mmapped segments that don't contain used chunks */ |
static size_t release_unused_segments(mstate m) |
{ |
size_t released = 0; |
int nsegs = 0; |
msegmentptr pred = &m->seg; |
msegmentptr sp = pred->next; |
while (sp != 0) |
{ |
char* base = sp->base; |
size_t size = sp->size; |
msegmentptr next = sp->next; |
++nsegs; |
if (is_mmapped_segment(sp) && !is_extern_segment(sp)) |
{ |
mchunkptr p = align_as_chunk(base); |
size_t psize = chunksize(p); |
/* Can unmap if first chunk holds entire segment and not pinned */ |
if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) |
{ |
tchunkptr tp = (tchunkptr)p; |
assert(segment_holds(sp, (char*)sp)); |
if (p == m->dv) { |
m->dv = 0; |
m->dvsize = 0; |
} |
else { |
unlink_large_chunk(m, tp); |
} |
if (CALL_MUNMAP(base, size) == 0) |
{ |
released += size; |
m->footprint -= size; |
/* unlink obsoleted record */ |
sp = pred; |
sp->next = next; |
} |
else { /* back out if cannot unmap */ |
insert_large_chunk(m, tp, psize); |
} |
} |
} |
if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ |
break; |
pred = sp; |
sp = next; |
} |
/* Reset check counter */ |
m->release_checks = ((nsegs > MAX_RELEASE_CHECK_RATE)? |
nsegs : MAX_RELEASE_CHECK_RATE); |
return released; |
} |
static int sys_trim(mstate m, size_t pad) |
{ |
size_t released = 0; |
ensure_initialization(); |
if (pad < MAX_REQUEST && is_initialized(m)) |
{ |
pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ |
if (m->topsize > pad) |
{ |
/* Shrink top space in granularity-size units, keeping at least one */ |
size_t unit = mparams.granularity; |
size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - |
SIZE_T_ONE) * unit; |
msegmentptr sp = segment_holding(m, (char*)m->top); |
if (!is_extern_segment(sp)) |
{ |
if (is_mmapped_segment(sp)) |
{ |
if (HAVE_MMAP && |
sp->size >= extra && |
!has_segment_link(m, sp)) /* can't shrink if pinned */ |
{ |
size_t newsize = sp->size - extra; |
/* Prefer mremap, fall back to munmap */ |
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || |
(CALL_MUNMAP(sp->base + newsize, extra) == 0)) |
{ |
released = extra; |
} |
} |
} |
} |
if (released != 0) |
{ |
sp->size -= released; |
m->footprint -= released; |
init_top(m, m->top, m->topsize - released); |
check_top_chunk(m, m->top); |
} |
} |
/* Unmap any unused mmapped segments */ |
if (HAVE_MMAP) |
released += release_unused_segments(m); |
/* On failure, disable autotrim to avoid repeated failed future calls */ |
if (released == 0 && m->topsize > m->trim_check) |
m->trim_check = MAX_SIZE_T; |
} |
return (released != 0)? 1 : 0; |
} |
/* ---------------------------- malloc support --------------------------- */ |
/* allocate a large request from the best fitting chunk in a treebin */ |
static void* tmalloc_large(mstate m, size_t nb) { |
tchunkptr v = 0; |
size_t rsize = -nb; /* Unsigned negation */ |
tchunkptr t; |
bindex_t idx; |
compute_tree_index(nb, idx); |
if ((t = *treebin_at(m, idx)) != 0) { |
/* Traverse tree for this bin looking for node with size == nb */ |
size_t sizebits = nb << leftshift_for_tree_index(idx); |
tchunkptr rst = 0; /* The deepest untaken right subtree */ |
for (;;) { |
tchunkptr rt; |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
v = t; |
if ((rsize = trem) == 0) |
break; |
} |
rt = t->child[1]; |
t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; |
if (rt != 0 && rt != t) |
rst = rt; |
if (t == 0) { |
t = rst; /* set t to least subtree holding sizes > nb */ |
break; |
} |
sizebits <<= 1; |
} |
} |
if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ |
binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; |
if (leftbits != 0) { |
bindex_t i; |
binmap_t leastbit = least_bit(leftbits); |
compute_bit2idx(leastbit, i); |
t = *treebin_at(m, i); |
} |
} |
while (t != 0) { /* find smallest of tree or subtree */ |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
rsize = trem; |
v = t; |
} |
t = leftmost_child(t); |
} |
/* If dv is a better fit, return 0 so malloc will use it */ |
if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { |
if (RTCHECK(ok_address(m, v))) { /* split */ |
mchunkptr r = chunk_plus_offset(v, nb); |
assert(chunksize(v) == rsize + nb); |
if (RTCHECK(ok_next(v, r))) { |
unlink_large_chunk(m, v); |
if (rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(m, v, (rsize + nb)); |
else { |
set_size_and_pinuse_of_inuse_chunk(m, v, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
insert_chunk(m, r, rsize); |
} |
return chunk2mem(v); |
} |
} |
CORRUPTION_ERROR_ACTION(m); |
} |
return 0; |
} |
/* allocate a small request from the best fitting chunk in a treebin */ |
static void* tmalloc_small(mstate m, size_t nb) |
{ |
tchunkptr t, v; |
size_t rsize; |
bindex_t i; |
binmap_t leastbit = least_bit(m->treemap); |
compute_bit2idx(leastbit, i); |
v = t = *treebin_at(m, i); |
rsize = chunksize(t) - nb; |
while ((t = leftmost_child(t)) != 0) { |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
rsize = trem; |
v = t; |
} |
} |
if (RTCHECK(ok_address(m, v))) { |
mchunkptr r = chunk_plus_offset(v, nb); |
assert(chunksize(v) == rsize + nb); |
if (RTCHECK(ok_next(v, r))) { |
unlink_large_chunk(m, v); |
if (rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(m, v, (rsize + nb)); |
else { |
set_size_and_pinuse_of_inuse_chunk(m, v, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
replace_dv(m, r, rsize); |
} |
return chunk2mem(v); |
} |
} |
CORRUPTION_ERROR_ACTION(m); |
return 0; |
} |
/* --------------------------- realloc support --------------------------- */ |
static void* internal_realloc(struct _reent *reent_ptr, mstate m, void* oldmem, size_t bytes) |
{ |
if (bytes >= MAX_REQUEST) |
{ |
MALLOC_FAILURE_ACTION; |
return 0; |
} |
PREACTION(m); |
{ |
mchunkptr oldp = mem2chunk(oldmem); |
size_t oldsize = chunksize(oldp); |
mchunkptr next = chunk_plus_offset(oldp, oldsize); |
mchunkptr newp = 0; |
void* extra = 0; |
/* Try to either shrink or extend into top. Else malloc-copy-free */ |
if (RTCHECK(ok_address(m, oldp) && ok_inuse(oldp) && |
ok_next(oldp, next) && ok_pinuse(next))) |
{ |
size_t nb = request2size(bytes); |
if (is_mmapped(oldp)) |
newp = mmap_resize(m, oldp, nb); |
else if (oldsize >= nb) { /* already big enough */ |
size_t rsize = oldsize - nb; |
newp = oldp; |
if (rsize >= MIN_CHUNK_SIZE) |
{ |
mchunkptr remainder = chunk_plus_offset(newp, nb); |
set_inuse(m, newp, nb); |
set_inuse_and_pinuse(m, remainder, rsize); |
extra = chunk2mem(remainder); |
} |
} |
else if (next == m->top && oldsize + m->topsize > nb) |
{ |
/* Expand into top */ |
size_t newsize = oldsize + m->topsize; |
size_t newtopsize = newsize - nb; |
mchunkptr newtop = chunk_plus_offset(oldp, nb); |
set_inuse(m, oldp, nb); |
newtop->head = newtopsize |PINUSE_BIT; |
m->top = newtop; |
m->topsize = newtopsize; |
newp = oldp; |
} |
} |
else { |
USAGE_ERROR_ACTION(m, oldmem); |
POSTACTION(m); |
return 0; |
} |
#if DEBUG |
if (newp != 0) { |
check_inuse_chunk(m, newp); /* Check requires lock */ |
} |
#endif |
POSTACTION(m); |
if (newp != 0) |
{ |
if (extra != 0) { |
_free_r(reent_ptr, extra); |
} |
return chunk2mem(newp); |
} |
else |
{ |
void* newmem = _malloc_r(reent_ptr, bytes); |
if (newmem != 0) { |
size_t oc = oldsize - overhead_for(oldp); |
memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); |
_free_r(reent_ptr, oldmem); |
} |
return newmem; |
} |
} |
return 0; |
} |
/* --------------------------- memalign support -------------------------- */ |
static void* internal_memalign(mstate m, size_t alignment, size_t bytes) |
{ |
if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ |
return internal_malloc(m, bytes); |
if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ |
alignment = MIN_CHUNK_SIZE; |
if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ |
size_t a = MALLOC_ALIGNMENT << 1; |
while (a < alignment) a <<= 1; |
alignment = a; |
} |
if (bytes >= MAX_REQUEST - alignment) { |
if (m != 0) { /* Test isn't needed but avoids compiler warning */ |
MALLOC_FAILURE_ACTION; |
} |
} |
else |
{ |
size_t nb = request2size(bytes); |
size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; |
char* mem = (char*)internal_malloc(m, req); |
if (mem != 0) |
{ |
void* leader = 0; |
void* trailer = 0; |
mchunkptr p = mem2chunk(mem); |
PREACTION(m); |
if ((((size_t)(mem)) % alignment) != 0) /* misaligned */ |
{ |
/* |
Find an aligned spot inside chunk. Since we need to give |
back leading space in a chunk of at least MIN_CHUNK_SIZE, if |
the first calculation places us at a spot with less than |
MIN_CHUNK_SIZE leader, we can move to the next aligned spot. |
We've allocated enough total room so that this is always |
possible. |
*/ |
char* br = (char*)mem2chunk((size_t)(((size_t)(mem + |
alignment - |
SIZE_T_ONE)) & |
-alignment)); |
char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? |
br : br+alignment; |
mchunkptr newp = (mchunkptr)pos; |
size_t leadsize = pos - (char*)(p); |
size_t newsize = chunksize(p) - leadsize; |
if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ |
newp->prev_foot = p->prev_foot + leadsize; |
newp->head = newsize; |
} |
else { /* Otherwise, give back leader, use the rest */ |
set_inuse(m, newp, newsize); |
set_inuse(m, p, leadsize); |
leader = chunk2mem(p); |
} |
p = newp; |
} |
/* Give back spare room at the end */ |
if (!is_mmapped(p)) |
{ |
size_t size = chunksize(p); |
if (size > nb + MIN_CHUNK_SIZE) |
{ |
size_t remainder_size = size - nb; |
mchunkptr remainder = chunk_plus_offset(p, nb); |
set_inuse(m, p, nb); |
set_inuse(m, remainder, remainder_size); |
trailer = chunk2mem(remainder); |
} |
} |
assert (chunksize(p) >= nb); |
assert((((size_t)(chunk2mem(p))) % alignment) == 0); |
check_inuse_chunk(m, p); |
POSTACTION(m); |
if (leader != 0) { |
internal_free(m, leader); |
} |
if (trailer != 0) { |
internal_free(m, trailer); |
} |
return chunk2mem(p); |
} |
} |
return 0; |
} |
void* memalign(size_t alignment, size_t bytes) |
{ |
return internal_memalign(gm, alignment, bytes); |
} |
void* _malloc_r(struct _reent *reent_ptr, size_t bytes) { |
/* |
Basic algorithm: |
If a small request (< 256 bytes minus per-chunk overhead): |
1. If one exists, use a remainderless chunk in associated smallbin. |
(Remainderless means that there are too few excess bytes to |
represent as a chunk.) |
2. If it is big enough, use the dv chunk, which is normally the |
chunk adjacent to the one used for the most recent small request. |
3. If one exists, split the smallest available chunk in a bin, |
saving remainder in dv. |
4. If it is big enough, use the top chunk. |
5. If available, get memory from system and use it |
Otherwise, for a large request: |
1. Find the smallest available binned chunk that fits, and use it |
if it is better fitting than dv chunk, splitting if necessary. |
2. If better fitting than any binned chunk, use the dv chunk. |
3. If it is big enough, use the top chunk. |
4. If request size >= mmap threshold, try to directly mmap this chunk. |
5. If available, get memory from system and use it |
The ugly goto's here ensure that postaction occurs along all paths. |
*/ |
ensure_initialization(); /* initialize in sys_alloc if not using locks */ |
PREACTION(gm); |
{ |
void* mem; |
size_t nb; |
if (bytes <= MAX_SMALL_REQUEST) |
{ |
bindex_t idx; |
binmap_t smallbits; |
nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); |
idx = small_index(nb); |
smallbits = gm->smallmap >> idx; |
if ((smallbits & 0x3U) != 0) /* Remainderless fit to a smallbin. */ |
{ |
mchunkptr b, p; |
idx += ~smallbits & 1; /* Uses next bin if idx empty */ |
b = smallbin_at(gm, idx); |
p = b->fd; |
assert(chunksize(p) == small_index2size(idx)); |
unlink_first_small_chunk(gm, b, p, idx); |
set_inuse_and_pinuse(gm, p, small_index2size(idx)); |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (nb > gm->dvsize) |
{ |
if (smallbits != 0) /* Use chunk in next nonempty smallbin */ |
{ |
mchunkptr b, p, r; |
size_t rsize; |
bindex_t i; |
binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); |
binmap_t leastbit = least_bit(leftbits); |
compute_bit2idx(leastbit, i); |
b = smallbin_at(gm, i); |
p = b->fd; |
assert(chunksize(p) == small_index2size(i)); |
unlink_first_small_chunk(gm, b, p, i); |
rsize = small_index2size(i) - nb; |
/* Fit here cannot be remainderless if 4byte sizes */ |
if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(gm, p, small_index2size(i)); |
else |
{ |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
r = chunk_plus_offset(p, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
replace_dv(gm, r, rsize); |
} |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) |
{ |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
} |
} |
else if (bytes >= MAX_REQUEST) |
nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ |
else |
{ |
nb = pad_request(bytes); |
if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) |
{ |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
} |
if (nb <= gm->dvsize) { |
size_t rsize = gm->dvsize - nb; |
mchunkptr p = gm->dv; |
if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ |
mchunkptr r = gm->dv = chunk_plus_offset(p, nb); |
gm->dvsize = rsize; |
set_size_and_pinuse_of_free_chunk(r, rsize); |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
} |
else { /* exhaust dv */ |
size_t dvs = gm->dvsize; |
gm->dvsize = 0; |
gm->dv = 0; |
set_inuse_and_pinuse(gm, p, dvs); |
} |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (nb < gm->topsize) { /* Split top */ |
size_t rsize = gm->topsize -= nb; |
mchunkptr p = gm->top; |
mchunkptr r = gm->top = chunk_plus_offset(p, nb); |
r->head = rsize | PINUSE_BIT; |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
mem = chunk2mem(p); |
check_top_chunk(gm, gm->top); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
mem = sys_alloc(gm, nb); |
postaction: |
POSTACTION(gm); |
return mem; |
} |
return 0; |
} |
void _free_r(struct _reent *reent_ptr, void* mem) { |
/* |
Consolidate freed chunks with preceeding or succeeding bordering |
free chunks, if they exist, and then place in a bin. Intermixed |
with special cases for top, dv, mmapped chunks, and usage errors. |
*/ |
if (mem != 0) |
{ |
mchunkptr p = mem2chunk(mem); |
#define fm gm |
PREACTION(fm); |
{ |
check_inuse_chunk(fm, p); |
if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) |
{ |
size_t psize = chunksize(p); |
mchunkptr next = chunk_plus_offset(p, psize); |
if (!pinuse(p)) |
{ |
size_t prevsize = p->prev_foot; |
if (is_mmapped(p)) |
{ |
psize += prevsize + MMAP_FOOT_PAD; |
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) |
fm->footprint -= psize; |
goto postaction; |
} |
else |
{ |
mchunkptr prev = chunk_minus_offset(p, prevsize); |
psize += prevsize; |
p = prev; |
if (RTCHECK(ok_address(fm, prev))) /* consolidate backward */ |
{ |
if (p != fm->dv) |
{ |
unlink_chunk(fm, p, prevsize); |
} |
else if ((next->head & INUSE_BITS) == INUSE_BITS) |
{ |
fm->dvsize = psize; |
set_free_with_pinuse(p, psize, next); |
goto postaction; |
} |
} |
else |
goto erroraction; |
} |
} |
if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) |
{ |
if (!cinuse(next)) /* consolidate forward */ |
{ |
if (next == fm->top) |
{ |
size_t tsize = fm->topsize += psize; |
fm->top = p; |
p->head = tsize | PINUSE_BIT; |
if (p == fm->dv) |
{ |
fm->dv = 0; |
fm->dvsize = 0; |
} |
if (should_trim(fm, tsize)) |
sys_trim(fm, 0); |
goto postaction; |
} |
else if (next == fm->dv) |
{ |
size_t dsize = fm->dvsize += psize; |
fm->dv = p; |
set_size_and_pinuse_of_free_chunk(p, dsize); |
goto postaction; |
} |
else |
{ |
size_t nsize = chunksize(next); |
psize += nsize; |
unlink_chunk(fm, next, nsize); |
set_size_and_pinuse_of_free_chunk(p, psize); |
if (p == fm->dv) |
{ |
fm->dvsize = psize; |
goto postaction; |
} |
} |
} |
else |
set_free_with_pinuse(p, psize, next); |
if (is_small(psize)) |
{ |
insert_small_chunk(fm, p, psize); |
check_free_chunk(fm, p); |
} |
else |
{ |
tchunkptr tp = (tchunkptr)p; |
insert_large_chunk(fm, tp, psize); |
check_free_chunk(fm, p); |
if (--fm->release_checks == 0) |
release_unused_segments(fm); |
} |
goto postaction; |
} |
} |
erroraction: |
USAGE_ERROR_ACTION(fm, p); |
postaction: |
POSTACTION(fm); |
} |
} |
#undef fm |
} |
void* _calloc_r(struct _reent *reent_ptr, size_t n_elements, size_t elem_size) { |
void* mem; |
size_t req = 0; |
if (n_elements != 0) { |
req = n_elements * elem_size; |
if (((n_elements | elem_size) & ~(size_t)0xffff) && |
(req / n_elements != elem_size)) |
req = MAX_SIZE_T; /* force downstream failure on overflow */ |
} |
mem = _malloc_r(reent_ptr, req); |
if (mem != 0 && calloc_must_clear(mem2chunk(mem))) |
memset(mem, 0, req); |
return mem; |
} |
void* _realloc_r (struct _reent *reent_ptr, void* oldmem, size_t bytes){ |
if (oldmem == 0) |
return _malloc_r(reent_ptr, bytes); |
#ifdef REALLOC_ZERO_BYTES_FREES |
if (bytes == 0) { |
_free_r(ptr, oldmem); |
return 0; |
} |
#endif /* REALLOC_ZERO_BYTES_FREES */ |
else { |
#if ! FOOTERS |
mstate m = gm; |
#else /* FOOTERS */ |
mstate m = get_mstate_for(mem2chunk(oldmem)); |
if (!ok_magic(m)) { |
USAGE_ERROR_ACTION(m, oldmem); |
return 0; |
} |
#endif /* FOOTERS */ |
return internal_realloc(reent_ptr, m, oldmem, bytes); |
} |
} |
/* ----------------------------------------------------------------------- |
History: |
V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) |
* Use zeros instead of prev foot for is_mmapped |
* Add mspace_track_large_chunks; thanks to Jean Brouwers |
* Fix set_inuse in internal_realloc; thanks to Jean Brouwers |
* Fix insufficient sys_alloc padding when using 16byte alignment |
* Fix bad error check in mspace_footprint |
* Adaptations for ptmalloc; thanks to Wolfram Gloger. |
* Reentrant spin locks; thanks to Earl Chew and others |
* Win32 improvements; thanks to Niall Douglas and Earl Chew |
* Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options |
* Extension hook in malloc_state |
* Various small adjustments to reduce warnings on some compilers |
* Various configuration extensions/changes for more platforms. Thanks |
to all who contributed these. |
V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) |
* Add max_footprint functions |
* Ensure all appropriate literals are size_t |
* Fix conditional compilation problem for some #define settings |
* Avoid concatenating segments with the one provided |
in create_mspace_with_base |
* Rename some variables to avoid compiler shadowing warnings |
* Use explicit lock initialization. |
* Better handling of sbrk interference. |
* Simplify and fix segment insertion, trimming and mspace_destroy |
* Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x |
* Thanks especially to Dennis Flanagan for help on these. |
V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) |
* Fix memalign brace error. |
V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) |
* Fix improper #endif nesting in C++ |
* Add explicit casts needed for C++ |
V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) |
* Use trees for large bins |
* Support mspaces |
* Use segments to unify sbrk-based and mmap-based system allocation, |
removing need for emulation on most platforms without sbrk. |
* Default safety checks |
* Optional footer checks. Thanks to William Robertson for the idea. |
* Internal code refactoring |
* Incorporate suggestions and platform-specific changes. |
Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, |
Aaron Bachmann, Emery Berger, and others. |
* Speed up non-fastbin processing enough to remove fastbins. |
* Remove useless cfree() to avoid conflicts with other apps. |
* Remove internal memcpy, memset. Compilers handle builtins better. |
* Remove some options that no one ever used and rename others. |
V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) |
* Fix malloc_state bitmap array misdeclaration |
V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) |
* Allow tuning of FIRST_SORTED_BIN_SIZE |
* Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. |
* Better detection and support for non-contiguousness of MORECORE. |
Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger |
* Bypass most of malloc if no frees. Thanks To Emery Berger. |
* Fix freeing of old top non-contiguous chunk im sysmalloc. |
* Raised default trim and map thresholds to 256K. |
* Fix mmap-related #defines. Thanks to Lubos Lunak. |
* Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. |
* Branch-free bin calculation |
* Default trim and mmap thresholds now 256K. |
V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) |
* Introduce independent_comalloc and independent_calloc. |
Thanks to Michael Pachos for motivation and help. |
* Make optional .h file available |
* Allow > 2GB requests on 32bit systems. |
* new WIN32 sbrk, mmap, munmap, lock code from <Walter@GeNeSys-e.de>. |
Thanks also to Andreas Mueller <a.mueller at paradatec.de>, |
and Anonymous. |
* Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for |
helping test this.) |
* memalign: check alignment arg |
* realloc: don't try to shift chunks backwards, since this |
leads to more fragmentation in some programs and doesn't |
seem to help in any others. |
* Collect all cases in malloc requiring system memory into sysmalloc |
* Use mmap as backup to sbrk |
* Place all internal state in malloc_state |
* Introduce fastbins (although similar to 2.5.1) |
* Many minor tunings and cosmetic improvements |
* Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK |
* Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS |
Thanks to Tony E. Bennett <tbennett@nvidia.com> and others. |
* Include errno.h to support default failure action. |
V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) |
* return null for negative arguments |
* Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com> |
* Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' |
(e.g. WIN32 platforms) |
* Cleanup header file inclusion for WIN32 platforms |
* Cleanup code to avoid Microsoft Visual C++ compiler complaints |
* Add 'USE_DL_PREFIX' to quickly allow co-existence with existing |
memory allocation routines |
* Set 'malloc_getpagesize' for WIN32 platforms (needs more work) |
* Use 'assert' rather than 'ASSERT' in WIN32 code to conform to |
usage of 'assert' in non-WIN32 code |
* Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to |
avoid infinite loop |
* Always call 'fREe()' rather than 'free()' |
V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) |
* Fixed ordering problem with boundary-stamping |
V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) |
* Added pvalloc, as recommended by H.J. Liu |
* Added 64bit pointer support mainly from Wolfram Gloger |
* Added anonymously donated WIN32 sbrk emulation |
* Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen |
* malloc_extend_top: fix mask error that caused wastage after |
foreign sbrks |
* Add linux mremap support code from HJ Liu |
V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) |
* Integrated most documentation with the code. |
* Add support for mmap, with help from |
Wolfram Gloger (Gloger@lrz.uni-muenchen.de). |
* Use last_remainder in more cases. |
* Pack bins using idea from colin@nyx10.cs.du.edu |
* Use ordered bins instead of best-fit threshhold |
* Eliminate block-local decls to simplify tracing and debugging. |
* Support another case of realloc via move into top |
* Fix error occuring when initial sbrk_base not word-aligned. |
* Rely on page size for units instead of SBRK_UNIT to |
avoid surprises about sbrk alignment conventions. |
* Add mallinfo, mallopt. Thanks to Raymond Nijssen |
(raymond@es.ele.tue.nl) for the suggestion. |
* Add `pad' argument to malloc_trim and top_pad mallopt parameter. |
* More precautions for cases where other routines call sbrk, |
courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). |
* Added macros etc., allowing use in linux libc from |
H.J. Lu (hjl@gnu.ai.mit.edu) |
* Inverted this history list |
V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) |
* Re-tuned and fixed to behave more nicely with V2.6.0 changes. |
* Removed all preallocation code since under current scheme |
the work required to undo bad preallocations exceeds |
the work saved in good cases for most test programs. |
* No longer use return list or unconsolidated bins since |
no scheme using them consistently outperforms those that don't |
given above changes. |
* Use best fit for very large chunks to prevent some worst-cases. |
* Added some support for debugging |
V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) |
* Removed footers when chunks are in use. Thanks to |
Paul Wilson (wilson@cs.texas.edu) for the suggestion. |
V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) |
* Added malloc_trim, with help from Wolfram Gloger |
(wmglo@Dent.MED.Uni-Muenchen.DE). |
V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) |
V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) |
* realloc: try to expand in both directions |
* malloc: swap order of clean-bin strategy; |
* realloc: only conditionally expand backwards |
* Try not to scavenge used bins |
* Use bin counts as a guide to preallocation |
* Occasionally bin return list chunks in first scan |
* Add a few optimizations from colin@nyx10.cs.du.edu |
V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) |
* faster bin computation & slightly different binning |
* merged all consolidations to one part of malloc proper |
(eliminating old malloc_find_space & malloc_clean_bin) |
* Scan 2 returns chunks (not just 1) |
* Propagate failure in realloc if malloc returns 0 |
* Add stuff to allow compilation on non-ANSI compilers |
from kpv@research.att.com |
V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) |
* removed potential for odd address access in prev_chunk |
* removed dependency on getpagesize.h |
* misc cosmetics and a bit more internal documentation |
* anticosmetics: mangled names in macros to evade debugger strangeness |
* tested on sparc, hp-700, dec-mips, rs6000 |
with gcc & native cc (hp, dec only) allowing |
Detlefs & Zorn comparison study (in SIGPLAN Notices.) |
Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) |
* Based loosely on libg++-1.2X malloc. (It retains some of the overall |
structure of old version, but most details differ.) |
*/ |
/programs/develop/libraries/newlib/stdlib/mallocr1.c |
---|
0,0 → 1,1853 |
/* |
This is a version (aka dlmalloc) of malloc/free/realloc written by |
Doug Lea and released to the public domain, as explained at |
http://creativecommons.org/licenses/publicdomain. Send questions, |
comments, complaints, performance data, etc to dl@cs.oswego.edu |
* Version 2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) |
Note: There may be an updated version of this malloc obtainable at |
ftp://gee.cs.oswego.edu/pub/misc/malloc.c |
Check before installing! |
* Quickstart |
This library is all in one file to simplify the most common usage: |
ftp it, compile it (-O3), and link it into another program. All of |
the compile-time options default to reasonable values for use on |
most platforms. You might later want to step through various |
compile-time and dynamic tuning options. |
For convenience, an include file for code using this malloc is at: |
ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.4.h |
You don't really need this .h file unless you call functions not |
defined in your system include files. The .h file contains only the |
excerpts from this file needed for using this malloc on ANSI C/C++ |
systems, so long as you haven't changed compile-time options about |
naming and tuning parameters. If you do, then you can create your |
own malloc.h that does include all settings by cutting at the point |
indicated below. Note that you may already by default be using a C |
library containing a malloc that is based on some version of this |
malloc (for example in linux). You might still want to use the one |
in this file to customize settings or to avoid overheads associated |
with library versions. |
*/ |
#include <ddk.h> |
#include <mutex.h> |
#include <syscall.h> |
struct malloc_chunk { |
size_t prev_foot; /* Size of previous chunk (if free). */ |
size_t head; /* Size and inuse bits. */ |
struct malloc_chunk* fd; /* double links -- used only if free. */ |
struct malloc_chunk* bk; |
}; |
typedef struct malloc_chunk mchunk; |
typedef struct malloc_chunk* mchunkptr; |
typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ |
typedef unsigned int bindex_t; /* Described below */ |
typedef unsigned int binmap_t; /* Described below */ |
typedef unsigned int flag_t; /* The type of various bit flag sets */ |
/* ------------------- size_t and alignment properties -------------------- */ |
/* The maximum possible size_t value has all bits set */ |
#define MAX_SIZE_T (~(size_t)0) |
void *user_alloc(size_t size) |
{ |
void *val; |
__asm__("int3"); |
__asm__ __volatile__( |
"int $0x40" |
:"=eax"(val) |
:"a"(68),"b"(12),"c"(size)); |
return val; |
} |
static inline |
int user_free(void *mem) |
{ |
int val; |
__asm__ __volatile__( |
"int $0x40" |
:"=eax"(val) |
:"a"(68),"b"(12),"c"(mem)); |
return val; |
} |
/* ------------------- size_t and alignment properties -------------------- */ |
/* The byte and bit size of a size_t */ |
#define SIZE_T_SIZE (sizeof(size_t)) |
#define SIZE_T_BITSIZE (sizeof(size_t) << 3) |
/* Some constants coerced to size_t */ |
/* Annoying but necessary to avoid errors on some platforms */ |
#define SIZE_T_ZERO ((size_t)0) |
#define SIZE_T_ONE ((size_t)1) |
#define SIZE_T_TWO ((size_t)2) |
#define SIZE_T_FOUR ((size_t)4) |
#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) |
#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) |
#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) |
#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) |
#define USE_LOCK_BIT (2U) |
#define USE_MMAP_BIT (SIZE_T_ONE) |
#define USE_NONCONTIGUOUS_BIT (4U) |
/* segment bit set in create_mspace_with_base */ |
#define EXTERN_BIT (8U) |
#define HAVE_MMAP 1 |
#define CALL_MMAP(s) MMAP_DEFAULT(s) |
#define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) |
#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL |
#define MAX_RELEASE_CHECK_RATE 4095 |
#define NO_SEGMENT_TRAVERSAL 1 |
#define MALLOC_ALIGNMENT ((size_t)8U) |
#define CHUNK_OVERHEAD (SIZE_T_SIZE) |
#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) |
#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) |
#define DEFAULT_TRIM_THRESHOLD ((size_t)512U * (size_t)1024U) |
/* The bit mask value corresponding to MALLOC_ALIGNMENT */ |
#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) |
/* True if address a has acceptable alignment */ |
#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) |
/* the number of bytes to offset an address to align it */ |
#define align_offset(A)\ |
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ |
((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) |
#define MFAIL ((void*)(MAX_SIZE_T)) |
#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ |
/* For sys_alloc, enough padding to ensure can malloc request on success */ |
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) |
/* |
TOP_FOOT_SIZE is padding at the end of a segment, including space |
that may be needed to place segment records and fenceposts when new |
noncontiguous segments are added. |
*/ |
#define TOP_FOOT_SIZE\ |
(align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) |
/* ------------------- Chunks sizes and alignments ----------------------- */ |
#define MCHUNK_SIZE (sizeof(mchunk)) |
/* MMapped chunks need a second word of overhead ... */ |
#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) |
/* ... and additional padding for fake next-chunk at foot */ |
#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) |
/* The smallest size we can malloc is an aligned minimal chunk */ |
#define MIN_CHUNK_SIZE\ |
((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
/* conversion from malloc headers to user pointers, and back */ |
#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) |
#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) |
/* chunk associated with aligned address A */ |
#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) |
/* Bounds on request (not chunk) sizes. */ |
#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) |
#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) |
/* pad request bytes into a usable size */ |
#define pad_request(req) \ |
(((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
/* pad request, checking for minimum (but not maximum) */ |
#define request2size(req) \ |
(((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) |
/* ------------------ Operations on head and foot fields ----------------- */ |
/* |
The head field of a chunk is or'ed with PINUSE_BIT when previous |
adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in |
use, unless mmapped, in which case both bits are cleared. |
FLAG4_BIT is not used by this malloc, but might be useful in extensions. |
*/ |
#define PINUSE_BIT (SIZE_T_ONE) |
#define CINUSE_BIT (SIZE_T_TWO) |
#define FLAG4_BIT (SIZE_T_FOUR) |
#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) |
#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) |
/* Head value for fenceposts */ |
#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) |
/* extraction of fields from head words */ |
#define cinuse(p) ((p)->head & CINUSE_BIT) |
#define pinuse(p) ((p)->head & PINUSE_BIT) |
#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) |
#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) |
#define chunksize(p) ((p)->head & ~(FLAG_BITS)) |
#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) |
/* Treat space at ptr +/- offset as a chunk */ |
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) |
#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) |
/* Ptr to next or previous physical malloc_chunk. */ |
#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) |
#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) |
/* extract next chunk's pinuse bit */ |
#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) |
/* Set size, pinuse bit, and foot */ |
#define set_size_and_pinuse_of_free_chunk(p, s)\ |
((p)->head = (s|PINUSE_BIT), set_foot(p, s)) |
/* Set size, pinuse bit, foot, and clear next pinuse */ |
#define set_free_with_pinuse(p, s, n)\ |
(clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) |
/* Get the internal overhead associated with chunk p */ |
#define overhead_for(p)\ |
(is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) |
struct malloc_tree_chunk { |
/* The first four fields must be compatible with malloc_chunk */ |
size_t prev_foot; |
size_t head; |
struct malloc_tree_chunk* fd; |
struct malloc_tree_chunk* bk; |
struct malloc_tree_chunk* child[2]; |
struct malloc_tree_chunk* parent; |
bindex_t index; |
}; |
typedef struct malloc_tree_chunk tchunk; |
typedef struct malloc_tree_chunk* tchunkptr; |
typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ |
/* A little helper macro for trees */ |
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) |
struct malloc_segment { |
char* base; /* base address */ |
size_t size; /* allocated size */ |
struct malloc_segment* next; /* ptr to next segment */ |
flag_t sflags; /* mmap and extern flag */ |
}; |
#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) |
#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) |
typedef struct malloc_segment msegment; |
typedef struct malloc_segment* msegmentptr; |
/* ---------------------------- malloc_state ----------------------------- */ |
/* |
A malloc_state holds all of the bookkeeping for a space. |
The main fields are: |
Top |
The topmost chunk of the currently active segment. Its size is |
cached in topsize. The actual size of topmost space is |
topsize+TOP_FOOT_SIZE, which includes space reserved for adding |
fenceposts and segment records if necessary when getting more |
space from the system. The size at which to autotrim top is |
cached from mparams in trim_check, except that it is disabled if |
an autotrim fails. |
Designated victim (dv) |
This is the preferred chunk for servicing small requests that |
don't have exact fits. It is normally the chunk split off most |
recently to service another small request. Its size is cached in |
dvsize. The link fields of this chunk are not maintained since it |
is not kept in a bin. |
SmallBins |
An array of bin headers for free chunks. These bins hold chunks |
with sizes less than MIN_LARGE_SIZE bytes. Each bin contains |
chunks of all the same size, spaced 8 bytes apart. To simplify |
use in double-linked lists, each bin header acts as a malloc_chunk |
pointing to the real first node, if it exists (else pointing to |
itself). This avoids special-casing for headers. But to avoid |
waste, we allocate only the fd/bk pointers of bins, and then use |
repositioning tricks to treat these as the fields of a chunk. |
TreeBins |
Treebins are pointers to the roots of trees holding a range of |
sizes. There are 2 equally spaced treebins for each power of two |
from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything |
larger. |
Bin maps |
There is one bit map for small bins ("smallmap") and one for |
treebins ("treemap). Each bin sets its bit when non-empty, and |
clears the bit when empty. Bit operations are then used to avoid |
bin-by-bin searching -- nearly all "search" is done without ever |
looking at bins that won't be selected. The bit maps |
conservatively use 32 bits per map word, even if on 64bit system. |
For a good description of some of the bit-based techniques used |
here, see Henry S. Warren Jr's book "Hacker's Delight" (and |
supplement at http://hackersdelight.org/). Many of these are |
intended to reduce the branchiness of paths through malloc etc, as |
well as to reduce the number of memory locations read or written. |
Segments |
A list of segments headed by an embedded malloc_segment record |
representing the initial space. |
Address check support |
The least_addr field is the least address ever obtained from |
MORECORE or MMAP. Attempted frees and reallocs of any address less |
than this are trapped (unless INSECURE is defined). |
Magic tag |
A cross-check field that should always hold same value as mparams.magic. |
Flags |
Bits recording whether to use MMAP, locks, or contiguous MORECORE |
Statistics |
Each space keeps track of current and maximum system memory |
obtained via MORECORE or MMAP. |
Trim support |
Fields holding the amount of unused topmost memory that should trigger |
timming, and a counter to force periodic scanning to release unused |
non-topmost segments. |
Locking |
If USE_LOCKS is defined, the "mutex" lock is acquired and released |
around every public call using this mspace. |
Extension support |
A void* pointer and a size_t field that can be used to help implement |
extensions to this malloc. |
*/ |
/* Bin types, widths and sizes */ |
#define NSMALLBINS (32U) |
#define NTREEBINS (32U) |
#define SMALLBIN_SHIFT (3U) |
#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) |
#define TREEBIN_SHIFT (8U) |
#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) |
#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) |
#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) |
struct malloc_state { |
binmap_t smallmap; |
binmap_t treemap; |
size_t dvsize; |
size_t topsize; |
char* least_addr; |
mchunkptr dv; |
mchunkptr top; |
size_t trim_check; |
size_t release_checks; |
size_t magic; |
mchunkptr smallbins[(NSMALLBINS+1)*2]; |
tbinptr treebins[NTREEBINS]; |
size_t footprint; |
size_t max_footprint; |
flag_t mflags; |
struct mutex lock; /* locate lock among fields that rarely change */ |
msegment seg; |
void* extp; /* Unused but available for extensions */ |
size_t exts; |
}; |
typedef struct malloc_state* mstate; |
/* ------------- Global malloc_state and malloc_params ------------------- */ |
/* |
malloc_params holds global properties, including those that can be |
dynamically set using mallopt. There is a single instance, mparams, |
initialized in init_mparams. Note that the non-zeroness of "magic" |
also serves as an initialization flag. |
*/ |
struct malloc_params |
{ |
volatile size_t magic; |
size_t page_size; |
size_t granularity; |
size_t mmap_threshold; |
size_t trim_threshold; |
flag_t default_mflags; |
}; |
static struct malloc_params mparams; |
#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) |
static struct malloc_state _gm_; |
#define gm (&_gm_) |
#define is_global(M) ((M) == &_gm_) |
#define is_initialized(M) ((M)->top != 0) |
//struct mutex malloc_global_mutex; |
static DEFINE_MUTEX(malloc_global_mutex); |
#define ACQUIRE_MALLOC_GLOBAL_LOCK() MutexLock(&malloc_global_mutex); |
#define RELEASE_MALLOC_GLOBAL_LOCK() MutexUnlock(&malloc_global_mutex); |
#define PREACTION(M) ( MutexLock(&(M)->lock)) |
#define POSTACTION(M) { MutexUnlock(&(M)->lock); } |
/* ---------------------------- Indexing Bins ---------------------------- */ |
#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) |
#define small_index(s) ((s) >> SMALLBIN_SHIFT) |
#define small_index2size(i) ((i) << SMALLBIN_SHIFT) |
#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) |
/* addressing by index. See above about smallbin repositioning */ |
#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) |
#define treebin_at(M,i) (&((M)->treebins[i])) |
#define compute_tree_index(S, I)\ |
{\ |
unsigned int X = S >> TREEBIN_SHIFT;\ |
if (X == 0)\ |
I = 0;\ |
else if (X > 0xFFFF)\ |
I = NTREEBINS-1;\ |
else {\ |
unsigned int K;\ |
__asm__("bsrl\t%1, %0\n\t" : "=r" (K) : "g" (X));\ |
I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ |
}\ |
} |
/* Bit representing maximum resolved size in a treebin at i */ |
#define bit_for_tree_index(i) \ |
(i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) |
/* Shift placing maximum resolved bit in a treebin at i as sign bit */ |
#define leftshift_for_tree_index(i) \ |
((i == NTREEBINS-1)? 0 : \ |
((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) |
/* The size of the smallest chunk held in bin with index i */ |
#define minsize_for_tree_index(i) \ |
((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ |
(((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) |
/* ------------------------ Operations on bin maps ----------------------- */ |
/* bit corresponding to given index */ |
#define idx2bit(i) ((binmap_t)(1) << (i)) |
/* Mark/Clear bits with given index */ |
#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) |
#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) |
#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) |
#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) |
#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) |
#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) |
/* isolate the least set bit of a bitmap */ |
#define least_bit(x) ((x) & -(x)) |
/* mask with all bits to left of least bit of x on */ |
#define left_bits(x) ((x<<1) | -(x<<1)) |
/* mask with all bits to left of or equal to least bit of x on */ |
#define same_or_left_bits(x) ((x) | -(x)) |
/* index corresponding to given bit. Use x86 asm if possible */ |
#define compute_bit2idx(X, I)\ |
{\ |
unsigned int J;\ |
__asm__("bsfl\t%1, %0\n\t" : "=r" (J) : "g" (X));\ |
I = (bindex_t)J;\ |
} |
#define mark_inuse_foot(M,p,s) |
/* Get/set size at footer */ |
#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) |
#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) |
/* Macros for setting head/foot of non-mmapped chunks */ |
/* Set cinuse bit and pinuse bit of next chunk */ |
#define set_inuse(M,p,s)\ |
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ |
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) |
/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ |
#define set_inuse_and_pinuse(M,p,s)\ |
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ |
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) |
/* Set size, cinuse and pinuse bit of this chunk */ |
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ |
((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) |
#define assert(x) |
#define RTCHECK(e) __builtin_expect(e, 1) |
#define check_free_chunk(M,P) |
#define check_inuse_chunk(M,P) |
#define check_malloced_chunk(M,P,N) |
#define check_mmapped_chunk(M,P) |
#define check_malloc_state(M) |
#define check_top_chunk(M,P) |
/* Check if address a is at least as high as any from MORECORE or MMAP */ |
#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) |
/* Check if address of next chunk n is higher than base chunk p */ |
#define ok_next(p, n) ((char*)(p) < (char*)(n)) |
/* Check if p has inuse status */ |
#define ok_inuse(p) is_inuse(p) |
/* Check if p has its pinuse bit on */ |
#define ok_pinuse(p) pinuse(p) |
#define CORRUPTION_ERROR_ACTION(m) \ |
do { \ |
printf("%s malloc heap corrupted\n",__FUNCTION__); \ |
while(1) \ |
{ \ |
delay(100); \ |
} \ |
}while(0) \ |
#define USAGE_ERROR_ACTION(m, p) \ |
do { \ |
printf("%s malloc heap corrupted\n",__FUNCTION__); \ |
while(1) \ |
{ \ |
delay(100); \ |
} \ |
}while(0) \ |
/* ----------------------- Operations on smallbins ----------------------- */ |
/* |
Various forms of linking and unlinking are defined as macros. Even |
the ones for trees, which are very long but have very short typical |
paths. This is ugly but reduces reliance on inlining support of |
compilers. |
*/ |
/* Link a free chunk into a smallbin */ |
#define insert_small_chunk(M, P, S) {\ |
bindex_t I = small_index(S);\ |
mchunkptr B = smallbin_at(M, I);\ |
mchunkptr F = B;\ |
assert(S >= MIN_CHUNK_SIZE);\ |
if (!smallmap_is_marked(M, I))\ |
mark_smallmap(M, I);\ |
else if (RTCHECK(ok_address(M, B->fd)))\ |
F = B->fd;\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
B->fd = P;\ |
F->bk = P;\ |
P->fd = F;\ |
P->bk = B;\ |
} |
/* Unlink a chunk from a smallbin */ |
#define unlink_small_chunk(M, P, S) {\ |
mchunkptr F = P->fd;\ |
mchunkptr B = P->bk;\ |
bindex_t I = small_index(S);\ |
assert(P != B);\ |
assert(P != F);\ |
assert(chunksize(P) == small_index2size(I));\ |
if (F == B)\ |
clear_smallmap(M, I);\ |
else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\ |
(B == smallbin_at(M,I) || ok_address(M, B)))) {\ |
F->bk = B;\ |
B->fd = F;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
} |
/* Unlink the first chunk from a smallbin */ |
#define unlink_first_small_chunk(M, B, P, I) {\ |
mchunkptr F = P->fd;\ |
assert(P != B);\ |
assert(P != F);\ |
assert(chunksize(P) == small_index2size(I));\ |
if (B == F)\ |
clear_smallmap(M, I);\ |
else if (RTCHECK(ok_address(M, F))) {\ |
B->fd = F;\ |
F->bk = B;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
} |
/* Replace dv node, binning the old one */ |
/* Used only when dvsize known to be small */ |
#define replace_dv(M, P, S) {\ |
size_t DVS = M->dvsize;\ |
if (DVS != 0) {\ |
mchunkptr DV = M->dv;\ |
assert(is_small(DVS));\ |
insert_small_chunk(M, DV, DVS);\ |
}\ |
M->dvsize = S;\ |
M->dv = P;\ |
} |
/* ------------------------- Operations on trees ------------------------- */ |
/* Insert chunk into tree */ |
#define insert_large_chunk(M, X, S) {\ |
tbinptr* H;\ |
bindex_t I;\ |
compute_tree_index(S, I);\ |
H = treebin_at(M, I);\ |
X->index = I;\ |
X->child[0] = X->child[1] = 0;\ |
if (!treemap_is_marked(M, I)) {\ |
mark_treemap(M, I);\ |
*H = X;\ |
X->parent = (tchunkptr)H;\ |
X->fd = X->bk = X;\ |
}\ |
else {\ |
tchunkptr T = *H;\ |
size_t K = S << leftshift_for_tree_index(I);\ |
for (;;) {\ |
if (chunksize(T) != S) {\ |
tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ |
K <<= 1;\ |
if (*C != 0)\ |
T = *C;\ |
else if (RTCHECK(ok_address(M, C))) {\ |
*C = X;\ |
X->parent = T;\ |
X->fd = X->bk = X;\ |
break;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
break;\ |
}\ |
}\ |
else {\ |
tchunkptr F = T->fd;\ |
if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ |
T->fd = F->bk = X;\ |
X->fd = F;\ |
X->bk = T;\ |
X->parent = 0;\ |
break;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
break;\ |
}\ |
}\ |
}\ |
}\ |
} |
/* |
Unlink steps: |
1. If x is a chained node, unlink it from its same-sized fd/bk links |
and choose its bk node as its replacement. |
2. If x was the last node of its size, but not a leaf node, it must |
be replaced with a leaf node (not merely one with an open left or |
right), to make sure that lefts and rights of descendents |
correspond properly to bit masks. We use the rightmost descendent |
of x. We could use any other leaf, but this is easy to locate and |
tends to counteract removal of leftmosts elsewhere, and so keeps |
paths shorter than minimally guaranteed. This doesn't loop much |
because on average a node in a tree is near the bottom. |
3. If x is the base of a chain (i.e., has parent links) relink |
x's parent and children to x's replacement (or null if none). |
*/ |
#define unlink_large_chunk(M, X) {\ |
tchunkptr XP = X->parent;\ |
tchunkptr R;\ |
if (X->bk != X) {\ |
tchunkptr F = X->fd;\ |
R = X->bk;\ |
if (RTCHECK(ok_address(M, F))) {\ |
F->bk = R;\ |
R->fd = F;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
else {\ |
tchunkptr* RP;\ |
if (((R = *(RP = &(X->child[1]))) != 0) ||\ |
((R = *(RP = &(X->child[0]))) != 0)) {\ |
tchunkptr* CP;\ |
while ((*(CP = &(R->child[1])) != 0) ||\ |
(*(CP = &(R->child[0])) != 0)) {\ |
R = *(RP = CP);\ |
}\ |
if (RTCHECK(ok_address(M, RP)))\ |
*RP = 0;\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
}\ |
if (XP != 0) {\ |
tbinptr* H = treebin_at(M, X->index);\ |
if (X == *H) {\ |
if ((*H = R) == 0) \ |
clear_treemap(M, X->index);\ |
}\ |
else if (RTCHECK(ok_address(M, XP))) {\ |
if (XP->child[0] == X) \ |
XP->child[0] = R;\ |
else \ |
XP->child[1] = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
if (R != 0) {\ |
if (RTCHECK(ok_address(M, R))) {\ |
tchunkptr C0, C1;\ |
R->parent = XP;\ |
if ((C0 = X->child[0]) != 0) {\ |
if (RTCHECK(ok_address(M, C0))) {\ |
R->child[0] = C0;\ |
C0->parent = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
if ((C1 = X->child[1]) != 0) {\ |
if (RTCHECK(ok_address(M, C1))) {\ |
R->child[1] = C1;\ |
C1->parent = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
} |
/* Relays to large vs small bin operations */ |
#define insert_chunk(M, P, S)\ |
if (is_small(S)) insert_small_chunk(M, P, S)\ |
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } |
#define unlink_chunk(M, P, S)\ |
if (is_small(S)) unlink_small_chunk(M, P, S)\ |
else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } |
/* -------------------------- system alloc setup ------------------------- */ |
/* Operations on mflags */ |
#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) |
#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) |
#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) |
#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) |
#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) |
#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) |
#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) |
#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) |
#define set_lock(M,L)\ |
((M)->mflags = (L)?\ |
((M)->mflags | USE_LOCK_BIT) :\ |
((M)->mflags & ~USE_LOCK_BIT)) |
/* page-align a size */ |
#define page_align(S)\ |
(((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) |
/* granularity-align a size */ |
#define granularity_align(S)\ |
(((S) + (mparams.granularity - SIZE_T_ONE))\ |
& ~(mparams.granularity - SIZE_T_ONE)) |
/* For mmap, use granularity alignment */ |
#define mmap_align(S) granularity_align(S) |
/* For sys_alloc, enough padding to ensure can malloc request on success */ |
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) |
#define is_page_aligned(S)\ |
(((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) |
#define is_granularity_aligned(S)\ |
(((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) |
/* True if segment S holds address A */ |
#define segment_holds(S, A)\ |
((char*)(A) >= S->base && (char*)(A) < S->base + S->size) |
/* Return segment holding given address */ |
static msegmentptr segment_holding(mstate m, char* addr) |
{ |
msegmentptr sp = &m->seg; |
for (;;) { |
if (addr >= sp->base && addr < sp->base + sp->size) |
return sp; |
if ((sp = sp->next) == 0) |
return 0; |
} |
} |
/* Return true if segment contains a segment link */ |
static int has_segment_link(mstate m, msegmentptr ss) |
{ |
msegmentptr sp = &m->seg; |
for (;;) { |
if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) |
return 1; |
if ((sp = sp->next) == 0) |
return 0; |
} |
} |
static inline void* os_mmap(size_t size) |
{ |
void* ptr = KernelAlloc(size); |
return (ptr != 0)? ptr: MFAIL; |
} |
static inline int os_munmap(void* ptr, size_t size) |
{ |
return (KernelFree(ptr) != 0) ? 0 : -1; |
} |
#define should_trim(M,s) ((s) > (M)->trim_check) |
#define MMAP_DEFAULT(s) os_mmap(s) |
#define MUNMAP_DEFAULT(a, s) os_munmap((a), (s)) |
#define DIRECT_MMAP_DEFAULT(s) os_mmap(s) |
#define internal_malloc(m, b) malloc(b) |
#define internal_free(m, mem) free(mem) |
/* ----------------------- Direct-mmapping chunks ----------------------- */ |
/* |
Directly mmapped chunks are set up with an offset to the start of |
the mmapped region stored in the prev_foot field of the chunk. This |
allows reconstruction of the required argument to MUNMAP when freed, |
and also allows adjustment of the returned chunk to meet alignment |
requirements (especially in memalign). |
*/ |
/* Malloc using mmap */ |
static void* mmap_alloc(mstate m, size_t nb) |
{ |
size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
if (mmsize > nb) /* Check for wrap around 0 */ |
{ |
char* mm = (char*)(os_mmap(mmsize)); |
if (mm != CMFAIL) |
{ |
size_t offset = align_offset(chunk2mem(mm)); |
size_t psize = mmsize - offset - MMAP_FOOT_PAD; |
mchunkptr p = (mchunkptr)(mm + offset); |
p->prev_foot = offset; |
p->head = psize; |
mark_inuse_foot(m, p, psize); |
chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; |
chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; |
if (m->least_addr == 0 || mm < m->least_addr) |
m->least_addr = mm; |
if ((m->footprint += mmsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
assert(is_aligned(chunk2mem(p))); |
check_mmapped_chunk(m, p); |
return chunk2mem(p); |
} |
} |
return 0; |
} |
/* Realloc using mmap */ |
static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) |
{ |
size_t oldsize = chunksize(oldp); |
if (is_small(nb)) /* Can't shrink mmap regions below small size */ |
return 0; |
/* Keep old chunk if big enough but not too big */ |
if (oldsize >= nb + SIZE_T_SIZE && |
(oldsize - nb) <= (mparams.granularity << 1)) |
return oldp; |
else |
{ |
size_t offset = oldp->prev_foot; |
size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; |
size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
char* cp = (char*)CALL_MREMAP((char*)oldp - offset, |
oldmmsize, newmmsize, 1); |
if (cp != CMFAIL) |
{ |
mchunkptr newp = (mchunkptr)(cp + offset); |
size_t psize = newmmsize - offset - MMAP_FOOT_PAD; |
newp->head = psize; |
mark_inuse_foot(m, newp, psize); |
chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; |
chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; |
if (cp < m->least_addr) |
m->least_addr = cp; |
if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
check_mmapped_chunk(m, newp); |
return newp; |
} |
} |
return 0; |
} |
/* ---------------------------- setting mparams -------------------------- */ |
/* Initialize mparams */ |
static int init_mparams(void) { |
ACQUIRE_MALLOC_GLOBAL_LOCK(); |
if (mparams.magic == 0) |
{ |
size_t magic; |
size_t psize; |
size_t gsize; |
psize = 4096; |
gsize = DEFAULT_GRANULARITY; |
/* Sanity-check configuration: |
size_t must be unsigned and as wide as pointer type. |
ints must be at least 4 bytes. |
alignment must be at least 8. |
Alignment, min chunk size, and page size must all be powers of 2. |
*/ |
mparams.granularity = gsize; |
mparams.page_size = psize; |
mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; |
mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; |
mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; |
/* Set up lock for main malloc area */ |
gm->mflags = mparams.default_mflags; |
MutexInit(&gm->lock); |
magic = (size_t)(GetTimerTicks() ^ (size_t)0x55555555U); |
magic |= (size_t)8U; /* ensure nonzero */ |
magic &= ~(size_t)7U; /* improve chances of fault for bad values */ |
mparams.magic = magic; |
} |
RELEASE_MALLOC_GLOBAL_LOCK(); |
return 1; |
} |
/* -------------------------- mspace management -------------------------- */ |
/* Initialize top chunk and its size */ |
static void init_top(mstate m, mchunkptr p, size_t psize) |
{ |
/* Ensure alignment */ |
size_t offset = align_offset(chunk2mem(p)); |
p = (mchunkptr)((char*)p + offset); |
psize -= offset; |
m->top = p; |
m->topsize = psize; |
p->head = psize | PINUSE_BIT; |
/* set size of fake trailing chunk holding overhead space only once */ |
chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; |
m->trim_check = mparams.trim_threshold; /* reset on each update */ |
} |
/* Initialize bins for a new mstate that is otherwise zeroed out */ |
static void init_bins(mstate m) |
{ |
/* Establish circular links for smallbins */ |
bindex_t i; |
for (i = 0; i < NSMALLBINS; ++i) { |
sbinptr bin = smallbin_at(m,i); |
bin->fd = bin->bk = bin; |
} |
} |
/* Allocate chunk and prepend remainder with chunk in successor base. */ |
static void* prepend_alloc(mstate m, char* newbase, char* oldbase, |
size_t nb) |
{ |
mchunkptr p = align_as_chunk(newbase); |
mchunkptr oldfirst = align_as_chunk(oldbase); |
size_t psize = (char*)oldfirst - (char*)p; |
mchunkptr q = chunk_plus_offset(p, nb); |
size_t qsize = psize - nb; |
set_size_and_pinuse_of_inuse_chunk(m, p, nb); |
assert((char*)oldfirst > (char*)q); |
assert(pinuse(oldfirst)); |
assert(qsize >= MIN_CHUNK_SIZE); |
/* consolidate remainder with first chunk of old base */ |
if (oldfirst == m->top) { |
size_t tsize = m->topsize += qsize; |
m->top = q; |
q->head = tsize | PINUSE_BIT; |
check_top_chunk(m, q); |
} |
else if (oldfirst == m->dv) { |
size_t dsize = m->dvsize += qsize; |
m->dv = q; |
set_size_and_pinuse_of_free_chunk(q, dsize); |
} |
else { |
if (!is_inuse(oldfirst)) { |
size_t nsize = chunksize(oldfirst); |
unlink_chunk(m, oldfirst, nsize); |
oldfirst = chunk_plus_offset(oldfirst, nsize); |
qsize += nsize; |
} |
set_free_with_pinuse(q, qsize, oldfirst); |
insert_chunk(m, q, qsize); |
check_free_chunk(m, q); |
} |
check_malloced_chunk(m, chunk2mem(p), nb); |
return chunk2mem(p); |
} |
/* Add a segment to hold a new noncontiguous region */ |
static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) |
{ |
/* Determine locations and sizes of segment, fenceposts, old top */ |
char* old_top = (char*)m->top; |
msegmentptr oldsp = segment_holding(m, old_top); |
char* old_end = oldsp->base + oldsp->size; |
size_t ssize = pad_request(sizeof(struct malloc_segment)); |
char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
size_t offset = align_offset(chunk2mem(rawsp)); |
char* asp = rawsp + offset; |
char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; |
mchunkptr sp = (mchunkptr)csp; |
msegmentptr ss = (msegmentptr)(chunk2mem(sp)); |
mchunkptr tnext = chunk_plus_offset(sp, ssize); |
mchunkptr p = tnext; |
int nfences = 0; |
/* reset top to new space */ |
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); |
/* Set up segment record */ |
assert(is_aligned(ss)); |
set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); |
*ss = m->seg; /* Push current record */ |
m->seg.base = tbase; |
m->seg.size = tsize; |
m->seg.sflags = mmapped; |
m->seg.next = ss; |
/* Insert trailing fenceposts */ |
for (;;) { |
mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); |
p->head = FENCEPOST_HEAD; |
++nfences; |
if ((char*)(&(nextp->head)) < old_end) |
p = nextp; |
else |
break; |
} |
assert(nfences >= 2); |
/* Insert the rest of old top into a bin as an ordinary free chunk */ |
if (csp != old_top) { |
mchunkptr q = (mchunkptr)old_top; |
size_t psize = csp - old_top; |
mchunkptr tn = chunk_plus_offset(q, psize); |
set_free_with_pinuse(q, psize, tn); |
insert_chunk(m, q, psize); |
} |
check_top_chunk(m, m->top); |
} |
/* -------------------------- System allocation -------------------------- */ |
/* Get memory from system using MORECORE or MMAP */ |
static void* sys_alloc(mstate m, size_t nb) |
{ |
char* tbase = CMFAIL; |
size_t tsize = 0; |
flag_t mmap_flag = 0; |
ensure_initialization(); |
/* Directly map large chunks, but only if already initialized */ |
if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) |
{ |
void* mem = mmap_alloc(m, nb); |
if (mem != 0) |
return mem; |
} |
/* |
Try getting memory in any of three ways (in most-preferred to |
least-preferred order): |
1. A call to MORECORE that can normally contiguously extend memory. |
(disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or |
or main space is mmapped or a previous contiguous call failed) |
2. A call to MMAP new space (disabled if not HAVE_MMAP). |
Note that under the default settings, if MORECORE is unable to |
fulfill a request, and HAVE_MMAP is true, then mmap is |
used as a noncontiguous system allocator. This is a useful backup |
strategy for systems with holes in address spaces -- in this case |
sbrk cannot contiguously expand the heap, but mmap may be able to |
find space. |
3. A call to MORECORE that cannot usually contiguously extend memory. |
(disabled if not HAVE_MORECORE) |
In all cases, we need to request enough bytes from system to ensure |
we can malloc nb bytes upon success, so pad with enough space for |
top_foot, plus alignment-pad to make sure we don't lose bytes if |
not on boundary, and round this up to a granularity unit. |
*/ |
if (HAVE_MMAP && tbase == CMFAIL) /* Try MMAP */ |
{ |
size_t rsize = granularity_align(nb + SYS_ALLOC_PADDING); |
if (rsize > nb) /* Fail if wraps around zero */ |
{ |
char* mp = (char*)(CALL_MMAP(rsize)); |
if (mp != CMFAIL) |
{ |
tbase = mp; |
tsize = rsize; |
mmap_flag = USE_MMAP_BIT; |
} |
} |
} |
if (tbase != CMFAIL) |
{ |
if ((m->footprint += tsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
if (!is_initialized(m)) /* first-time initialization */ |
{ |
if (m->least_addr == 0 || tbase < m->least_addr) |
m->least_addr = tbase; |
m->seg.base = tbase; |
m->seg.size = tsize; |
m->seg.sflags = mmap_flag; |
m->magic = mparams.magic; |
m->release_checks = MAX_RELEASE_CHECK_RATE; |
init_bins(m); |
if (is_global(m)) |
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); |
else |
{ |
/* Offset top by embedded malloc_state */ |
mchunkptr mn = next_chunk(mem2chunk(m)); |
init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); |
} |
} |
else |
{ |
/* Try to merge with an existing segment */ |
msegmentptr sp = &m->seg; |
/* Only consider most recent segment if traversal suppressed */ |
while (sp != 0 && tbase != sp->base + sp->size) |
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; |
if (sp != 0 && !is_extern_segment(sp) && |
(sp->sflags & USE_MMAP_BIT) == mmap_flag && |
segment_holds(sp, m->top)) /* append */ |
{ |
sp->size += tsize; |
init_top(m, m->top, m->topsize + tsize); |
} |
else |
{ |
if (tbase < m->least_addr) |
m->least_addr = tbase; |
sp = &m->seg; |
while (sp != 0 && sp->base != tbase + tsize) |
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; |
if (sp != 0 && |
!is_extern_segment(sp) && |
(sp->sflags & USE_MMAP_BIT) == mmap_flag) |
{ |
char* oldbase = sp->base; |
sp->base = tbase; |
sp->size += tsize; |
return prepend_alloc(m, tbase, oldbase, nb); |
} |
else |
add_segment(m, tbase, tsize, mmap_flag); |
} |
} |
if (nb < m->topsize) /* Allocate from new or extended top space */ |
{ |
size_t rsize = m->topsize -= nb; |
mchunkptr p = m->top; |
mchunkptr r = m->top = chunk_plus_offset(p, nb); |
r->head = rsize | PINUSE_BIT; |
set_size_and_pinuse_of_inuse_chunk(m, p, nb); |
check_top_chunk(m, m->top); |
check_malloced_chunk(m, chunk2mem(p), nb); |
return chunk2mem(p); |
} |
} |
// MALLOC_FAILURE_ACTION; |
return 0; |
} |
/* ----------------------- system deallocation -------------------------- */ |
/* Unmap and unlink any mmapped segments that don't contain used chunks */ |
static size_t release_unused_segments(mstate m) |
{ |
size_t released = 0; |
int nsegs = 0; |
msegmentptr pred = &m->seg; |
msegmentptr sp = pred->next; |
while (sp != 0) |
{ |
char* base = sp->base; |
size_t size = sp->size; |
msegmentptr next = sp->next; |
++nsegs; |
if (is_mmapped_segment(sp) && !is_extern_segment(sp)) |
{ |
mchunkptr p = align_as_chunk(base); |
size_t psize = chunksize(p); |
/* Can unmap if first chunk holds entire segment and not pinned */ |
if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) |
{ |
tchunkptr tp = (tchunkptr)p; |
assert(segment_holds(sp, (char*)sp)); |
if (p == m->dv) { |
m->dv = 0; |
m->dvsize = 0; |
} |
else { |
unlink_large_chunk(m, tp); |
} |
if (CALL_MUNMAP(base, size) == 0) |
{ |
released += size; |
m->footprint -= size; |
/* unlink obsoleted record */ |
sp = pred; |
sp->next = next; |
} |
else { /* back out if cannot unmap */ |
insert_large_chunk(m, tp, psize); |
} |
} |
} |
if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ |
break; |
pred = sp; |
sp = next; |
} |
/* Reset check counter */ |
m->release_checks = ((nsegs > MAX_RELEASE_CHECK_RATE)? |
nsegs : MAX_RELEASE_CHECK_RATE); |
return released; |
} |
static int sys_trim(mstate m, size_t pad) |
{ |
size_t released = 0; |
ensure_initialization(); |
if (pad < MAX_REQUEST && is_initialized(m)) |
{ |
pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ |
if (m->topsize > pad) |
{ |
/* Shrink top space in granularity-size units, keeping at least one */ |
size_t unit = mparams.granularity; |
size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - |
SIZE_T_ONE) * unit; |
msegmentptr sp = segment_holding(m, (char*)m->top); |
if (!is_extern_segment(sp)) |
{ |
if (is_mmapped_segment(sp)) |
{ |
if (HAVE_MMAP && |
sp->size >= extra && |
!has_segment_link(m, sp)) /* can't shrink if pinned */ |
{ |
size_t newsize = sp->size - extra; |
/* Prefer mremap, fall back to munmap */ |
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || |
(CALL_MUNMAP(sp->base + newsize, extra) == 0)) |
{ |
released = extra; |
} |
} |
} |
} |
if (released != 0) |
{ |
sp->size -= released; |
m->footprint -= released; |
init_top(m, m->top, m->topsize - released); |
check_top_chunk(m, m->top); |
} |
} |
/* Unmap any unused mmapped segments */ |
if (HAVE_MMAP) |
released += release_unused_segments(m); |
/* On failure, disable autotrim to avoid repeated failed future calls */ |
if (released == 0 && m->topsize > m->trim_check) |
m->trim_check = MAX_SIZE_T; |
} |
return (released != 0)? 1 : 0; |
} |
/* ---------------------------- malloc support --------------------------- */ |
/* allocate a large request from the best fitting chunk in a treebin */ |
static void* tmalloc_large(mstate m, size_t nb) { |
tchunkptr v = 0; |
size_t rsize = -nb; /* Unsigned negation */ |
tchunkptr t; |
bindex_t idx; |
compute_tree_index(nb, idx); |
if ((t = *treebin_at(m, idx)) != 0) { |
/* Traverse tree for this bin looking for node with size == nb */ |
size_t sizebits = nb << leftshift_for_tree_index(idx); |
tchunkptr rst = 0; /* The deepest untaken right subtree */ |
for (;;) { |
tchunkptr rt; |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
v = t; |
if ((rsize = trem) == 0) |
break; |
} |
rt = t->child[1]; |
t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; |
if (rt != 0 && rt != t) |
rst = rt; |
if (t == 0) { |
t = rst; /* set t to least subtree holding sizes > nb */ |
break; |
} |
sizebits <<= 1; |
} |
} |
if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ |
binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; |
if (leftbits != 0) { |
bindex_t i; |
binmap_t leastbit = least_bit(leftbits); |
compute_bit2idx(leastbit, i); |
t = *treebin_at(m, i); |
} |
} |
while (t != 0) { /* find smallest of tree or subtree */ |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
rsize = trem; |
v = t; |
} |
t = leftmost_child(t); |
} |
/* If dv is a better fit, return 0 so malloc will use it */ |
if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { |
if (RTCHECK(ok_address(m, v))) { /* split */ |
mchunkptr r = chunk_plus_offset(v, nb); |
assert(chunksize(v) == rsize + nb); |
if (RTCHECK(ok_next(v, r))) { |
unlink_large_chunk(m, v); |
if (rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(m, v, (rsize + nb)); |
else { |
set_size_and_pinuse_of_inuse_chunk(m, v, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
insert_chunk(m, r, rsize); |
} |
return chunk2mem(v); |
} |
} |
CORRUPTION_ERROR_ACTION(m); |
} |
return 0; |
} |
/* allocate a small request from the best fitting chunk in a treebin */ |
static void* tmalloc_small(mstate m, size_t nb) |
{ |
tchunkptr t, v; |
size_t rsize; |
bindex_t i; |
binmap_t leastbit = least_bit(m->treemap); |
compute_bit2idx(leastbit, i); |
v = t = *treebin_at(m, i); |
rsize = chunksize(t) - nb; |
while ((t = leftmost_child(t)) != 0) { |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
rsize = trem; |
v = t; |
} |
} |
if (RTCHECK(ok_address(m, v))) { |
mchunkptr r = chunk_plus_offset(v, nb); |
assert(chunksize(v) == rsize + nb); |
if (RTCHECK(ok_next(v, r))) { |
unlink_large_chunk(m, v); |
if (rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(m, v, (rsize + nb)); |
else { |
set_size_and_pinuse_of_inuse_chunk(m, v, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
replace_dv(m, r, rsize); |
} |
return chunk2mem(v); |
} |
} |
CORRUPTION_ERROR_ACTION(m); |
return 0; |
} |
/* --------------------------- memalign support -------------------------- */ |
static void* internal_memalign(mstate m, size_t alignment, size_t bytes) |
{ |
if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ |
return internal_malloc(m, bytes); |
if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ |
alignment = MIN_CHUNK_SIZE; |
if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ |
size_t a = MALLOC_ALIGNMENT << 1; |
while (a < alignment) a <<= 1; |
alignment = a; |
} |
if (bytes >= MAX_REQUEST - alignment) { |
if (m != 0) { /* Test isn't needed but avoids compiler warning */ |
// MALLOC_FAILURE_ACTION; |
} |
} |
else |
{ |
size_t nb = request2size(bytes); |
size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; |
char* mem = (char*)internal_malloc(m, req); |
if (mem != 0) |
{ |
void* leader = 0; |
void* trailer = 0; |
mchunkptr p = mem2chunk(mem); |
PREACTION(m); |
if ((((size_t)(mem)) % alignment) != 0) /* misaligned */ |
{ |
/* |
Find an aligned spot inside chunk. Since we need to give |
back leading space in a chunk of at least MIN_CHUNK_SIZE, if |
the first calculation places us at a spot with less than |
MIN_CHUNK_SIZE leader, we can move to the next aligned spot. |
We've allocated enough total room so that this is always |
possible. |
*/ |
char* br = (char*)mem2chunk((size_t)(((size_t)(mem + |
alignment - |
SIZE_T_ONE)) & |
-alignment)); |
char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? |
br : br+alignment; |
mchunkptr newp = (mchunkptr)pos; |
size_t leadsize = pos - (char*)(p); |
size_t newsize = chunksize(p) - leadsize; |
if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ |
newp->prev_foot = p->prev_foot + leadsize; |
newp->head = newsize; |
} |
else { /* Otherwise, give back leader, use the rest */ |
set_inuse(m, newp, newsize); |
set_inuse(m, p, leadsize); |
leader = chunk2mem(p); |
} |
p = newp; |
} |
/* Give back spare room at the end */ |
if (!is_mmapped(p)) |
{ |
size_t size = chunksize(p); |
if (size > nb + MIN_CHUNK_SIZE) |
{ |
size_t remainder_size = size - nb; |
mchunkptr remainder = chunk_plus_offset(p, nb); |
set_inuse(m, p, nb); |
set_inuse(m, remainder, remainder_size); |
trailer = chunk2mem(remainder); |
} |
} |
assert (chunksize(p) >= nb); |
assert((((size_t)(chunk2mem(p))) % alignment) == 0); |
check_inuse_chunk(m, p); |
POSTACTION(m); |
if (leader != 0) { |
internal_free(m, leader); |
} |
if (trailer != 0) { |
internal_free(m, trailer); |
} |
return chunk2mem(p); |
} |
} |
return 0; |
} |
void* memalign(size_t alignment, size_t bytes) |
{ |
return internal_memalign(gm, alignment, bytes); |
} |
void* malloc(size_t bytes) |
{ |
/* |
Basic algorithm: |
If a small request (< 256 bytes minus per-chunk overhead): |
1. If one exists, use a remainderless chunk in associated smallbin. |
(Remainderless means that there are too few excess bytes to |
represent as a chunk.) |
2. If it is big enough, use the dv chunk, which is normally the |
chunk adjacent to the one used for the most recent small request. |
3. If one exists, split the smallest available chunk in a bin, |
saving remainder in dv. |
4. If it is big enough, use the top chunk. |
5. If available, get memory from system and use it |
Otherwise, for a large request: |
1. Find the smallest available binned chunk that fits, and use it |
if it is better fitting than dv chunk, splitting if necessary. |
2. If better fitting than any binned chunk, use the dv chunk. |
3. If it is big enough, use the top chunk. |
4. If request size >= mmap threshold, try to directly mmap this chunk. |
5. If available, get memory from system and use it |
The ugly goto's here ensure that postaction occurs along all paths. |
*/ |
ensure_initialization(); /* initialize in sys_alloc if not using locks */ |
PREACTION(gm); |
{ |
void* mem; |
size_t nb; |
if (bytes <= MAX_SMALL_REQUEST) |
{ |
bindex_t idx; |
binmap_t smallbits; |
nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); |
idx = small_index(nb); |
smallbits = gm->smallmap >> idx; |
if ((smallbits & 0x3U) != 0) /* Remainderless fit to a smallbin. */ |
{ |
mchunkptr b, p; |
idx += ~smallbits & 1; /* Uses next bin if idx empty */ |
b = smallbin_at(gm, idx); |
p = b->fd; |
assert(chunksize(p) == small_index2size(idx)); |
unlink_first_small_chunk(gm, b, p, idx); |
set_inuse_and_pinuse(gm, p, small_index2size(idx)); |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (nb > gm->dvsize) |
{ |
if (smallbits != 0) /* Use chunk in next nonempty smallbin */ |
{ |
mchunkptr b, p, r; |
size_t rsize; |
bindex_t i; |
binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); |
binmap_t leastbit = least_bit(leftbits); |
compute_bit2idx(leastbit, i); |
b = smallbin_at(gm, i); |
p = b->fd; |
assert(chunksize(p) == small_index2size(i)); |
unlink_first_small_chunk(gm, b, p, i); |
rsize = small_index2size(i) - nb; |
/* Fit here cannot be remainderless if 4byte sizes */ |
if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(gm, p, small_index2size(i)); |
else |
{ |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
r = chunk_plus_offset(p, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
replace_dv(gm, r, rsize); |
} |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) |
{ |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
} |
} |
else if (bytes >= MAX_REQUEST) |
nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ |
else |
{ |
nb = pad_request(bytes); |
if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) |
{ |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
} |
if (nb <= gm->dvsize) { |
size_t rsize = gm->dvsize - nb; |
mchunkptr p = gm->dv; |
if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ |
mchunkptr r = gm->dv = chunk_plus_offset(p, nb); |
gm->dvsize = rsize; |
set_size_and_pinuse_of_free_chunk(r, rsize); |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
} |
else { /* exhaust dv */ |
size_t dvs = gm->dvsize; |
gm->dvsize = 0; |
gm->dv = 0; |
set_inuse_and_pinuse(gm, p, dvs); |
} |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (nb < gm->topsize) { /* Split top */ |
size_t rsize = gm->topsize -= nb; |
mchunkptr p = gm->top; |
mchunkptr r = gm->top = chunk_plus_offset(p, nb); |
r->head = rsize | PINUSE_BIT; |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
mem = chunk2mem(p); |
check_top_chunk(gm, gm->top); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
mem = sys_alloc(gm, nb); |
postaction: |
POSTACTION(gm); |
return mem; |
} |
return 0; |
} |
void free(void* mem) |
{ |
/* |
Consolidate freed chunks with preceeding or succeeding bordering |
free chunks, if they exist, and then place in a bin. Intermixed |
with special cases for top, dv, mmapped chunks, and usage errors. |
*/ |
if (mem != 0) |
{ |
mchunkptr p = mem2chunk(mem); |
#define fm gm |
PREACTION(fm); |
{ |
check_inuse_chunk(fm, p); |
if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) |
{ |
size_t psize = chunksize(p); |
mchunkptr next = chunk_plus_offset(p, psize); |
if (!pinuse(p)) |
{ |
size_t prevsize = p->prev_foot; |
if (is_mmapped(p)) |
{ |
psize += prevsize + MMAP_FOOT_PAD; |
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) |
fm->footprint -= psize; |
goto postaction; |
} |
else |
{ |
mchunkptr prev = chunk_minus_offset(p, prevsize); |
psize += prevsize; |
p = prev; |
if (RTCHECK(ok_address(fm, prev))) /* consolidate backward */ |
{ |
if (p != fm->dv) |
{ |
unlink_chunk(fm, p, prevsize); |
} |
else if ((next->head & INUSE_BITS) == INUSE_BITS) |
{ |
fm->dvsize = psize; |
set_free_with_pinuse(p, psize, next); |
goto postaction; |
} |
} |
else |
goto erroraction; |
} |
} |
if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) |
{ |
if (!cinuse(next)) /* consolidate forward */ |
{ |
if (next == fm->top) |
{ |
size_t tsize = fm->topsize += psize; |
fm->top = p; |
p->head = tsize | PINUSE_BIT; |
if (p == fm->dv) |
{ |
fm->dv = 0; |
fm->dvsize = 0; |
} |
if (should_trim(fm, tsize)) |
sys_trim(fm, 0); |
goto postaction; |
} |
else if (next == fm->dv) |
{ |
size_t dsize = fm->dvsize += psize; |
fm->dv = p; |
set_size_and_pinuse_of_free_chunk(p, dsize); |
goto postaction; |
} |
else |
{ |
size_t nsize = chunksize(next); |
psize += nsize; |
unlink_chunk(fm, next, nsize); |
set_size_and_pinuse_of_free_chunk(p, psize); |
if (p == fm->dv) |
{ |
fm->dvsize = psize; |
goto postaction; |
} |
} |
} |
else |
set_free_with_pinuse(p, psize, next); |
if (is_small(psize)) |
{ |
insert_small_chunk(fm, p, psize); |
check_free_chunk(fm, p); |
} |
else |
{ |
tchunkptr tp = (tchunkptr)p; |
insert_large_chunk(fm, tp, psize); |
check_free_chunk(fm, p); |
if (--fm->release_checks == 0) |
release_unused_segments(fm); |
} |
goto postaction; |
} |
} |
erroraction: |
USAGE_ERROR_ACTION(fm, p); |
postaction: |
POSTACTION(fm); |
} |
} |
#undef fm |
} |
/programs/develop/libraries/newlib/stdlib/mbctype.h |
---|
0,0 → 1,21 |
#ifndef _MBCTYPE_H_ |
#define _MBCTYPE_H_ |
/* escape character used for JIS encoding */ |
#define ESC_CHAR 0x1b |
/* functions used to support SHIFT_JIS, EUC-JP, and JIS multibyte encodings */ |
int _EXFUN(_issjis1, (int c)); |
int _EXFUN(_issjis2, (int c)); |
int _EXFUN(_iseucjp, (int c)); |
int _EXFUN(_isjis, (int c)); |
#define _issjis1(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xef)) |
#define _issjis2(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc)) |
#define _iseucjp1(c) ((c) == 0x8e || (c) == 0x8f || ((c) >= 0xa1 && (c) <= 0xfe)) |
#define _iseucjp2(c) ((c) >= 0xa1 && (c) <= 0xfe) |
#define _isjis(c) ((c) >= 0x21 && (c) <= 0x7e) |
#endif /* _MBCTYPE_H_ */ |
/programs/develop/libraries/newlib/stdlib/mbrtowc.c |
---|
0,0 → 1,79 |
#include <reent.h> |
#include <newlib.h> |
#include <wchar.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <errno.h> |
#include <string.h> |
#include "local.h" |
size_t |
_DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps), |
struct _reent *ptr _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
mbstate_t *ps) |
{ |
int retval = 0; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(ptr); |
ps = &(_REENT_MBRTOWC_STATE(ptr)); |
} |
#endif |
if (s == NULL) |
retval = __mbtowc (ptr, NULL, "", 1, __locale_charset (), ps); |
else |
retval = __mbtowc (ptr, pwc, s, n, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
ptr->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
} |
#ifndef _REENT_ONLY |
size_t |
_DEFUN (mbrtowc, (pwc, s, n, ps), |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
mbstate_t *ps) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
return _mbrtowc_r (_REENT, pwc, s, n, ps); |
#else |
int retval = 0; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(_REENT); |
ps = &(_REENT_MBRTOWC_STATE(_REENT)); |
} |
#endif |
if (s == NULL) |
retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps); |
else |
retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
_REENT->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdlib/mbtowc.c |
---|
0,0 → 1,95 |
/* |
FUNCTION |
<<mbtowc>>---minimal multibyte to wide char converter |
INDEX |
mbtowc |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int mbtowc(wchar_t *<[pwc]>, const char *<[s]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int mbtowc(<[pwc]>, <[s]>, <[n]>) |
wchar_t *<[pwc]>; |
const char *<[s]>; |
size_t <[n]>; |
DESCRIPTION |
When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming |
implementation of <<mbtowc>>. In this case, |
only ``multi-byte character sequences'' recognized are single bytes, |
and they are ``converted'' to themselves. |
Each call to <<mbtowc>> copies one character from <<*<[s]>>> to |
<<*<[pwc]>>>, unless <[s]> is a null pointer. The argument n |
is ignored. |
When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform |
the conversion, passing a state variable to allow state dependent |
decoding. The result is based on the locale setting which may |
be restricted to a defined set of locales. |
RETURNS |
This implementation of <<mbtowc>> returns <<0>> if |
<[s]> is <<NULL>> or is the empty string; |
it returns <<1>> if not _MB_CAPABLE or |
the character is a single-byte character; it returns <<-1>> |
if n is <<0>> or the multi-byte character is invalid; |
otherwise it returns the number of bytes in the multibyte character. |
If the return value is -1, no changes are made to the <<pwc>> |
output string. If the input is the empty string, a wchar_t nul |
is placed in the output string and 0 is returned. If the input |
has a length of 0, no changes are made to the <<pwc>> output string. |
PORTABILITY |
<<mbtowc>> is required in the ANSI C standard. However, the precise |
effects vary with the locale. |
<<mbtowc>> requires no supporting OS subroutines. |
*/ |
#ifndef _REENT_ONLY |
#include <newlib.h> |
#include <stdlib.h> |
#include <wchar.h> |
#include "local.h" |
int |
_DEFUN (mbtowc, (pwc, s, n), |
wchar_t *pwc _AND |
const char *s _AND |
size_t n) |
{ |
#ifdef _MB_CAPABLE |
int retval = 0; |
mbstate_t *ps; |
_REENT_CHECK_MISC(_REENT); |
ps = &(_REENT_MBTOWC_STATE(_REENT)); |
retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps); |
if (retval < 0) |
{ |
ps->__count = 0; |
return -1; |
} |
return retval; |
#else /* not _MB_CAPABLE */ |
if (s == NULL) |
return 0; |
if (n == 0) |
return -1; |
if (pwc) |
*pwc = (wchar_t) *s; |
return (*s != '\0'); |
#endif /* not _MB_CAPABLE */ |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdlib/mbtowc_r.c |
---|
0,0 → 1,646 |
#include <newlib.h> |
#include <stdlib.h> |
#include <locale.h> |
#include "mbctype.h" |
#include <wchar.h> |
#include <string.h> |
#include <errno.h> |
#include "local.h" |
int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *) |
#ifdef __CYGWIN__ |
/* Cygwin starts up in UTF-8 mode. */ |
= __utf8_mbtowc; |
#else |
= __ascii_mbtowc; |
#endif |
int |
_DEFUN (_mbtowc_r, (r, pwc, s, n, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
mbstate_t *state) |
{ |
return __mbtowc (r, pwc, s, n, __locale_charset (), state); |
} |
int |
_DEFUN (__ascii_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
#ifdef __CYGWIN__ |
if ((wchar_t)*t >= 0x80) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
#endif |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
#ifdef _MB_CAPABLE |
typedef enum { ESCAPE, DOLLAR, BRACKET, AT, B, J, |
NUL, JIS_CHAR, OTHER, JIS_C_NUM } JIS_CHAR_TYPE; |
typedef enum { ASCII, JIS, A_ESC, A_ESC_DL, JIS_1, J_ESC, J_ESC_BR, |
INV, JIS_S_NUM } JIS_STATE; |
typedef enum { COPY_A, COPY_J1, COPY_J2, MAKE_A, NOOP, EMPTY, ERROR } JIS_ACTION; |
/************************************************************************************** |
* state/action tables for processing JIS encoding |
* Where possible, switches to JIS are grouped with proceding JIS characters and switches |
* to ASCII are grouped with preceding JIS characters. Thus, maximum returned length |
* is 2 (switch to JIS) + 2 (JIS characters) + 2 (switch back to ASCII) = 6. |
*************************************************************************************/ |
static JIS_STATE JIS_state_table[JIS_S_NUM][JIS_C_NUM] = { |
/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTHER */ |
/* ASCII */ { A_ESC, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII }, |
/* JIS */ { J_ESC, JIS_1, JIS_1, JIS_1, JIS_1, JIS_1, INV, JIS_1, INV }, |
/* A_ESC */ { ASCII, A_ESC_DL, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII }, |
/* A_ESC_DL */{ ASCII, ASCII, ASCII, JIS, JIS, ASCII, ASCII, ASCII, ASCII }, |
/* JIS_1 */ { INV, JIS, JIS, JIS, JIS, JIS, INV, JIS, INV }, |
/* J_ESC */ { INV, INV, J_ESC_BR, INV, INV, INV, INV, INV, INV }, |
/* J_ESC_BR */{ INV, INV, INV, INV, ASCII, ASCII, INV, INV, INV }, |
}; |
static JIS_ACTION JIS_action_table[JIS_S_NUM][JIS_C_NUM] = { |
/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTHER */ |
/* ASCII */ { NOOP, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, EMPTY, COPY_A, COPY_A}, |
/* JIS */ { NOOP, COPY_J1, COPY_J1, COPY_J1, COPY_J1, COPY_J1, ERROR, COPY_J1, ERROR }, |
/* A_ESC */ { COPY_A, NOOP, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A}, |
/* A_ESC_DL */{ COPY_A, COPY_A, COPY_A, NOOP, NOOP, COPY_A, COPY_A, COPY_A, COPY_A}, |
/* JIS_1 */ { ERROR, COPY_J2, COPY_J2, COPY_J2, COPY_J2, COPY_J2, ERROR, COPY_J2, ERROR }, |
/* J_ESC */ { ERROR, ERROR, NOOP, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR }, |
/* J_ESC_BR */{ ERROR, ERROR, ERROR, ERROR, MAKE_A, MAKE_A, ERROR, ERROR, ERROR }, |
}; |
/* we override the mbstate_t __count field for more complex encodings and use it store a state value */ |
#define __state __count |
#ifdef _MB_EXTENDED_CHARSETS_ISO |
int |
_DEFUN (__iso_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
if (*t >= 0xa0) |
{ |
int iso_idx = __iso_8859_index (charset + 9); |
if (iso_idx >= 0) |
{ |
*pwc = __iso_8859_conv[iso_idx][*t - 0xa0]; |
if (*pwc == 0) /* Invalid character */ |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
return 1; |
} |
} |
*pwc = (wchar_t) *t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_ISO */ |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
int |
_DEFUN (__cp_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
if (*t >= 0x80) |
{ |
int cp_idx = __cp_index (charset + 2); |
if (cp_idx >= 0) |
{ |
*pwc = __cp_conv[cp_idx][*t - 0x80]; |
if (*pwc == 0) /* Invalid character */ |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
return 1; |
} |
} |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
int |
_DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
int ch; |
int i = 0; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
if (state->__count == 0) |
ch = t[i++]; |
else |
ch = state->__value.__wchb[0]; |
if (ch == '\0') |
{ |
*pwc = 0; |
state->__count = 0; |
return 0; /* s points to the null character */ |
} |
if (ch <= 0x7f) |
{ |
/* single-byte sequence */ |
state->__count = 0; |
*pwc = ch; |
return 1; |
} |
if (ch >= 0xc0 && ch <= 0xdf) |
{ |
/* two-byte sequence */ |
state->__value.__wchb[0] = ch; |
if (state->__count == 0) |
state->__count = 1; |
else if (n < (size_t)-1) |
++n; |
if (n < 2) |
return -2; |
ch = t[i++]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
if (state->__value.__wchb[0] < 0xc2) |
{ |
/* overlong UTF-8 sequence */ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__count = 0; |
*pwc = (wchar_t)((state->__value.__wchb[0] & 0x1f) << 6) |
| (wchar_t)(ch & 0x3f); |
return i; |
} |
if (ch >= 0xe0 && ch <= 0xef) |
{ |
/* three-byte sequence */ |
wchar_t tmp; |
state->__value.__wchb[0] = ch; |
if (state->__count == 0) |
state->__count = 1; |
else if (n < (size_t)-1) |
++n; |
if (n < 2) |
return -2; |
ch = (state->__count == 1) ? t[i++] : state->__value.__wchb[1]; |
if (state->__value.__wchb[0] == 0xe0 && ch < 0xa0) |
{ |
/* overlong UTF-8 sequence */ |
r->_errno = EILSEQ; |
return -1; |
} |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__value.__wchb[1] = ch; |
if (state->__count == 1) |
state->__count = 2; |
else if (n < (size_t)-1) |
++n; |
if (n < 3) |
return -2; |
ch = t[i++]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__count = 0; |
tmp = (wchar_t)((state->__value.__wchb[0] & 0x0f) << 12) |
| (wchar_t)((state->__value.__wchb[1] & 0x3f) << 6) |
| (wchar_t)(ch & 0x3f); |
*pwc = tmp; |
return i; |
} |
if (ch >= 0xf0 && ch <= 0xf4) |
{ |
/* four-byte sequence */ |
wint_t tmp; |
state->__value.__wchb[0] = ch; |
if (state->__count == 0) |
state->__count = 1; |
else if (n < (size_t)-1) |
++n; |
if (n < 2) |
return -2; |
ch = (state->__count == 1) ? t[i++] : state->__value.__wchb[1]; |
if ((state->__value.__wchb[0] == 0xf0 && ch < 0x90) |
|| (state->__value.__wchb[0] == 0xf4 && ch >= 0x90)) |
{ |
/* overlong UTF-8 sequence or result is > 0x10ffff */ |
r->_errno = EILSEQ; |
return -1; |
} |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__value.__wchb[1] = ch; |
if (state->__count == 1) |
state->__count = 2; |
else if (n < (size_t)-1) |
++n; |
if (n < 3) |
return -2; |
ch = (state->__count == 2) ? t[i++] : state->__value.__wchb[2]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__value.__wchb[2] = ch; |
if (state->__count == 2) |
state->__count = 3; |
else if (n < (size_t)-1) |
++n; |
if (state->__count == 3 && sizeof(wchar_t) == 2) |
{ |
/* On systems which have wchar_t being UTF-16 values, the value |
doesn't fit into a single wchar_t in this case. So what we |
do here is to store the state with a special value of __count |
and return the first half of a surrogate pair. The first |
three bytes of a UTF-8 sequence are enough to generate the |
first half of a UTF-16 surrogate pair. As return value we |
choose to return the number of bytes actually read up to |
here. |
The second half of the surrogate pair is returned in case we |
recognize the special __count value of four, and the next |
byte is actually a valid value. See below. */ |
tmp = (wint_t)((state->__value.__wchb[0] & 0x07) << 18) |
| (wint_t)((state->__value.__wchb[1] & 0x3f) << 12) |
| (wint_t)((state->__value.__wchb[2] & 0x3f) << 6); |
state->__count = 4; |
*pwc = 0xd800 | ((tmp - 0x10000) >> 10); |
return i; |
} |
if (n < 4) |
return -2; |
ch = t[i++]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
tmp = (wint_t)((state->__value.__wchb[0] & 0x07) << 18) |
| (wint_t)((state->__value.__wchb[1] & 0x3f) << 12) |
| (wint_t)((state->__value.__wchb[2] & 0x3f) << 6) |
| (wint_t)(ch & 0x3f); |
if (state->__count == 4 && sizeof(wchar_t) == 2) |
/* Create the second half of the surrogate pair for systems with |
wchar_t == UTF-16 . */ |
*pwc = 0xdc00 | (tmp & 0x3ff); |
else |
*pwc = tmp; |
state->__count = 0; |
return i; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
/* Cygwin defines its own doublebyte charset conversion functions |
because the underlying OS requires wchar_t == UTF-16. */ |
#ifndef __CYGWIN__ |
int |
_DEFUN (__sjis_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
int ch; |
int i = 0; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; /* not state-dependent */ |
if (n == 0) |
return -2; |
ch = t[i++]; |
if (state->__count == 0) |
{ |
if (_issjis1 (ch)) |
{ |
state->__value.__wchb[0] = ch; |
state->__count = 1; |
if (n <= 1) |
return -2; |
ch = t[i++]; |
} |
} |
if (state->__count == 1) |
{ |
if (_issjis2 (ch)) |
{ |
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch; |
state->__count = 0; |
return i; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
int |
_DEFUN (__eucjp_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
int ch; |
int i = 0; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
ch = t[i++]; |
if (state->__count == 0) |
{ |
if (_iseucjp1 (ch)) |
{ |
state->__value.__wchb[0] = ch; |
state->__count = 1; |
if (n <= 1) |
return -2; |
ch = t[i++]; |
} |
} |
if (state->__count == 1) |
{ |
if (_iseucjp2 (ch)) |
{ |
if (state->__value.__wchb[0] == 0x8f) |
{ |
state->__value.__wchb[1] = ch; |
state->__count = 2; |
if (n <= i) |
return -2; |
ch = t[i++]; |
} |
else |
{ |
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch; |
state->__count = 0; |
return i; |
} |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
if (state->__count == 2) |
{ |
if (_iseucjp2 (ch)) |
{ |
*pwc = (((wchar_t)state->__value.__wchb[1]) << 8) |
+ (wchar_t)(ch & 0x7f); |
state->__count = 0; |
return i; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
int |
_DEFUN (__jis_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
JIS_STATE curr_state; |
JIS_ACTION action; |
JIS_CHAR_TYPE ch; |
unsigned char *ptr; |
unsigned int i; |
int curr_ch; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
{ |
state->__state = ASCII; |
return 1; /* state-dependent */ |
} |
if (n == 0) |
return -2; |
curr_state = state->__state; |
ptr = t; |
for (i = 0; i < n; ++i) |
{ |
curr_ch = t[i]; |
switch (curr_ch) |
{ |
case ESC_CHAR: |
ch = ESCAPE; |
break; |
case '$': |
ch = DOLLAR; |
break; |
case '@': |
ch = AT; |
break; |
case '(': |
ch = BRACKET; |
break; |
case 'B': |
ch = B; |
break; |
case 'J': |
ch = J; |
break; |
case '\0': |
ch = NUL; |
break; |
default: |
if (_isjis (curr_ch)) |
ch = JIS_CHAR; |
else |
ch = OTHER; |
} |
action = JIS_action_table[curr_state][ch]; |
curr_state = JIS_state_table[curr_state][ch]; |
switch (action) |
{ |
case NOOP: |
break; |
case EMPTY: |
state->__state = ASCII; |
*pwc = (wchar_t)0; |
return 0; |
case COPY_A: |
state->__state = ASCII; |
*pwc = (wchar_t)*ptr; |
return (i + 1); |
case COPY_J1: |
state->__value.__wchb[0] = t[i]; |
break; |
case COPY_J2: |
state->__state = JIS; |
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)(t[i]); |
return (i + 1); |
case MAKE_A: |
ptr = (unsigned char *)(t + i + 1); |
break; |
case ERROR: |
default: |
r->_errno = EILSEQ; |
return -1; |
} |
} |
state->__state = curr_state; |
return -2; /* n < bytes needed */ |
} |
#endif /* !__CYGWIN__*/ |
#endif /* _MB_CAPABLE */ |
/programs/develop/libraries/newlib/stdlib/mlock.c |
---|
0,0 → 1,56 |
/* |
FUNCTION |
<<__malloc_lock>>, <<__malloc_unlock>>---lock malloc pool |
INDEX |
__malloc_lock |
INDEX |
__malloc_unlock |
ANSI_SYNOPSIS |
#include <malloc.h> |
void __malloc_lock (struct _reent *<[reent]>); |
void __malloc_unlock (struct _reent *<[reent]>); |
TRAD_SYNOPSIS |
void __malloc_lock(<[reent]>) |
struct _reent *<[reent]>; |
void __malloc_unlock(<[reent]>) |
struct _reent *<[reent]>; |
DESCRIPTION |
The <<malloc>> family of routines call these functions when they need to lock |
the memory pool. The version of these routines supplied in the library use |
the lock API defined in sys/lock.h. If multiple threads of execution can |
call <<malloc>>, or if <<malloc>> can be called reentrantly, then you need to |
define your own versions of these functions in order to safely lock the |
memory pool during a call. If you do not, the memory pool may become |
corrupted. |
A call to <<malloc>> may call <<__malloc_lock>> recursively; that is, |
the sequence of calls may go <<__malloc_lock>>, <<__malloc_lock>>, |
<<__malloc_unlock>>, <<__malloc_unlock>>. Any implementation of these |
routines must be careful to avoid causing a thread to wait for a lock |
that it already holds. |
*/ |
#include <malloc.h> |
#include <sys/lock.h> |
__LOCK_INIT_RECURSIVE(static, __malloc_lock_object); |
void |
__malloc_lock (ptr) |
struct _reent *ptr; |
{ |
__lock_acquire_recursive (__malloc_lock_object); |
} |
void |
__malloc_unlock (ptr) |
struct _reent *ptr; |
{ |
__lock_release_recursive (__malloc_lock_object); |
} |
/programs/develop/libraries/newlib/stdlib/mprec.c |
---|
0,0 → 1,1049 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. |
* |
* This strtod returns a nearest machine number to the input decimal |
* string (or sets errno to ERANGE). With IEEE arithmetic, ties are |
* broken by the IEEE round-even rule. Otherwise ties are broken by |
* biased rounding (add half and chop). |
* |
* Inspired loosely by William D. Clinger's paper "How to Read Floating |
* Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. |
* |
* Modifications: |
* |
* 1. We only require IEEE, IBM, or VAX double-precision |
* arithmetic (not IEEE double-extended). |
* 2. We get by with floating-point arithmetic in a case that |
* Clinger missed -- when we're computing d * 10^n |
* for a small integer d and the integer n is not too |
* much larger than 22 (the maximum integer k for which |
* we can represent 10^k exactly), we may be able to |
* compute (d*10^k) * 10^(e-k) with just one roundoff. |
* 3. Rather than a bit-at-a-time adjustment of the binary |
* result in the hard case, we use floating-point |
* arithmetic to determine the adjustment to within |
* one bit; only in really hard cases do we need to |
* compute a second residual. |
* 4. Because of 3., we don't need a large table of powers of 10 |
* for ten-to-e (just some small tables, e.g. of 10^k |
* for 0 <= k <= 22). |
*/ |
/* |
* #define IEEE_8087 for IEEE-arithmetic machines where the least |
* significant byte has the lowest address. |
* #define IEEE_MC68k for IEEE-arithmetic machines where the most |
* significant byte has the lowest address. |
* #define Sudden_Underflow for IEEE-format machines without gradual |
* underflow (i.e., that flush to zero on underflow). |
* #define IBM for IBM mainframe-style floating-point arithmetic. |
* #define VAX for VAX-style floating-point arithmetic. |
* #define Unsigned_Shifts if >> does treats its left operand as unsigned. |
* #define No_leftright to omit left-right logic in fast floating-point |
* computation of dtoa. |
* #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. |
* #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines |
* that use extended-precision instructions to compute rounded |
* products and quotients) with IBM. |
* #define ROUND_BIASED for IEEE-format with biased rounding. |
* #define Inaccurate_Divide for IEEE-format with correctly rounded |
* products but inaccurate quotients, e.g., for Intel i860. |
* #define Just_16 to store 16 bits per 32-bit long when doing high-precision |
* integer arithmetic. Whether this speeds things up or slows things |
* down depends on the machine and the number being converted. |
*/ |
#include <_ansi.h> |
#include <stdlib.h> |
#include <string.h> |
#include <reent.h> |
#include "mprec.h" |
/* This is defined in sys/reent.h as (sizeof (size_t) << 3) now, as in NetBSD. |
The old value of 15 was wrong and made newlib vulnerable against buffer |
overrun attacks (CVE-2009-0689), same as other implementations of gdtoa |
based on BSD code. |
#define _Kmax 15 |
*/ |
_Bigint * |
_DEFUN (Balloc, (ptr, k), struct _reent *ptr _AND int k) |
{ |
int x; |
_Bigint *rv ; |
_REENT_CHECK_MP(ptr); |
if (_REENT_MP_FREELIST(ptr) == NULL) |
{ |
/* Allocate a list of pointers to the mprec objects */ |
_REENT_MP_FREELIST(ptr) = (struct _Bigint **) _calloc_r (ptr, |
sizeof (struct _Bigint *), |
_Kmax + 1); |
if (_REENT_MP_FREELIST(ptr) == NULL) |
{ |
return NULL; |
} |
} |
if ((rv = _REENT_MP_FREELIST(ptr)[k]) != 0) |
{ |
_REENT_MP_FREELIST(ptr)[k] = rv->_next; |
} |
else |
{ |
x = 1 << k; |
/* Allocate an mprec Bigint and stick in in the freelist */ |
rv = (_Bigint *) _calloc_r (ptr, |
1, |
sizeof (_Bigint) + |
(x-1) * sizeof(rv->_x)); |
if (rv == NULL) return NULL; |
rv->_k = k; |
rv->_maxwds = x; |
} |
rv->_sign = rv->_wds = 0; |
return rv; |
} |
void |
_DEFUN (Bfree, (ptr, v), struct _reent *ptr _AND _Bigint * v) |
{ |
_REENT_CHECK_MP(ptr); |
if (v) |
{ |
v->_next = _REENT_MP_FREELIST(ptr)[v->_k]; |
_REENT_MP_FREELIST(ptr)[v->_k] = v; |
} |
} |
_Bigint * |
_DEFUN (multadd, (ptr, b, m, a), |
struct _reent *ptr _AND |
_Bigint * b _AND |
int m _AND |
int a) |
{ |
int i, wds; |
__ULong *x, y; |
#ifdef Pack_32 |
__ULong xi, z; |
#endif |
_Bigint *b1; |
wds = b->_wds; |
x = b->_x; |
i = 0; |
do |
{ |
#ifdef Pack_32 |
xi = *x; |
y = (xi & 0xffff) * m + a; |
z = (xi >> 16) * m + (y >> 16); |
a = (int) (z >> 16); |
*x++ = (z << 16) + (y & 0xffff); |
#else |
y = *x * m + a; |
a = (int) (y >> 16); |
*x++ = y & 0xffff; |
#endif |
} |
while (++i < wds); |
if (a) |
{ |
if (wds >= b->_maxwds) |
{ |
b1 = Balloc (ptr, b->_k + 1); |
Bcopy (b1, b); |
Bfree (ptr, b); |
b = b1; |
} |
b->_x[wds++] = a; |
b->_wds = wds; |
} |
return b; |
} |
_Bigint * |
_DEFUN (s2b, (ptr, s, nd0, nd, y9), |
struct _reent * ptr _AND |
_CONST char *s _AND |
int nd0 _AND |
int nd _AND |
__ULong y9) |
{ |
_Bigint *b; |
int i, k; |
__Long x, y; |
x = (nd + 8) / 9; |
for (k = 0, y = 1; x > y; y <<= 1, k++); |
#ifdef Pack_32 |
b = Balloc (ptr, k); |
b->_x[0] = y9; |
b->_wds = 1; |
#else |
b = Balloc (ptr, k + 1); |
b->_x[0] = y9 & 0xffff; |
b->_wds = (b->_x[1] = y9 >> 16) ? 2 : 1; |
#endif |
i = 9; |
if (9 < nd0) |
{ |
s += 9; |
do |
b = multadd (ptr, b, 10, *s++ - '0'); |
while (++i < nd0); |
s++; |
} |
else |
s += 10; |
for (; i < nd; i++) |
b = multadd (ptr, b, 10, *s++ - '0'); |
return b; |
} |
int |
_DEFUN (hi0bits, |
(x), register __ULong x) |
{ |
register int k = 0; |
if (!(x & 0xffff0000)) |
{ |
k = 16; |
x <<= 16; |
} |
if (!(x & 0xff000000)) |
{ |
k += 8; |
x <<= 8; |
} |
if (!(x & 0xf0000000)) |
{ |
k += 4; |
x <<= 4; |
} |
if (!(x & 0xc0000000)) |
{ |
k += 2; |
x <<= 2; |
} |
if (!(x & 0x80000000)) |
{ |
k++; |
if (!(x & 0x40000000)) |
return 32; |
} |
return k; |
} |
int |
_DEFUN (lo0bits, (y), __ULong *y) |
{ |
register int k; |
register __ULong x = *y; |
if (x & 7) |
{ |
if (x & 1) |
return 0; |
if (x & 2) |
{ |
*y = x >> 1; |
return 1; |
} |
*y = x >> 2; |
return 2; |
} |
k = 0; |
if (!(x & 0xffff)) |
{ |
k = 16; |
x >>= 16; |
} |
if (!(x & 0xff)) |
{ |
k += 8; |
x >>= 8; |
} |
if (!(x & 0xf)) |
{ |
k += 4; |
x >>= 4; |
} |
if (!(x & 0x3)) |
{ |
k += 2; |
x >>= 2; |
} |
if (!(x & 1)) |
{ |
k++; |
x >>= 1; |
if (!x & 1) |
return 32; |
} |
*y = x; |
return k; |
} |
_Bigint * |
_DEFUN (i2b, (ptr, i), struct _reent * ptr _AND int i) |
{ |
_Bigint *b; |
b = Balloc (ptr, 1); |
b->_x[0] = i; |
b->_wds = 1; |
return b; |
} |
_Bigint * |
_DEFUN (mult, (ptr, a, b), struct _reent * ptr _AND _Bigint * a _AND _Bigint * b) |
{ |
_Bigint *c; |
int k, wa, wb, wc; |
__ULong carry, y, z; |
__ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; |
#ifdef Pack_32 |
__ULong z2; |
#endif |
if (a->_wds < b->_wds) |
{ |
c = a; |
a = b; |
b = c; |
} |
k = a->_k; |
wa = a->_wds; |
wb = b->_wds; |
wc = wa + wb; |
if (wc > a->_maxwds) |
k++; |
c = Balloc (ptr, k); |
for (x = c->_x, xa = x + wc; x < xa; x++) |
*x = 0; |
xa = a->_x; |
xae = xa + wa; |
xb = b->_x; |
xbe = xb + wb; |
xc0 = c->_x; |
#ifdef Pack_32 |
for (; xb < xbe; xb++, xc0++) |
{ |
if ((y = *xb & 0xffff) != 0) |
{ |
x = xa; |
xc = xc0; |
carry = 0; |
do |
{ |
z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; |
carry = z >> 16; |
z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; |
carry = z2 >> 16; |
Storeinc (xc, z2, z); |
} |
while (x < xae); |
*xc = carry; |
} |
if ((y = *xb >> 16) != 0) |
{ |
x = xa; |
xc = xc0; |
carry = 0; |
z2 = *xc; |
do |
{ |
z = (*x & 0xffff) * y + (*xc >> 16) + carry; |
carry = z >> 16; |
Storeinc (xc, z, z2); |
z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; |
carry = z2 >> 16; |
} |
while (x < xae); |
*xc = z2; |
} |
} |
#else |
for (; xb < xbe; xc0++) |
{ |
if (y = *xb++) |
{ |
x = xa; |
xc = xc0; |
carry = 0; |
do |
{ |
z = *x++ * y + *xc + carry; |
carry = z >> 16; |
*xc++ = z & 0xffff; |
} |
while (x < xae); |
*xc = carry; |
} |
} |
#endif |
for (xc0 = c->_x, xc = xc0 + wc; wc > 0 && !*--xc; --wc); |
c->_wds = wc; |
return c; |
} |
_Bigint * |
_DEFUN (pow5mult, |
(ptr, b, k), struct _reent * ptr _AND _Bigint * b _AND int k) |
{ |
_Bigint *b1, *p5, *p51; |
int i; |
static _CONST int p05[3] = {5, 25, 125}; |
if ((i = k & 3) != 0) |
b = multadd (ptr, b, p05[i - 1], 0); |
if (!(k >>= 2)) |
return b; |
_REENT_CHECK_MP(ptr); |
if (!(p5 = _REENT_MP_P5S(ptr))) |
{ |
/* first time */ |
p5 = _REENT_MP_P5S(ptr) = i2b (ptr, 625); |
p5->_next = 0; |
} |
for (;;) |
{ |
if (k & 1) |
{ |
b1 = mult (ptr, b, p5); |
Bfree (ptr, b); |
b = b1; |
} |
if (!(k >>= 1)) |
break; |
if (!(p51 = p5->_next)) |
{ |
p51 = p5->_next = mult (ptr, p5, p5); |
p51->_next = 0; |
} |
p5 = p51; |
} |
return b; |
} |
_Bigint * |
_DEFUN (lshift, (ptr, b, k), struct _reent * ptr _AND _Bigint * b _AND int k) |
{ |
int i, k1, n, n1; |
_Bigint *b1; |
__ULong *x, *x1, *xe, z; |
#ifdef Pack_32 |
n = k >> 5; |
#else |
n = k >> 4; |
#endif |
k1 = b->_k; |
n1 = n + b->_wds + 1; |
for (i = b->_maxwds; n1 > i; i <<= 1) |
k1++; |
b1 = Balloc (ptr, k1); |
x1 = b1->_x; |
for (i = 0; i < n; i++) |
*x1++ = 0; |
x = b->_x; |
xe = x + b->_wds; |
#ifdef Pack_32 |
if (k &= 0x1f) |
{ |
k1 = 32 - k; |
z = 0; |
do |
{ |
*x1++ = *x << k | z; |
z = *x++ >> k1; |
} |
while (x < xe); |
if ((*x1 = z) != 0) |
++n1; |
} |
#else |
if (k &= 0xf) |
{ |
k1 = 16 - k; |
z = 0; |
do |
{ |
*x1++ = *x << k & 0xffff | z; |
z = *x++ >> k1; |
} |
while (x < xe); |
if (*x1 = z) |
++n1; |
} |
#endif |
else |
do |
*x1++ = *x++; |
while (x < xe); |
b1->_wds = n1 - 1; |
Bfree (ptr, b); |
return b1; |
} |
int |
_DEFUN (cmp, (a, b), _Bigint * a _AND _Bigint * b) |
{ |
__ULong *xa, *xa0, *xb, *xb0; |
int i, j; |
i = a->_wds; |
j = b->_wds; |
#ifdef DEBUG |
if (i > 1 && !a->_x[i - 1]) |
Bug ("cmp called with a->_x[a->_wds-1] == 0"); |
if (j > 1 && !b->_x[j - 1]) |
Bug ("cmp called with b->_x[b->_wds-1] == 0"); |
#endif |
if (i -= j) |
return i; |
xa0 = a->_x; |
xa = xa0 + j; |
xb0 = b->_x; |
xb = xb0 + j; |
for (;;) |
{ |
if (*--xa != *--xb) |
return *xa < *xb ? -1 : 1; |
if (xa <= xa0) |
break; |
} |
return 0; |
} |
_Bigint * |
_DEFUN (diff, (ptr, a, b), struct _reent * ptr _AND |
_Bigint * a _AND _Bigint * b) |
{ |
_Bigint *c; |
int i, wa, wb; |
__Long borrow, y; /* We need signed shifts here. */ |
__ULong *xa, *xae, *xb, *xbe, *xc; |
#ifdef Pack_32 |
__Long z; |
#endif |
i = cmp (a, b); |
if (!i) |
{ |
c = Balloc (ptr, 0); |
c->_wds = 1; |
c->_x[0] = 0; |
return c; |
} |
if (i < 0) |
{ |
c = a; |
a = b; |
b = c; |
i = 1; |
} |
else |
i = 0; |
c = Balloc (ptr, a->_k); |
c->_sign = i; |
wa = a->_wds; |
xa = a->_x; |
xae = xa + wa; |
wb = b->_wds; |
xb = b->_x; |
xbe = xb + wb; |
xc = c->_x; |
borrow = 0; |
#ifdef Pack_32 |
do |
{ |
y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (xc, z, y); |
} |
while (xb < xbe); |
while (xa < xae) |
{ |
y = (*xa & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*xa++ >> 16) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (xc, z, y); |
} |
#else |
do |
{ |
y = *xa++ - *xb++ + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*xc++ = y & 0xffff; |
} |
while (xb < xbe); |
while (xa < xae) |
{ |
y = *xa++ + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*xc++ = y & 0xffff; |
} |
#endif |
while (!*--xc) |
wa--; |
c->_wds = wa; |
return c; |
} |
double |
_DEFUN (ulp, (_x), double _x) |
{ |
union double_union x, a; |
register __Long L; |
x.d = _x; |
L = (word0 (x) & Exp_mask) - (P - 1) * Exp_msk1; |
#ifndef Sudden_Underflow |
if (L > 0) |
{ |
#endif |
#ifdef IBM |
L |= Exp_msk1 >> 4; |
#endif |
word0 (a) = L; |
#ifndef _DOUBLE_IS_32BITS |
word1 (a) = 0; |
#endif |
#ifndef Sudden_Underflow |
} |
else |
{ |
L = -L >> Exp_shift; |
if (L < Exp_shift) |
{ |
word0 (a) = 0x80000 >> L; |
#ifndef _DOUBLE_IS_32BITS |
word1 (a) = 0; |
#endif |
} |
else |
{ |
word0 (a) = 0; |
L -= Exp_shift; |
#ifndef _DOUBLE_IS_32BITS |
word1 (a) = L >= 31 ? 1 : 1 << (31 - L); |
#endif |
} |
} |
#endif |
return a.d; |
} |
double |
_DEFUN (b2d, (a, e), |
_Bigint * a _AND int *e) |
{ |
__ULong *xa, *xa0, w, y, z; |
int k; |
union double_union d; |
#ifdef VAX |
__ULong d0, d1; |
#else |
#define d0 word0(d) |
#define d1 word1(d) |
#endif |
xa0 = a->_x; |
xa = xa0 + a->_wds; |
y = *--xa; |
#ifdef DEBUG |
if (!y) |
Bug ("zero y in b2d"); |
#endif |
k = hi0bits (y); |
*e = 32 - k; |
#ifdef Pack_32 |
if (k < Ebits) |
{ |
d0 = Exp_1 | y >> (Ebits - k); |
w = xa > xa0 ? *--xa : 0; |
#ifndef _DOUBLE_IS_32BITS |
d1 = y << ((32 - Ebits) + k) | w >> (Ebits - k); |
#endif |
goto ret_d; |
} |
z = xa > xa0 ? *--xa : 0; |
if (k -= Ebits) |
{ |
d0 = Exp_1 | y << k | z >> (32 - k); |
y = xa > xa0 ? *--xa : 0; |
#ifndef _DOUBLE_IS_32BITS |
d1 = z << k | y >> (32 - k); |
#endif |
} |
else |
{ |
d0 = Exp_1 | y; |
#ifndef _DOUBLE_IS_32BITS |
d1 = z; |
#endif |
} |
#else |
if (k < Ebits + 16) |
{ |
z = xa > xa0 ? *--xa : 0; |
d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; |
w = xa > xa0 ? *--xa : 0; |
y = xa > xa0 ? *--xa : 0; |
d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; |
goto ret_d; |
} |
z = xa > xa0 ? *--xa : 0; |
w = xa > xa0 ? *--xa : 0; |
k -= Ebits + 16; |
d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; |
y = xa > xa0 ? *--xa : 0; |
d1 = w << k + 16 | y << k; |
#endif |
ret_d: |
#ifdef VAX |
word0 (d) = d0 >> 16 | d0 << 16; |
word1 (d) = d1 >> 16 | d1 << 16; |
#else |
#undef d0 |
#undef d1 |
#endif |
return d.d; |
} |
_Bigint * |
_DEFUN (d2b, |
(ptr, _d, e, bits), |
struct _reent * ptr _AND |
double _d _AND |
int *e _AND |
int *bits) |
{ |
union double_union d; |
_Bigint *b; |
int de, i, k; |
__ULong *x, y, z; |
#ifdef VAX |
__ULong d0, d1; |
#endif |
d.d = _d; |
#ifdef VAX |
d0 = word0 (d) >> 16 | word0 (d) << 16; |
d1 = word1 (d) >> 16 | word1 (d) << 16; |
#else |
#define d0 word0(d) |
#define d1 word1(d) |
d.d = _d; |
#endif |
#ifdef Pack_32 |
b = Balloc (ptr, 1); |
#else |
b = Balloc (ptr, 2); |
#endif |
x = b->_x; |
z = d0 & Frac_mask; |
d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ |
#ifdef Sudden_Underflow |
de = (int) (d0 >> Exp_shift); |
#ifndef IBM |
z |= Exp_msk11; |
#endif |
#else |
if ((de = (int) (d0 >> Exp_shift)) != 0) |
z |= Exp_msk1; |
#endif |
#ifdef Pack_32 |
#ifndef _DOUBLE_IS_32BITS |
if (d1) |
{ |
y = d1; |
k = lo0bits (&y); |
if (k) |
{ |
x[0] = y | z << (32 - k); |
z >>= k; |
} |
else |
x[0] = y; |
i = b->_wds = (x[1] = z) ? 2 : 1; |
} |
else |
#endif |
{ |
#ifdef DEBUG |
if (!z) |
Bug ("Zero passed to d2b"); |
#endif |
k = lo0bits (&z); |
x[0] = z; |
i = b->_wds = 1; |
#ifndef _DOUBLE_IS_32BITS |
k += 32; |
#endif |
} |
#else |
if (d1) |
{ |
y = d1; |
k = lo0bits (&y); |
if (k) |
if (k >= 16) |
{ |
x[0] = y | z << 32 - k & 0xffff; |
x[1] = z >> k - 16 & 0xffff; |
x[2] = z >> k; |
i = 2; |
} |
else |
{ |
x[0] = y & 0xffff; |
x[1] = y >> 16 | z << 16 - k & 0xffff; |
x[2] = z >> k & 0xffff; |
x[3] = z >> k + 16; |
i = 3; |
} |
else |
{ |
x[0] = y & 0xffff; |
x[1] = y >> 16; |
x[2] = z & 0xffff; |
x[3] = z >> 16; |
i = 3; |
} |
} |
else |
{ |
#ifdef DEBUG |
if (!z) |
Bug ("Zero passed to d2b"); |
#endif |
k = lo0bits (&z); |
if (k >= 16) |
{ |
x[0] = z; |
i = 0; |
} |
else |
{ |
x[0] = z & 0xffff; |
x[1] = z >> 16; |
i = 1; |
} |
k += 32; |
} |
while (!x[i]) |
--i; |
b->_wds = i + 1; |
#endif |
#ifndef Sudden_Underflow |
if (de) |
{ |
#endif |
#ifdef IBM |
*e = (de - Bias - (P - 1) << 2) + k; |
*bits = 4 * P + 8 - k - hi0bits (word0 (d) & Frac_mask); |
#else |
*e = de - Bias - (P - 1) + k; |
*bits = P - k; |
#endif |
#ifndef Sudden_Underflow |
} |
else |
{ |
*e = de - Bias - (P - 1) + 1 + k; |
#ifdef Pack_32 |
*bits = 32 * i - hi0bits (x[i - 1]); |
#else |
*bits = (i + 2) * 16 - hi0bits (x[i]); |
#endif |
} |
#endif |
return b; |
} |
#undef d0 |
#undef d1 |
double |
_DEFUN (ratio, (a, b), _Bigint * a _AND _Bigint * b) |
{ |
union double_union da, db; |
int k, ka, kb; |
da.d = b2d (a, &ka); |
db.d = b2d (b, &kb); |
#ifdef Pack_32 |
k = ka - kb + 32 * (a->_wds - b->_wds); |
#else |
k = ka - kb + 16 * (a->_wds - b->_wds); |
#endif |
#ifdef IBM |
if (k > 0) |
{ |
word0 (da) += (k >> 2) * Exp_msk1; |
if (k &= 3) |
da.d *= 1 << k; |
} |
else |
{ |
k = -k; |
word0 (db) += (k >> 2) * Exp_msk1; |
if (k &= 3) |
db.d *= 1 << k; |
} |
#else |
if (k > 0) |
word0 (da) += k * Exp_msk1; |
else |
{ |
k = -k; |
word0 (db) += k * Exp_msk1; |
} |
#endif |
return da.d / db.d; |
} |
_CONST double |
tens[] = |
{ |
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, |
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, |
1e20, 1e21, 1e22, 1e23, 1e24 |
}; |
#if !defined(_DOUBLE_IS_32BITS) && !defined(__v800) |
_CONST double bigtens[] = |
{1e16, 1e32, 1e64, 1e128, 1e256}; |
_CONST double tinytens[] = |
{1e-16, 1e-32, 1e-64, 1e-128, 1e-256}; |
#else |
_CONST double bigtens[] = |
{1e16, 1e32}; |
_CONST double tinytens[] = |
{1e-16, 1e-32}; |
#endif |
double |
_DEFUN (_mprec_log10, (dig), |
int dig) |
{ |
double v = 1.0; |
if (dig < 24) |
return tens[dig]; |
while (dig > 0) |
{ |
v *= 10; |
dig--; |
} |
return v; |
} |
void |
_DEFUN (copybits, (c, n, b), |
__ULong *c _AND |
int n _AND |
_Bigint *b) |
{ |
__ULong *ce, *x, *xe; |
#ifdef Pack_16 |
int nw, nw1; |
#endif |
ce = c + ((n-1) >> kshift) + 1; |
x = b->_x; |
#ifdef Pack_32 |
xe = x + b->_wds; |
while(x < xe) |
*c++ = *x++; |
#else |
nw = b->_wds; |
nw1 = nw & 1; |
for(xe = x + (nw - nw1); x < xe; x += 2) |
Storeinc(c, x[1], x[0]); |
if (nw1) |
*c++ = *x; |
#endif |
while(c < ce) |
*c++ = 0; |
} |
__ULong |
_DEFUN (any_on, (b, k), |
_Bigint *b _AND |
int k) |
{ |
int n, nwds; |
__ULong *x, *x0, x1, x2; |
x = b->_x; |
nwds = b->_wds; |
n = k >> kshift; |
if (n > nwds) |
n = nwds; |
else if (n < nwds && (k &= kmask)) { |
x1 = x2 = x[n]; |
x1 >>= k; |
x1 <<= k; |
if (x1 != x2) |
return 1; |
} |
x0 = x; |
x += n; |
while(x > x0) |
if (*--x) |
return 1; |
return 0; |
} |
/programs/develop/libraries/newlib/stdlib/mprec.h |
---|
0,0 → 1,415 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
#include <ieeefp.h> |
#include <math.h> |
#include <float.h> |
#include <errno.h> |
#include <sys/config.h> |
#include <sys/types.h> |
#ifdef __IEEE_LITTLE_ENDIAN |
#define IEEE_8087 |
#endif |
#ifdef __IEEE_BIG_ENDIAN |
#define IEEE_MC68k |
#endif |
#ifdef __Z8000__ |
#define Just_16 |
#endif |
#ifdef DEBUG |
#include "stdio.h" |
#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} |
#endif |
#ifdef Unsigned_Shifts |
#define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000; |
#else |
#define Sign_Extend(a,b) /*no-op*/ |
#endif |
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 |
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. |
#endif |
/* If we are going to examine or modify specific bits in a double using |
the word0 and/or word1 macros, then we must wrap the double inside |
a union. This is necessary to avoid undefined behavior according to |
the ANSI C spec. */ |
union double_union |
{ |
double d; |
__uint32_t i[2]; |
}; |
#ifdef IEEE_8087 |
#define word0(x) (x.i[1]) |
#define word1(x) (x.i[0]) |
#else |
#define word0(x) (x.i[0]) |
#define word1(x) (x.i[1]) |
#endif |
/* The following is taken from gdtoaimp.h for use with new strtod, but |
adjusted to avoid invalid type-punning. */ |
typedef __int32_t Long; |
/* Unfortunately, because __ULong might be a different type than |
__uint32_t, we can't re-use union double_union as-is without |
further edits in strtod.c. */ |
typedef union { double d; __ULong i[2]; } U; |
#define dword0(x) word0(x) |
#define dword1(x) word1(x) |
#define dval(x) (x.d) |
#undef SI |
#ifdef Sudden_Underflow |
#define SI 1 |
#else |
#define SI 0 |
#endif |
#define Storeinc(a,b,c) (*(a)++ = (b) << 16 | (c) & 0xffff) |
/* #define P DBL_MANT_DIG */ |
/* Ten_pmax = floor(P*log(2)/log(5)) */ |
/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ |
/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ |
/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ |
#if defined(IEEE_8087) + defined(IEEE_MC68k) |
#if defined (_DOUBLE_IS_32BITS) |
#define Exp_shift 23 |
#define Exp_shift1 23 |
#define Exp_msk1 ((__uint32_t)0x00800000L) |
#define Exp_msk11 ((__uint32_t)0x00800000L) |
#define Exp_mask ((__uint32_t)0x7f800000L) |
#define P 24 |
#define Bias 127 |
#define NO_HEX_FP /* not supported in this case */ |
#define IEEE_Arith |
#define Emin (-126) |
#define Exp_1 ((__uint32_t)0x3f800000L) |
#define Exp_11 ((__uint32_t)0x3f800000L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x007fffffL) |
#define Frac_mask1 ((__uint32_t)0x007fffffL) |
#define Ten_pmax 10 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Ten_pmax 10 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0x007fffffL) |
#define Bndry_mask1 ((__uint32_t)0x007fffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 5 |
#define Int_max 6 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L)) |
#undef word0 |
#undef word1 |
#undef dword0 |
#undef dword1 |
#define word0(x) (x.i[0]) |
#define word1(x) 0 |
#define dword0(x) word0(x) |
#define dword1(x) 0 |
#else |
#define Exp_shift 20 |
#define Exp_shift1 20 |
#define Exp_msk1 ((__uint32_t)0x100000L) |
#define Exp_msk11 ((__uint32_t)0x100000L) |
#define Exp_mask ((__uint32_t)0x7ff00000L) |
#define P 53 |
#define Bias 1023 |
#define IEEE_Arith |
#define Emin (-1022) |
#define Exp_1 ((__uint32_t)0x3ff00000L) |
#define Exp_11 ((__uint32_t)0x3ff00000L) |
#define Ebits 11 |
#define Frac_mask ((__uint32_t)0xfffffL) |
#define Frac_mask1 ((__uint32_t)0xfffffL) |
#define Ten_pmax 22 |
#define Bletch 0x10 |
#define Bndry_mask ((__uint32_t)0xfffffL) |
#define Bndry_mask1 ((__uint32_t)0xfffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 14 |
#define Int_max 14 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */ |
#endif /* !_DOUBLE_IS_32BITS */ |
#ifndef Flt_Rounds |
#ifdef FLT_ROUNDS |
#define Flt_Rounds FLT_ROUNDS |
#else |
#define Flt_Rounds 1 |
#endif |
#endif /*Flt_Rounds*/ |
#else /* !IEEE_8087 && !IEEE_MC68k */ |
#undef Sudden_Underflow |
#define Sudden_Underflow |
#ifdef IBM |
#define Flt_Rounds 0 |
#define Exp_shift 24 |
#define Exp_shift1 24 |
#define Exp_msk1 ((__uint32_t)0x1000000L) |
#define Exp_msk11 ((__uint32_t)0x1000000L) |
#define Exp_mask ((__uint32_t)0x7f000000L) |
#define P 14 |
#define Bias 65 |
#define Exp_1 ((__uint32_t)0x41000000L) |
#define Exp_11 ((__uint32_t)0x41000000L) |
#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ |
#define Frac_mask ((__uint32_t)0xffffffL) |
#define Frac_mask1 ((__uint32_t)0xffffffL) |
#define Bletch 4 |
#define Ten_pmax 22 |
#define Bndry_mask ((__uint32_t)0xefffffL) |
#define Bndry_mask1 ((__uint32_t)0xffffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 4 |
#define Tiny0 ((__uint32_t)0x100000L) |
#define Tiny1 0 |
#define Quick_max 14 |
#define Int_max 15 |
#else /* VAX */ |
#define Flt_Rounds 1 |
#define Exp_shift 23 |
#define Exp_shift1 7 |
#define Exp_msk1 0x80 |
#define Exp_msk11 ((__uint32_t)0x800000L) |
#define Exp_mask ((__uint32_t)0x7f80L) |
#define P 56 |
#define Bias 129 |
#define Exp_1 ((__uint32_t)0x40800000L) |
#define Exp_11 ((__uint32_t)0x4080L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x7fffffL) |
#define Frac_mask1 ((__uint32_t)0xffff007fL) |
#define Ten_pmax 24 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0xffff007fL) |
#define Bndry_mask1 ((__uint32_t)0xffff007fL) |
#define LSB ((__uint32_t)0x10000L) |
#define Sign_bit ((__uint32_t)0x8000L) |
#define Log2P 1 |
#define Tiny0 0x80 |
#define Tiny1 0 |
#define Quick_max 15 |
#define Int_max 15 |
#endif |
#endif |
#ifndef IEEE_Arith |
#define ROUND_BIASED |
#else |
#define Scale_Bit 0x10 |
#if defined(_DOUBLE_IS_32BITS) && defined(__v800) |
#define n_bigtens 2 |
#else |
#define n_bigtens 5 |
#endif |
#endif |
#ifdef IBM |
#define n_bigtens 3 |
#endif |
#ifdef VAX |
#define n_bigtens 2 |
#endif |
#ifndef __NO_INFNAN_CHECK |
#define INFNAN_CHECK |
#endif |
/* |
* NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to |
* 20050115, they used to be hard-wired here (to 0x7ff80000 and 0, |
* respectively), but now are determined by compiling and running |
* qnan.c to generate gd_qnan.h, which specifies d_QNAN0 and d_QNAN1. |
* Formerly gdtoaimp.h recommended supplying suitable -DNAN_WORD0=... |
* and -DNAN_WORD1=... values if necessary. This should still work. |
* (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) |
*/ |
#ifdef IEEE_Arith |
#ifdef IEEE_MC68k |
#define _0 0 |
#define _1 1 |
#ifndef NAN_WORD0 |
#define NAN_WORD0 d_QNAN0 |
#endif |
#ifndef NAN_WORD1 |
#define NAN_WORD1 d_QNAN1 |
#endif |
#else |
#define _0 1 |
#define _1 0 |
#ifndef NAN_WORD0 |
#define NAN_WORD0 d_QNAN1 |
#endif |
#ifndef NAN_WORD1 |
#define NAN_WORD1 d_QNAN0 |
#endif |
#endif |
#else |
#undef INFNAN_CHECK |
#endif |
#ifdef RND_PRODQUOT |
#define rounded_product(a,b) a = rnd_prod(a, b) |
#define rounded_quotient(a,b) a = rnd_quot(a, b) |
#ifdef KR_headers |
extern double rnd_prod(), rnd_quot(); |
#else |
extern double rnd_prod(double, double), rnd_quot(double, double); |
#endif |
#else |
#define rounded_product(a,b) a *= b |
#define rounded_quotient(a,b) a /= b |
#endif |
#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) |
#define Big1 ((__uint32_t)0xffffffffL) |
#ifndef Just_16 |
/* When Pack_32 is not defined, we store 16 bits per 32-bit long. |
* This makes some inner loops simpler and sometimes saves work |
* during multiplications, but it often seems to make things slightly |
* slower. Hence the default is now to store 32 bits per long. |
*/ |
#ifndef Pack_32 |
#define Pack_32 |
#endif |
#else /* Just_16 */ |
#ifndef Pack_16 |
#define Pack_16 |
#endif |
#endif /* Just_16 */ |
#ifdef Pack_32 |
#define ULbits 32 |
#define kshift 5 |
#define kmask 31 |
#define ALL_ON 0xffffffff |
#else |
#define ULbits 16 |
#define kshift 4 |
#define kmask 15 |
#define ALL_ON 0xffff |
#endif |
#ifdef __cplusplus |
extern "C" double strtod(const char *s00, char **se); |
extern "C" char *dtoa(double d, int mode, int ndigits, |
int *decpt, int *sign, char **rve); |
#endif |
typedef struct _Bigint _Bigint; |
#define Balloc _Balloc |
#define Bfree _Bfree |
#define multadd __multadd |
#define s2b __s2b |
#define lo0bits __lo0bits |
#define hi0bits __hi0bits |
#define i2b __i2b |
#define mult __multiply |
#define pow5mult __pow5mult |
#define lshift __lshift |
#define cmp __mcmp |
#define diff __mdiff |
#define ulp __ulp |
#define b2d __b2d |
#define d2b __d2b |
#define ratio __ratio |
#define any_on __any_on |
#define gethex __gethex |
#define copybits __copybits |
#define hexnan __hexnan |
#define hexdig_init __hexdig_init |
#define hexdig __hexdig |
#define tens __mprec_tens |
#define bigtens __mprec_bigtens |
#define tinytens __mprec_tinytens |
struct _reent ; |
struct FPI; |
double _EXFUN(ulp,(double x)); |
double _EXFUN(b2d,(_Bigint *a , int *e)); |
_Bigint * _EXFUN(Balloc,(struct _reent *p, int k)); |
void _EXFUN(Bfree,(struct _reent *p, _Bigint *v)); |
_Bigint * _EXFUN(multadd,(struct _reent *p, _Bigint *, int, int)); |
_Bigint * _EXFUN(s2b,(struct _reent *, const char*, int, int, __ULong)); |
_Bigint * _EXFUN(i2b,(struct _reent *,int)); |
_Bigint * _EXFUN(mult, (struct _reent *, _Bigint *, _Bigint *)); |
_Bigint * _EXFUN(pow5mult, (struct _reent *, _Bigint *, int k)); |
int _EXFUN(hi0bits,(__ULong)); |
int _EXFUN(lo0bits,(__ULong *)); |
_Bigint * _EXFUN(d2b,(struct _reent *p, double d, int *e, int *bits)); |
_Bigint * _EXFUN(lshift,(struct _reent *p, _Bigint *b, int k)); |
_Bigint * _EXFUN(diff,(struct _reent *p, _Bigint *a, _Bigint *b)); |
int _EXFUN(cmp,(_Bigint *a, _Bigint *b)); |
int _EXFUN(gethex,(struct _reent *p, _CONST char **sp, struct FPI *fpi, Long *exp, _Bigint **bp, int sign)); |
double _EXFUN(ratio,(_Bigint *a, _Bigint *b)); |
__ULong _EXFUN(any_on,(_Bigint *b, int k)); |
void _EXFUN(copybits,(__ULong *c, int n, _Bigint *b)); |
void _EXFUN(hexdig_init,(void)); |
#ifdef INFNAN_CHECK |
int _EXFUN(hexnan,(_CONST char **sp, struct FPI *fpi, __ULong *x0)); |
#endif |
#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(__Long) + 2*sizeof(int)) |
extern _CONST double tinytens[]; |
extern _CONST double bigtens[]; |
extern _CONST double tens[]; |
extern unsigned char hexdig[]; |
double _EXFUN(_mprec_log10,(int)); |
/programs/develop/libraries/newlib/stdlib/rand48.h |
---|
0,0 → 1,36 |
/* |
* Copyright (c) 1993 Martin Birgmeier |
* All rights reserved. |
* |
* You may redistribute unmodified or modified versions of this source |
* code provided that the above copyright notice and this and the |
* following conditions are retained. |
* |
* This software is provided ``as is'', and comes with no warranties |
* of any kind. I shall in no event be liable for anything that happens |
* to anyone/anything when using this software. |
*/ |
#ifndef _RAND48_H_ |
#define _RAND48_H_ |
#include <math.h> |
#include <stdlib.h> |
extern void _EXFUN(__dorand48,(struct _reent *r, unsigned short[3])); |
#define __rand48_seed _REENT_RAND48_SEED(r) |
#define __rand48_mult _REENT_RAND48_MULT(r) |
#define __rand48_add _REENT_RAND48_ADD(r) |
#if 0 |
/* following values are defined in <sys/reent.h> */ |
#define RAND48_SEED_0 (0x330e) |
#define RAND48_SEED_1 (0xabcd) |
#define RAND48_SEED_2 (0x1234) |
#define RAND48_MULT_0 (0xe66d) |
#define RAND48_MULT_1 (0xdeec) |
#define RAND48_MULT_2 (0x0005) |
#define RAND48_ADD (0x000b) |
#endif |
#endif /* _RAND48_H_ */ |
/programs/develop/libraries/newlib/stdlib/realloc.c |
---|
0,0 → 1,22 |
#ifdef MALLOC_PROVIDED |
int _dummy_calloc = 1; |
#else |
/* realloc.c -- a wrapper for realloc_r. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdlib.h> |
#include <malloc.h> |
#ifndef _REENT_ONLY |
_PTR |
_DEFUN (realloc, (ap, nbytes), |
_PTR ap _AND |
size_t nbytes) |
{ |
return _realloc_r (_REENT, ap, nbytes); |
} |
#endif |
#endif /* MALLOC_PROVIDED */ |
/programs/develop/libraries/newlib/stdlib/std.h |
---|
0,0 → 1,33 |
#include <stdlib.h> |
#include <stdio.h> |
#include <errno.h> |
#include <limits.h> |
#include <math.h> |
#ifndef CYGNUS_NEC |
#include <ctype.h> |
#endif |
#define Ise(c) ((c == 'e') || (c == 'E') || (c == 'd') || (c == 'D')) |
#define Isdigit(c) ((c <= '9') && (c >= '0')) |
#define Isspace(c) ((c == ' ') || (c == '\t') || (c=='\n') || (c=='\v') \ |
|| (c == '\r') || (c == '\f')) |
#define Issign(c) ((c == '-') || (c == '+')) |
#define Val(c) ((c - '0')) |
#define MAXE 308 |
#define MINE (-308) |
/* flags */ |
#define SIGN 0x01 |
#define ESIGN 0x02 |
#define DECP 0x04 |
#ifdef _HAVE_STDC |
int __ten_mul(double *acc, int digit); |
double __adjust(struct _reent *ptr, double *acc, int dexp, int sign); |
double __exp10(unsigned x); |
#else |
int __ten_mul(); |
double __adjust(); |
double __exp10(); |
#endif |
/programs/develop/libraries/newlib/stdlib/strtod.c |
---|
0,0 → 1,1187 |
/* |
FUNCTION |
<<strtod>>, <<strtof>>---string to double or float |
INDEX |
strtod |
INDEX |
_strtod_r |
INDEX |
strtof |
ANSI_SYNOPSIS |
#include <stdlib.h> |
double strtod(const char *<[str]>, char **<[tail]>); |
float strtof(const char *<[str]>, char **<[tail]>); |
double _strtod_r(void *<[reent]>, |
const char *<[str]>, char **<[tail]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
double strtod(<[str]>,<[tail]>) |
char *<[str]>; |
char **<[tail]>; |
float strtof(<[str]>,<[tail]>) |
char *<[str]>; |
char **<[tail]>; |
double _strtod_r(<[reent]>,<[str]>,<[tail]>) |
char *<[reent]>; |
char *<[str]>; |
char **<[tail]>; |
DESCRIPTION |
The function <<strtod>> parses the character string <[str]>, |
producing a substring which can be converted to a double |
value. The substring converted is the longest initial |
subsequence of <[str]>, beginning with the first |
non-whitespace character, that has one of these formats: |
.[+|-]<[digits]>[.[<[digits]>]][(e|E)[+|-]<[digits]>] |
.[+|-].<[digits]>[(e|E)[+|-]<[digits]>] |
.[+|-](i|I)(n|N)(f|F)[(i|I)(n|N)(i|I)(t|T)(y|Y)] |
.[+|-](n|N)(a|A)(n|N)[<(>[<[hexdigits]>]<)>] |
.[+|-]0(x|X)<[hexdigits]>[.[<[hexdigits]>]][(p|P)[+|-]<[digits]>] |
.[+|-]0(x|X).<[hexdigits]>[(p|P)[+|-]<[digits]>] |
The substring contains no characters if <[str]> is empty, consists |
entirely of whitespace, or if the first non-whitespace |
character is something other than <<+>>, <<->>, <<.>>, or a |
digit, and cannot be parsed as infinity or NaN. If the platform |
does not support NaN, then NaN is treated as an empty substring. |
If the substring is empty, no conversion is done, and |
the value of <[str]> is stored in <<*<[tail]>>>. Otherwise, |
the substring is converted, and a pointer to the final string |
(which will contain at least the terminating null character of |
<[str]>) is stored in <<*<[tail]>>>. If you want no |
assignment to <<*<[tail]>>>, pass a null pointer as <[tail]>. |
<<strtof>> is identical to <<strtod>> except for its return type. |
This implementation returns the nearest machine number to the |
input decimal string. Ties are broken by using the IEEE |
round-even rule. However, <<strtof>> is currently subject to |
double rounding errors. |
The alternate function <<_strtod_r>> is a reentrant version. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtod>> returns the converted substring value, if any. If |
no conversion could be performed, 0 is returned. If the |
correct value is out of the range of representable values, |
plus or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is |
stored in errno. If the correct value would cause underflow, 0 |
is returned and <<ERANGE>> is stored in errno. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 1998-2001 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to David M. Gay (dmg at acm dot org, |
* with " at " changed at "@" and " dot " changed to "."). */ |
/* Original file gdtoa-strtod.c Modified 06-21-2006 by Jeff Johnston to work within newlib. */ |
#include <_ansi.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <string.h> |
#include "mprec.h" |
#include "gdtoa.h" |
#include "gd_qnan.h" |
/* #ifndef NO_FENV_H */ |
/* #include <fenv.h> */ |
/* #endif */ |
#include "locale.h" |
#ifdef IEEE_Arith |
#ifndef NO_IEEE_Scale |
#define Avoid_Underflow |
#undef tinytens |
/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ |
/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ |
static _CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, |
9007199254740992.e-256 |
}; |
#endif |
#endif |
#ifdef Honor_FLT_ROUNDS |
#define Rounding rounding |
#undef Check_FLT_ROUNDS |
#define Check_FLT_ROUNDS |
#else |
#define Rounding Flt_Rounds |
#endif |
#ifndef NO_HEX_FP |
static void |
_DEFUN (ULtod, (L, bits, exp, k), |
__ULong *L _AND |
__ULong *bits _AND |
Long exp _AND |
int k) |
{ |
switch(k & STRTOG_Retmask) { |
case STRTOG_NoNumber: |
case STRTOG_Zero: |
L[0] = L[1] = 0; |
break; |
case STRTOG_Denormal: |
L[_1] = bits[0]; |
L[_0] = bits[1]; |
break; |
case STRTOG_Normal: |
case STRTOG_NaNbits: |
L[_1] = bits[0]; |
L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20); |
break; |
case STRTOG_Infinite: |
L[_0] = 0x7ff00000; |
L[_1] = 0; |
break; |
case STRTOG_NaN: |
L[_0] = 0x7fffffff; |
L[_1] = (__ULong)-1; |
} |
if (k & STRTOG_Neg) |
L[_0] |= 0x80000000L; |
} |
#endif /* !NO_HEX_FP */ |
#ifdef INFNAN_CHECK |
static int |
_DEFUN (match, (sp, t), |
_CONST char **sp _AND |
char *t) |
{ |
int c, d; |
_CONST char *s = *sp; |
while( (d = *t++) !=0) { |
if ((c = *++s) >= 'A' && c <= 'Z') |
c += 'a' - 'A'; |
if (c != d) |
return 0; |
} |
*sp = s + 1; |
return 1; |
} |
#endif /* INFNAN_CHECK */ |
double |
_DEFUN (_strtod_r, (ptr, s00, se), |
struct _reent *ptr _AND |
_CONST char *s00 _AND |
char **se) |
{ |
#ifdef Avoid_Underflow |
int scale; |
#endif |
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign, |
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; |
_CONST char *s, *s0, *s1; |
double aadj, adj; |
U aadj1, rv, rv0; |
Long L; |
__ULong y, z; |
_Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; |
#ifdef SET_INEXACT |
int inexact, oldinexact; |
#endif |
#ifdef Honor_FLT_ROUNDS |
int rounding; |
#endif |
delta = bs = bd = NULL; |
sign = nz0 = nz = decpt = 0; |
dval(rv) = 0.; |
for(s = s00;;s++) switch(*s) { |
case '-': |
sign = 1; |
/* no break */ |
case '+': |
if (*++s) |
goto break2; |
/* no break */ |
case 0: |
goto ret0; |
case '\t': |
case '\n': |
case '\v': |
case '\f': |
case '\r': |
case ' ': |
continue; |
default: |
goto break2; |
} |
break2: |
if (*s == '0') { |
#ifndef NO_HEX_FP |
{ |
static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; |
Long exp; |
__ULong bits[2]; |
switch(s[1]) { |
case 'x': |
case 'X': |
/* If the number is not hex, then the parse of |
0 is still valid. */ |
s00 = s + 1; |
{ |
#if defined(FE_DOWNWARD) && defined(FE_TONEAREST) && defined(FE_TOWARDZERO) && defined(FE_UPWARD) |
FPI fpi1 = fpi; |
switch(fegetround()) { |
case FE_TOWARDZERO: fpi1.rounding = 0; break; |
case FE_UPWARD: fpi1.rounding = 2; break; |
case FE_DOWNWARD: fpi1.rounding = 3; |
} |
#else |
#define fpi1 fpi |
#endif |
switch((i = gethex(ptr, &s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) { |
case STRTOG_NoNumber: |
s = s00; |
case STRTOG_Zero: |
break; |
default: |
if (bb) { |
copybits(bits, fpi.nbits, bb); |
Bfree(ptr,bb); |
} |
ULtod(rv.i, bits, exp, i); |
}} |
goto ret; |
} |
} |
#endif |
nz0 = 1; |
while(*++s == '0') ; |
if (!*s) |
goto ret; |
} |
s0 = s; |
y = z = 0; |
for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) |
if (nd < 9) |
y = 10*y + c - '0'; |
else if (nd < 16) |
z = 10*z + c - '0'; |
nd0 = nd; |
if (strncmp (s, _localeconv_r (ptr)->decimal_point, |
strlen (_localeconv_r (ptr)->decimal_point)) == 0) |
{ |
decpt = 1; |
c = *(s += strlen (_localeconv_r (ptr)->decimal_point)); |
if (!nd) { |
for(; c == '0'; c = *++s) |
nz++; |
if (c > '0' && c <= '9') { |
s0 = s; |
nf += nz; |
nz = 0; |
goto have_dig; |
} |
goto dig_done; |
} |
for(; c >= '0' && c <= '9'; c = *++s) { |
have_dig: |
nz++; |
if (c -= '0') { |
nf += nz; |
for(i = 1; i < nz; i++) |
if (nd++ < 9) |
y *= 10; |
else if (nd <= DBL_DIG + 1) |
z *= 10; |
if (nd++ < 9) |
y = 10*y + c; |
else if (nd <= DBL_DIG + 1) |
z = 10*z + c; |
nz = 0; |
} |
} |
} |
dig_done: |
e = 0; |
if (c == 'e' || c == 'E') { |
if (!nd && !nz && !nz0) { |
goto ret0; |
} |
s00 = s; |
esign = 0; |
switch(c = *++s) { |
case '-': |
esign = 1; |
case '+': |
c = *++s; |
} |
if (c >= '0' && c <= '9') { |
while(c == '0') |
c = *++s; |
if (c > '0' && c <= '9') { |
L = c - '0'; |
s1 = s; |
while((c = *++s) >= '0' && c <= '9') |
L = 10*L + c - '0'; |
if (s - s1 > 8 || L > 19999) |
/* Avoid confusion from exponents |
* so large that e might overflow. |
*/ |
e = 19999; /* safe for 16 bit ints */ |
else |
e = (int)L; |
if (esign) |
e = -e; |
} |
else |
e = 0; |
} |
else |
s = s00; |
} |
if (!nd) { |
if (!nz && !nz0) { |
#ifdef INFNAN_CHECK |
/* Check for Nan and Infinity */ |
__ULong bits[2]; |
static FPI fpinan = /* only 52 explicit bits */ |
{ 52, 1-1023-53+1, 2046-1023-53+1, 1, SI }; |
if (!decpt) |
switch(c) { |
case 'i': |
case 'I': |
if (match(&s,"nf")) { |
--s; |
if (!match(&s,"inity")) |
++s; |
dword0(rv) = 0x7ff00000; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
goto ret; |
} |
break; |
case 'n': |
case 'N': |
if (match(&s, "an")) { |
#ifndef No_Hex_NaN |
if (*s == '(' /*)*/ |
&& hexnan(&s, &fpinan, bits) |
== STRTOG_NaNbits) { |
dword0(rv) = 0x7ff00000 | bits[1]; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = bits[0]; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
else { |
#endif |
dword0(rv) = NAN_WORD0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = NAN_WORD1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#ifndef No_Hex_NaN |
} |
#endif |
goto ret; |
} |
} |
#endif /* INFNAN_CHECK */ |
ret0: |
s = s00; |
sign = 0; |
} |
goto ret; |
} |
e1 = e -= nf; |
/* Now we have nd0 digits, starting at s0, followed by a |
* decimal point, followed by nd-nd0 digits. The number we're |
* after is the integer represented by those digits times |
* 10**e */ |
if (!nd0) |
nd0 = nd; |
k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; |
dval(rv) = y; |
if (k > 9) { |
#ifdef SET_INEXACT |
if (k > DBL_DIG) |
oldinexact = get_inexact(); |
#endif |
dval(rv) = tens[k - 9] * dval(rv) + z; |
} |
bd0 = 0; |
if (nd <= DBL_DIG |
#ifndef RND_PRODQUOT |
#ifndef Honor_FLT_ROUNDS |
&& Flt_Rounds == 1 |
#endif |
#endif |
) { |
if (!e) |
goto ret; |
if (e > 0) { |
if (e <= Ten_pmax) { |
#ifdef VAX |
goto vax_ovfl_check; |
#else |
#ifdef Honor_FLT_ROUNDS |
/* round correctly FLT_ROUNDS = 2 or 3 */ |
if (sign) { |
dval(rv) = -dval(rv); |
sign = 0; |
} |
#endif |
/* rv = */ rounded_product(dval(rv), tens[e]); |
goto ret; |
#endif |
} |
i = DBL_DIG - nd; |
if (e <= Ten_pmax + i) { |
/* A fancier test would sometimes let us do |
* this for larger i values. |
*/ |
#ifdef Honor_FLT_ROUNDS |
/* round correctly FLT_ROUNDS = 2 or 3 */ |
if (sign) { |
dval(rv) = -dval(rv); |
sign = 0; |
} |
#endif |
e -= i; |
dval(rv) *= tens[i]; |
#ifdef VAX |
/* VAX exponent range is so narrow we must |
* worry about overflow here... |
*/ |
vax_ovfl_check: |
dword0(rv) -= P*Exp_msk1; |
/* rv = */ rounded_product(dval(rv), tens[e]); |
if ((dword0(rv) & Exp_mask) |
> Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) |
goto ovfl; |
dword0(rv) += P*Exp_msk1; |
#else |
/* rv = */ rounded_product(dval(rv), tens[e]); |
#endif |
goto ret; |
} |
} |
#ifndef Inaccurate_Divide |
else if (e >= -Ten_pmax) { |
#ifdef Honor_FLT_ROUNDS |
/* round correctly FLT_ROUNDS = 2 or 3 */ |
if (sign) { |
dval(rv) = -dval(rv); |
sign = 0; |
} |
#endif |
/* rv = */ rounded_quotient(dval(rv), tens[-e]); |
goto ret; |
} |
#endif |
} |
e1 += nd - k; |
#ifdef IEEE_Arith |
#ifdef SET_INEXACT |
inexact = 1; |
if (k <= DBL_DIG) |
oldinexact = get_inexact(); |
#endif |
#ifdef Avoid_Underflow |
scale = 0; |
#endif |
#ifdef Honor_FLT_ROUNDS |
if ((rounding = Flt_Rounds) >= 2) { |
if (sign) |
rounding = rounding == 2 ? 0 : 2; |
else |
if (rounding != 2) |
rounding = 0; |
} |
#endif |
#endif /*IEEE_Arith*/ |
/* Get starting approximation = rv * 10**e1 */ |
if (e1 > 0) { |
if ( (i = e1 & 15) !=0) |
dval(rv) *= tens[i]; |
if (e1 &= ~15) { |
if (e1 > DBL_MAX_10_EXP) { |
ovfl: |
#ifndef NO_ERRNO |
ptr->_errno = ERANGE; |
#endif |
/* Can't trust HUGE_VAL */ |
#ifdef IEEE_Arith |
#ifdef Honor_FLT_ROUNDS |
switch(rounding) { |
case 0: /* toward 0 */ |
case 3: /* toward -infinity */ |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
break; |
default: |
dword0(rv) = Exp_mask; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
#else /*Honor_FLT_ROUNDS*/ |
dword0(rv) = Exp_mask; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#endif /*Honor_FLT_ROUNDS*/ |
#ifdef SET_INEXACT |
/* set overflow bit */ |
dval(rv0) = 1e300; |
dval(rv0) *= dval(rv0); |
#endif |
#else /*IEEE_Arith*/ |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#endif /*IEEE_Arith*/ |
if (bd0) |
goto retfree; |
goto ret; |
} |
e1 >>= 4; |
for(j = 0; e1 > 1; j++, e1 >>= 1) |
if (e1 & 1) |
dval(rv) *= bigtens[j]; |
/* The last multiplication could overflow. */ |
dword0(rv) -= P*Exp_msk1; |
dval(rv) *= bigtens[j]; |
if ((z = dword0(rv) & Exp_mask) |
> Exp_msk1*(DBL_MAX_EXP+Bias-P)) |
goto ovfl; |
if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { |
/* set to largest number */ |
/* (Can't trust DBL_MAX) */ |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
else |
dword0(rv) += P*Exp_msk1; |
} |
} |
else if (e1 < 0) { |
e1 = -e1; |
if ( (i = e1 & 15) !=0) |
dval(rv) /= tens[i]; |
if (e1 >>= 4) { |
if (e1 >= 1 << n_bigtens) |
goto undfl; |
#ifdef Avoid_Underflow |
if (e1 & Scale_Bit) |
scale = 2*P; |
for(j = 0; e1 > 0; j++, e1 >>= 1) |
if (e1 & 1) |
dval(rv) *= tinytens[j]; |
if (scale && (j = 2*P + 1 - ((dword0(rv) & Exp_mask) |
>> Exp_shift)) > 0) { |
/* scaled rv is denormal; zap j low bits */ |
if (j >= 32) { |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
if (j >= 53) |
dword0(rv) = (P+2)*Exp_msk1; |
else |
dword0(rv) &= 0xffffffff << (j-32); |
} |
#ifndef _DOUBLE_IS_32BITS |
else |
dword1(rv) &= 0xffffffff << j; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
#else |
for(j = 0; e1 > 1; j++, e1 >>= 1) |
if (e1 & 1) |
dval(rv) *= tinytens[j]; |
/* The last multiplication could underflow. */ |
dval(rv0) = dval(rv); |
dval(rv) *= tinytens[j]; |
if (!dval(rv)) { |
dval(rv) = 2.*dval(rv0); |
dval(rv) *= tinytens[j]; |
#endif |
if (!dval(rv)) { |
undfl: |
dval(rv) = 0.; |
#ifndef NO_ERRNO |
ptr->_errno = ERANGE; |
#endif |
if (bd0) |
goto retfree; |
goto ret; |
} |
#ifndef Avoid_Underflow |
#ifndef _DOUBLE_IS_32BITS |
dword0(rv) = Tiny0; |
dword1(rv) = Tiny1; |
#else |
dword0(rv) = Tiny1; |
#endif /*_DOUBLE_IS_32BITS*/ |
/* The refinement below will clean |
* this approximation up. |
*/ |
} |
#endif |
} |
} |
/* Now the hard part -- adjusting rv to the correct value.*/ |
/* Put digits into bd: true value = bd * 10^e */ |
bd0 = s2b(ptr, s0, nd0, nd, y); |
for(;;) { |
bd = Balloc(ptr,bd0->_k); |
Bcopy(bd, bd0); |
bb = d2b(ptr,dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ |
bs = i2b(ptr,1); |
if (e >= 0) { |
bb2 = bb5 = 0; |
bd2 = bd5 = e; |
} |
else { |
bb2 = bb5 = -e; |
bd2 = bd5 = 0; |
} |
if (bbe >= 0) |
bb2 += bbe; |
else |
bd2 -= bbe; |
bs2 = bb2; |
#ifdef Honor_FLT_ROUNDS |
if (rounding != 1) |
bs2++; |
#endif |
#ifdef Avoid_Underflow |
j = bbe - scale; |
i = j + bbbits - 1; /* logb(rv) */ |
if (i < Emin) /* denormal */ |
j += P - Emin; |
else |
j = P + 1 - bbbits; |
#else /*Avoid_Underflow*/ |
#ifdef Sudden_Underflow |
#ifdef IBM |
j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); |
#else |
j = P + 1 - bbbits; |
#endif |
#else /*Sudden_Underflow*/ |
j = bbe; |
i = j + bbbits - 1; /* logb(rv) */ |
if (i < Emin) /* denormal */ |
j += P - Emin; |
else |
j = P + 1 - bbbits; |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
bb2 += j; |
bd2 += j; |
#ifdef Avoid_Underflow |
bd2 += scale; |
#endif |
i = bb2 < bd2 ? bb2 : bd2; |
if (i > bs2) |
i = bs2; |
if (i > 0) { |
bb2 -= i; |
bd2 -= i; |
bs2 -= i; |
} |
if (bb5 > 0) { |
bs = pow5mult(ptr, bs, bb5); |
bb1 = mult(ptr, bs, bb); |
Bfree(ptr, bb); |
bb = bb1; |
} |
if (bb2 > 0) |
bb = lshift(ptr, bb, bb2); |
if (bd5 > 0) |
bd = pow5mult(ptr, bd, bd5); |
if (bd2 > 0) |
bd = lshift(ptr, bd, bd2); |
if (bs2 > 0) |
bs = lshift(ptr, bs, bs2); |
delta = diff(ptr, bb, bd); |
dsign = delta->_sign; |
delta->_sign = 0; |
i = cmp(delta, bs); |
#ifdef Honor_FLT_ROUNDS |
if (rounding != 1) { |
if (i < 0) { |
/* Error is less than an ulp */ |
if (!delta->_x[0] && delta->_wds <= 1) { |
/* exact */ |
#ifdef SET_INEXACT |
inexact = 0; |
#endif |
break; |
} |
if (rounding) { |
if (dsign) { |
adj = 1.; |
goto apply_adj; |
} |
} |
else if (!dsign) { |
adj = -1.; |
if (!dword1(rv) |
&& !(dword0(rv) & Frac_mask)) { |
y = dword0(rv) & Exp_mask; |
#ifdef Avoid_Underflow |
if (!scale || y > 2*P*Exp_msk1) |
#else |
if (y) |
#endif |
{ |
delta = lshift(ptr, delta,Log2P); |
if (cmp(delta, bs) <= 0) |
adj = -0.5; |
} |
} |
apply_adj: |
#ifdef Avoid_Underflow |
if (scale && (y = dword0(rv) & Exp_mask) |
<= 2*P*Exp_msk1) |
dword0(adj) += (2*P+1)*Exp_msk1 - y; |
#else |
#ifdef Sudden_Underflow |
if ((dword0(rv) & Exp_mask) <= |
P*Exp_msk1) { |
dword0(rv) += P*Exp_msk1; |
dval(rv) += adj*ulp(dval(rv)); |
dword0(rv) -= P*Exp_msk1; |
} |
else |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
dval(rv) += adj*ulp(dval(rv)); |
} |
break; |
} |
adj = ratio(delta, bs); |
if (adj < 1.) |
adj = 1.; |
if (adj <= 0x7ffffffe) { |
/* adj = rounding ? ceil(adj) : floor(adj); */ |
y = adj; |
if (y != adj) { |
if (!((rounding>>1) ^ dsign)) |
y++; |
adj = y; |
} |
} |
#ifdef Avoid_Underflow |
if (scale && (y = dword0(rv) & Exp_mask) <= 2*P*Exp_msk1) |
dword0(adj) += (2*P+1)*Exp_msk1 - y; |
#else |
#ifdef Sudden_Underflow |
if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) { |
dword0(rv) += P*Exp_msk1; |
adj *= ulp(dval(rv)); |
if (dsign) |
dval(rv) += adj; |
else |
dval(rv) -= adj; |
dword0(rv) -= P*Exp_msk1; |
goto cont; |
} |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
adj *= ulp(dval(rv)); |
if (dsign) |
dval(rv) += adj; |
else |
dval(rv) -= adj; |
goto cont; |
} |
#endif /*Honor_FLT_ROUNDS*/ |
if (i < 0) { |
/* Error is less than half an ulp -- check for |
* special case of mantissa a power of two. |
*/ |
if (dsign || dword1(rv) || dword0(rv) & Bndry_mask |
#ifdef IEEE_Arith |
#ifdef Avoid_Underflow |
|| (dword0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1 |
#else |
|| (dword0(rv) & Exp_mask) <= Exp_msk1 |
#endif |
#endif |
) { |
#ifdef SET_INEXACT |
if (!delta->x[0] && delta->wds <= 1) |
inexact = 0; |
#endif |
break; |
} |
if (!delta->_x[0] && delta->_wds <= 1) { |
/* exact result */ |
#ifdef SET_INEXACT |
inexact = 0; |
#endif |
break; |
} |
delta = lshift(ptr,delta,Log2P); |
if (cmp(delta, bs) > 0) |
goto drop_down; |
break; |
} |
if (i == 0) { |
/* exactly half-way between */ |
if (dsign) { |
if ((dword0(rv) & Bndry_mask1) == Bndry_mask1 |
&& dword1(rv) == ( |
#ifdef Avoid_Underflow |
(scale && (y = dword0(rv) & Exp_mask) <= 2*P*Exp_msk1) |
? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : |
#endif |
0xffffffff)) { |
/*boundary case -- increment exponent*/ |
dword0(rv) = (dword0(rv) & Exp_mask) |
+ Exp_msk1 |
#ifdef IBM |
| Exp_msk1 >> 4 |
#endif |
; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#ifdef Avoid_Underflow |
dsign = 0; |
#endif |
break; |
} |
} |
else if (!(dword0(rv) & Bndry_mask) && !dword1(rv)) { |
drop_down: |
/* boundary case -- decrement exponent */ |
#ifdef Sudden_Underflow /*{{*/ |
L = dword0(rv) & Exp_mask; |
#ifdef IBM |
if (L < Exp_msk1) |
#else |
#ifdef Avoid_Underflow |
if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) |
#else |
if (L <= Exp_msk1) |
#endif /*Avoid_Underflow*/ |
#endif /*IBM*/ |
goto undfl; |
L -= Exp_msk1; |
#else /*Sudden_Underflow}{*/ |
#ifdef Avoid_Underflow |
if (scale) { |
L = dword0(rv) & Exp_mask; |
if (L <= (2*P+1)*Exp_msk1) { |
if (L > (P+2)*Exp_msk1) |
/* round even ==> */ |
/* accept rv */ |
break; |
/* rv = smallest denormal */ |
goto undfl; |
} |
} |
#endif /*Avoid_Underflow*/ |
L = (dword0(rv) & Exp_mask) - Exp_msk1; |
#endif /*Sudden_Underflow}*/ |
dword0(rv) = L | Bndry_mask1; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0xffffffff; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#ifdef IBM |
goto cont; |
#else |
break; |
#endif |
} |
#ifndef ROUND_BIASED |
if (!(dword1(rv) & LSB)) |
break; |
#endif |
if (dsign) |
dval(rv) += ulp(dval(rv)); |
#ifndef ROUND_BIASED |
else { |
dval(rv) -= ulp(dval(rv)); |
#ifndef Sudden_Underflow |
if (!dval(rv)) |
goto undfl; |
#endif |
} |
#ifdef Avoid_Underflow |
dsign = 1 - dsign; |
#endif |
#endif |
break; |
} |
if ((aadj = ratio(delta, bs)) <= 2.) { |
if (dsign) |
aadj = dval(aadj1) = 1.; |
else if (dword1(rv) || dword0(rv) & Bndry_mask) { |
#ifndef Sudden_Underflow |
if (dword1(rv) == Tiny1 && !dword0(rv)) |
goto undfl; |
#endif |
aadj = 1.; |
dval(aadj1) = -1.; |
} |
else { |
/* special case -- power of FLT_RADIX to be */ |
/* rounded down... */ |
if (aadj < 2./FLT_RADIX) |
aadj = 1./FLT_RADIX; |
else |
aadj *= 0.5; |
dval(aadj1) = -aadj; |
} |
} |
else { |
aadj *= 0.5; |
dval(aadj1) = dsign ? aadj : -aadj; |
#ifdef Check_FLT_ROUNDS |
switch(Rounding) { |
case 2: /* towards +infinity */ |
dval(aadj1) -= 0.5; |
break; |
case 0: /* towards 0 */ |
case 3: /* towards -infinity */ |
dval(aadj1) += 0.5; |
} |
#else |
if (Flt_Rounds == 0) |
dval(aadj1) += 0.5; |
#endif /*Check_FLT_ROUNDS*/ |
} |
y = dword0(rv) & Exp_mask; |
/* Check for overflow */ |
if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { |
dval(rv0) = dval(rv); |
dword0(rv) -= P*Exp_msk1; |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
if ((dword0(rv) & Exp_mask) >= |
Exp_msk1*(DBL_MAX_EXP+Bias-P)) { |
if (dword0(rv0) == Big0 && dword1(rv0) == Big1) |
goto ovfl; |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
goto cont; |
} |
else |
dword0(rv) += P*Exp_msk1; |
} |
else { |
#ifdef Avoid_Underflow |
if (scale && y <= 2*P*Exp_msk1) { |
if (aadj <= 0x7fffffff) { |
if ((z = aadj) <= 0) |
z = 1; |
aadj = z; |
dval(aadj1) = dsign ? aadj : -aadj; |
} |
dword0(aadj1) += (2*P+1)*Exp_msk1 - y; |
} |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
#else |
#ifdef Sudden_Underflow |
if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) { |
dval(rv0) = dval(rv); |
dword0(rv) += P*Exp_msk1; |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
#ifdef IBM |
if ((dword0(rv) & Exp_mask) < P*Exp_msk1) |
#else |
if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) |
#endif |
{ |
if (dword0(rv0) == Tiny0 |
&& dword1(rv0) == Tiny1) |
goto undfl; |
#ifndef _DOUBLE_IS_32BITS |
dword0(rv) = Tiny0; |
dword1(rv) = Tiny1; |
#else |
dword0(rv) = Tiny1; |
#endif /*_DOUBLE_IS_32BITS*/ |
goto cont; |
} |
else |
dword0(rv) -= P*Exp_msk1; |
} |
else { |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
} |
#else /*Sudden_Underflow*/ |
/* Compute adj so that the IEEE rounding rules will |
* correctly round rv + adj in some half-way cases. |
* If rv * ulp(rv) is denormalized (i.e., |
* y <= (P-1)*Exp_msk1), we must adjust aadj to avoid |
* trouble from bits lost to denormalization; |
* example: 1.2e-307 . |
*/ |
if (y <= (P-1)*Exp_msk1 && aadj > 1.) { |
dval(aadj1) = (double)(int)(aadj + 0.5); |
if (!dsign) |
dval(aadj1) = -dval(aadj1); |
} |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
} |
z = dword0(rv) & Exp_mask; |
#ifndef SET_INEXACT |
#ifdef Avoid_Underflow |
if (!scale) |
#endif |
if (y == z) { |
/* Can we stop now? */ |
L = (Long)aadj; |
aadj -= L; |
/* The tolerances below are conservative. */ |
if (dsign || dword1(rv) || dword0(rv) & Bndry_mask) { |
if (aadj < .4999999 || aadj > .5000001) |
break; |
} |
else if (aadj < .4999999/FLT_RADIX) |
break; |
} |
#endif |
cont: |
Bfree(ptr,bb); |
Bfree(ptr,bd); |
Bfree(ptr,bs); |
Bfree(ptr,delta); |
} |
#ifdef SET_INEXACT |
if (inexact) { |
if (!oldinexact) { |
dword0(rv0) = Exp_1 + (70 << Exp_shift); |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv0) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
dval(rv0) += 1.; |
} |
} |
else if (!oldinexact) |
clear_inexact(); |
#endif |
#ifdef Avoid_Underflow |
if (scale) { |
dword0(rv0) = Exp_1 - 2*P*Exp_msk1; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv0) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
dval(rv) *= dval(rv0); |
#ifndef NO_ERRNO |
/* try to avoid the bug of testing an 8087 register value */ |
if (dword0(rv) == 0 && dword1(rv) == 0) |
ptr->_errno = ERANGE; |
#endif |
} |
#endif /* Avoid_Underflow */ |
#ifdef SET_INEXACT |
if (inexact && !(dword0(rv) & Exp_mask)) { |
/* set underflow bit */ |
dval(rv0) = 1e-300; |
dval(rv0) *= dval(rv0); |
} |
#endif |
retfree: |
Bfree(ptr,bb); |
Bfree(ptr,bd); |
Bfree(ptr,bs); |
Bfree(ptr,bd0); |
Bfree(ptr,delta); |
ret: |
if (se) |
*se = (char *)s; |
return sign ? -dval(rv) : dval(rv); |
} |
#ifndef _REENT_ONLY |
double |
_DEFUN (strtod, (s00, se), |
_CONST char *s00 _AND char **se) |
{ |
return _strtod_r (_REENT, s00, se); |
} |
float |
_DEFUN (strtof, (s00, se), |
_CONST char *s00 _AND |
char **se) |
{ |
double retval = _strtod_r (_REENT, s00, se); |
if (isnan (retval)) |
return nanf (NULL); |
return (float)retval; |
} |
#endif |
/programs/develop/libraries/newlib/stdlib/strtol.c |
---|
0,0 → 1,226 |
/* |
FUNCTION |
<<strtol>>---string to long |
INDEX |
strtol |
INDEX |
_strtol_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
long strtol(const char *<[s]>, char **<[ptr]>,int <[base]>); |
long _strtol_r(void *<[reent]>, |
const char *<[s]>, char **<[ptr]>,int <[base]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
long strtol (<[s]>, <[ptr]>, <[base]>) |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
long _strtol_r (<[reent]>, <[s]>, <[ptr]>, <[base]>) |
char *<[reent]>; |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
DESCRIPTION |
The function <<strtol>> converts the string <<*<[s]>>> to |
a <<long>>. First, it breaks down the string into three parts: |
leading whitespace, which is ignored; a subject string consisting |
of characters resembling an integer in the radix specified by <[base]>; |
and a trailing portion consisting of zero or more unparseable characters, |
and always including the terminating null character. Then, it attempts |
to convert the subject string into a <<long>> and returns the |
result. |
If the value of <[base]> is 0, the subject string is expected to look |
like a normal C integer constant: an optional sign, a possible `<<0x>>' |
indicating a hexadecimal base, and a number. If <[base]> is between |
2 and 36, the expected form of the subject is a sequence of letters |
and digits representing an integer in the radix specified by <[base]>, |
with an optional plus or minus sign. The letters <<a>>--<<z>> (or, |
equivalently, <<A>>--<<Z>>) are used to signify values from 10 to 35; |
only letters whose ascribed values are less than <[base]> are |
permitted. If <[base]> is 16, a leading <<0x>> is permitted. |
The subject sequence is the longest initial sequence of the input |
string that has the expected form, starting with the first |
non-whitespace character. If the string is empty or consists entirely |
of whitespace, or if the first non-whitespace character is not a |
permissible letter or digit, the subject string is empty. |
If the subject string is acceptable, and the value of <[base]> is zero, |
<<strtol>> attempts to determine the radix from the input string. A |
string with a leading <<0x>> is treated as a hexadecimal value; a string with |
a leading 0 and no <<x>> is treated as octal; all other strings are |
treated as decimal. If <[base]> is between 2 and 36, it is used as the |
conversion radix, as described above. If the subject string begins with |
a minus sign, the value is negated. Finally, a pointer to the first |
character past the converted subject string is stored in <[ptr]>, if |
<[ptr]> is not <<NULL>>. |
If the subject string is empty (or not in acceptable form), no conversion |
is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is |
not <<NULL>>). |
The alternate function <<_strtol_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtol>> returns the converted value, if any. If no conversion was |
made, 0 is returned. |
<<strtol>> returns <<LONG_MAX>> or <<LONG_MIN>> if the magnitude of |
the converted value is too large, and sets <<errno>> to <<ERANGE>>. |
PORTABILITY |
<<strtol>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
/* |
* Convert a string to a long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
long |
_DEFUN (_strtol_r, (rptr, nptr, endptr, base), |
struct _reent *rptr _AND |
_CONST char *nptr _AND |
char **endptr _AND |
int base) |
{ |
register const unsigned char *s = (const unsigned char *)nptr; |
register unsigned long acc; |
register int c; |
register unsigned long cutoff; |
register int neg = 0, any, cutlim; |
/* |
* Skip white space and pick up leading +/- sign if any. |
* If base is 0, allow 0x for hex and 0 for octal, else |
* assume decimal; if base is already 16, allow 0x. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') { |
neg = 1; |
c = *s++; |
} else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) { |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
/* |
* Compute the cutoff value between legal numbers and illegal |
* numbers. That is the largest legal value, divided by the |
* base. An input number that is greater than this value, if |
* followed by a legal input character, is too big. One that |
* is equal to this value may be valid or not; the limit |
* between valid and invalid numbers is then based on the last |
* digit. For instance, if the range for longs is |
* [-2147483648..2147483647] and the input base is 10, |
* cutoff will be set to 214748364 and cutlim to either |
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated |
* a value > 214748364, or equal but the next digit is > 7 (or 8), |
* the number is too big, and we will return a range error. |
* |
* Set any if any `digits' consumed; make it negative to indicate |
* overflow. |
*/ |
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; |
cutlim = cutoff % (unsigned long)base; |
cutoff /= (unsigned long)base; |
for (acc = 0, any = 0;; c = *s++) { |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else { |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) { |
acc = neg ? LONG_MIN : LONG_MAX; |
rptr->_errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *) (any ? (char *)s - 1 : nptr); |
return (acc); |
} |
#ifndef _REENT_ONLY |
long |
_DEFUN (strtol, (s, ptr, base), |
_CONST char *s _AND |
char **ptr _AND |
int base) |
{ |
return _strtol_r (_REENT, s, ptr, base); |
} |
#endif |
/programs/develop/libraries/newlib/stdlib/strtoul.c |
---|
0,0 → 1,206 |
/* |
FUNCTION |
<<strtoul>>---string to unsigned long |
INDEX |
strtoul |
INDEX |
_strtoul_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
unsigned long strtoul(const char *<[s]>, char **<[ptr]>, |
int <[base]>); |
unsigned long _strtoul_r(void *<[reent]>, const char *<[s]>, |
char **<[ptr]>, int <[base]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
unsigned long strtoul(<[s]>, <[ptr]>, <[base]>) |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
unsigned long _strtoul_r(<[reent]>, <[s]>, <[ptr]>, <[base]>) |
char *<[reent]>; |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
DESCRIPTION |
The function <<strtoul>> converts the string <<*<[s]>>> to |
an <<unsigned long>>. First, it breaks down the string into three parts: |
leading whitespace, which is ignored; a subject string consisting |
of the digits meaningful in the radix specified by <[base]> |
(for example, <<0>> through <<7>> if the value of <[base]> is 8); |
and a trailing portion consisting of one or more unparseable characters, |
which always includes the terminating null character. Then, it attempts |
to convert the subject string into an unsigned long integer, and returns the |
result. |
If the value of <[base]> is zero, the subject string is expected to look |
like a normal C integer constant (save that no optional sign is permitted): |
a possible <<0x>> indicating hexadecimal radix, and a number. |
If <[base]> is between 2 and 36, the expected form of the subject is a |
sequence of digits (which may include letters, depending on the |
base) representing an integer in the radix specified by <[base]>. |
The letters <<a>>--<<z>> (or <<A>>--<<Z>>) are used as digits valued from |
10 to 35. If <[base]> is 16, a leading <<0x>> is permitted. |
The subject sequence is the longest initial sequence of the input |
string that has the expected form, starting with the first |
non-whitespace character. If the string is empty or consists entirely |
of whitespace, or if the first non-whitespace character is not a |
permissible digit, the subject string is empty. |
If the subject string is acceptable, and the value of <[base]> is zero, |
<<strtoul>> attempts to determine the radix from the input string. A |
string with a leading <<0x>> is treated as a hexadecimal value; a string with |
a leading <<0>> and no <<x>> is treated as octal; all other strings are |
treated as decimal. If <[base]> is between 2 and 36, it is used as the |
conversion radix, as described above. Finally, a pointer to the first |
character past the converted subject string is stored in <[ptr]>, if |
<[ptr]> is not <<NULL>>. |
If the subject string is empty (that is, if <<*>><[s]> does not start |
with a substring in acceptable form), no conversion |
is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is |
not <<NULL>>). |
The alternate function <<_strtoul_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtoul>> returns the converted value, if any. If no conversion was |
made, <<0>> is returned. |
<<strtoul>> returns <<ULONG_MAX>> if the magnitude of the converted |
value is too large, and sets <<errno>> to <<ERANGE>>. |
PORTABILITY |
<<strtoul>> is ANSI. |
<<strtoul>> requires no supporting OS subroutines. |
*/ |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
/* |
* Convert a string to an unsigned long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
unsigned long |
_DEFUN (_strtoul_r, (rptr, nptr, endptr, base), |
struct _reent *rptr _AND |
_CONST char *nptr _AND |
char **endptr _AND |
int base) |
{ |
register const unsigned char *s = (const unsigned char *)nptr; |
register unsigned long acc; |
register int c; |
register unsigned long cutoff; |
register int neg = 0, any, cutlim; |
/* |
* See strtol for comments as to the logic used. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') { |
neg = 1; |
c = *s++; |
} else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) { |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; |
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; |
for (acc = 0, any = 0;; c = *s++) { |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else { |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) { |
acc = ULONG_MAX; |
rptr->_errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *) (any ? (char *)s - 1 : nptr); |
return (acc); |
} |
#ifndef _REENT_ONLY |
unsigned long |
_DEFUN (strtoul, (s, ptr, base), |
_CONST char *s _AND |
char **ptr _AND |
int base) |
{ |
return _strtoul_r (_REENT, s, ptr, base); |
} |
#endif |
/programs/develop/libraries/newlib/stdlib/wcrtomb.c |
---|
0,0 → 1,78 |
#include <reent.h> |
#include <newlib.h> |
#include <wchar.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
size_t |
_DEFUN (_wcrtomb_r, (ptr, s, wc, ps), |
struct _reent *ptr _AND |
char *s _AND |
wchar_t wc _AND |
mbstate_t *ps) |
{ |
int retval = 0; |
char buf[10]; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(ptr); |
ps = &(_REENT_WCRTOMB_STATE(ptr)); |
} |
#endif |
if (s == NULL) |
retval = __wctomb (ptr, buf, L'\0', __locale_charset (), ps); |
else |
retval = __wctomb (ptr, s, wc, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
ptr->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
} |
#ifndef _REENT_ONLY |
size_t |
_DEFUN (wcrtomb, (s, wc, ps), |
char *s _AND |
wchar_t wc _AND |
mbstate_t *ps) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
return _wcrtomb_r (_REENT, s, wc, ps); |
#else |
int retval = 0; |
char buf[10]; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(_REENT); |
ps = &(_REENT_WCRTOMB_STATE(_REENT)); |
} |
#endif |
if (s == NULL) |
retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps); |
else |
retval = __wctomb (_REENT, s, wc, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
_REENT->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/stdlib/wctomb_r.c |
---|
0,0 → 1,376 |
#include <errno.h> |
#include <stdlib.h> |
#include <string.h> |
#include <wchar.h> |
#include <locale.h> |
#include "mbctype.h" |
#include "local.h" |
int (*__wctomb) (struct _reent *, char *, wchar_t, const char *charset, |
mbstate_t *) |
#ifdef __CYGWIN__ |
/* Cygwin starts up in UTF-8 mode. */ |
= __utf8_wctomb; |
#else |
= __ascii_wctomb; |
#endif |
int |
_DEFUN (_wctomb_r, (r, s, wchar, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
mbstate_t *state) |
{ |
return __wctomb (r, s, _wchar, __locale_charset (), state); |
} |
int |
_DEFUN (__ascii_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
/* Avoids compiler warnings about comparisons that are always false |
due to limited range when sizeof(wchar_t) is 2 but sizeof(wint_t) |
is 4, as is the case on cygwin. */ |
wint_t wchar = _wchar; |
if (s == NULL) |
return 0; |
#ifdef __CYGWIN__ |
if ((size_t)wchar >= 0x80) |
#else |
if ((size_t)wchar >= 0x100) |
#endif |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
*s = (char) wchar; |
return 1; |
} |
#ifdef _MB_CAPABLE |
/* for some conversions, we use the __count field as a place to store a state value */ |
#define __state __count |
int |
_DEFUN (__utf8_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
int ret = 0; |
if (s == NULL) |
return 0; /* UTF-8 encoding is not state-dependent */ |
if (sizeof (wchar_t) == 2 && state->__count == -4 |
&& (wchar < 0xdc00 || wchar >= 0xdfff)) |
{ |
/* There's a leftover lone high surrogate. Write out the CESU-8 value |
of the surrogate and proceed to convert the given character. Note |
to return extra 3 bytes. */ |
wchar_t tmp; |
tmp = (state->__value.__wchb[0] << 16 | state->__value.__wchb[1] << 8) |
- 0x10000 >> 10 | 0xd80d; |
*s++ = 0xe0 | ((tmp & 0xf000) >> 12); |
*s++ = 0x80 | ((tmp & 0xfc0) >> 6); |
*s++ = 0x80 | (tmp & 0x3f); |
state->__count = 0; |
ret = 3; |
} |
if (wchar <= 0x7f) |
{ |
*s = wchar; |
return ret + 1; |
} |
if (wchar >= 0x80 && wchar <= 0x7ff) |
{ |
*s++ = 0xc0 | ((wchar & 0x7c0) >> 6); |
*s = 0x80 | (wchar & 0x3f); |
return ret + 2; |
} |
if (wchar >= 0x800 && wchar <= 0xffff) |
{ |
/* No UTF-16 surrogate handling in UCS-4 */ |
if (sizeof (wchar_t) == 2 && wchar >= 0xd800 && wchar <= 0xdfff) |
{ |
wint_t tmp; |
if (wchar <= 0xdbff) |
{ |
/* First half of a surrogate pair. Store the state and |
return ret + 0. */ |
tmp = ((wchar & 0x3ff) << 10) + 0x10000; |
state->__value.__wchb[0] = (tmp >> 16) & 0xff; |
state->__value.__wchb[1] = (tmp >> 8) & 0xff; |
state->__count = -4; |
*s = (0xf0 | ((tmp & 0x1c0000) >> 18)); |
return ret; |
} |
if (state->__count == -4) |
{ |
/* Second half of a surrogate pair. Reconstruct the full |
Unicode value and return the trailing three bytes of the |
UTF-8 character. */ |
tmp = (state->__value.__wchb[0] << 16) |
| (state->__value.__wchb[1] << 8) |
| (wchar & 0x3ff); |
state->__count = 0; |
*s++ = 0xf0 | ((tmp & 0x1c0000) >> 18); |
*s++ = 0x80 | ((tmp & 0x3f000) >> 12); |
*s++ = 0x80 | ((tmp & 0xfc0) >> 6); |
*s = 0x80 | (tmp & 0x3f); |
return 4; |
} |
/* Otherwise translate into CESU-8 value. */ |
} |
*s++ = 0xe0 | ((wchar & 0xf000) >> 12); |
*s++ = 0x80 | ((wchar & 0xfc0) >> 6); |
*s = 0x80 | (wchar & 0x3f); |
return ret + 3; |
} |
if (wchar >= 0x10000 && wchar <= 0x10ffff) |
{ |
*s++ = 0xf0 | ((wchar & 0x1c0000) >> 18); |
*s++ = 0x80 | ((wchar & 0x3f000) >> 12); |
*s++ = 0x80 | ((wchar & 0xfc0) >> 6); |
*s = 0x80 | (wchar & 0x3f); |
return 4; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
/* Cygwin defines its own doublebyte charset conversion functions |
because the underlying OS requires wchar_t == UTF-16. */ |
#ifndef __CYGWIN__ |
int |
_DEFUN (__sjis_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
unsigned char char2 = (unsigned char)wchar; |
unsigned char char1 = (unsigned char)(wchar >> 8); |
if (s == NULL) |
return 0; /* not state-dependent */ |
if (char1 != 0x00) |
{ |
/* first byte is non-zero..validate multi-byte char */ |
if (_issjis1(char1) && _issjis2(char2)) |
{ |
*s++ = (char)char1; |
*s = (char)char2; |
return 2; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*s = (char) wchar; |
return 1; |
} |
int |
_DEFUN (__eucjp_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
unsigned char char2 = (unsigned char)wchar; |
unsigned char char1 = (unsigned char)(wchar >> 8); |
if (s == NULL) |
return 0; /* not state-dependent */ |
if (char1 != 0x00) |
{ |
/* first byte is non-zero..validate multi-byte char */ |
if (_iseucjp1 (char1) && _iseucjp2 (char2)) |
{ |
*s++ = (char)char1; |
*s = (char)char2; |
return 2; |
} |
else if (_iseucjp2 (char1) && _iseucjp2 (char2 | 0x80)) |
{ |
*s++ = (char)0x8f; |
*s++ = (char)char1; |
*s = (char)(char2 | 0x80); |
return 3; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*s = (char) wchar; |
return 1; |
} |
int |
_DEFUN (__jis_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
int cnt = 0; |
unsigned char char2 = (unsigned char)wchar; |
unsigned char char1 = (unsigned char)(wchar >> 8); |
if (s == NULL) |
return 1; /* state-dependent */ |
if (char1 != 0x00) |
{ |
/* first byte is non-zero..validate multi-byte char */ |
if (_isjis (char1) && _isjis (char2)) |
{ |
if (state->__state == 0) |
{ |
/* must switch from ASCII to JIS state */ |
state->__state = 1; |
*s++ = ESC_CHAR; |
*s++ = '$'; |
*s++ = 'B'; |
cnt = 3; |
} |
*s++ = (char)char1; |
*s = (char)char2; |
return cnt + 2; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
if (state->__state != 0) |
{ |
/* must switch from JIS to ASCII state */ |
state->__state = 0; |
*s++ = ESC_CHAR; |
*s++ = '('; |
*s++ = 'B'; |
cnt = 3; |
} |
*s = (char)char2; |
return cnt + 1; |
} |
#endif /* !__CYGWIN__ */ |
#ifdef _MB_EXTENDED_CHARSETS_ISO |
int |
_DEFUN (__iso_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
if (s == NULL) |
return 0; |
/* wchars <= 0x9f translate to all ISO charsets directly. */ |
if (wchar >= 0xa0) |
{ |
int iso_idx = __iso_8859_index (charset + 9); |
if (iso_idx >= 0) |
{ |
unsigned char mb; |
if (s == NULL) |
return 0; |
for (mb = 0; mb < 0x60; ++mb) |
if (__iso_8859_conv[iso_idx][mb] == wchar) |
{ |
*s = (char) (mb + 0xa0); |
return 1; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
} |
if ((size_t)wchar >= 0x100) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
*s = (char) wchar; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_ISO */ |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
int |
_DEFUN (__cp_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
if (s == NULL) |
return 0; |
if (wchar >= 0x80) |
{ |
int cp_idx = __cp_index (charset + 2); |
if (cp_idx >= 0) |
{ |
unsigned char mb; |
if (s == NULL) |
return 0; |
for (mb = 0; mb < 0x80; ++mb) |
if (__cp_conv[cp_idx][mb] == wchar) |
{ |
*s = (char) (mb + 0x80); |
return 1; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
} |
if ((size_t)wchar >= 0x100) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
*s = (char) wchar; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
#endif /* _MB_CAPABLE */ |
/programs/develop/libraries/newlib/stdlib |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/string/local.h |
---|
0,0 → 1,9 |
#include <_ansi.h> |
#include <../ctype/local.h> |
/* internal function to compute width of wide char. */ |
int _EXFUN (__wcwidth, (wint_t)); |
/* Defined in locale/locale.c. Returns a value != 0 if the current |
language is assumed to use CJK fonts. */ |
int __locale_cjk_lang (); |
/programs/develop/libraries/newlib/string/memchr.c |
---|
0,0 → 1,134 |
/* |
FUNCTION |
<<memchr>>---find character in memory |
INDEX |
memchr |
ANSI_SYNOPSIS |
#include <string.h> |
void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memchr(<[src]>, <[c]>, <[length]>) |
void *<[src]>; |
void *<[c]>; |
size_t <[length]>; |
DESCRIPTION |
This function searches memory starting at <<*<[src]>>> for the |
character <[c]>. The search only ends with the first |
occurrence of <[c]>, or after <[length]> characters; in |
particular, <<NUL>> does not terminate the search. |
RETURNS |
If the character <[c]> is found within <[length]> characters |
of <<*<[src]>>>, a pointer to the character is returned. If |
<[c]> is not found, then <<NULL>> is returned. |
PORTABILITY |
<<memchr>> is ANSI C. |
<<memchr>> requires no supporting OS subroutines. |
QUICKREF |
memchr ansi pure |
*/ |
#include <_ansi.h> |
#include <string.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X) ((long)X & (sizeof (long) - 1)) |
/* How many bytes are loaded each iteration of the word copy loop. */ |
#define LBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the bytewise iterator. */ |
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
/* DETECTCHAR returns nonzero if (long)X contains the byte used |
to fill (long)MASK. */ |
#define DETECTCHAR(X,MASK) (DETECTNULL(X ^ MASK)) |
_PTR |
_DEFUN (memchr, (src_void, c, length), |
_CONST _PTR src_void _AND |
int c _AND |
size_t length) |
{ |
_CONST unsigned char *src = (_CONST unsigned char *) src_void; |
unsigned char d = c; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
unsigned long *asrc; |
unsigned long mask; |
int i; |
while (UNALIGNED (src)) |
{ |
if (!length--) |
return NULL; |
if (*src == d) |
return (void *) src; |
src++; |
} |
if (!TOO_SMALL (length)) |
{ |
/* If we get this far, we know that length is large and src is |
word-aligned. */ |
/* The fast code reads the source one word at a time and only |
performs the bytewise search on word-sized segments if they |
contain the search character, which is detected by XORing |
the word-sized segment with a word-sized block of the search |
character and then detecting for the presence of NUL in the |
result. */ |
asrc = (unsigned long *) src; |
mask = d << 8 | d; |
mask = mask << 16 | mask; |
for (i = 32; i < LBLOCKSIZE * 8; i <<= 1) |
mask = (mask << i) | mask; |
while (length >= LBLOCKSIZE) |
{ |
if (DETECTCHAR (*asrc, mask)) |
break; |
length -= LBLOCKSIZE; |
asrc++; |
} |
/* If there are fewer than LBLOCKSIZE characters left, |
then we resort to the bytewise loop. */ |
src = (unsigned char *) asrc; |
} |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (length--) |
{ |
if (*src == d) |
return (void *) src; |
src++; |
} |
return NULL; |
} |
/programs/develop/libraries/newlib/string/memcmp.c |
---|
0,0 → 1,113 |
/* |
FUNCTION |
<<memcmp>>---compare two memory areas |
INDEX |
memcmp |
ANSI_SYNOPSIS |
#include <string.h> |
int memcmp(const void *<[s1]>, const void *<[s2]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int memcmp(<[s1]>, <[s2]>, <[n]>) |
void *<[s1]>; |
void *<[s2]>; |
size_t <[n]>; |
DESCRIPTION |
This function compares not more than <[n]> characters of the |
object pointed to by <[s1]> with the object pointed to by <[s2]>. |
RETURNS |
The function returns an integer greater than, equal to or |
less than zero according to whether the object pointed to by |
<[s1]> is greater than, equal to or less than the object |
pointed to by <[s2]>. |
PORTABILITY |
<<memcmp>> is ANSI C. |
<<memcmp>> requires no supporting OS subroutines. |
QUICKREF |
memcmp ansi pure |
*/ |
#include <string.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* How many bytes are copied each iteration of the word copy loop. */ |
#define LBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the byte copier. */ |
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) |
int |
_DEFUN (memcmp, (m1, m2, n), |
_CONST _PTR m1 _AND |
_CONST _PTR m2 _AND |
size_t n) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
unsigned char *s1 = (unsigned char *) m1; |
unsigned char *s2 = (unsigned char *) m2; |
while (n--) |
{ |
if (*s1 != *s2) |
{ |
return *s1 - *s2; |
} |
s1++; |
s2++; |
} |
return 0; |
#else |
unsigned char *s1 = (unsigned char *) m1; |
unsigned char *s2 = (unsigned char *) m2; |
unsigned long *a1; |
unsigned long *a2; |
/* If the size is too small, or either pointer is unaligned, |
then we punt to the byte compare loop. Hopefully this will |
not turn up in inner loops. */ |
if (!TOO_SMALL(n) && !UNALIGNED(s1,s2)) |
{ |
/* Otherwise, load and compare the blocks of memory one |
word at a time. */ |
a1 = (unsigned long*) s1; |
a2 = (unsigned long*) s2; |
while (n >= LBLOCKSIZE) |
{ |
if (*a1 != *a2) |
break; |
a1++; |
a2++; |
n -= LBLOCKSIZE; |
} |
/* check m mod LBLOCKSIZE remaining characters */ |
s1 = (unsigned char*)a1; |
s2 = (unsigned char*)a2; |
} |
while (n--) |
{ |
if (*s1 != *s2) |
return *s1 - *s2; |
s1++; |
s2++; |
} |
return 0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/programs/develop/libraries/newlib/string/memcpy.c |
---|
0,0 → 1,110 |
/* |
FUNCTION |
<<memcpy>>---copy memory regions |
ANSI_SYNOPSIS |
#include <string.h> |
void* memcpy(void *<[out]>, const void *<[in]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memcpy(<[out]>, <[in]>, <[n]> |
void *<[out]>; |
void *<[in]>; |
size_t <[n]>; |
DESCRIPTION |
This function copies <[n]> bytes from the memory region |
pointed to by <[in]> to the memory region pointed to by |
<[out]>. |
If the regions overlap, the behavior is undefined. |
RETURNS |
<<memcpy>> returns a pointer to the first byte of the <[out]> |
region. |
PORTABILITY |
<<memcpy>> is ANSI C. |
<<memcpy>> requires no supporting OS subroutines. |
QUICKREF |
memcpy ansi pure |
*/ |
#include <_ansi.h> |
#include <string.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* How many bytes are copied each iteration of the 4X unrolled loop. */ |
#define BIGBLOCKSIZE (sizeof (long) << 2) |
/* How many bytes are copied each iteration of the word copy loop. */ |
#define LITTLEBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the byte copier. */ |
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) |
_PTR |
_DEFUN (memcpy, (dst0, src0, len0), |
_PTR dst0 _AND |
_CONST _PTR src0 _AND |
size_t len0) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *dst = (char *) dst0; |
char *src = (char *) src0; |
_PTR save = dst0; |
while (len0--) |
{ |
*dst++ = *src++; |
} |
return save; |
#else |
char *dst = dst0; |
_CONST char *src = src0; |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If the size is small, or either SRC or DST is unaligned, |
then punt into the byte copy loop. This should be rare. */ |
if (!TOO_SMALL(len0) && !UNALIGNED (src, dst)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* Copy 4X long words at a time if possible. */ |
while (len0 >= BIGBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
len0 -= BIGBLOCKSIZE; |
} |
/* Copy one long word at a time if possible. */ |
while (len0 >= LITTLEBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
len0 -= LITTLEBLOCKSIZE; |
} |
/* Pick up any residual with a byte copier. */ |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while (len0--) |
*dst++ = *src++; |
return dst0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/programs/develop/libraries/newlib/string/memmove.c |
---|
0,0 → 1,142 |
/* |
FUNCTION |
<<memmove>>---move possibly overlapping memory |
INDEX |
memmove |
ANSI_SYNOPSIS |
#include <string.h> |
void *memmove(void *<[dst]>, const void *<[src]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memmove(<[dst]>, <[src]>, <[length]>) |
void *<[dst]>; |
void *<[src]>; |
size_t <[length]>; |
DESCRIPTION |
This function moves <[length]> characters from the block of |
memory starting at <<*<[src]>>> to the memory starting at |
<<*<[dst]>>>. <<memmove>> reproduces the characters correctly |
at <<*<[dst]>>> even if the two areas overlap. |
RETURNS |
The function returns <[dst]> as passed. |
PORTABILITY |
<<memmove>> is ANSI C. |
<<memmove>> requires no supporting OS subroutines. |
QUICKREF |
memmove ansi pure |
*/ |
#include <string.h> |
#include <_ansi.h> |
#include <stddef.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* How many bytes are copied each iteration of the 4X unrolled loop. */ |
#define BIGBLOCKSIZE (sizeof (long) << 2) |
/* How many bytes are copied each iteration of the word copy loop. */ |
#define LITTLEBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the byte copier. */ |
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) |
/*SUPPRESS 20*/ |
_PTR |
_DEFUN (memmove, (dst_void, src_void, length), |
_PTR dst_void _AND |
_CONST _PTR src_void _AND |
size_t length) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *dst = dst_void; |
_CONST char *src = src_void; |
if (src < dst && dst < src + length) |
{ |
/* Have to copy backwards */ |
src += length; |
dst += length; |
while (length--) |
{ |
*--dst = *--src; |
} |
} |
else |
{ |
while (length--) |
{ |
*dst++ = *src++; |
} |
} |
return dst_void; |
#else |
char *dst = dst_void; |
_CONST char *src = src_void; |
long *aligned_dst; |
_CONST long *aligned_src; |
if (src < dst && dst < src + length) |
{ |
/* Destructive overlap...have to copy backwards */ |
src += length; |
dst += length; |
while (length--) |
{ |
*--dst = *--src; |
} |
} |
else |
{ |
/* Use optimizing algorithm for a non-destructive copy to closely |
match memcpy. If the size is small or either SRC or DST is unaligned, |
then punt into the byte copy loop. This should be rare. */ |
if (!TOO_SMALL(length) && !UNALIGNED (src, dst)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* Copy 4X long words at a time if possible. */ |
while (length >= BIGBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
length -= BIGBLOCKSIZE; |
} |
/* Copy one long word at a time if possible. */ |
while (length >= LITTLEBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
length -= LITTLEBLOCKSIZE; |
} |
/* Pick up any residual with a byte copier. */ |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while (length--) |
{ |
*dst++ = *src++; |
} |
} |
return dst_void; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/programs/develop/libraries/newlib/string/memset.c |
---|
0,0 → 1,102 |
/* |
FUNCTION |
<<memset>>---set an area of memory |
INDEX |
memset |
ANSI_SYNOPSIS |
#include <string.h> |
void *memset(void *<[dst]>, int <[c]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memset(<[dst]>, <[c]>, <[length]>) |
void *<[dst]>; |
int <[c]>; |
size_t <[length]>; |
DESCRIPTION |
This function converts the argument <[c]> into an unsigned |
char and fills the first <[length]> characters of the array |
pointed to by <[dst]> to the value. |
RETURNS |
<<memset>> returns the value of <[dst]>. |
PORTABILITY |
<<memset>> is ANSI C. |
<<memset>> requires no supporting OS subroutines. |
QUICKREF |
memset ansi pure |
*/ |
#include <string.h> |
#define LBLOCKSIZE (sizeof(long)) |
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1)) |
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) |
_PTR |
_DEFUN (memset, (m, c, n), |
_PTR m _AND |
int c _AND |
size_t n) |
{ |
char *s = (char *) m; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
int i; |
unsigned long buffer; |
unsigned long *aligned_addr; |
unsigned int d = c & 0xff; /* To avoid sign extension, copy C to an |
unsigned variable. */ |
while (UNALIGNED (s)) |
{ |
if (n--) |
*s++ = (char) c; |
else |
return m; |
} |
if (!TOO_SMALL (n)) |
{ |
/* If we get this far, we know that n is large and s is word-aligned. */ |
aligned_addr = (unsigned long *) s; |
/* Store D into each char sized location in BUFFER so that |
we can set large blocks quickly. */ |
buffer = (d << 8) | d; |
buffer |= (buffer << 16); |
for (i = 32; i < LBLOCKSIZE * 8; i <<= 1) |
buffer = (buffer << i) | buffer; |
/* Unroll the loop. */ |
while (n >= LBLOCKSIZE*4) |
{ |
*aligned_addr++ = buffer; |
*aligned_addr++ = buffer; |
*aligned_addr++ = buffer; |
*aligned_addr++ = buffer; |
n -= 4*LBLOCKSIZE; |
} |
while (n >= LBLOCKSIZE) |
{ |
*aligned_addr++ = buffer; |
n -= LBLOCKSIZE; |
} |
/* Pick up the remainder with a bytewise loop. */ |
s = (char*)aligned_addr; |
} |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (n--) |
*s++ = (char) c; |
return m; |
} |
/programs/develop/libraries/newlib/string/str-two-way.h |
---|
0,0 → 1,415 |
/* Byte-wise substring search, using the Two-Way algorithm. |
* Copyright (C) 2008, 2010 Eric Blake |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* Before including this file, you need to include <string.h>, and define: |
RESULT_TYPE A macro that expands to the return type. |
AVAILABLE(h, h_l, j, n_l) A macro that returns nonzero if there are |
at least N_L bytes left starting at |
H[J]. H is 'unsigned char *', H_L, J, |
and N_L are 'size_t'; H_L is an |
lvalue. For NUL-terminated searches, |
H_L can be modified each iteration to |
avoid having to compute the end of H |
up front. |
For case-insensitivity, you may optionally define: |
CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L |
characters of P1 and P2 are equal. |
CANON_ELEMENT(c) A macro that canonicalizes an element |
right after it has been fetched from |
one of the two strings. The argument |
is an 'unsigned char'; the result must |
be an 'unsigned char' as well. |
This file undefines the macros documented above, and defines |
LONG_NEEDLE_THRESHOLD. |
*/ |
#include <limits.h> |
#include <stdint.h> |
/* We use the Two-Way string matching algorithm, which guarantees |
linear complexity with constant space. Additionally, for long |
needles, we also use a bad character shift table similar to the |
Boyer-Moore algorithm to achieve improved (potentially sub-linear) |
performance. |
See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260 |
and http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm |
*/ |
/* Point at which computing a bad-byte shift table is likely to be |
worthwhile. Small needles should not compute a table, since it |
adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a |
speedup no greater than a factor of NEEDLE_LEN. The larger the |
needle, the better the potential performance gain. On the other |
hand, on non-POSIX systems with CHAR_BIT larger than eight, the |
memory required for the table is prohibitive. */ |
#if CHAR_BIT < 10 |
# define LONG_NEEDLE_THRESHOLD 32U |
#else |
# define LONG_NEEDLE_THRESHOLD SIZE_MAX |
#endif |
#define MAX(a, b) ((a < b) ? (b) : (a)) |
#ifndef CANON_ELEMENT |
# define CANON_ELEMENT(c) c |
#endif |
#ifndef CMP_FUNC |
# define CMP_FUNC memcmp |
#endif |
/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN. |
Return the index of the first byte in the right half, and set |
*PERIOD to the global period of the right half. |
The global period of a string is the smallest index (possibly its |
length) at which all remaining bytes in the string are repetitions |
of the prefix (the last repetition may be a subset of the prefix). |
When NEEDLE is factored into two halves, a local period is the |
length of the smallest word that shares a suffix with the left half |
and shares a prefix with the right half. All factorizations of a |
non-empty NEEDLE have a local period of at least 1 and no greater |
than NEEDLE_LEN. |
A critical factorization has the property that the local period |
equals the global period. All strings have at least one critical |
factorization with the left half smaller than the global period. |
Given an ordered alphabet, a critical factorization can be computed |
in linear time, with 2 * NEEDLE_LEN comparisons, by computing the |
larger of two ordered maximal suffixes. The ordered maximal |
suffixes are determined by lexicographic comparison of |
periodicity. */ |
static size_t |
critical_factorization (const unsigned char *needle, size_t needle_len, |
size_t *period) |
{ |
/* Index of last byte of left half, or SIZE_MAX. */ |
size_t max_suffix, max_suffix_rev; |
size_t j; /* Index into NEEDLE for current candidate suffix. */ |
size_t k; /* Offset into current period. */ |
size_t p; /* Intermediate period. */ |
unsigned char a, b; /* Current comparison bytes. */ |
/* Invariants: |
0 <= j < NEEDLE_LEN - 1 |
-1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) |
min(max_suffix, max_suffix_rev) < global period of NEEDLE |
1 <= p <= global period of NEEDLE |
p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] |
1 <= k <= p |
*/ |
/* Perform lexicographic search. */ |
max_suffix = SIZE_MAX; |
j = 0; |
k = p = 1; |
while (j + k < needle_len) |
{ |
a = CANON_ELEMENT (needle[j + k]); |
b = CANON_ELEMENT (needle[(size_t)(max_suffix + k)]); |
if (a < b) |
{ |
/* Suffix is smaller, period is entire prefix so far. */ |
j += k; |
k = 1; |
p = j - max_suffix; |
} |
else if (a == b) |
{ |
/* Advance through repetition of the current period. */ |
if (k != p) |
++k; |
else |
{ |
j += p; |
k = 1; |
} |
} |
else /* b < a */ |
{ |
/* Suffix is larger, start over from current location. */ |
max_suffix = j++; |
k = p = 1; |
} |
} |
*period = p; |
/* Perform reverse lexicographic search. */ |
max_suffix_rev = SIZE_MAX; |
j = 0; |
k = p = 1; |
while (j + k < needle_len) |
{ |
a = CANON_ELEMENT (needle[j + k]); |
b = CANON_ELEMENT (needle[max_suffix_rev + k]); |
if (b < a) |
{ |
/* Suffix is smaller, period is entire prefix so far. */ |
j += k; |
k = 1; |
p = j - max_suffix_rev; |
} |
else if (a == b) |
{ |
/* Advance through repetition of the current period. */ |
if (k != p) |
++k; |
else |
{ |
j += p; |
k = 1; |
} |
} |
else /* a < b */ |
{ |
/* Suffix is larger, start over from current location. */ |
max_suffix_rev = j++; |
k = p = 1; |
} |
} |
/* Choose the longer suffix. Return the first byte of the right |
half, rather than the last byte of the left half. */ |
if (max_suffix_rev + 1 < max_suffix + 1) |
return max_suffix + 1; |
*period = p; |
return max_suffix_rev + 1; |
} |
/* Return the first location of non-empty NEEDLE within HAYSTACK, or |
NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This |
method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD. |
Performance is guaranteed to be linear, with an initialization cost |
of 2 * NEEDLE_LEN comparisons. |
If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at |
most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. |
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * |
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ |
static RETURN_TYPE |
two_way_short_needle (const unsigned char *haystack, size_t haystack_len, |
const unsigned char *needle, size_t needle_len) |
{ |
size_t i; /* Index into current byte of NEEDLE. */ |
size_t j; /* Index into current window of HAYSTACK. */ |
size_t period; /* The period of the right half of needle. */ |
size_t suffix; /* The index of the right half of needle. */ |
/* Factor the needle into two halves, such that the left half is |
smaller than the global period, and the right half is |
periodic (with a period as large as NEEDLE_LEN - suffix). */ |
suffix = critical_factorization (needle, needle_len, &period); |
/* Perform the search. Each iteration compares the right half |
first. */ |
if (CMP_FUNC (needle, needle + period, suffix) == 0) |
{ |
/* Entire needle is periodic; a mismatch can only advance by the |
period, so use memory to avoid rescanning known occurrences |
of the period. */ |
size_t memory = 0; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Scan for matches in right half. */ |
i = MAX (suffix, memory); |
while (i < needle_len && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i + 1 < memory + 1) |
return (RETURN_TYPE) (haystack + j); |
/* No match, so remember how many repetitions of period |
on the right half were scanned. */ |
j += period; |
memory = needle_len - period; |
} |
else |
{ |
j += i - suffix + 1; |
memory = 0; |
} |
} |
} |
else |
{ |
/* The two halves of needle are distinct; no extra memory is |
required, and any mismatch results in a maximal shift. */ |
period = MAX (suffix, needle_len - suffix) + 1; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Scan for matches in right half. */ |
i = suffix; |
while (i < needle_len && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i == SIZE_MAX) |
return (RETURN_TYPE) (haystack + j); |
j += period; |
} |
else |
j += i - suffix + 1; |
} |
} |
return NULL; |
} |
/* Return the first location of non-empty NEEDLE within HAYSTACK, or |
NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This |
method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN. |
Performance is guaranteed to be linear, with an initialization cost |
of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations. |
If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at |
most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, |
and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. |
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * |
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and |
sublinear performance is not possible. */ |
static RETURN_TYPE |
two_way_long_needle (const unsigned char *haystack, size_t haystack_len, |
const unsigned char *needle, size_t needle_len) |
{ |
size_t i; /* Index into current byte of NEEDLE. */ |
size_t j; /* Index into current window of HAYSTACK. */ |
size_t period; /* The period of the right half of needle. */ |
size_t suffix; /* The index of the right half of needle. */ |
size_t shift_table[1U << CHAR_BIT]; /* See below. */ |
/* Factor the needle into two halves, such that the left half is |
smaller than the global period, and the right half is |
periodic (with a period as large as NEEDLE_LEN - suffix). */ |
suffix = critical_factorization (needle, needle_len, &period); |
/* Populate shift_table. For each possible byte value c, |
shift_table[c] is the distance from the last occurrence of c to |
the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. |
shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ |
for (i = 0; i < 1U << CHAR_BIT; i++) |
shift_table[i] = needle_len; |
for (i = 0; i < needle_len; i++) |
shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; |
/* Perform the search. Each iteration compares the right half |
first. */ |
if (CMP_FUNC (needle, needle + period, suffix) == 0) |
{ |
/* Entire needle is periodic; a mismatch can only advance by the |
period, so use memory to avoid rescanning known occurrences |
of the period. */ |
size_t memory = 0; |
size_t shift; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Check the last byte first; if it does not match, then |
shift to the next possible match location. */ |
shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
if (0 < shift) |
{ |
if (memory && shift < period) |
{ |
/* Since needle is periodic, but the last period has |
a byte out of place, there can be no match until |
after the mismatch. */ |
shift = needle_len - period; |
} |
memory = 0; |
j += shift; |
continue; |
} |
/* Scan for matches in right half. The last byte has |
already been matched, by virtue of the shift table. */ |
i = MAX (suffix, memory); |
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len - 1 <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i + 1 < memory + 1) |
return (RETURN_TYPE) (haystack + j); |
/* No match, so remember how many repetitions of period |
on the right half were scanned. */ |
j += period; |
memory = needle_len - period; |
} |
else |
{ |
j += i - suffix + 1; |
memory = 0; |
} |
} |
} |
else |
{ |
/* The two halves of needle are distinct; no extra memory is |
required, and any mismatch results in a maximal shift. */ |
size_t shift; |
period = MAX (suffix, needle_len - suffix) + 1; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Check the last byte first; if it does not match, then |
shift to the next possible match location. */ |
shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
if (0 < shift) |
{ |
j += shift; |
continue; |
} |
/* Scan for matches in right half. The last byte has |
already been matched, by virtue of the shift table. */ |
i = suffix; |
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len - 1 <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i == SIZE_MAX) |
return (RETURN_TYPE) (haystack + j); |
j += period; |
} |
else |
j += i - suffix + 1; |
} |
} |
return NULL; |
} |
#undef AVAILABLE |
#undef CANON_ELEMENT |
#undef CMP_FUNC |
#undef MAX |
#undef RETURN_TYPE |
/programs/develop/libraries/newlib/string/strcasecmp.c |
---|
0,0 → 1,60 |
/* |
FUNCTION |
<<strcasecmp>>---case-insensitive character string compare |
INDEX |
strcasecmp |
ANSI_SYNOPSIS |
#include <string.h> |
int strcasecmp(const char *<[a]>, const char *<[b]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strcasecmp(<[a]>, <[b]>) |
char *<[a]>; |
char *<[b]>; |
DESCRIPTION |
<<strcasecmp>> compares the string at <[a]> to |
the string at <[b]> in a case-insensitive manner. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after |
both are converted to lowercase), <<strcasecmp>> returns a |
number greater than zero. If the two strings match, |
<<strcasecmp>> returns zero. If <<*<[a]>>> sorts |
lexicographically before <<*<[b]>>>, <<strcasecmp>> returns a |
number less than zero. |
PORTABILITY |
<<strcasecmp>> is in the Berkeley Software Distribution. |
<<strcasecmp>> requires no supporting OS subroutines. It uses |
tolower() from elsewhere in this library. |
QUICKREF |
strcasecmp |
*/ |
#include <string.h> |
#include <ctype.h> |
int |
_DEFUN (strcasecmp, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
_CONST unsigned char *ucs1 = (_CONST unsigned char *) s1; |
_CONST unsigned char *ucs2 = (_CONST unsigned char *) s2; |
int d = 0; |
for ( ; ; ) |
{ |
_CONST int c1 = tolower(*ucs1++); |
_CONST int c2 = tolower(*ucs2++); |
if (((d = c1 - c2) != 0) || (c2 == '\0')) |
break; |
} |
return d; |
} |
/programs/develop/libraries/newlib/string/strchr.c |
---|
0,0 → 1,123 |
/* |
FUNCTION |
<<strchr>>---search for character in string |
INDEX |
strchr |
ANSI_SYNOPSIS |
#include <string.h> |
char * strchr(const char *<[string]>, int <[c]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char * strchr(<[string]>, <[c]>); |
const char *<[string]>; |
int <[c]>; |
DESCRIPTION |
This function finds the first occurence of <[c]> (converted to |
a char) in the string pointed to by <[string]> (including the |
terminating null character). |
RETURNS |
Returns a pointer to the located character, or a null pointer |
if <[c]> does not occur in <[string]>. |
PORTABILITY |
<<strchr>> is ANSI C. |
<<strchr>> requires no supporting OS subroutines. |
QUICKREF |
strchr ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if X is not aligned on a "long" boundary. */ |
#define UNALIGNED(X) ((long)X & (sizeof (long) - 1)) |
/* How many bytes are loaded each iteration of the word copy loop. */ |
#define LBLOCKSIZE (sizeof (long)) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
/* DETECTCHAR returns nonzero if (long)X contains the byte used |
to fill (long)MASK. */ |
#define DETECTCHAR(X,MASK) (DETECTNULL(X ^ MASK)) |
char * |
_DEFUN (strchr, (s1, i), |
_CONST char *s1 _AND |
int i) |
{ |
_CONST unsigned char *s = (_CONST unsigned char *)s1; |
unsigned char c = i; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
unsigned long mask,j; |
unsigned long *aligned_addr; |
/* Special case for finding 0. */ |
if (!c) |
{ |
while (UNALIGNED (s)) |
{ |
if (!*s) |
return (char *) s; |
s++; |
} |
/* Operate a word at a time. */ |
aligned_addr = (unsigned long *) s; |
while (!DETECTNULL (*aligned_addr)) |
aligned_addr++; |
/* Found the end of string. */ |
s = (const unsigned char *) aligned_addr; |
while (*s) |
s++; |
return (char *) s; |
} |
/* All other bytes. Align the pointer, then search a long at a time. */ |
while (UNALIGNED (s)) |
{ |
if (!*s) |
return NULL; |
if (*s == c) |
return (char *) s; |
s++; |
} |
mask = c; |
for (j = 8; j < LBLOCKSIZE * 8; j <<= 1) |
mask = (mask << j) | mask; |
aligned_addr = (unsigned long *) s; |
while (!DETECTNULL (*aligned_addr) && !DETECTCHAR (*aligned_addr, mask)) |
aligned_addr++; |
/* The block of bytes currently pointed to by aligned_addr |
contains either a null or the target char, or both. We |
catch it using the bytewise search. */ |
s = (unsigned char *) aligned_addr; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (*s && *s != c) |
s++; |
if (*s == c) |
return (char *)s; |
return NULL; |
} |
/programs/develop/libraries/newlib/string/strcmp.c |
---|
0,0 → 1,106 |
/* |
FUNCTION |
<<strcmp>>---character string compare |
INDEX |
strcmp |
ANSI_SYNOPSIS |
#include <string.h> |
int strcmp(const char *<[a]>, const char *<[b]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strcmp(<[a]>, <[b]>) |
char *<[a]>; |
char *<[b]>; |
DESCRIPTION |
<<strcmp>> compares the string at <[a]> to |
the string at <[b]>. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>>, |
<<strcmp>> returns a number greater than zero. If the two |
strings match, <<strcmp>> returns zero. If <<*<[a]>>> |
sorts lexicographically before <<*<[b]>>>, <<strcmp>> returns a |
number less than zero. |
PORTABILITY |
<<strcmp>> is ANSI C. |
<<strcmp>> requires no supporting OS subroutines. |
QUICKREF |
strcmp ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* DETECTNULL returns nonzero if (long)X contains a NULL byte. */ |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
int |
_DEFUN (strcmp, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
while (*s1 != '\0' && *s1 == *s2) |
{ |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#else |
unsigned long *a1; |
unsigned long *a2; |
/* If s1 or s2 are unaligned, then compare bytes. */ |
if (!UNALIGNED (s1, s2)) |
{ |
/* If s1 and s2 are word-aligned, compare them a word at a time. */ |
a1 = (unsigned long*)s1; |
a2 = (unsigned long*)s2; |
while (*a1 == *a2) |
{ |
/* To get here, *a1 == *a2, thus if we find a null in *a1, |
then the strings must be equal, so return zero. */ |
if (DETECTNULL (*a1)) |
return 0; |
a1++; |
a2++; |
} |
/* A difference was detected in last few bytes of s1, so search bytewise */ |
s1 = (char*)a1; |
s2 = (char*)a2; |
} |
while (*s1 != '\0' && *s1 == *s2) |
{ |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/programs/develop/libraries/newlib/string/strcpy.c |
---|
0,0 → 1,99 |
/* |
FUNCTION |
<<strcpy>>---copy string |
INDEX |
strcpy |
ANSI_SYNOPSIS |
#include <string.h> |
char *strcpy(char *<[dst]>, const char *<[src]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strcpy(<[dst]>, <[src]>) |
char *<[dst]>; |
char *<[src]>; |
DESCRIPTION |
<<strcpy>> copies the string pointed to by <[src]> |
(including the terminating null character) to the array |
pointed to by <[dst]>. |
RETURNS |
This function returns the initial value of <[dst]>. |
PORTABILITY |
<<strcpy>> is ANSI C. |
<<strcpy>> requires no supporting OS subroutines. |
QUICKREF |
strcpy ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/*SUPPRESS 560*/ |
/*SUPPRESS 530*/ |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
char* |
_DEFUN (strcpy, (dst0, src0), |
char *dst0 _AND |
_CONST char *src0) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *s = dst0; |
while (*dst0++ = *src0++) |
; |
return s; |
#else |
char *dst = dst0; |
_CONST char *src = src0; |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If SRC or DEST is unaligned, then copy bytes. */ |
if (!UNALIGNED (src, dst)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* SRC and DEST are both "long int" aligned, try to do "long int" |
sized copies. */ |
while (!DETECTNULL(*aligned_src)) |
{ |
*aligned_dst++ = *aligned_src++; |
} |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while ((*dst++ = *src++)) |
; |
return dst0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/programs/develop/libraries/newlib/string/strcspn.c |
---|
0,0 → 1,54 |
/* |
FUNCTION |
<<strcspn>>---count characters not in string |
INDEX |
strcspn |
ANSI_SYNOPSIS |
size_t strcspn(const char *<[s1]>, const char *<[s2]>); |
TRAD_SYNOPSIS |
size_t strcspn(<[s1]>, <[s2]>) |
char *<[s1]>; |
char *<[s2]>; |
DESCRIPTION |
This function computes the length of the initial part of |
the string pointed to by <[s1]> which consists entirely of |
characters <[NOT]> from the string pointed to by <[s2]> |
(excluding the terminating null character). |
RETURNS |
<<strcspn>> returns the length of the substring found. |
PORTABILITY |
<<strcspn>> is ANSI C. |
<<strcspn>> requires no supporting OS subroutines. |
*/ |
#include <string.h> |
size_t |
_DEFUN (strcspn, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
_CONST char *s = s1; |
_CONST char *c; |
while (*s1) |
{ |
for (c = s2; *c; c++) |
{ |
if (*s1 == *c) |
break; |
} |
if (*c) |
break; |
s1++; |
} |
return s1 - s; |
} |
/programs/develop/libraries/newlib/string/strdup.c |
---|
0,0 → 1,13 |
#ifndef _REENT_ONLY |
#include <reent.h> |
#include <stdlib.h> |
#include <string.h> |
char * |
_DEFUN (strdup, (str), _CONST char *str) |
{ |
return _strdup_r (_REENT, str); |
} |
#endif /* !_REENT_ONLY */ |
/programs/develop/libraries/newlib/string/strdup_r.c |
---|
0,0 → 1,17 |
#include <reent.h> |
#include <stdlib.h> |
#include <string.h> |
char * |
_DEFUN (_strdup_r, (reent_ptr, str), |
struct _reent *reent_ptr _AND |
_CONST char *str) |
{ |
size_t len = strlen (str) + 1; |
char *copy = _malloc_r (reent_ptr, len); |
if (copy) |
{ |
memcpy (copy, str, len); |
} |
return copy; |
} |
/programs/develop/libraries/newlib/string/strerror.c |
---|
0,0 → 1,793 |
/*** |
**** CAUTION!!! KEEP DOC CONSISTENT---if you change text of a message |
**** here, change two places: |
**** 1) the leading doc section (alphabetized by macro) |
**** 2) the real text inside switch(errnum) |
***/ |
/* |
FUNCTION |
<<strerror>>---convert error number to string |
INDEX |
strerror |
ANSI_SYNOPSIS |
#include <string.h> |
char *strerror(int <[errnum]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strerror(<[errnum]>) |
int <[errnum]>; |
DESCRIPTION |
<<strerror>> converts the error number <[errnum]> into a |
string. The value of <[errnum]> is usually a copy of <<errno>>. |
If <<errnum>> is not a known error number, the result points to an |
empty string. |
This implementation of <<strerror>> prints out the following strings |
for each of the values defined in `<<errno.h>>': |
o+ |
o E2BIG |
Arg list too long |
o EACCES |
Permission denied |
o EADDRINUSE |
Address already in use |
o EADV |
Advertise error |
o EAFNOSUPPORT |
Address family not supported by protocol family |
o EAGAIN |
No more processes |
o EALREADY |
Socket already connected |
o EBADF |
Bad file number |
o EBADMSG |
Bad message |
o EBUSY |
Device or resource busy |
o ECHILD |
No children |
o ECOMM |
Communication error |
o ECONNABORTED |
Software caused connection abort |
o ECONNREFUSED |
Connection refused |
o EDEADLK |
Deadlock |
o EDESTADDRREQ |
Destination address required |
o EEXIST |
File exists |
o EDOM |
Math argument |
o EFAULT |
Bad address |
o EFBIG |
File too large |
o EHOSTDOWN |
Host is down |
o EHOSTUNREACH |
Host is unreachable |
o EIDRM |
Identifier removed |
o EINPROGRESS |
Connection already in progress |
o EINTR |
Interrupted system call |
o EINVAL |
Invalid argument |
o EIO |
I/O error |
o EISCONN |
Socket is already connected |
o EISDIR |
Is a directory |
o ELIBACC |
Cannot access a needed shared library |
o ELIBBAD |
Accessing a corrupted shared library |
o ELIBEXEC |
Cannot exec a shared library directly |
o ELIBMAX |
Attempting to link in more shared libraries than system limit |
o ELIBSCN |
<<.lib>> section in a.out corrupted |
o EMFILE |
Too many open files |
o EMLINK |
Too many links |
o EMSGSIZE |
Message too long |
o EMULTIHOP |
Multihop attempted |
o ENAMETOOLONG |
File or path name too long |
o ENETDOWN |
Network interface not configured |
o ENETUNREACH |
Network is unreachable |
o ENFILE |
Too many open files in system |
o ENODEV |
No such device |
o ENOENT |
No such file or directory |
o ENOEXEC |
Exec format error |
o ENOLCK |
No lock |
o ENOLINK |
Virtual circuit is gone |
o ENOMEM |
Not enough space |
o ENOMSG |
No message of desired type |
o ENONET |
Machine is not on the network |
o ENOPKG |
No package |
o ENOPROTOOPT |
Protocol not available |
o ENOSPC |
No space left on device |
o ENOSR |
No stream resources |
o ENOSTR |
Not a stream |
o ENOSYS |
Function not implemented |
o ENOTBLK |
Block device required |
o ENOTCONN |
Socket is not connected |
o ENOTDIR |
Not a directory |
o ENOTEMPTY |
Directory not empty |
o ENOTSOCK |
Socket operation on non-socket |
o ENOTSUP |
Not supported |
o ENOTTY |
Not a character device |
o ENXIO |
No such device or address |
o EPERM |
Not owner |
o EPIPE |
Broken pipe |
o EPROTO |
Protocol error |
o EPROTOTYPE |
Protocol wrong type for socket |
o EPROTONOSUPPORT |
Unknown protocol |
o ERANGE |
Result too large |
o EREMOTE |
Resource is remote |
o EROFS |
Read-only file system |
o ESHUTDOWN |
Can't send after socket shutdown |
o ESOCKTNOSUPPORT |
Socket type not supported |
o ESPIPE |
Illegal seek |
o ESRCH |
No such process |
o ESRMNT |
Srmount error |
o ETIME |
Stream ioctl timeout |
o ETIMEDOUT |
Connection timed out |
o ETXTBSY |
Text file busy |
o EXDEV |
Cross-device link |
o ECANCELED |
Operation canceled |
o ENOTRECOVERABLE |
State not recoverable |
o EOWNERDEAD |
Previous owner died |
o ESTRPIPE |
Strings pipe error |
o- |
RETURNS |
This function returns a pointer to a string. Your application must |
not modify that string. |
PORTABILITY |
ANSI C requires <<strerror>>, but does not specify the strings used |
for each error number. |
Although this implementation of <<strerror>> is reentrant, ANSI C |
declares that subsequent calls to <<strerror>> may overwrite the |
result string; therefore portable code cannot depend on the reentrancy |
of this subroutine. |
This implementation of <<strerror>> provides for user-defined |
extensibility. <<errno.h>> defines <[__ELASTERROR]>, which can be |
used as a base for user-defined error values. If the user supplies a |
routine named <<_user_strerror>>, and <[errnum]> passed to |
<<strerror>> does not match any of the supported values, |
<<_user_strerror>> is called with <[errnum]> as its argument. |
<<_user_strerror>> takes one argument of type <[int]>, and returns a |
character pointer. If <[errnum]> is unknown to <<_user_strerror>>, |
<<_user_strerror>> returns <[NULL]>. The default <<_user_strerror>> |
returns <[NULL]> for all input values. |
<<strerror>> requires no supporting OS subroutines. |
QUICKREF |
strerror ansi pure |
*/ |
#include <errno.h> |
#include <string.h> |
char * |
_DEFUN (strerror, (errnum), |
int errnum) |
{ |
char *error; |
extern char *_user_strerror _PARAMS ((int)); |
switch (errnum) |
{ |
/* go32 defines EPERM as EACCES */ |
#if defined (EPERM) && (!defined (EACCES) || (EPERM != EACCES)) |
case EPERM: |
error = "Not owner"; |
break; |
#endif |
#ifdef ENOENT |
case ENOENT: |
error = "No such file or directory"; |
break; |
#endif |
#ifdef ESRCH |
case ESRCH: |
error = "No such process"; |
break; |
#endif |
#ifdef EINTR |
case EINTR: |
error = "Interrupted system call"; |
break; |
#endif |
#ifdef EIO |
case EIO: |
error = "I/O error"; |
break; |
#endif |
/* go32 defines ENXIO as ENODEV */ |
#if defined (ENXIO) && (!defined (ENODEV) || (ENXIO != ENODEV)) |
case ENXIO: |
error = "No such device or address"; |
break; |
#endif |
#ifdef E2BIG |
case E2BIG: |
error = "Arg list too long"; |
break; |
#endif |
#ifdef ENOEXEC |
case ENOEXEC: |
error = "Exec format error"; |
break; |
#endif |
#ifdef EALREADY |
case EALREADY: |
error = "Socket already connected"; |
break; |
#endif |
#ifdef EBADF |
case EBADF: |
error = "Bad file number"; |
break; |
#endif |
#ifdef ECHILD |
case ECHILD: |
error = "No children"; |
break; |
#endif |
#ifdef EDESTADDRREQ |
case EDESTADDRREQ: |
error = "Destination address required"; |
break; |
#endif |
#ifdef EAGAIN |
case EAGAIN: |
error = "No more processes"; |
break; |
#endif |
#ifdef ENOMEM |
case ENOMEM: |
error = "Not enough space"; |
break; |
#endif |
#ifdef EACCES |
case EACCES: |
error = "Permission denied"; |
break; |
#endif |
#ifdef EFAULT |
case EFAULT: |
error = "Bad address"; |
break; |
#endif |
#ifdef ENOTBLK |
case ENOTBLK: |
error = "Block device required"; |
break; |
#endif |
#ifdef EBUSY |
case EBUSY: |
error = "Device or resource busy"; |
break; |
#endif |
#ifdef EEXIST |
case EEXIST: |
error = "File exists"; |
break; |
#endif |
#ifdef EXDEV |
case EXDEV: |
error = "Cross-device link"; |
break; |
#endif |
#ifdef ENODEV |
case ENODEV: |
error = "No such device"; |
break; |
#endif |
#ifdef ENOTDIR |
case ENOTDIR: |
error = "Not a directory"; |
break; |
#endif |
#ifdef EHOSTDOWN |
case EHOSTDOWN: |
error = "Host is down"; |
break; |
#endif |
#ifdef EINPROGRESS |
case EINPROGRESS: |
error = "Connection already in progress"; |
break; |
#endif |
#ifdef EISDIR |
case EISDIR: |
error = "Is a directory"; |
break; |
#endif |
#ifdef EINVAL |
case EINVAL: |
error = "Invalid argument"; |
break; |
#endif |
#ifdef ENETDOWN |
case ENETDOWN: |
error = "Network interface is not configured"; |
break; |
#endif |
#ifdef ENFILE |
case ENFILE: |
error = "Too many open files in system"; |
break; |
#endif |
#ifdef EMFILE |
case EMFILE: |
error = "Too many open files"; |
break; |
#endif |
#ifdef ENOTTY |
case ENOTTY: |
error = "Not a character device"; |
break; |
#endif |
#ifdef ETXTBSY |
case ETXTBSY: |
error = "Text file busy"; |
break; |
#endif |
#ifdef EFBIG |
case EFBIG: |
error = "File too large"; |
break; |
#endif |
#ifdef EHOSTUNREACH |
case EHOSTUNREACH: |
error = "Host is unreachable"; |
break; |
#endif |
#ifdef ENOSPC |
case ENOSPC: |
error = "No space left on device"; |
break; |
#endif |
#ifdef ENOTSUP |
case ENOTSUP: |
error = "Not supported"; |
break; |
#endif |
#ifdef ESPIPE |
case ESPIPE: |
error = "Illegal seek"; |
break; |
#endif |
#ifdef EROFS |
case EROFS: |
error = "Read-only file system"; |
break; |
#endif |
#ifdef EMLINK |
case EMLINK: |
error = "Too many links"; |
break; |
#endif |
#ifdef EPIPE |
case EPIPE: |
error = "Broken pipe"; |
break; |
#endif |
#ifdef EDOM |
case EDOM: |
error = "Math argument"; |
break; |
#endif |
#ifdef ERANGE |
case ERANGE: |
error = "Result too large"; |
break; |
#endif |
#ifdef ENOMSG |
case ENOMSG: |
error = "No message of desired type"; |
break; |
#endif |
#ifdef EIDRM |
case EIDRM: |
error = "Identifier removed"; |
break; |
#endif |
#ifdef EDEADLK |
case EDEADLK: |
error = "Deadlock"; |
break; |
#endif |
#ifdef ENETUNREACH |
case ENETUNREACH: |
error = "Network is unreachable"; |
break; |
#endif |
#ifdef ENOLCK |
case ENOLCK: |
error = "No lock"; |
break; |
#endif |
#ifdef ENOSTR |
case ENOSTR: |
error = "Not a stream"; |
break; |
#endif |
#ifdef ETIME |
case ETIME: |
error = "Stream ioctl timeout"; |
break; |
#endif |
#ifdef ENOSR |
case ENOSR: |
error = "No stream resources"; |
break; |
#endif |
#ifdef ENONET |
case ENONET: |
error = "Machine is not on the network"; |
break; |
#endif |
#ifdef ENOPKG |
case ENOPKG: |
error = "No package"; |
break; |
#endif |
#ifdef EREMOTE |
case EREMOTE: |
error = "Resource is remote"; |
break; |
#endif |
#ifdef ENOLINK |
case ENOLINK: |
error = "Virtual circuit is gone"; |
break; |
#endif |
#ifdef EADV |
case EADV: |
error = "Advertise error"; |
break; |
#endif |
#ifdef ESRMNT |
case ESRMNT: |
error = "Srmount error"; |
break; |
#endif |
#ifdef ECOMM |
case ECOMM: |
error = "Communication error"; |
break; |
#endif |
#ifdef EPROTO |
case EPROTO: |
error = "Protocol error"; |
break; |
#endif |
#ifdef EPROTONOSUPPORT |
case EPROTONOSUPPORT: |
error = "Unknown protocol"; |
break; |
#endif |
#ifdef EMULTIHOP |
case EMULTIHOP: |
error = "Multihop attempted"; |
break; |
#endif |
#ifdef EBADMSG |
case EBADMSG: |
error = "Bad message"; |
break; |
#endif |
#ifdef ELIBACC |
case ELIBACC: |
error = "Cannot access a needed shared library"; |
break; |
#endif |
#ifdef ELIBBAD |
case ELIBBAD: |
error = "Accessing a corrupted shared library"; |
break; |
#endif |
#ifdef ELIBSCN |
case ELIBSCN: |
error = ".lib section in a.out corrupted"; |
break; |
#endif |
#ifdef ELIBMAX |
case ELIBMAX: |
error = "Attempting to link in more shared libraries than system limit"; |
break; |
#endif |
#ifdef ELIBEXEC |
case ELIBEXEC: |
error = "Cannot exec a shared library directly"; |
break; |
#endif |
#ifdef ENOSYS |
case ENOSYS: |
error = "Function not implemented"; |
break; |
#endif |
#ifdef ENMFILE |
case ENMFILE: |
error = "No more files"; |
break; |
#endif |
#ifdef ENOTEMPTY |
case ENOTEMPTY: |
error = "Directory not empty"; |
break; |
#endif |
#ifdef ENAMETOOLONG |
case ENAMETOOLONG: |
error = "File or path name too long"; |
break; |
#endif |
#ifdef ELOOP |
case ELOOP: |
error = "Too many symbolic links"; |
break; |
#endif |
#ifdef ENOBUFS |
case ENOBUFS: |
error = "No buffer space available"; |
break; |
#endif |
#ifdef EAFNOSUPPORT |
case EAFNOSUPPORT: |
error = "Address family not supported by protocol family"; |
break; |
#endif |
#ifdef EPROTOTYPE |
case EPROTOTYPE: |
error = "Protocol wrong type for socket"; |
break; |
#endif |
#ifdef ENOTSOCK |
case ENOTSOCK: |
error = "Socket operation on non-socket"; |
break; |
#endif |
#ifdef ENOPROTOOPT |
case ENOPROTOOPT: |
error = "Protocol not available"; |
break; |
#endif |
#ifdef ESHUTDOWN |
case ESHUTDOWN: |
error = "Can't send after socket shutdown"; |
break; |
#endif |
#ifdef ECONNREFUSED |
case ECONNREFUSED: |
error = "Connection refused"; |
break; |
#endif |
#ifdef EADDRINUSE |
case EADDRINUSE: |
error = "Address already in use"; |
break; |
#endif |
#ifdef ECONNABORTED |
case ECONNABORTED: |
error = "Software caused connection abort"; |
break; |
#endif |
#if (defined(EWOULDBLOCK) && (!defined (EAGAIN) || (EWOULDBLOCK != EAGAIN))) |
case EWOULDBLOCK: |
error = "Operation would block"; |
break; |
#endif |
#ifdef ENOTCONN |
case ENOTCONN: |
error = "Socket is not connected"; |
break; |
#endif |
#ifdef ESOCKTNOSUPPORT |
case ESOCKTNOSUPPORT: |
error = "Socket type not supported"; |
break; |
#endif |
#ifdef EISCONN |
case EISCONN: |
error = "Socket is already connected"; |
break; |
#endif |
#ifdef ECANCELED |
case ECANCELED: |
error = "Operation canceled"; |
break; |
#endif |
#ifdef ENOTRECOVERABLE |
case ENOTRECOVERABLE: |
error = "State not recoverable"; |
break; |
#endif |
#ifdef EOWNERDEAD |
case EOWNERDEAD: |
error = "Previous owner died"; |
break; |
#endif |
#ifdef ESTRPIPE |
case ESTRPIPE: |
error = "Streams pipe error"; |
break; |
#endif |
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP)) |
case EOPNOTSUPP: |
error = "Operation not supported on socket"; |
break; |
#endif |
#ifdef EMSGSIZE |
case EMSGSIZE: |
error = "Message too long"; |
break; |
#endif |
#ifdef ETIMEDOUT |
case ETIMEDOUT: |
error = "Connection timed out"; |
break; |
#endif |
default: |
if ((error = _user_strerror (errnum)) == 0) |
error = ""; |
break; |
} |
return error; |
} |
/programs/develop/libraries/newlib/string/strlen.c |
---|
0,0 → 1,88 |
/* |
FUNCTION |
<<strlen>>---character string length |
INDEX |
strlen |
ANSI_SYNOPSIS |
#include <string.h> |
size_t strlen(const char *<[str]>); |
TRAD_SYNOPSIS |
#include <string.h> |
size_t strlen(<[str]>) |
char *<[src]>; |
DESCRIPTION |
The <<strlen>> function works out the length of the string |
starting at <<*<[str]>>> by counting chararacters until it |
reaches a <<NULL>> character. |
RETURNS |
<<strlen>> returns the character count. |
PORTABILITY |
<<strlen>> is ANSI C. |
<<strlen>> requires no supporting OS subroutines. |
QUICKREF |
strlen ansi pure |
*/ |
#include <_ansi.h> |
#include <string.h> |
#include <limits.h> |
#define LBLOCKSIZE (sizeof (long)) |
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1)) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
size_t |
_DEFUN (strlen, (str), |
_CONST char *str) |
{ |
_CONST char *start = str; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
unsigned long *aligned_addr; |
/* Align the pointer, so we can search a word at a time. */ |
while (UNALIGNED (str)) |
{ |
if (!*str) |
return str - start; |
str++; |
} |
/* If the string is word-aligned, we can check for the presence of |
a null in each word-sized block. */ |
aligned_addr = (unsigned long *)str; |
while (!DETECTNULL (*aligned_addr)) |
aligned_addr++; |
/* Once a null is detected, we check each byte in that block for a |
precise position of the null. */ |
str = (char *) aligned_addr; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (*str) |
str++; |
return str - start; |
} |
/programs/develop/libraries/newlib/string/strncasecmp.c |
---|
0,0 → 1,63 |
/* |
FUNCTION |
<<strncasecmp>>---case-insensitive character string compare |
INDEX |
strncasecmp |
ANSI_SYNOPSIS |
#include <string.h> |
int strncasecmp(const char *<[a]>, const char * <[b]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strncasecmp(<[a]>, <[b]>, <[length]>) |
char *<[a]>; |
char *<[b]>; |
size_t <[length]> |
DESCRIPTION |
<<strncasecmp>> compares up to <[length]> characters |
from the string at <[a]> to the string at <[b]> in a |
case-insensitive manner. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after |
both are converted to lowercase), <<strncasecmp>> returns a |
number greater than zero. If the two strings are equivalent, |
<<strncasecmp>> returns zero. If <<*<[a]>>> sorts |
lexicographically before <<*<[b]>>>, <<strncasecmp>> returns a |
number less than zero. |
PORTABILITY |
<<strncasecmp>> is in the Berkeley Software Distribution. |
<<strncasecmp>> requires no supporting OS subroutines. It uses |
tolower() from elsewhere in this library. |
QUICKREF |
strncasecmp |
*/ |
#include <string.h> |
#include <ctype.h> |
int |
_DEFUN (strncasecmp, (s1, s2, n), |
_CONST char *s1 _AND |
_CONST char *s2 _AND |
size_t n) |
{ |
_CONST unsigned char *ucs1 = (_CONST unsigned char *) s1; |
_CONST unsigned char *ucs2 = (_CONST unsigned char *) s2; |
int d = 0; |
for ( ; n != 0; n--) |
{ |
_CONST int c1 = tolower(*ucs1++); |
_CONST int c2 = tolower(*ucs2++); |
if (((d = c1 - c2) != 0) || (c2 == '\0')) |
break; |
} |
return d; |
} |
/programs/develop/libraries/newlib/string/strncmp.c |
---|
0,0 → 1,122 |
/* |
FUNCTION |
<<strncmp>>---character string compare |
INDEX |
strncmp |
ANSI_SYNOPSIS |
#include <string.h> |
int strncmp(const char *<[a]>, const char * <[b]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strncmp(<[a]>, <[b]>, <[length]>) |
char *<[a]>; |
char *<[b]>; |
size_t <[length]> |
DESCRIPTION |
<<strncmp>> compares up to <[length]> characters |
from the string at <[a]> to the string at <[b]>. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>>, |
<<strncmp>> returns a number greater than zero. If the two |
strings are equivalent, <<strncmp>> returns zero. If <<*<[a]>>> |
sorts lexicographically before <<*<[b]>>>, <<strncmp>> returns a |
number less than zero. |
PORTABILITY |
<<strncmp>> is ANSI C. |
<<strncmp>> requires no supporting OS subroutines. |
QUICKREF |
strncmp ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* DETECTNULL returns nonzero if (long)X contains a NULL byte. */ |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
int |
_DEFUN (strncmp, (s1, s2, n), |
_CONST char *s1 _AND |
_CONST char *s2 _AND |
size_t n) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
if (n == 0) |
return 0; |
while (n-- != 0 && *s1 == *s2) |
{ |
if (n == 0 || *s1 == '\0') |
break; |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#else |
unsigned long *a1; |
unsigned long *a2; |
if (n == 0) |
return 0; |
/* If s1 or s2 are unaligned, then compare bytes. */ |
if (!UNALIGNED (s1, s2)) |
{ |
/* If s1 and s2 are word-aligned, compare them a word at a time. */ |
a1 = (unsigned long*)s1; |
a2 = (unsigned long*)s2; |
while (n >= sizeof (long) && *a1 == *a2) |
{ |
n -= sizeof (long); |
/* If we've run out of bytes or hit a null, return zero |
since we already know *a1 == *a2. */ |
if (n == 0 || DETECTNULL (*a1)) |
return 0; |
a1++; |
a2++; |
} |
/* A difference was detected in last few bytes of s1, so search bytewise */ |
s1 = (char*)a1; |
s2 = (char*)a2; |
} |
while (n-- > 0 && *s1 == *s2) |
{ |
/* If we've run out of bytes or hit a null, return zero |
since we already know *s1 == *s2. */ |
if (n == 0 || *s1 == '\0') |
return 0; |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/programs/develop/libraries/newlib/string/strncpy.c |
---|
0,0 → 1,125 |
/* |
FUNCTION |
<<strncpy>>---counted copy string |
INDEX |
strncpy |
ANSI_SYNOPSIS |
#include <string.h> |
char *strncpy(char *<[dst]>, const char *<[src]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strncpy(<[dst]>, <[src]>, <[length]>) |
char *<[dst]>; |
char *<[src]>; |
size_t <[length]>; |
DESCRIPTION |
<<strncpy>> copies not more than <[length]> characters from the |
the string pointed to by <[src]> (including the terminating |
null character) to the array pointed to by <[dst]>. If the |
string pointed to by <[src]> is shorter than <[length]> |
characters, null characters are appended to the destination |
array until a total of <[length]> characters have been |
written. |
RETURNS |
This function returns the initial value of <[dst]>. |
PORTABILITY |
<<strncpy>> is ANSI C. |
<<strncpy>> requires no supporting OS subroutines. |
QUICKREF |
strncpy ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/*SUPPRESS 560*/ |
/*SUPPRESS 530*/ |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
#define TOO_SMALL(LEN) ((LEN) < sizeof (long)) |
char * |
_DEFUN (strncpy, (dst0, src0), |
char *dst0 _AND |
_CONST char *src0 _AND |
size_t count) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *dscan; |
_CONST char *sscan; |
dscan = dst0; |
sscan = src0; |
while (count > 0) |
{ |
--count; |
if ((*dscan++ = *sscan++) == '\0') |
break; |
} |
while (count-- > 0) |
*dscan++ = '\0'; |
return dst0; |
#else |
char *dst = dst0; |
_CONST char *src = src0; |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If SRC and DEST is aligned and count large enough, then copy words. */ |
if (!UNALIGNED (src, dst) && !TOO_SMALL (count)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* SRC and DEST are both "long int" aligned, try to do "long int" |
sized copies. */ |
while (count >= sizeof (long int) && !DETECTNULL(*aligned_src)) |
{ |
count -= sizeof (long int); |
*aligned_dst++ = *aligned_src++; |
} |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while (count > 0) |
{ |
--count; |
if ((*dst++ = *src++) == '\0') |
break; |
} |
while (count-- > 0) |
*dst++ = '\0'; |
return dst0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/programs/develop/libraries/newlib/string/strnlen.c |
---|
0,0 → 1,49 |
/* |
FUNCTION |
<<strnlen>>---character string length |
INDEX |
strnlen |
ANSI_SYNOPSIS |
#include <string.h> |
size_t strnlen(const char *<[str]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <string.h> |
size_t strnlen(<[str]>, <[n]>) |
char *<[src]>; |
size_t <[n]>; |
DESCRIPTION |
The <<strnlen>> function works out the length of the string |
starting at <<*<[str]>>> by counting chararacters until it |
reaches a NUL character or the maximum: <[n]> number of |
characters have been inspected. |
RETURNS |
<<strnlen>> returns the character count or <[n]>. |
PORTABILITY |
<<strnlen>> is a GNU extension. |
<<strnlen>> requires no supporting OS subroutines. |
*/ |
#undef __STRICT_ANSI__ |
#include <_ansi.h> |
#include <string.h> |
size_t |
_DEFUN (strnlen, (str, n), |
_CONST char *str _AND |
size_t n) |
{ |
_CONST char *start = str; |
while (n-- > 0 && *str) |
str++; |
return str - start; |
} |
/programs/develop/libraries/newlib/string/strrchr.c |
---|
0,0 → 1,59 |
/* |
FUNCTION |
<<strrchr>>---reverse search for character in string |
INDEX |
strrchr |
ANSI_SYNOPSIS |
#include <string.h> |
char * strrchr(const char *<[string]>, int <[c]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char * strrchr(<[string]>, <[c]>); |
char *<[string]>; |
int *<[c]>; |
DESCRIPTION |
This function finds the last occurence of <[c]> (converted to |
a char) in the string pointed to by <[string]> (including the |
terminating null character). |
RETURNS |
Returns a pointer to the located character, or a null pointer |
if <[c]> does not occur in <[string]>. |
PORTABILITY |
<<strrchr>> is ANSI C. |
<<strrchr>> requires no supporting OS subroutines. |
QUICKREF |
strrchr ansi pure |
*/ |
#include <string.h> |
char * |
_DEFUN (strrchr, (s, i), |
_CONST char *s _AND |
int i) |
{ |
_CONST char *last = NULL; |
if (i) |
{ |
while ((s=strchr(s, i))) |
{ |
last = s; |
s++; |
} |
} |
else |
{ |
last = strchr(s, i); |
} |
return (char *) last; |
} |
/programs/develop/libraries/newlib/string/strspn.c |
---|
0,0 → 1,59 |
/* |
FUNCTION |
<<strspn>>---find initial match |
INDEX |
strspn |
ANSI_SYNOPSIS |
#include <string.h> |
size_t strspn(const char *<[s1]>, const char *<[s2]>); |
TRAD_SYNOPSIS |
#include <string.h> |
size_t strspn(<[s1]>, <[s2]>) |
char *<[s1]>; |
char *<[s2]>; |
DESCRIPTION |
This function computes the length of the initial segment of |
the string pointed to by <[s1]> which consists entirely of |
characters from the string pointed to by <[s2]> (excluding the |
terminating null character). |
RETURNS |
<<strspn>> returns the length of the segment found. |
PORTABILITY |
<<strspn>> is ANSI C. |
<<strspn>> requires no supporting OS subroutines. |
QUICKREF |
strspn ansi pure |
*/ |
#include <string.h> |
size_t |
_DEFUN (strspn, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
_CONST char *s = s1; |
_CONST char *c; |
while (*s1) |
{ |
for (c = s2; *c; c++) |
{ |
if (*s1 == *c) |
break; |
} |
if (*c == '\0') |
break; |
s1++; |
} |
return s1 - s; |
} |
/programs/develop/libraries/newlib/string/strstr.c |
---|
0,0 → 1,121 |
/* |
FUNCTION |
<<strstr>>---find string segment |
INDEX |
strstr |
ANSI_SYNOPSIS |
#include <string.h> |
char *strstr(const char *<[s1]>, const char *<[s2]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strstr(<[s1]>, <[s2]>) |
char *<[s1]>; |
char *<[s2]>; |
DESCRIPTION |
Locates the first occurrence in the string pointed to by <[s1]> of |
the sequence of characters in the string pointed to by <[s2]> |
(excluding the terminating null character). |
RETURNS |
Returns a pointer to the located string segment, or a null |
pointer if the string <[s2]> is not found. If <[s2]> points to |
a string with zero length, <[s1]> is returned. |
PORTABILITY |
<<strstr>> is ANSI C. |
<<strstr>> requires no supporting OS subroutines. |
QUICKREF |
strstr ansi pure |
*/ |
#include <string.h> |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
# define RETURN_TYPE char * |
# define AVAILABLE(h, h_l, j, n_l) \ |
(!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ |
&& ((h_l) = (j) + (n_l))) |
# include "str-two-way.h" |
#endif |
char * |
_DEFUN (strstr, (searchee, lookfor), |
_CONST char *searchee _AND |
_CONST char *lookfor) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
/* Less code size, but quadratic performance in the worst case. */ |
if (*searchee == 0) |
{ |
if (*lookfor) |
return (char *) NULL; |
return (char *) searchee; |
} |
while (*searchee) |
{ |
size_t i; |
i = 0; |
while (1) |
{ |
if (lookfor[i] == 0) |
{ |
return (char *) searchee; |
} |
if (lookfor[i] != searchee[i]) |
{ |
break; |
} |
i++; |
} |
searchee++; |
} |
return (char *) NULL; |
#else /* compilation for speed */ |
/* Larger code size, but guaranteed linear performance. */ |
const char *haystack = searchee; |
const char *needle = lookfor; |
size_t needle_len; /* Length of NEEDLE. */ |
size_t haystack_len; /* Known minimum length of HAYSTACK. */ |
int ok = 1; /* True if NEEDLE is prefix of HAYSTACK. */ |
/* Determine length of NEEDLE, and in the process, make sure |
HAYSTACK is at least as long (no point processing all of a long |
NEEDLE if HAYSTACK is too short). */ |
while (*haystack && *needle) |
ok &= *haystack++ == *needle++; |
if (*needle) |
return NULL; |
if (ok) |
return (char *) searchee; |
/* Reduce the size of haystack using strchr, since it has a smaller |
linear coefficient than the Two-Way algorithm. */ |
needle_len = needle - lookfor; |
haystack = strchr (searchee + 1, *lookfor); |
if (!haystack || needle_len == 1) |
return (char *) haystack; |
haystack_len = (haystack > searchee + needle_len ? 1 |
: needle_len + searchee - haystack); |
/* Perform the search. */ |
if (needle_len < LONG_NEEDLE_THRESHOLD) |
return two_way_short_needle ((const unsigned char *) haystack, |
haystack_len, |
(const unsigned char *) lookfor, needle_len); |
return two_way_long_needle ((const unsigned char *) haystack, haystack_len, |
(const unsigned char *) lookfor, needle_len); |
#endif /* compilation for speed */ |
} |
/programs/develop/libraries/newlib/string/u_strerr.c |
---|
0,0 → 1,8 |
#include <_ansi.h> |
char * |
_DEFUN(_user_strerror, (errnum), |
int errnum) |
{ |
return 0; |
} |
/programs/develop/libraries/newlib/string/vsprintf.c |
---|
0,0 → 1,1379 |
/* |
* linux/lib/vsprintf.c |
* |
* Copyright (C) 1991, 1992 Linus Torvalds |
*/ |
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ |
/* |
* Wirzenius wrote this portably, Torvalds fucked it up :-) |
*/ |
/* |
* Fri Jul 13 2001 Crutcher Dunnavant <crutcher+kernel@datastacks.com> |
* - changed to provide snprintf and vsnprintf functions |
* So Feb 1 16:51:32 CET 2004 Juergen Quade <quade@hsnr.de> |
* - scnprintf and vscnprintf |
*/ |
#define likely(x) __builtin_expect(!!(x), 1) |
#define unlikely(x) __builtin_expect(!!(x), 0) |
#include <string.h> |
#include <ctype.h> |
#include <stdarg.h> |
#include <stdint.h> |
//#include <linux/module.h> |
//#include <types.h> |
//#include <linux/kernel.h> |
//#include <linux/kallsyms.h> |
//#include <linux/uaccess.h> |
//#include <linux/ioport.h> |
//#include <asm/page.h> /* for PAGE_SIZE */ |
//#include <asm/div64.h> |
//#include <asm/sections.h> /* for dereference_function_descriptor() */ |
#define do_div(n, base) \ |
({ \ |
unsigned long __upper, __low, __high, __mod, __base; \ |
__base = (base); \ |
asm("":"=a" (__low), "=d" (__high) : "A" (n)); \ |
__upper = __high; \ |
if (__high) { \ |
__upper = __high % (__base); \ |
__high = __high / (__base); \ |
} \ |
asm("divl %2":"=a" (__low), "=d" (__mod) \ |
: "rm" (__base), "0" (__low), "1" (__upper)); \ |
asm("":"=A" (n) : "a" (__low), "d" (__high)); \ |
__mod; \ |
}) |
#define EPERM 1 /* Operation not permitted */ |
#define ENOENT 2 /* No such file or directory */ |
#define ESRCH 3 /* No such process */ |
#define EINTR 4 /* Interrupted system call */ |
#define EIO 5 /* I/O error */ |
#define ENXIO 6 /* No such device or address */ |
#define E2BIG 7 /* Argument list too long */ |
#define ENOEXEC 8 /* Exec format error */ |
#define EBADF 9 /* Bad file number */ |
#define ECHILD 10 /* No child processes */ |
#define EAGAIN 11 /* Try again */ |
#define ENOMEM 12 /* Out of memory */ |
#define EACCES 13 /* Permission denied */ |
#define EFAULT 14 /* Bad address */ |
#define ENOTBLK 15 /* Block device required */ |
#define EBUSY 16 /* Device or resource busy */ |
#define EEXIST 17 /* File exists */ |
#define EXDEV 18 /* Cross-device link */ |
#define ENODEV 19 /* No such device */ |
#define ENOTDIR 20 /* Not a directory */ |
#define EISDIR 21 /* Is a directory */ |
#define EINVAL 22 /* Invalid argument */ |
#define ENFILE 23 /* File table overflow */ |
#define EMFILE 24 /* Too many open files */ |
#define ENOTTY 25 /* Not a typewriter */ |
#define ETXTBSY 26 /* Text file busy */ |
#define EFBIG 27 /* File too large */ |
#define ENOSPC 28 /* No space left on device */ |
#define ESPIPE 29 /* Illegal seek */ |
#define EROFS 30 /* Read-only file system */ |
#define EMLINK 31 /* Too many links */ |
#define EPIPE 32 /* Broken pipe */ |
#define EDOM 33 /* Math argument out of domain of func */ |
#define ERANGE 34 /* Math result not representable */ |
#define PAGE_SIZE 4096 |
/* Works only for digits and letters, but small and fast */ |
#define TOLOWER(x) ((x) | 0x20) |
static unsigned int simple_guess_base(const char *cp) |
{ |
if (cp[0] == '0') { |
if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) |
return 16; |
else |
return 8; |
} else { |
return 10; |
} |
} |
/** |
* simple_strtoul - convert a string to an unsigned long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) |
{ |
unsigned long result = 0; |
if (!base) |
base = simple_guess_base(cp); |
if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') |
cp += 2; |
while (isxdigit(*cp)) { |
unsigned int value; |
value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; |
if (value >= base) |
break; |
result = result * base + value; |
cp++; |
} |
if (endp) |
*endp = (char *)cp; |
return result; |
} |
/** |
* simple_strtol - convert a string to a signed long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
long simple_strtol(const char *cp, char **endp, unsigned int base) |
{ |
if(*cp == '-') |
return -simple_strtoul(cp + 1, endp, base); |
return simple_strtoul(cp, endp, base); |
} |
/** |
* simple_strtoull - convert a string to an unsigned long long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) |
{ |
unsigned long long result = 0; |
if (!base) |
base = simple_guess_base(cp); |
if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') |
cp += 2; |
while (isxdigit(*cp)) { |
unsigned int value; |
value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; |
if (value >= base) |
break; |
result = result * base + value; |
cp++; |
} |
if (endp) |
*endp = (char *)cp; |
return result; |
} |
/** |
* simple_strtoll - convert a string to a signed long long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
long long simple_strtoll(const char *cp, char **endp, unsigned int base) |
{ |
if(*cp=='-') |
return -simple_strtoull(cp + 1, endp, base); |
return simple_strtoull(cp, endp, base); |
} |
/** |
* strict_strtoul - convert a string to an unsigned long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtoul converts a string to an unsigned long only if the |
* string is really an unsigned long string, any string containing |
* any invalid char at the tail will be rejected and -EINVAL is returned, |
* only a newline char at the tail is acceptible because people generally |
* change a module parameter in the following way: |
* |
* echo 1024 > /sys/module/e1000/parameters/copybreak |
* |
* echo will append a newline to the tail. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
* |
* simple_strtoul just ignores the successive invalid characters and |
* return the converted value of prefix part of the string. |
*/ |
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res) |
{ |
char *tail; |
unsigned long val; |
size_t len; |
*res = 0; |
len = strlen(cp); |
if (len == 0) |
return -EINVAL; |
val = simple_strtoul(cp, &tail, base); |
if (tail == cp) |
return -EINVAL; |
if ((*tail == '\0') || |
((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { |
*res = val; |
return 0; |
} |
return -EINVAL; |
} |
/** |
* strict_strtol - convert a string to a long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtol is similiar to strict_strtoul, but it allows the first |
* character of a string is '-'. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
*/ |
int strict_strtol(const char *cp, unsigned int base, long *res) |
{ |
int ret; |
if (*cp == '-') { |
ret = strict_strtoul(cp + 1, base, (unsigned long *)res); |
if (!ret) |
*res = -(*res); |
} else { |
ret = strict_strtoul(cp, base, (unsigned long *)res); |
} |
return ret; |
} |
/** |
* strict_strtoull - convert a string to an unsigned long long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtoull converts a string to an unsigned long long only if the |
* string is really an unsigned long long string, any string containing |
* any invalid char at the tail will be rejected and -EINVAL is returned, |
* only a newline char at the tail is acceptible because people generally |
* change a module parameter in the following way: |
* |
* echo 1024 > /sys/module/e1000/parameters/copybreak |
* |
* echo will append a newline to the tail of the string. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
* |
* simple_strtoull just ignores the successive invalid characters and |
* return the converted value of prefix part of the string. |
*/ |
int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res) |
{ |
char *tail; |
unsigned long long val; |
size_t len; |
*res = 0; |
len = strlen(cp); |
if (len == 0) |
return -EINVAL; |
val = simple_strtoull(cp, &tail, base); |
if (tail == cp) |
return -EINVAL; |
if ((*tail == '\0') || |
((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { |
*res = val; |
return 0; |
} |
return -EINVAL; |
} |
/** |
* strict_strtoll - convert a string to a long long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtoll is similiar to strict_strtoull, but it allows the first |
* character of a string is '-'. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
*/ |
int strict_strtoll(const char *cp, unsigned int base, long long *res) |
{ |
int ret; |
if (*cp == '-') { |
ret = strict_strtoull(cp + 1, base, (unsigned long long *)res); |
if (!ret) |
*res = -(*res); |
} else { |
ret = strict_strtoull(cp, base, (unsigned long long *)res); |
} |
return ret; |
} |
static int skip_atoi(const char **s) |
{ |
int i=0; |
while (isdigit(**s)) |
i = i*10 + *((*s)++) - '0'; |
return i; |
} |
/* Decimal conversion is by far the most typical, and is used |
* for /proc and /sys data. This directly impacts e.g. top performance |
* with many processes running. We optimize it for speed |
* using code from |
* http://www.cs.uiowa.edu/~jones/bcd/decimal.html |
* (with permission from the author, Douglas W. Jones). */ |
/* Formats correctly any integer in [0,99999]. |
* Outputs from one to five digits depending on input. |
* On i386 gcc 4.1.2 -O2: ~250 bytes of code. */ |
static char* put_dec_trunc(char *buf, unsigned q) |
{ |
unsigned d3, d2, d1, d0; |
d1 = (q>>4) & 0xf; |
d2 = (q>>8) & 0xf; |
d3 = (q>>12); |
d0 = 6*(d3 + d2 + d1) + (q & 0xf); |
q = (d0 * 0xcd) >> 11; |
d0 = d0 - 10*q; |
*buf++ = d0 + '0'; /* least significant digit */ |
d1 = q + 9*d3 + 5*d2 + d1; |
if (d1 != 0) { |
q = (d1 * 0xcd) >> 11; |
d1 = d1 - 10*q; |
*buf++ = d1 + '0'; /* next digit */ |
d2 = q + 2*d2; |
if ((d2 != 0) || (d3 != 0)) { |
q = (d2 * 0xd) >> 7; |
d2 = d2 - 10*q; |
*buf++ = d2 + '0'; /* next digit */ |
d3 = q + 4*d3; |
if (d3 != 0) { |
q = (d3 * 0xcd) >> 11; |
d3 = d3 - 10*q; |
*buf++ = d3 + '0'; /* next digit */ |
if (q != 0) |
*buf++ = q + '0'; /* most sign. digit */ |
} |
} |
} |
return buf; |
} |
/* Same with if's removed. Always emits five digits */ |
static char* put_dec_full(char *buf, unsigned q) |
{ |
/* BTW, if q is in [0,9999], 8-bit ints will be enough, */ |
/* but anyway, gcc produces better code with full-sized ints */ |
unsigned d3, d2, d1, d0; |
d1 = (q>>4) & 0xf; |
d2 = (q>>8) & 0xf; |
d3 = (q>>12); |
/* Possible ways to approx. divide by 10 */ |
/* gcc -O2 replaces multiply with shifts and adds */ |
// (x * 0xcd) >> 11: 11001101 - shorter code than * 0x67 (on i386) |
// (x * 0x67) >> 10: 1100111 |
// (x * 0x34) >> 9: 110100 - same |
// (x * 0x1a) >> 8: 11010 - same |
// (x * 0x0d) >> 7: 1101 - same, shortest code (on i386) |
d0 = 6*(d3 + d2 + d1) + (q & 0xf); |
q = (d0 * 0xcd) >> 11; |
d0 = d0 - 10*q; |
*buf++ = d0 + '0'; |
d1 = q + 9*d3 + 5*d2 + d1; |
q = (d1 * 0xcd) >> 11; |
d1 = d1 - 10*q; |
*buf++ = d1 + '0'; |
d2 = q + 2*d2; |
q = (d2 * 0xd) >> 7; |
d2 = d2 - 10*q; |
*buf++ = d2 + '0'; |
d3 = q + 4*d3; |
q = (d3 * 0xcd) >> 11; /* - shorter code */ |
/* q = (d3 * 0x67) >> 10; - would also work */ |
d3 = d3 - 10*q; |
*buf++ = d3 + '0'; |
*buf++ = q + '0'; |
return buf; |
} |
/* No inlining helps gcc to use registers better */ |
static char* put_dec(char *buf, unsigned long long num) |
{ |
while (1) { |
unsigned rem; |
if (num < 100000) |
return put_dec_trunc(buf, num); |
rem = do_div(num, 100000); |
buf = put_dec_full(buf, rem); |
} |
} |
#define ZEROPAD 1 /* pad with zero */ |
#define SIGN 2 /* unsigned/signed long */ |
#define PLUS 4 /* show plus */ |
#define SPACE 8 /* space if plus */ |
#define LEFT 16 /* left justified */ |
#define SMALL 32 /* Must be 32 == 0x20 */ |
#define SPECIAL 64 /* 0x */ |
enum format_type { |
FORMAT_TYPE_NONE, /* Just a string part */ |
FORMAT_TYPE_WIDTH, |
FORMAT_TYPE_PRECISION, |
FORMAT_TYPE_CHAR, |
FORMAT_TYPE_STR, |
FORMAT_TYPE_PTR, |
FORMAT_TYPE_PERCENT_CHAR, |
FORMAT_TYPE_INVALID, |
FORMAT_TYPE_LONG_LONG, |
FORMAT_TYPE_ULONG, |
FORMAT_TYPE_LONG, |
FORMAT_TYPE_UBYTE, |
FORMAT_TYPE_BYTE, |
FORMAT_TYPE_USHORT, |
FORMAT_TYPE_SHORT, |
FORMAT_TYPE_UINT, |
FORMAT_TYPE_INT, |
FORMAT_TYPE_NRCHARS, |
FORMAT_TYPE_SIZE_T, |
FORMAT_TYPE_PTRDIFF |
}; |
struct printf_spec { |
enum format_type type; |
int flags; /* flags to number() */ |
int field_width; /* width of output field */ |
int base; |
int precision; /* # of digits/chars */ |
int qualifier; |
}; |
static char *number(char *buf, char *end, unsigned long long num, |
struct printf_spec spec) |
{ |
/* we are called with base 8, 10 or 16, only, thus don't need "G..." */ |
static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */ |
char tmp[66]; |
char sign; |
char locase; |
int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); |
int i; |
/* locase = 0 or 0x20. ORing digits or letters with 'locase' |
* produces same digits or (maybe lowercased) letters */ |
locase = (spec.flags & SMALL); |
if (spec.flags & LEFT) |
spec.flags &= ~ZEROPAD; |
sign = 0; |
if (spec.flags & SIGN) { |
if ((signed long long) num < 0) { |
sign = '-'; |
num = - (signed long long) num; |
spec.field_width--; |
} else if (spec.flags & PLUS) { |
sign = '+'; |
spec.field_width--; |
} else if (spec.flags & SPACE) { |
sign = ' '; |
spec.field_width--; |
} |
} |
if (need_pfx) { |
spec.field_width--; |
if (spec.base == 16) |
spec.field_width--; |
} |
/* generate full string in tmp[], in reverse order */ |
i = 0; |
if (num == 0) |
tmp[i++] = '0'; |
/* Generic code, for any base: |
else do { |
tmp[i++] = (digits[do_div(num,base)] | locase); |
} while (num != 0); |
*/ |
else if (spec.base != 10) { /* 8 or 16 */ |
int mask = spec.base - 1; |
int shift = 3; |
if (spec.base == 16) shift = 4; |
do { |
tmp[i++] = (digits[((unsigned char)num) & mask] | locase); |
num >>= shift; |
} while (num); |
} else { /* base 10 */ |
i = put_dec(tmp, num) - tmp; |
} |
/* printing 100 using %2d gives "100", not "00" */ |
if (i > spec.precision) |
spec.precision = i; |
/* leading space padding */ |
spec.field_width -= spec.precision; |
if (!(spec.flags & (ZEROPAD+LEFT))) { |
while(--spec.field_width >= 0) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
} |
/* sign */ |
if (sign) { |
if (buf < end) |
*buf = sign; |
++buf; |
} |
/* "0x" / "0" prefix */ |
if (need_pfx) { |
if (buf < end) |
*buf = '0'; |
++buf; |
if (spec.base == 16) { |
if (buf < end) |
*buf = ('X' | locase); |
++buf; |
} |
} |
/* zero or space padding */ |
if (!(spec.flags & LEFT)) { |
char c = (spec.flags & ZEROPAD) ? '0' : ' '; |
while (--spec.field_width >= 0) { |
if (buf < end) |
*buf = c; |
++buf; |
} |
} |
/* hmm even more zero padding? */ |
while (i <= --spec.precision) { |
if (buf < end) |
*buf = '0'; |
++buf; |
} |
/* actual digits of result */ |
while (--i >= 0) { |
if (buf < end) |
*buf = tmp[i]; |
++buf; |
} |
/* trailing space padding */ |
while (--spec.field_width >= 0) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
return buf; |
} |
static char *string(char *buf, char *end, char *s, struct printf_spec spec) |
{ |
int len, i; |
if ((unsigned long)s < PAGE_SIZE) |
s = "<NULL>"; |
len = strnlen(s, spec.precision); |
if (!(spec.flags & LEFT)) { |
while (len < spec.field_width--) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
} |
for (i = 0; i < len; ++i) { |
if (buf < end) |
*buf = *s; |
++buf; ++s; |
} |
while (len < spec.field_width--) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
return buf; |
} |
/* |
* Show a '%p' thing. |
*/ |
static char *pointer(const char *fmt, char *buf, char *end, void *ptr, |
struct printf_spec spec) |
{ |
if (!ptr) |
return string(buf, end, "(null)", spec); |
spec.flags |= SMALL; |
if (spec.field_width == -1) { |
spec.field_width = 2*sizeof(void *); |
spec.flags |= ZEROPAD; |
} |
spec.base = 16; |
return number(buf, end, (unsigned long) ptr, spec); |
} |
/* |
* Helper function to decode printf style format. |
* Each call decode a token from the format and return the |
* number of characters read (or likely the delta where it wants |
* to go on the next call). |
* The decoded token is returned through the parameters |
* |
* 'h', 'l', or 'L' for integer fields |
* 'z' support added 23/7/1999 S.H. |
* 'z' changed to 'Z' --davidm 1/25/99 |
* 't' added for ptrdiff_t |
* |
* @fmt: the format string |
* @type of the token returned |
* @flags: various flags such as +, -, # tokens.. |
* @field_width: overwritten width |
* @base: base of the number (octal, hex, ...) |
* @precision: precision of a number |
* @qualifier: qualifier of a number (long, size_t, ...) |
*/ |
static int format_decode(const char *fmt, struct printf_spec *spec) |
{ |
const char *start = fmt; |
/* we finished early by reading the field width */ |
if (spec->type == FORMAT_TYPE_WIDTH) { |
if (spec->field_width < 0) { |
spec->field_width = -spec->field_width; |
spec->flags |= LEFT; |
} |
spec->type = FORMAT_TYPE_NONE; |
goto precision; |
} |
/* we finished early by reading the precision */ |
if (spec->type == FORMAT_TYPE_PRECISION) { |
if (spec->precision < 0) |
spec->precision = 0; |
spec->type = FORMAT_TYPE_NONE; |
goto qualifier; |
} |
/* By default */ |
spec->type = FORMAT_TYPE_NONE; |
for (; *fmt ; ++fmt) { |
if (*fmt == '%') |
break; |
} |
/* Return the current non-format string */ |
if (fmt != start || !*fmt) |
return fmt - start; |
/* Process flags */ |
spec->flags = 0; |
while (1) { /* this also skips first '%' */ |
int found = 1; |
++fmt; |
switch (*fmt) { |
case '-': spec->flags |= LEFT; break; |
case '+': spec->flags |= PLUS; break; |
case ' ': spec->flags |= SPACE; break; |
case '#': spec->flags |= SPECIAL; break; |
case '0': spec->flags |= ZEROPAD; break; |
default: found = 0; |
} |
if (!found) |
break; |
} |
/* get field width */ |
spec->field_width = -1; |
if (isdigit(*fmt)) |
spec->field_width = skip_atoi(&fmt); |
else if (*fmt == '*') { |
/* it's the next argument */ |
spec->type = FORMAT_TYPE_WIDTH; |
return ++fmt - start; |
} |
precision: |
/* get the precision */ |
spec->precision = -1; |
if (*fmt == '.') { |
++fmt; |
if (isdigit(*fmt)) { |
spec->precision = skip_atoi(&fmt); |
if (spec->precision < 0) |
spec->precision = 0; |
} else if (*fmt == '*') { |
/* it's the next argument */ |
spec->type = FORMAT_TYPE_PRECISION; |
return ++fmt - start; |
} |
} |
qualifier: |
/* get the conversion qualifier */ |
spec->qualifier = -1; |
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || |
*fmt == 'Z' || *fmt == 'z' || *fmt == 't') { |
spec->qualifier = *fmt++; |
if (unlikely(spec->qualifier == *fmt)) { |
if (spec->qualifier == 'l') { |
spec->qualifier = 'L'; |
++fmt; |
} else if (spec->qualifier == 'h') { |
spec->qualifier = 'H'; |
++fmt; |
} |
} |
} |
/* default base */ |
spec->base = 10; |
switch (*fmt) { |
case 'c': |
spec->type = FORMAT_TYPE_CHAR; |
return ++fmt - start; |
case 's': |
spec->type = FORMAT_TYPE_STR; |
return ++fmt - start; |
case 'p': |
spec->type = FORMAT_TYPE_PTR; |
return fmt - start; |
/* skip alnum */ |
case 'n': |
spec->type = FORMAT_TYPE_NRCHARS; |
return ++fmt - start; |
case '%': |
spec->type = FORMAT_TYPE_PERCENT_CHAR; |
return ++fmt - start; |
/* integer number formats - set up the flags and "break" */ |
case 'o': |
spec->base = 8; |
break; |
case 'x': |
spec->flags |= SMALL; |
case 'X': |
spec->base = 16; |
break; |
case 'd': |
case 'i': |
spec->flags |= SIGN; |
case 'u': |
break; |
default: |
spec->type = FORMAT_TYPE_INVALID; |
return fmt - start; |
} |
if (spec->qualifier == 'L') |
spec->type = FORMAT_TYPE_LONG_LONG; |
else if (spec->qualifier == 'l') { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_LONG; |
else |
spec->type = FORMAT_TYPE_ULONG; |
} else if (spec->qualifier == 'Z' || spec->qualifier == 'z') { |
spec->type = FORMAT_TYPE_SIZE_T; |
} else if (spec->qualifier == 't') { |
spec->type = FORMAT_TYPE_PTRDIFF; |
} else if (spec->qualifier == 'H') { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_BYTE; |
else |
spec->type = FORMAT_TYPE_UBYTE; |
} else if (spec->qualifier == 'h') { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_SHORT; |
else |
spec->type = FORMAT_TYPE_USHORT; |
} else { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_INT; |
else |
spec->type = FORMAT_TYPE_UINT; |
} |
return ++fmt - start; |
} |
/** |
* vsnprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @size: The size of the buffer, including the trailing null space |
* @fmt: The format string to use |
* @args: Arguments for the format string |
* |
* |
* The return value is the number of characters which would |
* be generated for the given input, excluding the trailing |
* '\0', as per ISO C99. If you want to have the exact |
* number of characters written into @buf as return value |
* (not including the trailing '\0'), use vscnprintf(). If the |
* return is greater than or equal to @size, the resulting |
* string is truncated. |
* |
* Call this function if you are already dealing with a va_list. |
* You probably want snprintf() instead. |
*/ |
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) |
{ |
unsigned long long num; |
char *str, *end, c; |
int read; |
struct printf_spec spec = {0}; |
/* Reject out-of-range values early. Large positive sizes are |
used for unknown buffer sizes. */ |
if (unlikely((int) size < 0)) { |
/* There can be only one.. */ |
static char warn = 1; |
// WARN_ON(warn); |
warn = 0; |
return 0; |
} |
str = buf; |
end = buf + size; |
/* Make sure end is always >= buf */ |
if (end < buf) { |
end = ((void *)-1); |
size = end - buf; |
} |
while (*fmt) { |
const char *old_fmt = fmt; |
read = format_decode(fmt, &spec); |
fmt += read; |
switch (spec.type) { |
case FORMAT_TYPE_NONE: { |
int copy = read; |
if (str < end) { |
if (copy > end - str) |
copy = end - str; |
memcpy(str, old_fmt, copy); |
} |
str += read; |
break; |
} |
case FORMAT_TYPE_WIDTH: |
spec.field_width = va_arg(args, int); |
break; |
case FORMAT_TYPE_PRECISION: |
spec.precision = va_arg(args, int); |
break; |
case FORMAT_TYPE_CHAR: |
if (!(spec.flags & LEFT)) { |
while (--spec.field_width > 0) { |
if (str < end) |
*str = ' '; |
++str; |
} |
} |
c = (unsigned char) va_arg(args, int); |
if (str < end) |
*str = c; |
++str; |
while (--spec.field_width > 0) { |
if (str < end) |
*str = ' '; |
++str; |
} |
break; |
case FORMAT_TYPE_STR: |
str = string(str, end, va_arg(args, char *), spec); |
break; |
case FORMAT_TYPE_PTR: |
str = pointer(fmt+1, str, end, va_arg(args, void *), |
spec); |
while (isalnum(*fmt)) |
fmt++; |
break; |
case FORMAT_TYPE_PERCENT_CHAR: |
if (str < end) |
*str = '%'; |
++str; |
break; |
case FORMAT_TYPE_INVALID: |
if (str < end) |
*str = '%'; |
++str; |
break; |
case FORMAT_TYPE_NRCHARS: { |
int qualifier = spec.qualifier; |
if (qualifier == 'l') { |
long *ip = va_arg(args, long *); |
*ip = (str - buf); |
} else if (qualifier == 'Z' || |
qualifier == 'z') { |
size_t *ip = va_arg(args, size_t *); |
*ip = (str - buf); |
} else { |
int *ip = va_arg(args, int *); |
*ip = (str - buf); |
} |
break; |
} |
default: |
switch (spec.type) { |
case FORMAT_TYPE_LONG_LONG: |
num = va_arg(args, long long); |
break; |
case FORMAT_TYPE_ULONG: |
num = va_arg(args, unsigned long); |
break; |
case FORMAT_TYPE_LONG: |
num = va_arg(args, long); |
break; |
case FORMAT_TYPE_SIZE_T: |
num = va_arg(args, size_t); |
break; |
// case FORMAT_TYPE_PTRDIFF: |
// num = va_arg(args, ptrdiff_t); |
// break; |
case FORMAT_TYPE_UBYTE: |
num = (unsigned char) va_arg(args, int); |
break; |
case FORMAT_TYPE_BYTE: |
num = (signed char) va_arg(args, int); |
break; |
case FORMAT_TYPE_USHORT: |
num = (unsigned short) va_arg(args, int); |
break; |
case FORMAT_TYPE_SHORT: |
num = (short) va_arg(args, int); |
break; |
case FORMAT_TYPE_INT: |
num = (int) va_arg(args, int); |
break; |
default: |
num = va_arg(args, unsigned int); |
} |
str = number(str, end, num, spec); |
} |
} |
if (size > 0) { |
if (str < end) |
*str = '\0'; |
else |
end[-1] = '\0'; |
} |
/* the trailing null byte doesn't count towards the total */ |
return str-buf; |
} |
/** |
* snprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @size: The size of the buffer, including the trailing null space |
* @fmt: The format string to use |
* @...: Arguments for the format string |
* |
* The return value is the number of characters which would be |
* generated for the given input, excluding the trailing null, |
* as per ISO C99. If the return is greater than or equal to |
* @size, the resulting string is truncated. |
* |
* See the vsnprintf() documentation for format string extensions over C99. |
*/ |
int snprintf(char * buf, size_t size, const char *fmt, ...) |
{ |
va_list args; |
int i; |
va_start(args, fmt); |
i=vsnprintf(buf,size,fmt,args); |
va_end(args); |
return i; |
} |
/** |
* scnprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @size: The size of the buffer, including the trailing null space |
* @fmt: The format string to use |
* @...: Arguments for the format string |
* |
* The return value is the number of characters written into @buf not including |
* the trailing '\0'. If @size is <= 0 the function returns 0. |
*/ |
int scnprintf(char * buf, size_t size, const char *fmt, ...) |
{ |
va_list args; |
int i; |
va_start(args, fmt); |
i = vsnprintf(buf, size, fmt, args); |
va_end(args); |
return (i >= size) ? (size - 1) : i; |
} |
/** |
* vsprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @fmt: The format string to use |
* @args: Arguments for the format string |
* |
* The function returns the number of characters written |
* into @buf. Use vsnprintf() or vscnprintf() in order to avoid |
* buffer overflows. |
* |
* Call this function if you are already dealing with a va_list. |
* You probably want sprintf() instead. |
* |
* See the vsnprintf() documentation for format string extensions over C99. |
*/ |
int vsprintf(char *buf, const char *fmt, va_list args) |
{ |
return vsnprintf(buf, __INT_MAX__, fmt, args); |
} |
/** |
* sprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @fmt: The format string to use |
* @...: Arguments for the format string |
* |
* The function returns the number of characters written |
* into @buf. Use snprintf() or scnprintf() in order to avoid |
* buffer overflows. |
* |
* See the vsnprintf() documentation for format string extensions over C99. |
*/ |
int sprintf(char * buf, const char *fmt, ...) |
{ |
va_list args; |
int i; |
va_start(args, fmt); |
i=vsnprintf(buf, __INT_MAX__, fmt, args); |
va_end(args); |
return i; |
} |
static inline |
void api_putc(char c) |
{ |
if (c == '\n') api_putc('\r'); |
__asm__ __volatile__( |
"int $0x40" |
::"a"(63),"b"(1),"c"(c)); |
} |
int API print(const char *fmt,...) |
{ |
char buf[256]; |
va_list args; |
int retval; |
int i; |
va_start(args, fmt); |
i = vsnprintf(buf, 256, fmt, args); |
va_end(args); |
retval = (i >= 256) ? (256 - 1) : i; |
for(i = 0; i< retval; i++) |
api_putc(buf[i]); |
return retval; |
}; |
#if 0 |
/** |
* vsscanf - Unformat a buffer into a list of arguments |
* @buf: input buffer |
* @fmt: format of buffer |
* @args: arguments |
*/ |
int vsscanf(const char * buf, const char * fmt, va_list args) |
{ |
const char *str = buf; |
char *next; |
char digit; |
int num = 0; |
int qualifier; |
int base; |
int field_width; |
int is_sign = 0; |
while(*fmt && *str) { |
/* skip any white space in format */ |
/* white space in format matchs any amount of |
* white space, including none, in the input. |
*/ |
if (isspace(*fmt)) { |
while (isspace(*fmt)) |
++fmt; |
while (isspace(*str)) |
++str; |
} |
/* anything that is not a conversion must match exactly */ |
if (*fmt != '%' && *fmt) { |
if (*fmt++ != *str++) |
break; |
continue; |
} |
if (!*fmt) |
break; |
++fmt; |
/* skip this conversion. |
* advance both strings to next white space |
*/ |
if (*fmt == '*') { |
while (!isspace(*fmt) && *fmt) |
fmt++; |
while (!isspace(*str) && *str) |
str++; |
continue; |
} |
/* get field width */ |
field_width = -1; |
if (isdigit(*fmt)) |
field_width = skip_atoi(&fmt); |
/* get conversion qualifier */ |
qualifier = -1; |
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || |
*fmt == 'Z' || *fmt == 'z') { |
qualifier = *fmt++; |
if (unlikely(qualifier == *fmt)) { |
if (qualifier == 'h') { |
qualifier = 'H'; |
fmt++; |
} else if (qualifier == 'l') { |
qualifier = 'L'; |
fmt++; |
} |
} |
} |
base = 10; |
is_sign = 0; |
if (!*fmt || !*str) |
break; |
switch(*fmt++) { |
case 'c': |
{ |
char *s = (char *) va_arg(args,char*); |
if (field_width == -1) |
field_width = 1; |
do { |
*s++ = *str++; |
} while (--field_width > 0 && *str); |
num++; |
} |
continue; |
case 's': |
{ |
char *s = (char *) va_arg(args, char *); |
if(field_width == -1) |
field_width = INT_MAX; |
/* first, skip leading white space in buffer */ |
while (isspace(*str)) |
str++; |
/* now copy until next white space */ |
while (*str && !isspace(*str) && field_width--) { |
*s++ = *str++; |
} |
*s = '\0'; |
num++; |
} |
continue; |
case 'n': |
/* return number of characters read so far */ |
{ |
int *i = (int *)va_arg(args,int*); |
*i = str - buf; |
} |
continue; |
case 'o': |
base = 8; |
break; |
case 'x': |
case 'X': |
base = 16; |
break; |
case 'i': |
base = 0; |
case 'd': |
is_sign = 1; |
case 'u': |
break; |
case '%': |
/* looking for '%' in str */ |
if (*str++ != '%') |
return num; |
continue; |
default: |
/* invalid format; stop here */ |
return num; |
} |
/* have some sort of integer conversion. |
* first, skip white space in buffer. |
*/ |
while (isspace(*str)) |
str++; |
digit = *str; |
if (is_sign && digit == '-') |
digit = *(str + 1); |
if (!digit |
|| (base == 16 && !isxdigit(digit)) |
|| (base == 10 && !isdigit(digit)) |
|| (base == 8 && (!isdigit(digit) || digit > '7')) |
|| (base == 0 && !isdigit(digit))) |
break; |
switch(qualifier) { |
case 'H': /* that's 'hh' in format */ |
if (is_sign) { |
signed char *s = (signed char *) va_arg(args,signed char *); |
*s = (signed char) simple_strtol(str,&next,base); |
} else { |
unsigned char *s = (unsigned char *) va_arg(args, unsigned char *); |
*s = (unsigned char) simple_strtoul(str, &next, base); |
} |
break; |
case 'h': |
if (is_sign) { |
short *s = (short *) va_arg(args,short *); |
*s = (short) simple_strtol(str,&next,base); |
} else { |
unsigned short *s = (unsigned short *) va_arg(args, unsigned short *); |
*s = (unsigned short) simple_strtoul(str, &next, base); |
} |
break; |
case 'l': |
if (is_sign) { |
long *l = (long *) va_arg(args,long *); |
*l = simple_strtol(str,&next,base); |
} else { |
unsigned long *l = (unsigned long*) va_arg(args,unsigned long*); |
*l = simple_strtoul(str,&next,base); |
} |
break; |
case 'L': |
if (is_sign) { |
long long *l = (long long*) va_arg(args,long long *); |
*l = simple_strtoll(str,&next,base); |
} else { |
unsigned long long *l = (unsigned long long*) va_arg(args,unsigned long long*); |
*l = simple_strtoull(str,&next,base); |
} |
break; |
case 'Z': |
case 'z': |
{ |
size_t *s = (size_t*) va_arg(args,size_t*); |
*s = (size_t) simple_strtoul(str,&next,base); |
} |
break; |
default: |
if (is_sign) { |
int *i = (int *) va_arg(args, int*); |
*i = (int) simple_strtol(str,&next,base); |
} else { |
unsigned int *i = (unsigned int*) va_arg(args, unsigned int*); |
*i = (unsigned int) simple_strtoul(str,&next,base); |
} |
break; |
} |
num++; |
if (!next) |
break; |
str = next; |
} |
/* |
* Now we've come all the way through so either the input string or the |
* format ended. In the former case, there can be a %n at the current |
* position in the format that needs to be filled. |
*/ |
if (*fmt == '%' && *(fmt + 1) == 'n') { |
int *p = (int *)va_arg(args, int *); |
*p = str - buf; |
} |
return num; |
} |
#endif |
/programs/develop/libraries/newlib/string |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/tests/error.c |
---|
0,0 → 1,117 |
/* Error handler for noninteractive utilities |
Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc. |
This file is part of the GNU C Library. |
The GNU C 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. |
The GNU C 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 the GNU C Library; if not, write to the Free |
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
02111-1307 USA. */ |
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ |
#include <stdarg.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <errno.h> |
#include "error.h" |
/* This variable is incremented each time `error' is called. */ |
unsigned int error_message_count; |
char *strerror_r (); |
/* The calling program should define program_name and set it to the |
name of the executing program. */ |
//extern char *program_name; |
static void |
print_errno_message (int errnum) |
{ |
char const *s; |
s = strerror (errnum); |
fprintf (stderr, ": %s", s); |
} |
static void |
error_tail (int status, int errnum, const char *message, va_list args) |
{ |
vfprintf (stderr, message, args); |
va_end (args); |
++error_message_count; |
if (errnum) |
print_errno_message (errnum); |
putc ('\n', stderr); |
fflush (stderr); |
if (status) |
exit (status); |
} |
/* Print the program name and error message MESSAGE, which is a printf-style |
format string with optional args. |
If ERRNUM is nonzero, print its corresponding system error message. |
Exit with status STATUS if it is nonzero. */ |
void |
error (int status, int errnum, const char *message, ...) |
{ |
va_list args; |
// fflush (stdout); |
// fprintf (stderr, "%s: ", program_name); |
va_start (args, message); |
error_tail (status, errnum, message, args); |
}; |
/* Sometimes we want to have at most one error per line. This |
variable controls whether this mode is selected or not. */ |
int error_one_per_line; |
void |
error_at_line (int status, int errnum, const char *file_name, |
unsigned int line_number, const char *message, ...) |
{ |
va_list args; |
if (error_one_per_line) |
{ |
static const char *old_file_name; |
static unsigned int old_line_number; |
if (old_line_number == line_number |
&& (file_name == old_file_name |
|| strcmp (old_file_name, file_name) == 0)) |
/* Simply return and print nothing. */ |
return; |
old_file_name = file_name; |
old_line_number = line_number; |
} |
// fflush (stdout); |
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", |
file_name, line_number); |
va_start (args, message); |
error_tail (status, errnum, message, args); |
} |
/programs/develop/libraries/newlib/tests/error.h |
---|
0,0 → 1,47 |
/* Declaration for error-reporting function |
Copyright (C) 1995,1996,1997,2003,2006,2007 Free Software Foundation, Inc. |
This file is part of the GNU C Library. |
The GNU C 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. |
The GNU C 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 the GNU C Library; if not, write to the Free |
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
02111-1307 USA. */ |
#ifndef _ERROR_H |
#define _ERROR_H 1 |
/* Print a message with `fprintf (stderr, FORMAT, ...)'; |
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). |
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ |
extern void error (int __status, int __errnum, __const char *__format, ...) |
__attribute__ ((__format__ (__printf__, 3, 4))); |
extern void error_at_line (int __status, int __errnum, __const char *__fname, |
unsigned int __lineno, __const char *__format, ...) |
__attribute__ ((__format__ (__printf__, 5, 6))); |
/* If NULL, error will flush stdout, then print on stderr the program |
name, a colon and a space. Otherwise, error will call this |
function without parameters instead. */ |
extern void (*error_print_progname) (void); |
/* This variable is incremented each time `error' is called. */ |
extern unsigned int error_message_count; |
/* Sometimes we want to have at most one error per line. This |
variable controls whether this mode is selected or not. */ |
extern int error_one_per_line; |
#endif /* error.h */ |
/programs/develop/libraries/newlib/tests/tst-calloc.c |
---|
0,0 → 1,126 |
/* Copyright (C) 2000, 2002 Free Software Foundation, Inc. |
This file is part of the GNU C Library. |
Contributed by Ulrich Drepper <drepper@redhat.com>. |
The GNU C 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. |
The GNU C 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 the GNU C Library; if not, write to the Free |
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
02111-1307 USA. */ |
#include <errno.h> |
#include <error.h> |
#include <limits.h> |
#include <malloc.h> |
#include <stdlib.h> |
#include <stdio.h> |
/* Number of samples per size. */ |
#define N 50000 |
static void |
fixed_test (int size) |
{ |
char *ptrs[N]; |
int i; |
for (i = 0; i < N; ++i) |
{ |
int j; |
ptrs[i] = (char *) calloc (1, size); |
if (ptrs[i] == NULL) |
break; |
for (j = 0; j < size; ++j) |
{ |
if (ptrs[i][j] != '\0') |
error (EXIT_FAILURE, 0, |
"byte not cleared (size %d, element %d, byte %d)", |
size, i, j); |
ptrs[i][j] = '\xff'; |
} |
} |
while (i-- > 0) |
free (ptrs[i]); |
} |
static void |
random_test (void) |
{ |
char *ptrs[N]; |
int i; |
for (i = 0; i < N; ++i) |
{ |
int j; |
int n = 1 + random () % 10; |
int elem = 1 + random () % 100; |
int size = n * elem; |
ptrs[i] = (char *) calloc (n, elem); |
if (ptrs[i] == NULL) |
break; |
for (j = 0; j < size; ++j) |
{ |
if (ptrs[i][j] != '\0') |
error (EXIT_FAILURE, 0, |
"byte not cleared (size %d, element %d, byte %d)", |
size, i, j); |
ptrs[i][j] = '\xff'; |
} |
} |
while (i-- > 0) |
free (ptrs[i]); |
} |
static void |
null_test (void) |
{ |
/* If the size is 0 the result is implementation defined. Just make |
sure the program doesn't crash. */ |
calloc (0, 0); |
calloc (0, UINT_MAX); |
calloc (UINT_MAX, 0); |
calloc (0, ~((size_t) 0)); |
calloc (~((size_t) 0), 0); |
} |
int |
main (void) |
{ |
/* We are allocating blocks with `calloc' and check whether every |
block is completely cleared. We first try this for some fixed |
times and then with random size. */ |
fixed_test (15); |
fixed_test (5); |
fixed_test (17); |
fixed_test (6); |
fixed_test (31); |
fixed_test (96); |
random_test (); |
null_test (); |
return 0; |
} |
/programs/develop/libraries/newlib/tests |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib/unpack/unpacker.asm |
---|
0,0 → 1,532 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format MS COFF |
section '.text' code readable align 16 |
public _unpack@8 |
; void __stdcall unpack(void* packed_data, void* unpacked_data); |
_unpack@8: |
unpack: |
pushad |
mov esi, [esp+32+4] |
mov edi, [esp+32+8] |
mov eax, [esi+8] |
and al, 0xC0 |
cmp al, 0xC0 |
jz .failed |
mov eax, [esi+8] |
push eax |
add esi, 12 |
and al, not 0xC0 |
dec eax |
jz .lzma |
.failed: |
pop eax |
popad |
ret 8 |
.lzma: |
call .lzma_unpack |
.common: |
pop eax |
test al, 0x80 |
jnz .ctr1 |
test al, 0x40 |
jz .ok |
lodsd |
mov ecx, eax |
jecxz .ok |
mov dl, [esi] |
mov esi, [esp+32+8] |
.c1: |
lodsb |
sub al, 0E8h |
cmp al, 1 |
ja .c1 |
cmp byte [esi], dl |
jnz .c1 |
lodsd |
; "bswap eax" is not supported on i386 |
shr ax, 8 |
ror eax, 16 |
xchg al, ah |
sub eax, esi |
add eax, [esp+32+8] |
mov [esi-4], eax |
loop .c1 |
.ok: |
popad |
ret 8 |
.ctr1: |
lodsd |
mov ecx, eax |
jecxz .ok |
mov dl, [esi] |
mov esi, [esp+32+8] |
.c2: |
lodsb |
@@: |
cmp al, 0xF |
jnz .f |
lodsb |
cmp al, 80h |
jb @b |
cmp al, 90h |
jb @f |
.f: |
sub al, 0E8h |
cmp al, 1 |
ja .c2 |
@@: |
cmp byte [esi], dl |
jnz .c2 |
lodsd |
shr ax, 8 |
ror eax, 16 |
xchg al, ah |
sub eax, esi |
add eax, [esp+32+8] |
mov [esi-4], eax |
loop .c2 |
jmp .ok |
.lzma_unpack: |
.pb = 2 ; pos state bits |
.lp = 0 ; literal pos state bits |
.lc = 3 ; literal context bits |
.posStateMask = ((1 shl .pb)-1) |
.literalPosMask = ((1 shl .lp)-1) |
.kNumPosBitsMax = 4 |
.kNumPosStatesMax = (1 shl .kNumPosBitsMax) |
.kLenNumLowBits = 3 |
.kLenNumLowSymbols = (1 shl .kLenNumLowBits) |
.kLenNumMidBits = 3 |
.kLenNumMidSymbols = (1 shl .kLenNumMidBits) |
.kLenNumHighBits = 8 |
.kLenNumHighSymbols = (1 shl .kLenNumHighBits) |
.LenChoice = 0 |
.LenChoice2 = 1 |
.LenLow = 2 |
.LenMid = (.LenLow + (.kNumPosStatesMax shl .kLenNumLowBits)) |
.LenHigh = (.LenMid + (.kNumPosStatesMax shl .kLenNumMidBits)) |
.kNumLenProbs = (.LenHigh + .kLenNumHighSymbols) |
.kNumStates = 12 |
.kNumLitStates = 7 |
.kStartPosModelIndex = 4 |
.kEndPosModelIndex = 14 |
.kNumFullDistances = (1 shl (.kEndPosModelIndex/2)) |
.kNumPosSlotBits = 6 |
.kNumLenToPosStates = 4 |
.kNumAlignBits = 4 |
.kAlignTableSize = (1 shl .kNumAlignBits) |
.kMatchMinLen = 2 |
.IsMatch = 0 |
.IsRep = (.IsMatch + (.kNumStates shl .kNumPosBitsMax)) |
.IsRepG0 = (.IsRep + .kNumStates) |
.IsRepG1 = (.IsRepG0 + .kNumStates) |
.IsRepG2 = (.IsRepG1 + .kNumStates) |
.IsRep0Long = (.IsRepG2 + .kNumStates) |
.PosSlot = (.IsRep0Long + (.kNumStates shl .kNumPosBitsMax)) |
.SpecPos = (.PosSlot + (.kNumLenToPosStates shl .kNumPosSlotBits)) |
.Align_ = (.SpecPos + .kNumFullDistances - .kEndPosModelIndex) |
.Lencoder = (.Align_ + .kAlignTableSize) |
.RepLencoder = (.Lencoder + .kNumLenProbs) |
.Literal = (.RepLencoder + .kNumLenProbs) |
.LZMA_BASE_SIZE = 1846 ; must be ==Literal |
.LZMA_LIT_SIZE = 768 |
.kNumTopBits = 24 |
.kTopValue = (1 shl .kNumTopBits) |
.kNumBitModelTotalBits = 11 |
.kBitModelTotal = (1 shl .kNumBitModelTotalBits) |
.kNumMoveBits = 5 |
push edi |
; int state=0; |
xor ebx, ebx |
mov [.previousByte], bl |
; unsigned rep0=1,rep1=1,rep2=1,rep3=1; |
mov eax, 1 |
mov edi, .rep0 |
stosd |
stosd |
stosd |
stosd |
; int len=0; |
; result=0; |
mov ecx, .Literal + (.LZMA_LIT_SIZE shl (.lc+.lp)) |
mov eax, .kBitModelTotal/2 |
lea edi, [.p] |
rep stosd |
; RangeDecoderInit |
; rd->ExtraBytes = 0 |
; rd->Buffer = stream |
; rd->BufferLim = stream+bufferSize |
; rd->Range = 0xFFFFFFFF |
pop edi |
mov ebp, [esi-8] ; dest_length |
add ebp, edi ; ebp = destination limit |
lodsd |
; rd->code_ = eax |
mov [.code_], eax |
or [.range], -1 |
.main_loop: |
cmp edi, ebp |
jae .main_loop_done |
mov edx, edi |
and edx, .posStateMask |
mov eax, ebx |
shl eax, .kNumPosBitsMax+2 |
lea eax, [.p+.IsMatch*4 + eax + edx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jc .1 |
movzx eax, [.previousByte] |
if .literalPosMask |
mov ah, dl |
and ah, .literalPosMask |
end if |
shr eax, 8-.lc |
imul eax, .LZMA_LIT_SIZE*4 |
add eax, (.p+.Literal*4) |
; add eax, [.p] |
cmp ebx, .kNumLitStates |
jb .literal |
xor edx, edx |
sub edx, [.rep0] |
mov dl, [edi + edx] |
call .LzmaLiteralDecodeMatch |
jmp @f |
.literal: |
call .LzmaLiteralDecode |
@@: |
mov [.previousByte], al |
stosb |
mov al, bl |
cmp bl, 4 |
jb @f |
mov al, 3 |
cmp bl, 10 |
jb @f |
mov al, 6 |
@@: sub bl, al |
jmp .main_loop |
.1: |
lea eax, [.p+.IsRep*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jnc .10 |
lea eax, [.p+.IsRepG0*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jc .111 |
mov eax, ebx |
shl eax, .kNumPosBitsMax+2 |
lea eax, [.p+.IsRep0Long*4 + eax + edx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jc .1101 |
cmp bl, 7 |
setae bl |
lea ebx, [9 + ebx + ebx] |
xor edx, edx |
sub edx, [.rep0] |
mov al, [edi + edx] |
stosb |
mov [.previousByte], al |
jmp .main_loop |
.111: |
lea eax, [.p+.IsRepG1*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
mov eax, [.rep1] |
jnc .l3 |
.l1: |
lea eax, [.p+.IsRepG2*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
mov eax, [.rep2] |
jnc .l2 |
xchg [.rep3], eax |
.l2: |
push [.rep1] |
pop [.rep2] |
.l3: |
xchg eax, [.rep0] |
mov [.rep1], eax |
.1101: |
mov eax, (.p+.RepLencoder*4) |
; add eax, [.p] |
call .LzmaLenDecode |
cmp bl, 7 |
setc bl |
adc bl, bl |
xor bl, 3 |
add bl, 8 |
jmp .repmovsb |
.10: |
mov eax, [.rep0] |
xchg eax, [.rep1] |
xchg eax, [.rep2] |
xchg eax, [.rep3] |
cmp bl, 7 |
setc bl |
adc bl, bl |
xor bl, 3 |
add bl, 7 |
mov eax, (.p+.Lencoder*4) |
; add eax, [.p] |
call .LzmaLenDecode |
mov eax, .kNumLenToPosStates-1 |
cmp eax, ecx |
jb @f |
mov eax, ecx |
@@: |
push ecx |
mov ecx, .kNumPosSlotBits |
shl eax, cl |
shl eax, 2 |
add eax, (.p+.PosSlot*4) |
; add eax, [.p] |
call .RangeDecoderBitTreeDecode |
mov [.rep0], ecx |
cmp ecx, .kStartPosModelIndex |
jb .l6 |
push ecx |
mov eax, ecx |
and eax, 1 |
shr ecx, 1 |
or eax, 2 |
dec ecx |
shl eax, cl |
mov [.rep0], eax |
pop edx |
cmp edx, .kEndPosModelIndex |
jae .l5 |
sub eax, edx |
shl eax, 2 |
add eax, (.p+(.SpecPos - 1)*4) |
; add eax, [.p] |
call .RangeDecoderReverseBitTreeDecode |
add [.rep0], ecx |
jmp .l6 |
.l5: |
sub ecx, .kNumAlignBits |
call .RangeDecoderDecodeDirectBits |
mov ecx, .kNumAlignBits |
shl eax, cl |
add [.rep0], eax |
mov eax, (.p+.Align_*4) |
; add eax, [.p] |
call .RangeDecoderReverseBitTreeDecode |
add [.rep0], ecx |
.l6: |
pop ecx |
inc [.rep0] |
jz .main_loop_done |
.repmovsb: |
add ecx, .kMatchMinLen |
push esi |
mov esi, edi |
sub esi, [.rep0] |
rep movsb |
pop esi |
mov al, [edi-1] |
mov [.previousByte], al |
jmp .main_loop |
.main_loop_done: |
ret |
.RangeDecoderBitDecode: |
; in: eax->prob |
; out: CF=bit; destroys eax |
push edx |
mov edx, [.range] |
shr edx, .kNumBitModelTotalBits |
imul edx, [eax] |
cmp [.code_], edx |
jae .ae |
mov [.range], edx |
mov edx, .kBitModelTotal |
sub edx, [eax] |
shr edx, .kNumMoveBits |
add [eax], edx |
clc |
.n: |
lahf |
cmp [.range], .kTopValue |
jae @f |
shl [.range], 8 |
shl [.code_], 8 |
lodsb |
mov byte [.code_], al |
@@: |
sahf |
pop edx |
ret |
.ae: |
sub [.range], edx |
sub [.code_], edx |
mov edx, [eax] |
shr edx, .kNumMoveBits |
sub [eax], edx |
stc |
jmp .n |
.RangeDecoderDecodeDirectBits: |
; in: ecx=numTotalBits |
; out: eax=result; destroys edx |
xor eax, eax |
.l: |
shr [.range], 1 |
shl eax, 1 |
mov edx, [.code_] |
sub edx, [.range] |
jb @f |
mov [.code_], edx |
or eax, 1 |
@@: |
cmp [.range], .kTopValue |
jae @f |
shl [.range], 8 |
shl [.code_], 8 |
push eax |
lodsb |
mov byte [.code_], al |
pop eax |
@@: |
loop .l |
ret |
.LzmaLiteralDecode: |
; in: eax->probs |
; out: al=byte; destroys edx |
push ecx |
mov ecx, 1 |
@@: |
push eax |
lea eax, [eax+ecx*4] |
call .RangeDecoderBitDecode |
pop eax |
adc cl, cl |
jnc @b |
.LzmaLiteralDecode.ret: |
mov al, cl |
pop ecx |
ret |
.LzmaLiteralDecodeMatch: |
; in: eax->probs, dl=matchByte |
; out: al=byte; destroys edx |
push ecx |
mov ecx, 1 |
.LzmaLiteralDecodeMatch.1: |
add dl, dl |
setc ch |
push eax |
lea eax, [eax+ecx*4+0x100*4] |
call .RangeDecoderBitDecode |
pop eax |
adc cl, cl |
jc .LzmaLiteralDecode.ret |
xor ch, cl |
test ch, 1 |
mov ch, 0 |
jnz @b |
jmp .LzmaLiteralDecodeMatch.1 |
.LzmaLenDecode: |
; in: eax->prob, edx=posState |
; out: ecx=len |
push eax |
add eax, .LenChoice*4 |
call .RangeDecoderBitDecode |
pop eax |
jnc .0 |
push eax |
add eax, .LenChoice2*4 |
call .RangeDecoderBitDecode |
pop eax |
jc @f |
mov ecx, .kLenNumMidBits |
shl edx, cl |
lea eax, [eax + .LenMid*4 + edx*4] |
call .RangeDecoderBitTreeDecode |
add ecx, .kLenNumLowSymbols |
ret |
@@: |
add eax, .LenHigh*4 |
mov ecx, .kLenNumHighBits |
call .RangeDecoderBitTreeDecode |
add ecx, .kLenNumLowSymbols + .kLenNumMidSymbols |
ret |
.0: |
mov ecx, .kLenNumLowBits |
shl edx, cl |
lea eax, [eax + .LenLow*4 + edx*4] |
.RangeDecoderBitTreeDecode: |
; in: eax->probs,ecx=numLevels |
; out: ecx=length; destroys edx |
push ebx |
mov edx, 1 |
mov ebx, edx |
@@: |
push eax |
lea eax, [eax+edx*4] |
call .RangeDecoderBitDecode |
pop eax |
adc dl, dl |
add bl, bl |
loop @b |
sub dl, bl |
pop ebx |
mov ecx, edx |
ret |
.RangeDecoderReverseBitTreeDecode: |
; in: eax->probs,ecx=numLevels |
; out: ecx=length; destroys edx |
push ebx ecx |
mov edx, 1 |
xor ebx, ebx |
@@: |
push eax |
lea eax, [eax+edx*4] |
call .RangeDecoderBitDecode |
lahf |
adc edx, edx |
sahf |
rcr ebx, 1 |
pop eax |
loop @b |
pop ecx |
rol ebx, cl |
mov ecx, ebx |
pop ebx |
ret |
section ".bss" data readable writeable align 16 |
unpack.p rd (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl (unpack.lc+unpack.lp)))*2 |
align 4 |
unpack.code_ dd ? |
unpack.range dd ? |
unpack.rep0 dd ? |
unpack.rep1 dd ? |
unpack.rep2 dd ? |
unpack.rep3 dd ? |
unpack.previousByte db ? |
/programs/develop/libraries/newlib/unpack |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |
/programs/develop/libraries/newlib |
---|
Property changes: |
Added: tsvn:logminsize |
+5 |
\ No newline at end of property |