/programs/develop/ktcc/trunk/libc/include/ctype.h |
---|
4,31 → 4,31 |
** dependable answers. |
*/ |
#define ALNUM 1 |
#define ALPHA 2 |
#define CNTRL 4 |
#define DIGIT 8 |
#define GRAPH 16 |
#define LOWER 32 |
#define PRINT 64 |
#define PUNCT 128 |
#define BLANK 256 |
#define UPPER 512 |
#define XDIGIT 1024 |
#define __ALNUM 1 |
#define __ALPHA 2 |
#define __CNTRL 4 |
#define __DIGIT 8 |
#define __GRAPH 16 |
#define __LOWER 32 |
#define __PRINT 64 |
#define __PUNCT 128 |
#define __BLANK 256 |
#define __UPPER 512 |
#define __XDIGIT 1024 |
extern char _is[128]; |
extern char __is[128]; |
#define isalnum(c)(_is[c] & ALNUM ) /* 'a'-'z', 'A'-'Z', '0'-'9' */ |
#define isalpha(c)(_is[c] & ALPHA ) /* 'a'-'z', 'A'-'Z' */ |
#define iscntrl(c)(_is[c] & CNTRL ) /* 0-31, 127 */ |
#define isdigit(c)(_is[c] & DIGIT ) /* '0'-'9' */ |
#define isgraph(c)(_is[c] & GRAPH ) /* '!'-'~' */ |
#define islower(c)(_is[c] & LOWER ) /* 'a'-'z' */ |
#define isprint(c)(_is[c] & PRINT ) /* ' '-'~' */ |
#define ispunct(c)(_is[c] & PUNCT ) /* !alnum && !cntrl && !space */ |
#define isspace(c)(_is[c] & BLANK ) /* HT, LF, VT, FF, CR, ' ' */ |
#define isupper(c)(_is[c] & UPPER ) /* 'A'-'Z' */ |
#define isxdigit(c)(_is[c] & XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */ |
#define isalnum(c)(__is[c] & __ALNUM ) /* 'a'-'z', 'A'-'Z', '0'-'9' */ |
#define isalpha(c)(__is[c] & __ALPHA ) /* 'a'-'z', 'A'-'Z' */ |
#define iscntrl(c)(__is[c] & __CNTRL ) /* 0-31, 127 */ |
#define isdigit(c)(__is[c] & __DIGIT ) /* '0'-'9' */ |
#define isgraph(c)(__is[c] & __GRAPH ) /* '!'-'~' */ |
#define islower(c)(__is[c] & __LOWER ) /* 'a'-'z' */ |
#define isprint(c)(__is[c] & __PRINT ) /* ' '-'~' */ |
#define ispunct(c)(__is[c] & __PUNCT ) /* !alnum && !cntrl && !space */ |
#define isspace(c)(__is[c] & __BLANK ) /* HT, LF, VT, FF, CR, ' ' */ |
#define isupper(c)(__is[c] & __UPPER ) /* 'A'-'Z' */ |
#define isxdigit(c)(__is[c] & __XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */ |
#define isascii(c) (!((c)&(~0x7f))) |
#define toascii(c) ((c)&0x7f) |
/programs/develop/ktcc/trunk/libc/include/float.h |
---|
27,7 → 27,7 |
#define DBL_MAX_10_EXP 308 |
/* horrible intel long double */ |
#ifdef __i386__ |
#if defined __i386__ || defined __x86_64__ |
#define LDBL_MANT_DIG 64 |
#define LDBL_DIG 18 |
/programs/develop/ktcc/trunk/libc/include/math.h |
---|
2,7 → 2,7 |
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
extern int stdcall integer(float number); |
//extern int stdcall integer(float number); |
extern double acos(double _x); |
extern double asin(double _x); |
163,6 → 163,11 |
extern float gammaf_r(float, int *); |
extern float lgammaf_r(float, int *); |
double round (double x); |
long double roundl (long double x); |
//#endif /* !_POSIX_SOURCE */ |
//#endif /* !__STRICT_ANSI__ */ |
//#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ |
/programs/develop/ktcc/trunk/libc/include/stdarg.h |
---|
1,15 → 1,75 |
#ifndef _STDARG_H |
#define _STDARG_H |
#ifdef __x86_64__ |
#ifndef _WIN64 |
//This should be in sync with the declaration on our lib/libtcc1.c |
/* GCC compatible definition of va_list. */ |
typedef struct { |
unsigned int gp_offset; |
unsigned int fp_offset; |
union { |
unsigned int overflow_offset; |
char *overflow_arg_area; |
}; |
char *reg_save_area; |
} __va_list_struct; |
typedef __va_list_struct va_list[1]; |
void __va_start(__va_list_struct *ap, void *fp); |
void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align); |
#define va_start(ap, last) __va_start(ap, __builtin_frame_address(0)) |
#define va_arg(ap, type) \ |
(*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type)))) |
#define va_copy(dest, src) (*(dest) = *(src)) |
#define va_end(ap) |
#else /* _WIN64 */ |
typedef char *va_list; |
#define va_start(ap,last) __builtin_va_start(ap,last) |
#define va_arg(ap,type) (ap += 8, sizeof(type)<=8 ? *(type*)ap : **(type**)ap) |
#define va_copy(dest, src) ((dest) = (src)) |
#define va_end(ap) |
#endif |
#elif __arm__ |
typedef char *va_list; |
#define _tcc_alignof(type) ((int)&((struct {char c;type x;} *)0)->x) |
#define _tcc_align(addr,type) (((unsigned)addr + _tcc_alignof(type) - 1) \ |
& ~(_tcc_alignof(type) - 1)) |
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) |
#define va_arg(ap,type) (ap = (void *) ((_tcc_align(ap,type)+sizeof(type)+3) \ |
&~3), *(type *)(ap - ((sizeof(type)+3)&~3))) |
#define va_copy(dest, src) (dest) = (src) |
#define va_end(ap) |
#elif defined(__aarch64__) |
typedef struct { |
void *__stack; |
void *__gr_top; |
void *__vr_top; |
int __gr_offs; |
int __vr_offs; |
} va_list; |
#define va_start(ap, last) __va_start(ap, last) |
#define va_arg(ap, type) __va_arg(ap, type) |
#define va_end(ap) |
#define va_copy(dest, src) ((dest) = (src)) |
#else /* __i386__ */ |
typedef char *va_list; |
/* only correct for i386 */ |
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) |
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3))) |
#define va_copy(dest, src) (dest) = (src) |
#define va_end(ap) |
#endif |
/* fix a buggy dependency on GCC in libio.h */ |
typedef va_list __gnuc_va_list; |
#define _VA_LIST_DEFINED |
#endif |
#endif /* _STDARG_H */ |
/programs/develop/ktcc/trunk/libc/include/stdbool.h |
---|
6,5 → 6,6 |
#define bool _Bool |
#define true 1 |
#define false 0 |
#define __bool_true_false_are_defined 1 |
#endif /* _STDBOOL_H */ |
/programs/develop/ktcc/trunk/libc/include/stddef.h |
---|
1,21 → 1,46 |
#ifndef _STDDEF_H |
#define _STDDEF_H |
#define NULL ((void *)0) |
typedef __SIZE_TYPE__ size_t; |
typedef __PTRDIFF_TYPE__ ssize_t; |
typedef __WCHAR_TYPE__ wchar_t; |
typedef __PTRDIFF_TYPE__ ptrdiff_t; |
#define offsetof(type, field) ((size_t) &((type *)0)->field) |
typedef __PTRDIFF_TYPE__ intptr_t; |
typedef __SIZE_TYPE__ uintptr_t; |
/* need to do that because of glibc 2.1 bug (should have a way to test |
presence of 'long long' without __GNUC__, or TCC should define |
__GNUC__ ? */ |
#if !defined(__int8_t_defined) && !defined(__dietlibc__) |
#ifndef __int8_t_defined |
#define __int8_t_defined |
typedef char int8_t; |
typedef short int int16_t; |
typedef int int32_t; |
typedef long long int int64_t; |
typedef signed char int8_t; |
typedef signed short int int16_t; |
typedef signed int int32_t; |
typedef signed long long int int64_t; |
typedef unsigned char uint8_t; |
typedef unsigned short int uint16_t; |
typedef unsigned int uint32_t; |
typedef unsigned long long int uint64_t; |
#endif |
#ifndef NULL |
#define NULL ((void*)0) |
#endif |
#define offsetof(type, field) ((size_t)&((type *)0)->field) |
void *alloca(size_t size); |
#endif |
/* Older glibc require a wint_t from <stddef.h> (when requested |
by __need_wint_t, as otherwise stddef.h isn't allowed to |
define this type). Note that this must be outside the normal |
_STDDEF_H guard, so that it works even when we've included the file |
already (without requiring wint_t). Some other libs define _WINT_T |
if they've already provided that type, so we can use that as guard. |
TCC defines __WINT_TYPE__ for us. */ |
#if defined (__need_wint_t) |
#ifndef _WINT_T |
#define _WINT_T |
typedef __WINT_TYPE__ wint_t; |
#endif |
#undef __need_wint_t |
#endif |
/programs/develop/ktcc/trunk/libc/include/stdio.h |
---|
2,14 → 2,18 |
#define stdio_h |
#include "kolibrisys.h" |
#include <stdarg.h> |
/* use stdarg.h |
typedef char *va_list; |
#define _roundsize(n) ( (sizeof(n) + 3) & ~3 ) |
#define va_start(ap,v) (ap = (va_list)&v+_roundsize(v)) |
#define va_arg(ap,t) ( *(t *)((ap += _roundsize(t)) - _roundsize(t)) ) |
#define va_end(ap) (ap = (va_list)0) |
*/ |
#ifndef NULL |
# define NULL ((void*)0) |
#endif |
#define NULL ((void*)0) |
int format_print(char *dest, size_t maxlen,const char *fmt0, va_list argp); |
typedef struct { |
21,6 → 25,9 |
int mode; |
} FILE; |
#define stderr ((FILE*)3) /* works inly for fprintf!!! */ |
#define FILE_OPEN_READ 0 |
#define FILE_OPEN_WRITE 1 |
#define FILE_OPEN_APPEND 2 |
55,5 → 62,7 |
extern int cdecl sprintf(char *dest,const char *format,...); |
#define getc(a) fgetc(a) |
char * fgets ( char * str, int num, FILE * stream ); |
int putchar ( int character ); |
#endif |
/programs/develop/ktcc/trunk/libc/include/stdlib.h |
---|
21,4 → 21,10 |
extern int rand (void); |
extern void srand (unsigned int seed); |
double strtod (const char* str, char** endptr); |
long double strtold (const char* str, char** endptr); |
float strtof (const char* str, char** endptr); |
#define exit(a) _ksys_exit() |
#endif |
/programs/develop/ktcc/trunk/libc/include/varargs.h |
---|
1,11 → 1,12 |
/** |
* This file has no copyright assigned and is placed in the Public Domain. |
* This file is part of the w64 mingw-runtime package. |
* No warranty is given; refer to the file DISCLAIMER within this package. |
*/ |
#ifndef _VARARGS_H |
#define _VARARGS_H |
#include <stdarg.h> |
#error "TinyCC no longer implements <varargs.h>." |
#error "Revise your code to use <stdarg.h>." |
#define va_dcl |
#define va_alist __va_alist |
#undef va_start |
#define va_start(ap) ap = __builtin_varargs_start |
#endif |