History

new subdirs: include, lib, tests

grischka committed 17 years ago

Commit ea5e81b1 parent e8a52a816 files · +0 −6Browse files

Showing the changes to include (6 of 16 files). Show all

Unified · Split

6 files
  1. include/float.h +57 −0
  2. include/stdarg.h +83 −0
  3. include/stdbool.h +10 −0
  4. include/stddef.h +26 −0
  5. include/tcclib.h +77 −0
  6. include/varargs.h +11 −0
include/float.h+57−0
@@ -0,0 +1,57 @@
1+#ifndef _FLOAT_H_
2+#define _FLOAT_H_
3+
4+#define FLT_RADIX 2
5+
6+/* IEEE float */
7+#define FLT_MANT_DIG 24
8+#define FLT_DIG 6
9+#define FLT_ROUNDS 1
10+#define FLT_EPSILON 1.19209290e-07F
11+#define FLT_MIN_EXP (-125)
12+#define FLT_MIN 1.17549435e-38F
13+#define FLT_MIN_10_EXP (-37)
14+#define FLT_MAX_EXP 128
15+#define FLT_MAX 3.40282347e+38F
16+#define FLT_MAX_10_EXP 38
17+
18+/* IEEE double */
19+#define DBL_MANT_DIG 53
20+#define DBL_DIG 15
21+#define DBL_EPSILON 2.2204460492503131e-16
22+#define DBL_MIN_EXP (-1021)
23+#define DBL_MIN 2.2250738585072014e-308
24+#define DBL_MIN_10_EXP (-307)
25+#define DBL_MAX_EXP 1024
26+#define DBL_MAX 1.7976931348623157e+308
27+#define DBL_MAX_10_EXP 308
28+
29+/* horrible intel long double */
30+#ifdef __i386__
31+
32+#define LDBL_MANT_DIG 64
33+#define LDBL_DIG 18
34+#define LDBL_EPSILON 1.08420217248550443401e-19L
35+#define LDBL_MIN_EXP (-16381)
36+#define LDBL_MIN 3.36210314311209350626e-4932L
37+#define LDBL_MIN_10_EXP (-4931)
38+#define LDBL_MAX_EXP 16384
39+#define LDBL_MAX 1.18973149535723176502e+4932L
40+#define LDBL_MAX_10_EXP 4932
41+
42+#else
43+
44+/* same as IEEE double */
45+#define LDBL_MANT_DIG 53
46+#define LDBL_DIG 15
47+#define LDBL_EPSILON 2.2204460492503131e-16
48+#define LDBL_MIN_EXP (-1021)
49+#define LDBL_MIN 2.2250738585072014e-308
50+#define LDBL_MIN_10_EXP (-307)
51+#define LDBL_MAX_EXP 1024
52+#define LDBL_MAX 1.7976931348623157e+308
53+#define LDBL_MAX_10_EXP 308
54+
55+#endif
56+
57+#endif /* _FLOAT_H_ */
include/stdarg.h+83−0
@@ -0,0 +1,83 @@
1+#ifndef _STDARG_H
2+#define _STDARG_H
3+
4+#ifdef __x86_64__
5+
6+#ifdef __TINYC__
7+
8+#include <stdlib.h>
9+
10+/* GCC compatible definition of va_list. */
11+struct __va_list_struct {
12+ unsigned int gp_offset;
13+ unsigned int fp_offset;
14+ union {
15+ unsigned int overflow_offset;
16+ char *overflow_arg_area;
17+ };
18+ char *reg_save_area;
19+};
20+
21+typedef struct __va_list_struct *va_list;
22+
23+/* we use __builtin_(malloc|free) to avoid #define malloc tcc_malloc */
24+/* XXX: this lacks the support of aggregated types. */
25+#define va_start(ap, last) \
26+ (ap = (va_list)__builtin_malloc(sizeof(struct __va_list_struct)), \
27+ *ap = *(struct __va_list_struct*)( \
28+ (char*)__builtin_frame_address(0) - 16), \
29+ ap->overflow_arg_area = ((char *)__builtin_frame_address(0) + \
30+ ap->overflow_offset), \
31+ ap->reg_save_area = (char *)__builtin_frame_address(0) - 176 - 16 \
32+ )
33+#define va_arg(ap, type) \
34+ (*(type*)(__builtin_types_compatible_p(type, long double) \
35+ ? (ap->overflow_arg_area += 16, \
36+ ap->overflow_arg_area - 16) \
37+ : __builtin_types_compatible_p(type, double) \
38+ ? (ap->fp_offset < 128 + 48 \
39+ ? (ap->fp_offset += 16, \
40+ ap->reg_save_area + ap->fp_offset - 16) \
41+ : (ap->overflow_arg_area += 8, \
42+ ap->overflow_arg_area - 8)) \
43+ : (ap->gp_offset < 48 \
44+ ? (ap->gp_offset += 8, \
45+ ap->reg_save_area + ap->gp_offset - 8) \
46+ : (ap->overflow_arg_area += 8, \
47+ ap->overflow_arg_area - 8)) \
48+ ))
49+#define va_copy(dest, src) \
50+ ((dest) = (va_list)malloc(sizeof(struct __va_list_struct)), \
51+ *(dest) = *(src))
52+#define va_end(ap) __builtin_free(ap)
53+
54+#else
55+
56+/* for GNU C */
57+
58+typedef __builtin_va_list va_list;
59+
60+#define va_start(ap, last) __builtin_va_start(ap, last)
61+#define va_arg(ap, type) __builtin_va_arg(ap, type)
62+#define va_copy(dest, src) __builtin_va_copy(dest, src)
63+#define va_end(ap) __builtin_va_end(ap)
64+
65+#endif
66+
67+#else
68+
69+typedef char *va_list;
70+
71+/* only correct for i386 */
72+#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
73+#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
74+#define va_copy(dest, src) (dest) = (src)
75+#define va_end(ap)
76+
77+#endif
78+
79+/* fix a buggy dependency on GCC in libio.h */
80+typedef va_list __gnuc_va_list;
81+#define _VA_LIST_DEFINED
82+
83+#endif /* _STDARG_H */
include/stdbool.h+10−0
@@ -0,0 +1,10 @@
1+#ifndef _STDBOOL_H
2+#define _STDBOOL_H
3+
4+/* ISOC99 boolean */
5+
6+#define bool _Bool
7+#define true 1
8+#define false 0
9+
10+#endif /* _STDBOOL_H */
include/stddef.h+26−0
@@ -0,0 +1,26 @@
1+#ifndef _STDDEF_H
2+#define _STDDEF_H
3+
4+#define NULL ((void *)0)
5+typedef __SIZE_TYPE__ size_t;
6+typedef __WCHAR_TYPE__ wchar_t;
7+typedef __PTRDIFF_TYPE__ ptrdiff_t;
8+#define offsetof(type, field) ((size_t) &((type *)0)->field)
9+
10+/* need to do that because of glibc 2.1 bug (should have a way to test
11+ presence of 'long long' without __GNUC__, or TCC should define
12+ __GNUC__ ? */
13+#if !defined(__int8_t_defined) && !defined(__dietlibc__)
14+#define __int8_t_defined
15+typedef char int8_t;
16+typedef short int int16_t;
17+typedef int int32_t;
18+typedef long long int int64_t;
19+#endif
20+
21+#ifdef __i386__
22+void *_alloca(size_t);
23+#define alloca _alloca
24+#endif
25+
26+#endif
include/tcclib.h+77−0
@@ -0,0 +1,77 @@
1+/* Simple libc header for TCC
2+ *
3+ * Add any function you want from the libc there. This file is here
4+ * only for your convenience so that you do not need to put the whole
5+ * glibc include files on your floppy disk
6+ */
7+#ifndef _TCCLIB_H
8+#define _TCCLIB_H
9+
10+#include <stddef.h>
11+#include <stdarg.h>
12+
13+/* stdlib.h */
14+void *calloc(size_t nmemb, size_t size);
15+void *malloc(size_t size);
16+void free(void *ptr);
17+void *realloc(void *ptr, size_t size);
18+int atoi(const char *nptr);
19+long int strtol(const char *nptr, char **endptr, int base);
20+unsigned long int strtoul(const char *nptr, char **endptr, int base);
21+
22+/* stdio.h */
23+typedef struct __FILE FILE;
24+#define EOF (-1)
25+extern FILE *stdin;
26+extern FILE *stdout;
27+extern FILE *stderr;
28+FILE *fopen(const char *path, const char *mode);
29+FILE *fdopen(int fildes, const char *mode);
30+FILE *freopen(const char *path, const char *mode, FILE *stream);
31+int fclose(FILE *stream);
32+size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
33+size_t fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream);
34+int fgetc(FILE *stream);
35+char *fgets(char *s, int size, FILE *stream);
36+int getc(FILE *stream);
37+int getchar(void);
38+char *gets(char *s);
39+int ungetc(int c, FILE *stream);
40+int fflush(FILE *stream);
41+
42+int printf(const char *format, ...);
43+int fprintf(FILE *stream, const char *format, ...);
44+int sprintf(char *str, const char *format, ...);
45+int snprintf(char *str, size_t size, const char *format, ...);
46+int asprintf(char **strp, const char *format, ...);
47+int dprintf(int fd, const char *format, ...);
48+int vprintf(const char *format, va_list ap);
49+int vfprintf(FILE *stream, const char *format, va_list ap);
50+int vsprintf(char *str, const char *format, va_list ap);
51+int vsnprintf(char *str, size_t size, const char *format, va_list ap);
52+int vasprintf(char **strp, const char *format, va_list ap);
53+int vdprintf(int fd, const char *format, va_list ap);
54+
55+void perror(const char *s);
56+
57+/* string.h */
58+char *strcat(char *dest, const char *src);
59+char *strchr(const char *s, int c);
60+char *strrchr(const char *s, int c);
61+char *strcpy(char *dest, const char *src);
62+void *memcpy(void *dest, const void *src, size_t n);
63+void *memmove(void *dest, const void *src, size_t n);
64+void *memset(void *s, int c, size_t n);
65+char *strdup(const char *s);
66+
67+/* dlfcn.h */
68+#define RTLD_LAZY 0x001
69+#define RTLD_NOW 0x002
70+#define RTLD_GLOBAL 0x100
71+
72+void *dlopen(const char *filename, int flag);
73+const char *dlerror(void);
74+void *dlsym(void *handle, char *symbol);
75+int dlclose(void *handle);
76+
77+#endif /* _TCCLIB_H */
include/varargs.h+11−0
@@ -0,0 +1,11 @@
1+#ifndef _VARARGS_H
2+#define _VARARGS_H
3+
4+#include <stdarg.h>
5+
6+#define va_dcl
7+#define va_alist __va_alist
8+#undef va_start
9+#define va_start(ap) ap = __builtin_varargs_start
10+
11+#endif