mirror of
https://github.com/mirror/tinycc.git
synced 2026-08-24 11:33:28 +08:00
Compare commits
271 Commits
release_0_
...
release_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
110a4edc15 | ||
|
|
68310299b6 | ||
|
|
bf8d8f5f3e | ||
|
|
aed6a7cb60 | ||
|
|
530b77e365 | ||
|
|
ca4b4a52ad | ||
|
|
03c787d6ce | ||
|
|
40f5ce002e | ||
|
|
67aebdd5b7 | ||
|
|
0a35f9d66e | ||
|
|
f9181416f6 | ||
|
|
5c6509578e | ||
|
|
b8f6e1ae30 | ||
|
|
92204e8818 | ||
|
|
9dc9cbf319 | ||
|
|
0d1ed74102 | ||
|
|
805990b94e | ||
|
|
ae37bd5abc | ||
|
|
a93bcdffae | ||
|
|
15626621fb | ||
|
|
e9e89ad699 | ||
|
|
859da934e0 | ||
|
|
48ae0c0468 | ||
|
|
5829791ffa | ||
|
|
ea5e81bd6a | ||
|
|
e8a52a8249 | ||
|
|
eca1fbaf92 | ||
|
|
b56f956247 | ||
|
|
d165e87340 | ||
|
|
73ba078d2f | ||
|
|
d36fea34e3 | ||
|
|
dd5630ff95 | ||
|
|
0f0ed4a8bf | ||
|
|
90697c4c56 | ||
|
|
d62301b050 | ||
|
|
9a7173bf69 | ||
|
|
e6ba81b012 | ||
|
|
b1697be691 | ||
|
|
795f67428e | ||
|
|
9a8b2912ed | ||
|
|
742cf05875 | ||
|
|
85d016b507 | ||
|
|
39a4b859d4 | ||
|
|
51a7f163ad | ||
|
|
83fd36333a | ||
|
|
be43c8e0ed | ||
|
|
a9c78d04f2 | ||
|
|
b879ffa193 | ||
|
|
de3f0a46fe | ||
|
|
2e9b57b6d0 | ||
|
|
9fe28b610e | ||
|
|
0e239e2ba5 | ||
|
|
fcf2e5981f | ||
|
|
830b7533c9 | ||
|
|
6c10429aa5 | ||
|
|
29c8e1545a | ||
|
|
c80f81c199 | ||
|
|
5818945ef6 | ||
|
|
0e015988cc | ||
|
|
97072b3cd7 | ||
|
|
754b0beb7d | ||
|
|
e6db5f5fb6 | ||
|
|
06fa15fb99 | ||
|
|
ebb874e216 | ||
|
|
6512d9e2ea | ||
|
|
af6cbc48d1 | ||
|
|
040ef000e4 | ||
|
|
fe8f230ab6 | ||
|
|
b8a32d8d40 | ||
|
|
7db1e69df2 | ||
|
|
006c907da7 | ||
|
|
4f056031f4 | ||
|
|
62e73da612 | ||
|
|
ae607280c5 | ||
|
|
4a8c2229ce | ||
|
|
3116744bdd | ||
|
|
b41fc95566 | ||
|
|
00f0932760 | ||
|
|
6213d4b4b6 | ||
|
|
5a044b67bb | ||
|
|
64147b346b | ||
|
|
7c3f19c079 | ||
|
|
aa8d22e38e | ||
|
|
0a9873aa22 | ||
|
|
fb0ac27691 | ||
|
|
1e776b29d3 | ||
|
|
ba8c95a98d | ||
|
|
27d23342ea | ||
|
|
c92daa02e4 | ||
|
|
ce8d71edbc | ||
|
|
2355fc7686 | ||
|
|
d6072d3703 | ||
|
|
73a84cefda | ||
|
|
7dd792ef51 | ||
|
|
76b02c2a03 | ||
|
|
5fd6f7bd44 | ||
|
|
deb410710c | ||
|
|
1b599ea7f8 | ||
|
|
2d9b5e0bb8 | ||
|
|
83466c6151 | ||
|
|
78f288bc87 | ||
|
|
7bebf1f59a | ||
|
|
7f51aa13e7 | ||
|
|
a80acab4fc | ||
|
|
3783b33508 | ||
|
|
43a34d354a | ||
|
|
5a92536cea | ||
|
|
e263ee3cbf | ||
|
|
15e0dc08a6 | ||
|
|
256f6e6200 | ||
|
|
e8039673ad | ||
|
|
12265da6cd | ||
|
|
2c657f6608 | ||
|
|
8f7e3f325d | ||
|
|
2c6cd08bcc | ||
|
|
1300cec38c | ||
|
|
f9bf48d643 | ||
|
|
96bd8f2b25 | ||
|
|
f2698687fb | ||
|
|
5247bbc2f0 | ||
|
|
0d598aca08 | ||
|
|
23594b6980 | ||
|
|
f22e961f80 | ||
|
|
a327c7a552 | ||
|
|
4d9aaacc85 | ||
|
|
cd24bd05b4 | ||
|
|
9bcc0b970b | ||
|
|
88b3cb570e | ||
|
|
6ed868c51c | ||
|
|
e2c89576c7 | ||
|
|
c6537d11cb | ||
|
|
2eaa1104f7 | ||
|
|
265dddbecf | ||
|
|
3667408a57 | ||
|
|
5342b32eef | ||
|
|
adb1456472 | ||
|
|
6c96c41ee4 | ||
|
|
f466577673 | ||
|
|
34140dd627 | ||
|
|
b0d40c12da | ||
|
|
f99d3de221 | ||
|
|
2de1b2d14c | ||
|
|
2bcb964694 | ||
|
|
3e8b9e6d10 | ||
|
|
d778bde7f9 | ||
|
|
54bf8c0556 | ||
|
|
2bcc187b1b | ||
|
|
d13aa5426a | ||
|
|
7097268ac5 | ||
|
|
84f4e99635 | ||
|
|
8b0c4c6582 | ||
|
|
fb2c34f8cd | ||
|
|
65b974e396 | ||
|
|
365d0ad545 | ||
|
|
52b7254b9c | ||
|
|
0bea5c7f21 | ||
|
|
24a19cc37e | ||
|
|
38d2e8b9d8 | ||
|
|
3b8cd565be | ||
|
|
200b58dad8 | ||
|
|
6ca0299e5b | ||
|
|
5487bc23c8 | ||
|
|
aee0da0b17 | ||
|
|
6d66b5a971 | ||
|
|
8ba48f84fe | ||
|
|
62c5a5466a | ||
|
|
7bc5e51847 | ||
|
|
7b8e283980 | ||
|
|
e9c64e3f47 | ||
|
|
81f957ae09 | ||
|
|
3ba1190eb4 | ||
|
|
6f8b8887b1 | ||
|
|
bb24eb9de4 | ||
|
|
44738b516a | ||
|
|
c42532c37d | ||
|
|
b0b8ac13ce | ||
|
|
16559cd60c | ||
|
|
4386b4566b | ||
|
|
4d7eadb2fa | ||
|
|
c262e9ea04 | ||
|
|
b78d3ff1dc | ||
|
|
f6db2edc40 | ||
|
|
0c7f0ed312 | ||
|
|
fe9b1f60ce | ||
|
|
09f4ce9857 | ||
|
|
484ee920c1 | ||
|
|
debf0234cc | ||
|
|
58f6207abe | ||
|
|
5556cf1565 | ||
|
|
6144d43321 | ||
|
|
c897c52088 | ||
|
|
ce93d5440f | ||
|
|
02af482c32 | ||
|
|
7baf968102 | ||
|
|
acc4f88e6d | ||
|
|
4821702fb4 | ||
|
|
d733dc752e | ||
|
|
ef156f0c44 | ||
|
|
0bca832c18 | ||
|
|
44211ddff5 | ||
|
|
8f2d519203 | ||
|
|
9825011ced | ||
|
|
2c538d7a2b | ||
|
|
bdd09709d7 | ||
|
|
fc72e41a55 | ||
|
|
6ab1140623 | ||
|
|
0b8d7f44b4 | ||
|
|
27feb1adac | ||
|
|
1c1919072b | ||
|
|
be5e9cb962 | ||
|
|
48c85f1b15 | ||
|
|
398e22c541 | ||
|
|
6bbfb8f610 | ||
|
|
1d0e5e8b01 | ||
|
|
1e1d3ff687 | ||
|
|
736b565766 | ||
|
|
c2ec76a41f | ||
|
|
6b52984ce4 | ||
|
|
c9c05ca5f0 | ||
|
|
32ba2eadf6 | ||
|
|
3e74b91de6 | ||
|
|
e657dfb491 | ||
|
|
2a6c104722 | ||
|
|
38e8a23025 | ||
|
|
bb07bf31aa | ||
|
|
eb79471184 | ||
|
|
59c3563827 | ||
|
|
45466d2df6 | ||
|
|
807321efba | ||
|
|
ff3a5daf25 | ||
|
|
0bd402d2eb | ||
|
|
9668499b9f | ||
|
|
72a88fbab0 | ||
|
|
4d9f6d2bcf | ||
|
|
d65463809c | ||
|
|
62f99adb71 | ||
|
|
aa7ef7919e | ||
|
|
13affef3f1 | ||
|
|
c50af8399d | ||
|
|
ec7d36326d | ||
|
|
bf45336afb | ||
|
|
6e5b1cc43a | ||
|
|
3bd3c71fd1 | ||
|
|
79c72b2419 | ||
|
|
df36de6507 | ||
|
|
c52df4de38 | ||
|
|
8da6027e73 | ||
|
|
c1265d1616 | ||
|
|
22d8df96c6 | ||
|
|
8da2d689df | ||
|
|
fe203057c2 | ||
|
|
114883e078 | ||
|
|
7a5123a770 | ||
|
|
4df5bd2eb0 | ||
|
|
44cea6aee9 | ||
|
|
77a19bf50e | ||
|
|
b7f12dfbdf | ||
|
|
9890ea1233 | ||
|
|
feed3262c9 | ||
|
|
bef8703f77 | ||
|
|
46169b92d9 | ||
|
|
d369a77647 | ||
|
|
c5ce5eaeda | ||
|
|
9c1106d854 | ||
|
|
f8d0241764 | ||
|
|
c5959b77b4 | ||
|
|
7b940fcb1b | ||
|
|
21d2d99bdc | ||
|
|
277e01cd64 | ||
|
|
9d95be78c8 | ||
|
|
370f5e571c |
21
.cvsignore
21
.cvsignore
@@ -1,45 +1,26 @@
|
||||
tcc_g
|
||||
tcc
|
||||
tc2.c
|
||||
ex3
|
||||
ex1.c
|
||||
ex2.c
|
||||
otcc1.c
|
||||
doc
|
||||
tc3s.c
|
||||
p3.c
|
||||
tc1.c
|
||||
error.c
|
||||
i386-gen1.c
|
||||
ex4.c
|
||||
test.out2
|
||||
test.out3
|
||||
web.sh
|
||||
ex3.c
|
||||
memdebug.c
|
||||
bench
|
||||
ex5.c
|
||||
tcc-newparse.c
|
||||
p1.c
|
||||
Makefile.uClibc
|
||||
boundtest
|
||||
p4.c
|
||||
p5.c
|
||||
prog.ref
|
||||
test.ref
|
||||
a.c
|
||||
p3
|
||||
test.out
|
||||
elf.h
|
||||
stab.h
|
||||
stab.def
|
||||
p2
|
||||
tcc-doc.html
|
||||
ideas
|
||||
tcctest.ref
|
||||
test
|
||||
linux.tcc
|
||||
wintest.c
|
||||
ldtest
|
||||
libtcc_test
|
||||
instr.S
|
||||
@@ -53,4 +34,4 @@ tcc.pod
|
||||
config.h
|
||||
config.mak
|
||||
config.texi
|
||||
gcctestsuite.sh
|
||||
tests
|
||||
135
Changelog
135
Changelog
@@ -1,3 +1,138 @@
|
||||
version 0.9.25:
|
||||
|
||||
- first support for x86-64 target (Shinichiro Hamaji)
|
||||
- support µClibc
|
||||
- split tcc.c into tcc.h libtcc.c tccpp.c tccgen.c tcc.c
|
||||
- improved preprocess output with linenumbers and spaces preserved
|
||||
- tcc_relocate now copies code into user buffer
|
||||
- fix bitfields with non-int types and in unions
|
||||
- improve ARM cross-compiling (Daniel Glöckner)
|
||||
- link stabstr sections from multiple objects
|
||||
- better (still limited) support for multiple TCCStates
|
||||
|
||||
version 0.9.24:
|
||||
|
||||
- added verbosity levels -v, -vv, -vvv
|
||||
- Accept standard input as an inputstream (Hanzac Chen)
|
||||
- Support c89 compilers other than gcc (Hanzac Chen)
|
||||
- -soname linker option (Marc Andre Tanner)
|
||||
- Just warn about unknown directives, ignore quotes in #error/#warning
|
||||
- Define __STDC_VERSION__=199901L (477)
|
||||
- Switch to newer tccpe.c (includes support for resources)
|
||||
- Handle backslashes within #include/#error/#warning
|
||||
- Import changesets (part 4) 428,457,460,467: defines for openbsd etc.
|
||||
- Use _WIN32 for a windows hosted tcc and define it for the PE target,
|
||||
otherwise define __unix / __linux (Detlef Riekenberg)
|
||||
- Import changesets (part 3) 409,410: ARM EABI by Daniel Glöckner
|
||||
- Some in-between fixes:
|
||||
TCC -E no longer hangs with macro calls involving newlines.
|
||||
(next_nomacro1 now advances the read-pointer with TOK_LINEFEED)
|
||||
Global cast (int g_i = 1LL;) no longer crashes tcc.
|
||||
(nocode_wanted is initially 1, and only 0 for gen_function)
|
||||
On win32 now tcc.exe finds 'include' & 'lib' even if itself is in 'bin'.
|
||||
(new function w32_tcc_lib_path removes 'bin' if detected)
|
||||
Added quick build batch file for mingw (win32/build-tcc.bat)
|
||||
Last added case label optimization (455) produced wrong code. Reverted.
|
||||
|
||||
- Import more changesets from Rob Landley's fork (part 2):
|
||||
487: Handle long long constants in gen_opic() (Rob Landley)
|
||||
484: Handle parentheses within __attribute__((...)) (Rob Landley)
|
||||
480: Remove a goto in decl_initializer_alloc (Rob Landley)
|
||||
475: Fix dereferences in inline assembly output (Joshua Phillips)
|
||||
474: Cast ptrs to ints of different sizes correctly (Joshua Phillips)
|
||||
473: Fix size of structs with empty array member (Joshua Phillips)
|
||||
470: No warning for && and || with mixed pointers/integers (Rob Landley)
|
||||
469: Fix symbol visibility problems in the linker (Vincent Pit)
|
||||
468: Allow && and || involving pointer arguments (Rob Landley)
|
||||
455: Optimize case labels with no code in between (Zdenek Pavlas)
|
||||
450: Implement alloca for x86 (grischka)
|
||||
415: Parse unicode escape sequences (Axel Liljencrantz)
|
||||
407: Add a simple va_copy() in stdarg.h (Hasso Tepper)
|
||||
400: Allow typedef names as symbols (Dave Dodge)
|
||||
|
||||
- Import some changesets from Rob Landley's fork (part 1):
|
||||
462: Use LGPL with bcheck.c and il-gen.c
|
||||
458: Fix global compound literals (in unary: case '&':) (Andrew Johnson)
|
||||
456: Use return code from tcc_output_file in main() (Michael Somos)
|
||||
442: Fix indirections with function pointers (***fn)() (grischka)
|
||||
441: Fix LL left shift in libtcc1.c:__shldi3 (grischka)
|
||||
440: Pass structures and function ptrs through ?: (grischka)
|
||||
439: Keep rvalue in bit assignment (bit2 = bit1 = x) (grischka)
|
||||
438: Degrade nonportable pointer assignment to warning (grischka)
|
||||
437: Call 'saveregs()' before jumping with logical and/or/not (grischka)
|
||||
435: Put local static variables into global memory (grischka)
|
||||
432/434: Cast double and ptr to bool (grischka)
|
||||
420: Zero pad x87 tenbyte long doubles (Felix Nawothnig)
|
||||
417: Make 'sizeof' unsigned (Rob Landley)
|
||||
397: Fix save_reg for longlongs (Daniel Glöckner)
|
||||
396: Fix "invalid relocation entry" problem on ubuntu - (Bernhard Fischer)
|
||||
|
||||
- ignore AS_NEEDED ld command
|
||||
- mark executable sections as executable when running in memory
|
||||
- added support for win32 wchar_t (Filip Navara)
|
||||
- segment override prefix support (Filip Navara)
|
||||
- normalized slashes in paths (Filip Navara)
|
||||
- windows style fastcall (Filip Navara)
|
||||
- support for empty input register section in asm (Filip Navara)
|
||||
- anonymous union/struct support (Filip Navara)
|
||||
- fixed parsing of function parameters
|
||||
- workaround for function pointers in conditional expressions (Dave Dodge)
|
||||
- initial '-E' option support to use the C preprocessor alone
|
||||
- discard type qualifiers when comparing function parameters (Dave Dodge)
|
||||
- Bug fix: A long long value used as a test expression ignores the
|
||||
upper 32 bits at runtime (Dave Dodge)
|
||||
- fixed multiple concatenation of PPNUM tokens (initial patch by Dave Dodge)
|
||||
- fixed multiple typedef specifiers handling
|
||||
- fixed sign extension in some type conversions (Dave Dodge)
|
||||
|
||||
version 0.9.23:
|
||||
|
||||
- initial PE executable format for windows version (grischka)
|
||||
- '#pragma pack' support (grischka)
|
||||
- '#include_next' support (Bernhard Fischer)
|
||||
- ignore '-pipe' option
|
||||
- added -f[no-]leading-underscore
|
||||
- preprocessor function macro parsing fix (grischka)
|
||||
|
||||
version 0.9.22:
|
||||
|
||||
- simple memory optimisations: kernel compilation is 30% faster
|
||||
- linker symbol definitions fixes
|
||||
- gcc 3.4 fixes
|
||||
- fixed value stack full error
|
||||
- 'packed' attribute support for variables and structure fields
|
||||
- ignore 'const' and 'volatile' in function prototypes
|
||||
- allow '_Bool' in bit fields
|
||||
|
||||
version 0.9.21:
|
||||
|
||||
- ARM target support (Daniel Glöckner)
|
||||
- added '-funsigned-char, '-fsigned-char' and
|
||||
'-Wimplicit-function-declaration'
|
||||
- fixed assignment of const struct in struct
|
||||
- line comment fix (reported by Bertram Felgenhauer)
|
||||
- initial TMS320C67xx target support (TK)
|
||||
- win32 configure
|
||||
- regparm() attribute
|
||||
- many built-in assembler fixes
|
||||
- added '.org', '.fill' and '.previous' assembler directives
|
||||
- '-fno-common' option
|
||||
- '-Ttext' linker option
|
||||
- section alignment fixes
|
||||
- bit fields fixes
|
||||
- do not generate code for unused inline functions
|
||||
- '-oformat' linker option.
|
||||
- added 'binary' output format.
|
||||
|
||||
version 0.9.20:
|
||||
|
||||
- added '-w' option
|
||||
- added '.gnu.linkonce' ELF sections support
|
||||
- fixed libc linking when running in memory (avoid 'stat' function
|
||||
errors).
|
||||
- extended '-run' option to be able to give several arguments to a C
|
||||
script.
|
||||
|
||||
version 0.9.19:
|
||||
|
||||
- "alacarte" linking (Dave Long)
|
||||
|
||||
404
Makefile
404
Makefile
@@ -1,234 +1,272 @@
|
||||
#
|
||||
# Tiny C Compiler Makefile
|
||||
#
|
||||
include config.mak
|
||||
|
||||
CFLAGS=-O2 -g -Wall
|
||||
LIBS=-ldl
|
||||
TOP ?= .
|
||||
include $(TOP)/config.mak
|
||||
|
||||
CFLAGS+=-g -Wall
|
||||
CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
|
||||
LIBS_P=
|
||||
|
||||
ifneq ($(GCC_MAJOR),2)
|
||||
CFLAGS+=-fno-strict-aliasing
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),i386)
|
||||
CFLAGS+=-mpreferred-stack-boundary=2
|
||||
ifeq ($(GCC_MAJOR),2)
|
||||
CFLAGS+=-m386 -malign-functions=0
|
||||
else
|
||||
CFLAGS+=-march=i386 -falign-functions=0
|
||||
ifneq ($(GCC_MAJOR),3)
|
||||
CFLAGS+=-Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
DISAS=objdump -d
|
||||
INSTALL=install
|
||||
ifeq ($(ARCH),x86-64)
|
||||
CFLAGS+=-Wno-pointer-sign
|
||||
endif
|
||||
|
||||
# run local version of tcc with local libraries and includes
|
||||
TCC=./tcc -B. -I.
|
||||
ifndef CONFIG_WIN32
|
||||
LIBS=-lm
|
||||
ifndef CONFIG_NOLDL
|
||||
LIBS+=-ldl
|
||||
endif
|
||||
endif
|
||||
|
||||
all: tcc libtcc1.a bcheck.o tcc-doc.html tcc.1 libtcc.a libtcc_test
|
||||
ifdef CONFIG_WIN32
|
||||
NATIVE_TARGET=-DTCC_TARGET_PE
|
||||
LIBTCC1=libtcc1.a
|
||||
else
|
||||
ifeq ($(ARCH),i386)
|
||||
NATIVE_TARGET=-DTCC_TARGET_I386
|
||||
LIBTCC1=libtcc1.a
|
||||
BCHECK_O=bcheck.o
|
||||
else
|
||||
ifeq ($(ARCH),arm)
|
||||
NATIVE_TARGET=-DTCC_TARGET_ARM
|
||||
NATIVE_TARGET+=$(if $(wildcard /lib/ld-linux.so.3),-DTCC_ARM_EABI)
|
||||
NATIVE_TARGET+=$(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo),-DTCC_ARM_VFP)
|
||||
else
|
||||
ifeq ($(ARCH),x86-64)
|
||||
NATIVE_TARGET=-DTCC_TARGET_X86_64
|
||||
LIBTCC1=libtcc1.a
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
Makefile: config.mak
|
||||
ifneq ($(wildcard /lib/ld-uClibc.so.0),)
|
||||
NATIVE_TARGET+=-DTCC_UCLIBC
|
||||
BCHECK_O=
|
||||
endif
|
||||
|
||||
# auto test
|
||||
ifdef CONFIG_USE_LIBGCC
|
||||
LIBTCC1=
|
||||
endif
|
||||
|
||||
test: test.ref test.out
|
||||
@if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
|
||||
ifeq ($(TOP),.)
|
||||
|
||||
tcctest.ref: tcctest.c
|
||||
$(CC) $(CFLAGS) -I. -o $@ $<
|
||||
PROGS=tcc$(EXESUF)
|
||||
|
||||
test.ref: tcctest.ref
|
||||
./tcctest.ref > $@
|
||||
I386_CROSS = i386-tcc$(EXESUF)
|
||||
WIN32_CROSS = i386-win32-tcc$(EXESUF)
|
||||
X64_CROSS = x86_64-tcc$(EXESUF)
|
||||
ARM_CROSS = arm-tcc-fpa$(EXESUF) arm-tcc-fpa-ld$(EXESUF) \
|
||||
arm-tcc-vfp$(EXESUF) arm-tcc-vfp-eabi$(EXESUF)
|
||||
C67_CROSS = c67-tcc$(EXESUF)
|
||||
|
||||
test.out: tcc tcctest.c
|
||||
$(TCC) -run tcctest.c > $@
|
||||
CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c \
|
||||
tcc.h config.h libtcc.h tcctok.h
|
||||
I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h
|
||||
WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h tccpe.c
|
||||
X86_64_FILES = $(CORE_FILES) x86_64-gen.c
|
||||
ARM_FILES = $(CORE_FILES) arm-gen.c
|
||||
C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
|
||||
|
||||
run: tcc tcctest.c
|
||||
$(TCC) -run tcctest.c
|
||||
ifdef CONFIG_WIN32
|
||||
PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF)
|
||||
NATIVE_FILES=$(WIN32_FILES)
|
||||
PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(C67_CROSS)
|
||||
else
|
||||
ifeq ($(ARCH),i386)
|
||||
NATIVE_FILES=$(I386_FILES)
|
||||
PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(ARM_CROSS) $(C67_CROSS)
|
||||
else
|
||||
ifeq ($(ARCH),x86-64)
|
||||
NATIVE_FILES=$(X86_64_FILES)
|
||||
PROGS_CROSS=$(I386_CROSS) $(WIN32_CROSS) $(ARM_CROSS) $(C67_CROSS)
|
||||
else
|
||||
ifeq ($(ARCH),arm)
|
||||
NATIVE_FILES=$(ARM_FILES)
|
||||
PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(C67_CROSS)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# iterated test2 (compile tcc then compile tcctest.c !)
|
||||
test2: tcc tcc.c tcctest.c test.ref
|
||||
$(TCC) -run tcc.c -B. -I. -run tcctest.c > test.out2
|
||||
@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
|
||||
ifdef CONFIG_CROSS
|
||||
PROGS+=$(PROGS_CROSS)
|
||||
endif
|
||||
|
||||
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
|
||||
test3: tcc tcc.c tcctest.c test.ref
|
||||
$(TCC) -run tcc.c -B. -I. -run tcc.c -B. -I. -run tcctest.c > test.out3
|
||||
@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
|
||||
all: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc-doc.html tcc.1 libtcc_test$(EXESUF)
|
||||
|
||||
# binary output test
|
||||
test4: tcc test.ref
|
||||
# dynamic output
|
||||
$(TCC) -o tcctest1 tcctest.c
|
||||
./tcctest1 > test1.out
|
||||
@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
|
||||
# static output
|
||||
$(TCC) -static -o tcctest2 tcctest.c
|
||||
./tcctest2 > test2.out
|
||||
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
|
||||
# object + link output
|
||||
$(TCC) -c -o tcctest3.o tcctest.c
|
||||
$(TCC) -o tcctest3 tcctest3.o
|
||||
./tcctest3 > test3.out
|
||||
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
|
||||
# dynamic output + bound check
|
||||
$(TCC) -b -o tcctest4 tcctest.c
|
||||
./tcctest4 > test4.out
|
||||
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
|
||||
# Host Tiny C Compiler
|
||||
tcc$(EXESUF): $(NATIVE_FILES)
|
||||
$(CC) -o $@ $< $(NATIVE_TARGET) $(CFLAGS) $(LIBS)
|
||||
|
||||
# memory and bound check auto test
|
||||
BOUNDS_OK = 1 4 8 10
|
||||
BOUNDS_FAIL= 2 5 7 9 11 12 13
|
||||
# Cross Tiny C Compilers
|
||||
i386-tcc$(EXESUF): $(I386_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_I386 $(CFLAGS) $(LIBS)
|
||||
|
||||
btest: boundtest.c tcc
|
||||
@for i in $(BOUNDS_OK); do \
|
||||
if $(TCC) -b -run boundtest.c $$i ; then \
|
||||
/bin/true ; \
|
||||
else\
|
||||
echo Failed positive test $$i ; exit 1 ; \
|
||||
fi ;\
|
||||
done ;\
|
||||
for i in $(BOUNDS_FAIL); do \
|
||||
if $(TCC) -b -run boundtest.c $$i ; then \
|
||||
echo Failed negative test $$i ; exit 1 ;\
|
||||
else\
|
||||
/bin/true ; \
|
||||
fi\
|
||||
done ;\
|
||||
echo Bound test OK
|
||||
i386-win32-tcc$(EXESUF): $(WIN32_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_PE $(CFLAGS) $(LIBS)
|
||||
|
||||
# speed test
|
||||
speed: tcc ex2 ex3
|
||||
time ./ex2 1238 2 3 4 10 13 4
|
||||
time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
|
||||
time ./ex3 35
|
||||
time ./tcc -I. ./ex3.c 35
|
||||
x86_64-tcc$(EXESUF): $(X86_64_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_X86_64 $(CFLAGS) $(LIBS)
|
||||
|
||||
ex2: ex2.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
c67-tcc$(EXESUF): $(C67_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_C67 $(CFLAGS) $(LIBS)
|
||||
|
||||
ex3: ex3.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
arm-tcc-fpa$(EXESUF): $(ARM_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_ARM $(CFLAGS) $(LIBS)
|
||||
|
||||
# Native Tiny C Compiler
|
||||
arm-tcc-fpa-ld$(EXESUF): $(ARM_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12 $(CFLAGS) $(LIBS)
|
||||
|
||||
tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile
|
||||
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
|
||||
arm-tcc-vfp$(EXESUF): $(ARM_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_ARM -DTCC_ARM_VFP $(CFLAGS) $(LIBS)
|
||||
|
||||
tcc: tcc_g Makefile
|
||||
strip -s -R .comment -R .note -o $@ $<
|
||||
arm-tcc-vfp-eabi$(EXESUF): $(ARM_FILES)
|
||||
$(CC) -o $@ $< -DTCC_TARGET_ARM -DTCC_ARM_EABI $(CFLAGS) $(LIBS)
|
||||
|
||||
# libtcc generation and test
|
||||
libtcc.o: $(NATIVE_FILES)
|
||||
$(CC) -o $@ -c libtcc.c $(NATIVE_TARGET) $(CFLAGS)
|
||||
|
||||
libtcc.a: libtcc.o
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
libtcc_test$(EXESUF): tests/libtcc_test.c libtcc.a
|
||||
$(CC) -o $@ $^ -I. $(CFLAGS) $(LIBS)
|
||||
|
||||
libtest: libtcc_test$(EXESUF) $(LIBTCC1)
|
||||
./libtcc_test$(EXESUF) lib_path=.
|
||||
|
||||
# profiling version
|
||||
tcc_p$(EXESUF): $(NATIVE_FILES)
|
||||
$(CC) -o $@ $< $(NATIVE_TARGET) $(CFLAGS_P) $(LIBS_P)
|
||||
|
||||
# windows utilities
|
||||
tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c
|
||||
$(CC) -o $@ $< $(CFLAGS)
|
||||
tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
|
||||
$(CC) -o $@ $< $(CFLAGS)
|
||||
|
||||
# TinyCC runtime libraries
|
||||
libtcc1.o: libtcc1.c
|
||||
$(CC) -O2 -Wall -c -o $@ $<
|
||||
LIBTCC1_OBJS=libtcc1.o
|
||||
LIBTCC1_CC=$(CC)
|
||||
VPATH+=lib
|
||||
ifdef CONFIG_WIN32
|
||||
# for windows, we must use TCC because we generate ELF objects
|
||||
LIBTCC1_OBJS+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
||||
LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE
|
||||
VPATH+=win32/lib
|
||||
endif
|
||||
ifeq ($(ARCH),i386)
|
||||
LIBTCC1_OBJS+=alloca86.o alloca86-bt.o
|
||||
endif
|
||||
|
||||
libtcc1.a: libtcc1.o
|
||||
%.o: %.c
|
||||
$(LIBTCC1_CC) -o $@ -c $< -O2 -Wall
|
||||
|
||||
%.o: %.S
|
||||
$(LIBTCC1_CC) -o $@ -c $<
|
||||
|
||||
libtcc1.a: $(LIBTCC1_OBJS)
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
bcheck.o: bcheck.c
|
||||
$(CC) -O2 -Wall -c -o $@ $<
|
||||
$(CC) -o $@ -c $< -O2 -Wall
|
||||
|
||||
install: tcc_install libinstall
|
||||
# install
|
||||
TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
|
||||
INSTALL=install
|
||||
|
||||
tcc_install: tcc tcc.1 libtcc1.a bcheck.o
|
||||
$(INSTALL) -m755 tcc $(bindir)
|
||||
$(INSTALL) tcc.1 $(mandir)/man1
|
||||
mkdir -p $(libdir)/tcc
|
||||
mkdir -p $(libdir)/tcc/include
|
||||
$(INSTALL) -m644 libtcc1.a bcheck.o $(libdir)/tcc
|
||||
$(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
|
||||
tcclib.h $(libdir)/tcc/include
|
||||
ifndef CONFIG_WIN32
|
||||
install: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc.1 tcc-doc.html
|
||||
mkdir -p "$(bindir)"
|
||||
$(INSTALL) -s -m755 $(PROGS) "$(bindir)"
|
||||
mkdir -p "$(mandir)/man1"
|
||||
$(INSTALL) tcc.1 "$(mandir)/man1"
|
||||
mkdir -p "$(tccdir)"
|
||||
mkdir -p "$(tccdir)/include"
|
||||
ifneq ($(LIBTCC1),)
|
||||
$(INSTALL) -m644 $(LIBTCC1) "$(tccdir)"
|
||||
endif
|
||||
ifneq ($(BCHECK_O),)
|
||||
$(INSTALL) -m644 $(BCHECK_O) "$(tccdir)"
|
||||
endif
|
||||
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
|
||||
mkdir -p "$(docdir)"
|
||||
$(INSTALL) -m644 tcc-doc.html "$(docdir)"
|
||||
mkdir -p "$(libdir)"
|
||||
$(INSTALL) -m644 libtcc.a "$(libdir)"
|
||||
mkdir -p "$(includedir)"
|
||||
$(INSTALL) -m644 libtcc.h "$(includedir)"
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
|
||||
core gmon.out test.out test.ref a.out tcc_p \
|
||||
*.exe tcc-doc.html tcc.pod tcc.1 libtcc.a libtcc_test \
|
||||
tcctest[1234] test[1234].out
|
||||
uninstall:
|
||||
rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
|
||||
rm -fv $(foreach P,$(LIBTCC1) $(BCHECK_O),"$(tccdir)/$P")
|
||||
rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
|
||||
rm -fv "$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1"
|
||||
rm -fv "$(libdir)/libtcc.a" "$(includedir)/libtcc.h"
|
||||
|
||||
distclean: clean
|
||||
rm -f config.h config.mak config.texi
|
||||
|
||||
# win32 TCC
|
||||
tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
|
||||
i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
|
||||
|
||||
tcc.exe: tcc_g.exe
|
||||
i386-mingw32msvc-strip -o $@ $<
|
||||
|
||||
# profiling version
|
||||
tcc_p: tcc.c Makefile
|
||||
$(CC) $(CFLAGS_P) -o $@ $< $(LIBS_P)
|
||||
|
||||
# libtcc generation and example
|
||||
libinstall: libtcc.a
|
||||
$(INSTALL) -m644 libtcc.a $(libdir)
|
||||
$(INSTALL) -m644 libtcc.h $(includedir)
|
||||
|
||||
libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
|
||||
$(CC) $(CFLAGS) -DLIBTCC -c -o $@ $<
|
||||
|
||||
libtcc.a: libtcc.o
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
libtcc_test: libtcc_test.c libtcc.a
|
||||
$(CC) $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
|
||||
|
||||
libtest: libtcc_test
|
||||
./libtcc_test
|
||||
|
||||
# targets for development
|
||||
|
||||
%.bin: %.c tcc
|
||||
$(TCC) -g -o $@ $<
|
||||
$(DISAS) $@
|
||||
|
||||
instr: instr.o
|
||||
objdump -d instr.o
|
||||
|
||||
# tiny assembler testing
|
||||
|
||||
asmtest.ref: asmtest.S
|
||||
$(CC) -c -o asmtest.ref.o asmtest.S
|
||||
objdump -D asmtest.ref.o > $@
|
||||
|
||||
# XXX: we compute tcc.c to go faster during development !
|
||||
asmtest.out: asmtest.S tcc
|
||||
# ./tcc tcc.c -c asmtest.S
|
||||
#asmtest.out: asmtest.S tcc
|
||||
./tcc -c asmtest.S
|
||||
objdump -D asmtest.o > $@
|
||||
|
||||
asmtest: asmtest.out asmtest.ref
|
||||
@if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
|
||||
|
||||
instr.o: instr.S
|
||||
$(CC) -O2 -Wall -g -c -o $@ $<
|
||||
|
||||
cache: tcc_g
|
||||
cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
|
||||
vg_annotate tcc.c > /tmp/linpack.cache.log
|
||||
else
|
||||
install: $(PROGS) $(LIBTCC1) libtcc.a tcc-doc.html
|
||||
mkdir -p "$(tccdir)"
|
||||
mkdir -p "$(tccdir)/lib"
|
||||
mkdir -p "$(tccdir)/include"
|
||||
mkdir -p "$(tccdir)/examples"
|
||||
mkdir -p "$(tccdir)/doc"
|
||||
mkdir -p "$(tccdir)/libtcc"
|
||||
$(INSTALL) -s -m755 $(PROGS) "$(tccdir)"
|
||||
$(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(tccdir)/lib"
|
||||
cp -r win32/include/. "$(tccdir)/include"
|
||||
cp -r win32/examples/. "$(tccdir)/examples"
|
||||
# $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
|
||||
$(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc"
|
||||
$(INSTALL) -m644 libtcc.a libtcc.h "$(tccdir)/libtcc"
|
||||
endif
|
||||
|
||||
# documentation and man page
|
||||
tcc-doc.html: tcc-doc.texi
|
||||
texi2html -monolithic -number $<
|
||||
-texi2html -monolithic -number $<
|
||||
|
||||
tcc.1: tcc-doc.texi
|
||||
./texi2pod.pl $< tcc.pod
|
||||
pod2man --section=1 --center=" " --release=" " tcc.pod > $@
|
||||
|
||||
FILES= Makefile Makefile.uClibc configure VERSION \
|
||||
README TODO COPYING \
|
||||
Changelog tcc-doc.texi tcc-doc.html \
|
||||
tcc.1 \
|
||||
tcc.c i386-gen.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h\
|
||||
bcheck.c libtcc1.c \
|
||||
elf.h stab.h stab.def \
|
||||
stddef.h stdarg.h stdbool.h float.h varargs.h \
|
||||
tcclib.h libtcc.h libtcc_test.c \
|
||||
ex1.c ex2.c ex3.c ex4.c ex5.c \
|
||||
tcctest.c boundtest.c gcctestsuite.sh
|
||||
|
||||
FILE=tcc-$(VERSION)
|
||||
-./texi2pod.pl $< tcc.pod
|
||||
-pod2man --section=1 --center=" " --release=" " tcc.pod > $@
|
||||
|
||||
# tar release (use 'make -k tar' on a checkouted tree)
|
||||
TCC-VERSION=tcc-$(shell cat VERSION)
|
||||
tar:
|
||||
rm -rf /tmp/$(FILE)
|
||||
mkdir -p /tmp/$(FILE)
|
||||
cp -P $(FILES) /tmp/$(FILE)
|
||||
( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
|
||||
rm -rf /tmp/$(FILE)
|
||||
rm -rf /tmp/$(TCC-VERSION)
|
||||
cp -r . /tmp/$(TCC-VERSION)
|
||||
( cd /tmp ; tar zcvf ~/$(TCC-VERSION).tar.gz $(TCC-VERSION) --exclude CVS )
|
||||
rm -rf /tmp/$(TCC-VERSION)
|
||||
|
||||
# in tests subdir
|
||||
test clean :
|
||||
$(MAKE) -C tests $@
|
||||
|
||||
# clean
|
||||
clean: local_clean
|
||||
local_clean:
|
||||
rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.out libtcc_test$(EXESUF)
|
||||
|
||||
distclean: clean
|
||||
rm -vf config.h config.mak config.texi tcc.1 tcc-doc.html
|
||||
|
||||
endif # ifeq ($(TOP),.)
|
||||
|
||||
8
README
8
README
@@ -28,9 +28,7 @@ Features:
|
||||
Documentation:
|
||||
-------------
|
||||
|
||||
1) Installation
|
||||
|
||||
*** TCC currently only works on Linux x86 with glibc >= 2.1 ***.
|
||||
1) Installation on a i386 Linux host (for Windows read tcc-win32.txt)
|
||||
|
||||
./configure
|
||||
make
|
||||
@@ -50,7 +48,7 @@ The include file <tcclib.h> can be used if you want a small basic libc
|
||||
include support (especially useful for floppy disks). Of course, you
|
||||
can also use standard headers, although they are slower to compile.
|
||||
|
||||
You can begin your C script with '#!/usr/local/bin/tcc' on the first
|
||||
You can begin your C script with '#!/usr/local/bin/tcc -run' on the first
|
||||
line and set its execute bits (chmod a+x your_script). Then, you can
|
||||
launch the C code as a shell or perl script :-) The command line
|
||||
arguments are put in 'argc' and 'argv' of the main functions, as in
|
||||
@@ -81,6 +79,8 @@ when doing 'make test'.
|
||||
|
||||
Please read tcc-doc.html to have all the features of TCC.
|
||||
|
||||
Additional information is available for the Windows port in tcc-win32.txt.
|
||||
|
||||
License:
|
||||
-------
|
||||
|
||||
|
||||
82
TODO
82
TODO
@@ -1,55 +1,65 @@
|
||||
TODO list:
|
||||
|
||||
- long long constant evaluation
|
||||
Bugs:
|
||||
|
||||
- fix macro substitution with nested definitions (ShangHongzhang)
|
||||
- FPU st(0) is left unclean (kwisatz haderach). Incompatible with
|
||||
optimized gcc/msc code
|
||||
|
||||
- constructors
|
||||
- cast bug (Peter Wang)
|
||||
- define incomplete type if defined several times (Peter Wang).
|
||||
- configure --cc=tcc (still one bug in libtcc1.c)
|
||||
- disable-asm and disable-bcheck options
|
||||
- test binutils/gcc compile
|
||||
- add alloca(), __builtin_expect()
|
||||
- gcc '-E' option.
|
||||
- optimize VT_LOCAL + const
|
||||
- tci patch + argument.
|
||||
- '-b' bug.
|
||||
- atexit (Nigel Horne)
|
||||
- see -lxxx bug (Michael Charity).
|
||||
- handle inline functions as macros.
|
||||
- see transparent union pb in /urs/include/sys/socket.h
|
||||
- precise behaviour of typeof with arrays ? (__put_user macro)
|
||||
- #include_next support for /usr/include/limits ?
|
||||
but should suffice for most cases)
|
||||
- handle '? x, y : z' in unsized variable initialization (',' is
|
||||
considered incorrectly as separator in preparser)
|
||||
- function pointers/lvalues in ? : (linux kernel net/core/dev.c)
|
||||
- transform functions to function pointers in function parameters (net/ipv4/ip_output.c)
|
||||
- transform functions to function pointers in function parameters
|
||||
(net/ipv4/ip_output.c)
|
||||
- fix function pointer type display
|
||||
- fix bound exit on RedHat 7.3
|
||||
- check lcc test suite -> fix bitfield binary operations
|
||||
- check section alignment in C
|
||||
- fix invalid cast in comparison 'if (v == (int8_t)v)'
|
||||
- packed attribute
|
||||
- support link once trick (gcc 3.2 / glibc compilation issue)
|
||||
- finish varargs.h support (gcc 3.2 testsuite issue)
|
||||
- fix static functions declared inside block
|
||||
- fix multiple unions init
|
||||
- sizeof, alignof, typeof can still generate code in some cases.
|
||||
- Fix the remaining libtcc memory leaks.
|
||||
- make libtcc fully reentrant (except for the compilation stage itself).
|
||||
|
||||
Bound checking:
|
||||
|
||||
- '-b' bug.
|
||||
- fix bound exit on RedHat 7.3
|
||||
- setjmp is not supported properly in bound checking.
|
||||
- fix bound check code with '&' on local variables (currently done
|
||||
only for local arrays).
|
||||
- bound checking and float/long long/struct copy code. bound
|
||||
checking and symbol + offset optimization
|
||||
|
||||
Missing features:
|
||||
|
||||
- disable-asm and disable-bcheck options
|
||||
- __builtin_expect()
|
||||
- improve '-E' option.
|
||||
- add '-MD' option
|
||||
- atexit (Nigel Horne)
|
||||
- packed attribute
|
||||
- C99: add variable size arrays (gcc 3.2 testsuite issue)
|
||||
- C99: add complex types (gcc 3.2 testsuite issue)
|
||||
- postfix compound literals (see 20010124-1.c)
|
||||
- fix multiple unions init
|
||||
- look at GCC 3.2 compatibility problems.
|
||||
- setjmp is not supported properly in bound checking.
|
||||
- better local variables handling (needed for other targets)
|
||||
- fix bound check code with '&' on local variables (currently done
|
||||
only for local arrays).
|
||||
- sizeof, alignof, typeof can still generate code in some cases.
|
||||
- bound checking and float/long long/struct copy code. bound
|
||||
checking and symbol + offset optimization
|
||||
- Fix the remaining libtcc memory leaks.
|
||||
- make libtcc fully reentrant (except for the compilation stage itself).
|
||||
- '-MD' option
|
||||
|
||||
Optimizations:
|
||||
|
||||
- suppress specific anonymous symbol handling
|
||||
- more parse optimizations (=even faster compilation)
|
||||
- memory alloc optimizations (=even faster compilation)
|
||||
- optimize VT_LOCAL + const
|
||||
- better local variables handling (needed for other targets)
|
||||
|
||||
Not critical:
|
||||
|
||||
@@ -65,11 +75,21 @@ Not critical:
|
||||
- add portable byte code generator and interpreter for other
|
||||
unsupported architectures.
|
||||
- C++: variable declaration in for, minimal 'class' support.
|
||||
- win32: add __stdcall, __intxx. use resolve for bchecked malloc et
|
||||
al. check GetModuleHandle for dlls. check exception code (exception
|
||||
filter func).
|
||||
- win32: __intxx. use resolve for bchecked malloc et al.
|
||||
check exception code (exception filter func).
|
||||
- handle void (__attribute__() *ptr)()
|
||||
|
||||
Fixed (probably):
|
||||
|
||||
|
||||
|
||||
- bug with defines:
|
||||
#define spin_lock(lock) do { } while (0)
|
||||
#define wq_spin_lock spin_lock
|
||||
#define TEST() wq_spin_lock(a)
|
||||
- typedefs can be structure fields
|
||||
- see bugfixes.diff + improvement.diff from Daniel Glockner
|
||||
- long long constant evaluation
|
||||
- add alloca()
|
||||
- gcc '-E' option.
|
||||
- #include_next support for /usr/include/limits ?
|
||||
- function pointers/lvalues in ? : (linux kernel net/core/dev.c)
|
||||
- win32: add __stdcall, check GetModuleHandle for dlls.
|
||||
|
||||
446
coff.h
Normal file
446
coff.h
Normal file
@@ -0,0 +1,446 @@
|
||||
/**************************************************************************/
|
||||
/* COFF.H */
|
||||
/* COFF data structures and related definitions used by the linker */
|
||||
/**************************************************************************/
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* COFF FILE HEADER */
|
||||
/*------------------------------------------------------------------------*/
|
||||
struct filehdr {
|
||||
unsigned short f_magic; /* magic number */
|
||||
unsigned short f_nscns; /* number of sections */
|
||||
long f_timdat; /* time & date stamp */
|
||||
long f_symptr; /* file pointer to symtab */
|
||||
long f_nsyms; /* number of symtab entries */
|
||||
unsigned short f_opthdr; /* sizeof(optional hdr) */
|
||||
unsigned short f_flags; /* flags */
|
||||
unsigned short f_TargetID; /* for C6x = 0x0099 */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* File header flags */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define F_RELFLG 0x01 /* relocation info stripped from file */
|
||||
#define F_EXEC 0x02 /* file is executable (no unresolved refs) */
|
||||
#define F_LNNO 0x04 /* line nunbers stripped from file */
|
||||
#define F_LSYMS 0x08 /* local symbols stripped from file */
|
||||
#define F_GSP10 0x10 /* 34010 version */
|
||||
#define F_GSP20 0x20 /* 34020 version */
|
||||
#define F_SWABD 0x40 /* bytes swabbed (in names) */
|
||||
#define F_AR16WR 0x80 /* byte ordering of an AR16WR (PDP-11) */
|
||||
#define F_LITTLE 0x100 /* byte ordering of an AR32WR (vax) */
|
||||
#define F_BIG 0x200 /* byte ordering of an AR32W (3B, maxi) */
|
||||
#define F_PATCH 0x400 /* contains "patch" list in optional header */
|
||||
#define F_NODF 0x400
|
||||
|
||||
#define F_VERSION (F_GSP10 | F_GSP20)
|
||||
#define F_BYTE_ORDER (F_LITTLE | F_BIG)
|
||||
#define FILHDR struct filehdr
|
||||
|
||||
//#define FILHSZ sizeof(FILHDR)
|
||||
#define FILHSZ 22 // above rounds to align on 4 bytes which causes problems
|
||||
|
||||
#define COFF_C67_MAGIC 0x00c2
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Macros to recognize magic numbers */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define ISMAGIC(x) (((unsigned short)(x))==(unsigned short)magic)
|
||||
#define ISARCHIVE(x) ((((unsigned short)(x))==(unsigned short)ARTYPE))
|
||||
#define BADMAGIC(x) (((unsigned short)(x) & 0x8080) && !ISMAGIC(x))
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* OPTIONAL FILE HEADER */
|
||||
/*------------------------------------------------------------------------*/
|
||||
typedef struct aouthdr {
|
||||
short magic; /* see magic.h */
|
||||
short vstamp; /* version stamp */
|
||||
long tsize; /* text size in bytes, padded to FW bdry*/
|
||||
long dsize; /* initialized data " " */
|
||||
long bsize; /* uninitialized data " " */
|
||||
long entrypt; /* entry pt. */
|
||||
long text_start; /* base of text used for this file */
|
||||
long data_start; /* base of data used for this file */
|
||||
} AOUTHDR;
|
||||
|
||||
#define AOUTSZ sizeof(AOUTHDR)
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* When a UNIX aout header is to be built in the optional header, */
|
||||
/* the following magic numbers can appear in that header: */
|
||||
/* */
|
||||
/* AOUT1MAGIC : default : readonly sharable text segment */
|
||||
/* AOUT2MAGIC: : writable text segment */
|
||||
/* PAGEMAGIC : : configured for paging */
|
||||
/*----------------------------------------------------------------------*/
|
||||
#define AOUT1MAGIC 0410
|
||||
#define AOUT2MAGIC 0407
|
||||
#define PAGEMAGIC 0413
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* COMMON ARCHIVE FILE STRUCTURES */
|
||||
/* */
|
||||
/* ARCHIVE File Organization: */
|
||||
/* _______________________________________________ */
|
||||
/* |__________ARCHIVE_MAGIC_STRING_______________| */
|
||||
/* |__________ARCHIVE_FILE_MEMBER_1______________| */
|
||||
/* | | */
|
||||
/* | Archive File Header "ar_hdr" | */
|
||||
/* |.............................................| */
|
||||
/* | Member Contents | */
|
||||
/* | 1. External symbol directory | */
|
||||
/* | 2. Text file | */
|
||||
/* |_____________________________________________| */
|
||||
/* |________ARCHIVE_FILE_MEMBER_2________________| */
|
||||
/* | "ar_hdr" | */
|
||||
/* |.............................................| */
|
||||
/* | Member Contents (.o or text file) | */
|
||||
/* |_____________________________________________| */
|
||||
/* | . . . | */
|
||||
/* | . . . | */
|
||||
/* | . . . | */
|
||||
/* |_____________________________________________| */
|
||||
/* |________ARCHIVE_FILE_MEMBER_n________________| */
|
||||
/* | "ar_hdr" | */
|
||||
/* |.............................................| */
|
||||
/* | Member Contents | */
|
||||
/* |_____________________________________________| */
|
||||
/* */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#define COFF_ARMAG "!<arch>\n"
|
||||
#define SARMAG 8
|
||||
#define ARFMAG "`\n"
|
||||
|
||||
struct ar_hdr /* archive file member header - printable ascii */
|
||||
{
|
||||
char ar_name[16]; /* file member name - `/' terminated */
|
||||
char ar_date[12]; /* file member date - decimal */
|
||||
char ar_uid[6]; /* file member user id - decimal */
|
||||
char ar_gid[6]; /* file member group id - decimal */
|
||||
char ar_mode[8]; /* file member mode - octal */
|
||||
char ar_size[10]; /* file member size - decimal */
|
||||
char ar_fmag[2]; /* ARFMAG - string to end header */
|
||||
};
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* SECTION HEADER */
|
||||
/*------------------------------------------------------------------------*/
|
||||
struct scnhdr {
|
||||
char s_name[8]; /* section name */
|
||||
long s_paddr; /* physical address */
|
||||
long s_vaddr; /* virtual address */
|
||||
long s_size; /* section size */
|
||||
long s_scnptr; /* file ptr to raw data for section */
|
||||
long s_relptr; /* file ptr to relocation */
|
||||
long s_lnnoptr; /* file ptr to line numbers */
|
||||
unsigned int s_nreloc; /* number of relocation entries */
|
||||
unsigned int s_nlnno; /* number of line number entries */
|
||||
unsigned int s_flags; /* flags */
|
||||
unsigned short s_reserved; /* reserved byte */
|
||||
unsigned short s_page; /* memory page id */
|
||||
};
|
||||
|
||||
#define SCNHDR struct scnhdr
|
||||
#define SCNHSZ sizeof(SCNHDR)
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Define constants for names of "special" sections */
|
||||
/*------------------------------------------------------------------------*/
|
||||
//#define _TEXT ".text"
|
||||
#define _DATA ".data"
|
||||
#define _BSS ".bss"
|
||||
#define _CINIT ".cinit"
|
||||
#define _TV ".tv"
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* The low 4 bits of s_flags is used as a section "type" */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define STYP_REG 0x00 /* "regular" : allocated, relocated, loaded */
|
||||
#define STYP_DSECT 0x01 /* "dummy" : not allocated, relocated, not loaded */
|
||||
#define STYP_NOLOAD 0x02 /* "noload" : allocated, relocated, not loaded */
|
||||
#define STYP_GROUP 0x04 /* "grouped" : formed of input sections */
|
||||
#define STYP_PAD 0x08 /* "padding" : not allocated, not relocated, loaded */
|
||||
#define STYP_COPY 0x10 /* "copy" : used for C init tables -
|
||||
not allocated, relocated,
|
||||
loaded; reloc & lineno
|
||||
entries processed normally */
|
||||
#define STYP_TEXT 0x20 /* section contains text only */
|
||||
#define STYP_DATA 0x40 /* section contains data only */
|
||||
#define STYP_BSS 0x80 /* section contains bss only */
|
||||
|
||||
#define STYP_ALIGN 0x100 /* align flag passed by old version assemblers */
|
||||
#define ALIGN_MASK 0x0F00 /* part of s_flags that is used for align vals */
|
||||
#define ALIGNSIZE(x) (1 << ((x & ALIGN_MASK) >> 8))
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* RELOCATION ENTRIES */
|
||||
/*------------------------------------------------------------------------*/
|
||||
struct reloc
|
||||
{
|
||||
long r_vaddr; /* (virtual) address of reference */
|
||||
short r_symndx; /* index into symbol table */
|
||||
unsigned short r_disp; /* additional bits for address calculation */
|
||||
unsigned short r_type; /* relocation type */
|
||||
};
|
||||
|
||||
#define RELOC struct reloc
|
||||
#define RELSZ 10 /* sizeof(RELOC) */
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* define all relocation types */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
#define R_ABS 0 /* absolute address - no relocation */
|
||||
#define R_DIR16 01 /* UNUSED */
|
||||
#define R_REL16 02 /* UNUSED */
|
||||
#define R_DIR24 04 /* UNUSED */
|
||||
#define R_REL24 05 /* 24 bits, direct */
|
||||
#define R_DIR32 06 /* UNUSED */
|
||||
#define R_RELBYTE 017 /* 8 bits, direct */
|
||||
#define R_RELWORD 020 /* 16 bits, direct */
|
||||
#define R_RELLONG 021 /* 32 bits, direct */
|
||||
#define R_PCRBYTE 022 /* 8 bits, PC-relative */
|
||||
#define R_PCRWORD 023 /* 16 bits, PC-relative */
|
||||
#define R_PCRLONG 024 /* 32 bits, PC-relative */
|
||||
#define R_OCRLONG 030 /* GSP: 32 bits, one's complement direct */
|
||||
#define R_GSPPCR16 031 /* GSP: 16 bits, PC relative (in words) */
|
||||
#define R_GSPOPR32 032 /* GSP: 32 bits, direct big-endian */
|
||||
#define R_PARTLS16 040 /* Brahma: 16 bit offset of 24 bit address*/
|
||||
#define R_PARTMS8 041 /* Brahma: 8 bit page of 24 bit address */
|
||||
#define R_PARTLS7 050 /* DSP: 7 bit offset of 16 bit address */
|
||||
#define R_PARTMS9 051 /* DSP: 9 bit page of 16 bit address */
|
||||
#define R_REL13 052 /* DSP: 13 bits, direct */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* LINE NUMBER ENTRIES */
|
||||
/*------------------------------------------------------------------------*/
|
||||
struct lineno
|
||||
{
|
||||
union
|
||||
{
|
||||
long l_symndx ; /* sym. table index of function name
|
||||
iff l_lnno == 0 */
|
||||
long l_paddr ; /* (physical) address of line number */
|
||||
} l_addr ;
|
||||
unsigned short l_lnno ; /* line number */
|
||||
};
|
||||
|
||||
#define LINENO struct lineno
|
||||
#define LINESZ 6 /* sizeof(LINENO) */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* STORAGE CLASSES */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define C_EFCN -1 /* physical end of function */
|
||||
#define C_NULL 0
|
||||
#define C_AUTO 1 /* automatic variable */
|
||||
#define C_EXT 2 /* external symbol */
|
||||
#define C_STAT 3 /* static */
|
||||
#define C_REG 4 /* register variable */
|
||||
#define C_EXTDEF 5 /* external definition */
|
||||
#define C_LABEL 6 /* label */
|
||||
#define C_ULABEL 7 /* undefined label */
|
||||
#define C_MOS 8 /* member of structure */
|
||||
#define C_ARG 9 /* function argument */
|
||||
#define C_STRTAG 10 /* structure tag */
|
||||
#define C_MOU 11 /* member of union */
|
||||
#define C_UNTAG 12 /* union tag */
|
||||
#define C_TPDEF 13 /* type definition */
|
||||
#define C_USTATIC 14 /* undefined static */
|
||||
#define C_ENTAG 15 /* enumeration tag */
|
||||
#define C_MOE 16 /* member of enumeration */
|
||||
#define C_REGPARM 17 /* register parameter */
|
||||
#define C_FIELD 18 /* bit field */
|
||||
|
||||
#define C_BLOCK 100 /* ".bb" or ".eb" */
|
||||
#define C_FCN 101 /* ".bf" or ".ef" */
|
||||
#define C_EOS 102 /* end of structure */
|
||||
#define C_FILE 103 /* file name */
|
||||
#define C_LINE 104 /* dummy sclass for line number entry */
|
||||
#define C_ALIAS 105 /* duplicate tag */
|
||||
#define C_HIDDEN 106 /* special storage class for external */
|
||||
/* symbols in dmert public libraries */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* SYMBOL TABLE ENTRIES */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#define SYMNMLEN 8 /* Number of characters in a symbol name */
|
||||
#define FILNMLEN 14 /* Number of characters in a file name */
|
||||
#define DIMNUM 4 /* Number of array dimensions in auxiliary entry */
|
||||
|
||||
|
||||
struct syment
|
||||
{
|
||||
union
|
||||
{
|
||||
char _n_name[SYMNMLEN]; /* old COFF version */
|
||||
struct
|
||||
{
|
||||
long _n_zeroes; /* new == 0 */
|
||||
long _n_offset; /* offset into string table */
|
||||
} _n_n;
|
||||
char *_n_nptr[2]; /* allows for overlaying */
|
||||
} _n;
|
||||
long n_value; /* value of symbol */
|
||||
short n_scnum; /* section number */
|
||||
unsigned short n_type; /* type and derived type */
|
||||
char n_sclass; /* storage class */
|
||||
char n_numaux; /* number of aux. entries */
|
||||
};
|
||||
|
||||
#define n_name _n._n_name
|
||||
#define n_nptr _n._n_nptr[1]
|
||||
#define n_zeroes _n._n_n._n_zeroes
|
||||
#define n_offset _n._n_n._n_offset
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Relocatable symbols have a section number of the */
|
||||
/* section in which they are defined. Otherwise, section */
|
||||
/* numbers have the following meanings: */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define N_UNDEF 0 /* undefined symbol */
|
||||
#define N_ABS -1 /* value of symbol is absolute */
|
||||
#define N_DEBUG -2 /* special debugging symbol */
|
||||
#define N_TV (unsigned short)-3 /* needs transfer vector (preload) */
|
||||
#define P_TV (unsigned short)-4 /* needs transfer vector (postload) */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* The fundamental type of a symbol packed into the low */
|
||||
/* 4 bits of the word. */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define _EF ".ef"
|
||||
|
||||
#define T_NULL 0 /* no type info */
|
||||
#define T_ARG 1 /* function argument (only used by compiler) */
|
||||
#define T_CHAR 2 /* character */
|
||||
#define T_SHORT 3 /* short integer */
|
||||
#define T_INT 4 /* integer */
|
||||
#define T_LONG 5 /* long integer */
|
||||
#define T_FLOAT 6 /* floating point */
|
||||
#define T_DOUBLE 7 /* double word */
|
||||
#define T_STRUCT 8 /* structure */
|
||||
#define T_UNION 9 /* union */
|
||||
#define T_ENUM 10 /* enumeration */
|
||||
#define T_MOE 11 /* member of enumeration */
|
||||
#define T_UCHAR 12 /* unsigned character */
|
||||
#define T_USHORT 13 /* unsigned short */
|
||||
#define T_UINT 14 /* unsigned integer */
|
||||
#define T_ULONG 15 /* unsigned long */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* derived types are: */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define DT_NON 0 /* no derived type */
|
||||
#define DT_PTR 1 /* pointer */
|
||||
#define DT_FCN 2 /* function */
|
||||
#define DT_ARY 3 /* array */
|
||||
|
||||
#define MKTYPE(basic, d1,d2,d3,d4,d5,d6) \
|
||||
((basic) | ((d1) << 4) | ((d2) << 6) | ((d3) << 8) |\
|
||||
((d4) << 10) | ((d5) << 12) | ((d6) << 14))
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* type packing constants and macros */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define N_BTMASK_COFF 017
|
||||
#define N_TMASK_COFF 060
|
||||
#define N_TMASK1_COFF 0300
|
||||
#define N_TMASK2_COFF 0360
|
||||
#define N_BTSHFT_COFF 4
|
||||
#define N_TSHIFT_COFF 2
|
||||
|
||||
#define BTYPE_COFF(x) ((x) & N_BTMASK_COFF)
|
||||
#define ISINT(x) (((x) >= T_CHAR && (x) <= T_LONG) || \
|
||||
((x) >= T_UCHAR && (x) <= T_ULONG) || (x) == T_ENUM)
|
||||
#define ISFLT_COFF(x) ((x) == T_DOUBLE || (x) == T_FLOAT)
|
||||
#define ISPTR_COFF(x) (((x) & N_TMASK_COFF) == (DT_PTR << N_BTSHFT_COFF))
|
||||
#define ISFCN_COFF(x) (((x) & N_TMASK_COFF) == (DT_FCN << N_BTSHFT_COFF))
|
||||
#define ISARY_COFF(x) (((x) & N_TMASK_COFF) == (DT_ARY << N_BTSHFT_COFF))
|
||||
#define ISTAG_COFF(x) ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)
|
||||
|
||||
#define INCREF_COFF(x) ((((x)&~N_BTMASK_COFF)<<N_TSHIFT_COFF)|(DT_PTR<<N_BTSHFT_COFF)|(x&N_BTMASK_COFF))
|
||||
#define DECREF_COFF(x) ((((x)>>N_TSHIFT_COFF)&~N_BTMASK_COFF)|((x)&N_BTMASK_COFF))
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* AUXILIARY SYMBOL ENTRY */
|
||||
/*------------------------------------------------------------------------*/
|
||||
union auxent
|
||||
{
|
||||
struct
|
||||
{
|
||||
long x_tagndx; /* str, un, or enum tag indx */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned short x_lnno; /* declaration line number */
|
||||
unsigned short x_size; /* str, union, array size */
|
||||
} x_lnsz;
|
||||
long x_fsize; /* size of function */
|
||||
} x_misc;
|
||||
union
|
||||
{
|
||||
struct /* if ISFCN, tag, or .bb */
|
||||
{
|
||||
long x_lnnoptr; /* ptr to fcn line # */
|
||||
long x_endndx; /* entry ndx past block end */
|
||||
} x_fcn;
|
||||
struct /* if ISARY, up to 4 dimen. */
|
||||
{
|
||||
unsigned short x_dimen[DIMNUM];
|
||||
} x_ary;
|
||||
} x_fcnary;
|
||||
unsigned short x_regcount; /* number of registers used by func */
|
||||
} x_sym;
|
||||
struct
|
||||
{
|
||||
char x_fname[FILNMLEN];
|
||||
} x_file;
|
||||
struct
|
||||
{
|
||||
long x_scnlen; /* section length */
|
||||
unsigned short x_nreloc; /* number of relocation entries */
|
||||
unsigned short x_nlinno; /* number of line numbers */
|
||||
} x_scn;
|
||||
};
|
||||
|
||||
#define SYMENT struct syment
|
||||
#define SYMESZ 18 /* sizeof(SYMENT) */
|
||||
|
||||
#define AUXENT union auxent
|
||||
#define AUXESZ 18 /* sizeof(AUXENT) */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* NAMES OF "SPECIAL" SYMBOLS */
|
||||
/*------------------------------------------------------------------------*/
|
||||
#define _STEXT ".text"
|
||||
#define _ETEXT "etext"
|
||||
#define _SDATA ".data"
|
||||
#define _EDATA "edata"
|
||||
#define _SBSS ".bss"
|
||||
#define _END "end"
|
||||
#define _CINITPTR "cinit"
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* ENTRY POINT SYMBOLS */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#define _START "_start"
|
||||
#define _MAIN "_main"
|
||||
/* _CSTART "_c_int00" (defined in params.h) */
|
||||
|
||||
|
||||
#define _TVORIG "_tvorig"
|
||||
#define _TORIGIN "_torigin"
|
||||
#define _DORIGIN "_dorigin"
|
||||
|
||||
#define _SORIGIN "_sorigin"
|
||||
139
configure
vendored
139
configure
vendored
@@ -18,23 +18,29 @@ TMPS="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.S"
|
||||
TMPH="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.h"
|
||||
|
||||
# default parameters
|
||||
prefix="/usr/local"
|
||||
build_cross="no"
|
||||
use_libgcc="no"
|
||||
prefix=""
|
||||
execprefix=""
|
||||
bindir=""
|
||||
libdir=""
|
||||
tccdir=""
|
||||
includedir=""
|
||||
mandir=""
|
||||
sysroot=""
|
||||
cross_prefix=""
|
||||
cc="gcc"
|
||||
host_cc="gcc"
|
||||
ar="ar"
|
||||
make="make"
|
||||
strip="strip"
|
||||
cpu=`uname -m`
|
||||
case "$cpu" in
|
||||
i386|i486|i586|i686|i86pc|BePC)
|
||||
cpu="x86"
|
||||
;;
|
||||
x86_64)
|
||||
cpu="x86-64"
|
||||
;;
|
||||
armv4l)
|
||||
cpu="armv4l"
|
||||
;;
|
||||
@@ -56,10 +62,22 @@ case "$cpu" in
|
||||
esac
|
||||
gprof="no"
|
||||
bigendian="no"
|
||||
mingw32="no"
|
||||
LIBSUF=".a"
|
||||
EXESUF=""
|
||||
|
||||
# OS specific
|
||||
targetos=`uname -s`
|
||||
case $targetos in
|
||||
MINGW32*)
|
||||
mingw32="yes"
|
||||
;;
|
||||
DragonFly)
|
||||
noldl="yes"
|
||||
;;
|
||||
OpenBSD)
|
||||
noldl="yes"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
@@ -88,14 +106,14 @@ for opt do
|
||||
;;
|
||||
--mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
|
||||
;;
|
||||
--sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`
|
||||
;;
|
||||
--source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
|
||||
;;
|
||||
--cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
|
||||
;;
|
||||
--cc=*) cc=`echo $opt | cut -d '=' -f 2`
|
||||
;;
|
||||
--make=*) make=`echo $opt | cut -d '=' -f 2`
|
||||
;;
|
||||
--extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
|
||||
;;
|
||||
--extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
|
||||
@@ -106,6 +124,12 @@ for opt do
|
||||
;;
|
||||
--enable-gprof) gprof="yes"
|
||||
;;
|
||||
--enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
|
||||
;;
|
||||
--enable-cross) build_cross="yes"
|
||||
;;
|
||||
--with-libgcc) use_libgcc="yes"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -118,6 +142,11 @@ cc="${cross_prefix}${cc}"
|
||||
ar="${cross_prefix}${ar}"
|
||||
strip="${cross_prefix}${strip}"
|
||||
|
||||
if test "$mingw32" = "yes" ; then
|
||||
LIBSUF=".lib"
|
||||
EXESUF=".exe"
|
||||
fi
|
||||
|
||||
if test -z "$cross_prefix" ; then
|
||||
|
||||
# ---
|
||||
@@ -125,15 +154,15 @@ if test -z "$cross_prefix" ; then
|
||||
cat > $TMPC << EOF
|
||||
#include <inttypes.h>
|
||||
int main(int argc, char ** argv){
|
||||
volatile uint32_t i=0x01234567;
|
||||
return (*((uint8_t*)(&i))) == 0x67;
|
||||
volatile uint32_t i=0x01234567;
|
||||
return (*((uint8_t*)(&i))) == 0x67;
|
||||
}
|
||||
EOF
|
||||
|
||||
if $cc -o $TMPE $TMPC 2>/dev/null ; then
|
||||
$TMPE && bigendian="yes"
|
||||
$TMPE && bigendian="yes"
|
||||
else
|
||||
echo big/little test failed
|
||||
echo big/little test failed
|
||||
fi
|
||||
|
||||
else
|
||||
@@ -158,7 +187,20 @@ EOF
|
||||
|
||||
gcc_major="2"
|
||||
if $cc -o $TMPO $TMPC 2> /dev/null ; then
|
||||
gcc_major="3"
|
||||
gcc_major="3"
|
||||
fi
|
||||
cat > $TMPC <<EOF
|
||||
int main(void) {
|
||||
#if __GNUC__ >= 4
|
||||
return 0;
|
||||
#else
|
||||
#error gcc < 4
|
||||
#endif
|
||||
}
|
||||
EOF
|
||||
|
||||
if $cc -o $TMPO $TMPC 2> /dev/null ; then
|
||||
gcc_major="4"
|
||||
fi
|
||||
|
||||
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
|
||||
@@ -177,43 +219,69 @@ echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
|
||||
echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
|
||||
echo " --includedir=DIR C header files in DIR [PREFIX/include]"
|
||||
echo " --mandir=DIR man documentation in DIR [PREFIX/man]"
|
||||
echo " --enable-cross build cross compilers"
|
||||
echo ""
|
||||
echo "Advanced options (experts only):"
|
||||
echo " --source-path=PATH path of source code [$source_path]"
|
||||
echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
|
||||
echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
|
||||
echo " --cc=CC use C compiler CC [$cc]"
|
||||
echo " --make=MAKE use specified make [$make]"
|
||||
echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc1.a"
|
||||
echo ""
|
||||
#echo "NOTE: The object files are build at the place where configure is launched"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test x"$execprefix" = x""; then
|
||||
execprefix="${prefix}"
|
||||
fi
|
||||
if test x"$bindir" = x""; then
|
||||
bindir="${execprefix}/bin"
|
||||
fi
|
||||
if test "$mingw32" = "yes" ; then
|
||||
if test -z "$prefix" ; then
|
||||
prefix="C:/Program Files/tcc"
|
||||
fi
|
||||
execprefix="$prefix"
|
||||
bindir="$prefix"
|
||||
tccdir="$prefix"
|
||||
docdir="$prefix/doc"
|
||||
else
|
||||
if test -z "$prefix" ; then
|
||||
prefix="/usr/local"
|
||||
fi
|
||||
if test x"$execprefix" = x""; then
|
||||
execprefix="${prefix}"
|
||||
fi
|
||||
if test x"$bindir" = x""; then
|
||||
bindir="${execprefix}/bin"
|
||||
fi
|
||||
if test x"$docdir" = x""; then
|
||||
docdir="$prefix/share/doc/tcc"
|
||||
fi
|
||||
fi # mingw32
|
||||
|
||||
if test x"$libdir" = x""; then
|
||||
libdir="${execprefix}/lib"
|
||||
fi
|
||||
if test x"$includedir" = x""; then
|
||||
includedir="${prefix}/include"
|
||||
if test x"$tccdir" = x""; then
|
||||
tccdir="${execprefix}/lib/tcc"
|
||||
fi
|
||||
if test x"$mandir" = x""; then
|
||||
mandir="${prefix}/man"
|
||||
fi
|
||||
if test x"$includedir" = x""; then
|
||||
includedir="${prefix}/include"
|
||||
fi
|
||||
|
||||
echo "Binary directory $bindir"
|
||||
echo "TinyCC directory $tccdir"
|
||||
echo "Library directory $libdir"
|
||||
echo "Include directory $includedir"
|
||||
echo "Manual directory $mandir"
|
||||
echo "Manual directory $mandir"
|
||||
echo "Doc directory $docdir"
|
||||
echo "Target root prefix $sysroot"
|
||||
echo "Source path $source_path"
|
||||
echo "C compiler $cc"
|
||||
echo "make $make"
|
||||
echo "CPU $cpu"
|
||||
echo "Big Endian $bigendian"
|
||||
echo "gprof enabled $gprof"
|
||||
echo "cross compilers $build_cross"
|
||||
echo "use libgcc $use_libgcc"
|
||||
|
||||
echo "Creating config.mak and config.h"
|
||||
|
||||
@@ -222,11 +290,13 @@ echo "/* Automatically generated by configure - do not modify */" > $TMPH
|
||||
|
||||
echo "prefix=$prefix" >> config.mak
|
||||
echo "bindir=$bindir" >> config.mak
|
||||
echo "tccdir=$tccdir" >> config.mak
|
||||
echo "libdir=$libdir" >> config.mak
|
||||
echo "includedir=$includedir" >> config.mak
|
||||
echo "mandir=$mandir" >> config.mak
|
||||
echo "#define CONFIG_TCC_LIBDIR \"$libdir\"" >> $TMPH
|
||||
echo "MAKE=$make" >> config.mak
|
||||
echo "docdir=$docdir" >> config.mak
|
||||
echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH
|
||||
echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
|
||||
echo "CC=$cc" >> config.mak
|
||||
echo "GCC_MAJOR=$gcc_major" >> config.mak
|
||||
echo "#define GCC_MAJOR $gcc_major" >> $TMPH
|
||||
@@ -235,9 +305,14 @@ echo "AR=$ar" >> config.mak
|
||||
echo "STRIP=$strip -s -R .comment -R .note" >> config.mak
|
||||
echo "CFLAGS=$CFLAGS" >> config.mak
|
||||
echo "LDFLAGS=$LDFLAGS" >> config.mak
|
||||
echo "LIBSUF=$LIBSUF" >> config.mak
|
||||
echo "EXESUF=$EXESUF" >> config.mak
|
||||
if test "$cpu" = "x86" ; then
|
||||
echo "ARCH=i386" >> config.mak
|
||||
echo "#define HOST_I386 1" >> $TMPH
|
||||
elif test "$cpu" = "x86-64" ; then
|
||||
echo "ARCH=x86-64" >> config.mak
|
||||
echo "#define HOST_X86_64 1" >> $TMPH
|
||||
elif test "$cpu" = "armv4l" ; then
|
||||
echo "ARCH=arm" >> config.mak
|
||||
echo "#define HOST_ARM 1" >> $TMPH
|
||||
@@ -257,6 +332,13 @@ else
|
||||
echo "Unsupported CPU"
|
||||
exit 1
|
||||
fi
|
||||
if test "$noldl" = "yes" ; then
|
||||
echo "CONFIG_NOLDL=yes" >> config.mak
|
||||
fi
|
||||
if test "$mingw32" = "yes" ; then
|
||||
echo "CONFIG_WIN32=yes" >> config.mak
|
||||
echo "#define CONFIG_WIN32 1" >> $TMPH
|
||||
fi
|
||||
if test "$bigendian" = "yes" ; then
|
||||
echo "WORDS_BIGENDIAN=yes" >> config.mak
|
||||
echo "#define WORDS_BIGENDIAN 1" >> $TMPH
|
||||
@@ -265,6 +347,13 @@ if test "$gprof" = "yes" ; then
|
||||
echo "TARGET_GPROF=yes" >> config.mak
|
||||
echo "#define HAVE_GPROF 1" >> $TMPH
|
||||
fi
|
||||
if test "$build_cross" = "yes" ; then
|
||||
echo "CONFIG_CROSS=yes" >> config.mak
|
||||
fi
|
||||
if test "$use_libgcc" = "yes" ; then
|
||||
echo "#define CONFIG_USE_LIBGCC" >> $TMPH
|
||||
echo "CONFIG_USE_LIBGCC=yes" >> config.mak
|
||||
fi
|
||||
version=`head $source_path/VERSION`
|
||||
echo "VERSION=$version" >>config.mak
|
||||
echo "#define TCC_VERSION \"$version\"" >> $TMPH
|
||||
@@ -275,7 +364,7 @@ if test "$source_path_used" = "yes" ; then
|
||||
DIRS="tests"
|
||||
FILES="Makefile tests/Makefile"
|
||||
for dir in $DIRS ; do
|
||||
mkdir -p $dir
|
||||
mkdir -p $dir
|
||||
done
|
||||
for f in $FILES ; do
|
||||
ln -sf $source_path/$f $f
|
||||
@@ -285,9 +374,9 @@ echo "SRC_PATH=$source_path" >> config.mak
|
||||
|
||||
diff $TMPH config.h >/dev/null 2>&1
|
||||
if test $? -ne 0 ; then
|
||||
mv -f $TMPH config.h
|
||||
mv -f $TMPH config.h
|
||||
else
|
||||
echo "config.h is unchanged"
|
||||
echo "config.h is unchanged"
|
||||
fi
|
||||
|
||||
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
|
||||
|
||||
8
examples/ex1.c
Executable file
8
examples/ex1.c
Executable file
@@ -0,0 +1,8 @@
|
||||
#! /usr/local/bin/tcc -run
|
||||
#include <tcclib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
||||
98
examples/ex2.c
Normal file
98
examples/ex2.c
Normal file
@@ -0,0 +1,98 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define N 20
|
||||
|
||||
int nb_num;
|
||||
int tab[N];
|
||||
int stack_ptr;
|
||||
int stack_op[N];
|
||||
int stack_res[60];
|
||||
int result;
|
||||
|
||||
int find(int n, int i1, int a, int b, int op)
|
||||
{
|
||||
int i, j;
|
||||
int c;
|
||||
|
||||
if (stack_ptr >= 0) {
|
||||
stack_res[3*stack_ptr] = a;
|
||||
stack_op[stack_ptr] = op;
|
||||
stack_res[3*stack_ptr+1] = b;
|
||||
stack_res[3*stack_ptr+2] = n;
|
||||
if (n == result)
|
||||
return 1;
|
||||
tab[i1] = n;
|
||||
}
|
||||
|
||||
for(i=0;i<nb_num;i++) {
|
||||
for(j=i+1;j<nb_num;j++) {
|
||||
a = tab[i];
|
||||
b = tab[j];
|
||||
if (a != 0 && b != 0) {
|
||||
|
||||
tab[j] = 0;
|
||||
stack_ptr++;
|
||||
|
||||
if (find(a + b, i, a, b, '+'))
|
||||
return 1;
|
||||
if (find(a - b, i, a, b, '-'))
|
||||
return 1;
|
||||
if (find(b - a, i, b, a, '-'))
|
||||
return 1;
|
||||
if (find(a * b, i, a, b, '*'))
|
||||
return 1;
|
||||
if (b != 0) {
|
||||
c = a / b;
|
||||
if (find(c, i, a, b, '/'))
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a != 0) {
|
||||
c = b / a;
|
||||
if (find(c, i, b, a, '/'))
|
||||
return 1;
|
||||
}
|
||||
|
||||
stack_ptr--;
|
||||
tab[i] = a;
|
||||
tab[j] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, res, p;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s: result numbers...\n"
|
||||
"Try to find result from numbers with the 4 basic operations.\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = 1;
|
||||
result = atoi(argv[p]);
|
||||
printf("result=%d\n", result);
|
||||
nb_num = 0;
|
||||
for(i=p+1;i<argc;i++) {
|
||||
tab[nb_num++] = atoi(argv[i]);
|
||||
}
|
||||
|
||||
stack_ptr = -1;
|
||||
res = find(0, 0, 0, 0, ' ');
|
||||
if (res) {
|
||||
for(i=0;i<=stack_ptr;i++) {
|
||||
printf("%d %c %d = %d\n",
|
||||
stack_res[3*i], stack_op[i],
|
||||
stack_res[3*i+1], stack_res[3*i+2]);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
printf("Impossible\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
24
examples/ex3.c
Normal file
24
examples/ex3.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int fib(n)
|
||||
{
|
||||
if (n <= 2)
|
||||
return 1;
|
||||
else
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int n;
|
||||
if (argc < 2) {
|
||||
printf("usage: fib n\n"
|
||||
"Compute nth Fibonacci number\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
n = atoi(argv[1]);
|
||||
printf("fib(%d) = %d\n", n, fib(n, 2));
|
||||
return 0;
|
||||
}
|
||||
26
examples/ex4.c
Executable file
26
examples/ex4.c
Executable file
@@ -0,0 +1,26 @@
|
||||
#!./tcc -run -L/usr/X11R6/lib -lX11
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/* Yes, TCC can use X11 too ! */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Display *display;
|
||||
Screen *screen;
|
||||
|
||||
display = XOpenDisplay("");
|
||||
if (!display) {
|
||||
fprintf(stderr, "Could not open X11 display\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("X11 display opened.\n");
|
||||
screen = XScreenOfDisplay(display, 0);
|
||||
printf("width = %d\nheight = %d\ndepth = %d\n",
|
||||
screen->width,
|
||||
screen->height,
|
||||
screen->root_depth);
|
||||
XCloseDisplay(display);
|
||||
return 0;
|
||||
}
|
||||
8
examples/ex5.c
Normal file
8
examples/ex5.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
||||
275
i386-asm.c
275
i386-asm.c
@@ -109,9 +109,12 @@ typedef struct Operand {
|
||||
} Operand;
|
||||
|
||||
static const uint8_t reg_to_size[5] = {
|
||||
/*
|
||||
[OP_REG8] = 0,
|
||||
[OP_REG16] = 1,
|
||||
[OP_REG32] = 2,
|
||||
*/
|
||||
0, 0, 1, 0, 2
|
||||
};
|
||||
|
||||
#define WORD_PREFIX_OPCODE 0x66
|
||||
@@ -151,6 +154,15 @@ static const uint8_t test_bits[NB_TEST_OPCODES] = {
|
||||
0x0f, /* g */
|
||||
};
|
||||
|
||||
static const uint8_t segment_prefixes[] = {
|
||||
0x26, /* es */
|
||||
0x2e, /* cs */
|
||||
0x36, /* ss */
|
||||
0x3e, /* ds */
|
||||
0x64, /* fs */
|
||||
0x65 /* gs */
|
||||
};
|
||||
|
||||
static const ASMInstr asm_instrs[] = {
|
||||
#define ALT(x) x
|
||||
#define DEF_ASM_OP0(name, opcode)
|
||||
@@ -311,8 +323,10 @@ static void parse_operand(TCCState *s1, Operand *op)
|
||||
if (tok != ',') {
|
||||
op->reg2 = asm_parse_reg();
|
||||
}
|
||||
skip(',');
|
||||
op->shift = get_reg_shift(s1);
|
||||
if (tok == ',') {
|
||||
next();
|
||||
op->shift = get_reg_shift(s1);
|
||||
}
|
||||
}
|
||||
skip(')');
|
||||
}
|
||||
@@ -364,7 +378,7 @@ static void gen_le16(int v)
|
||||
/* generate the modrm operand */
|
||||
static inline void asm_modrm(int reg, Operand *op)
|
||||
{
|
||||
int mod, reg1, reg2;
|
||||
int mod, reg1, reg2, sib_reg1;
|
||||
|
||||
if (op->type & (OP_REG | OP_MMX | OP_SSE)) {
|
||||
g(0xc0 + (reg << 3) + op->reg);
|
||||
@@ -373,8 +387,12 @@ static inline void asm_modrm(int reg, Operand *op)
|
||||
g(0x05 + (reg << 3));
|
||||
gen_expr32(&op->e);
|
||||
} else {
|
||||
sib_reg1 = op->reg;
|
||||
/* fist compute displacement encoding */
|
||||
if (op->e.v == 0 && !op->e.sym && op->reg != 5) {
|
||||
if (sib_reg1 == -1) {
|
||||
sib_reg1 = 5;
|
||||
mod = 0x00;
|
||||
} else if (op->e.v == 0 && !op->e.sym && op->reg != 5) {
|
||||
mod = 0x00;
|
||||
} else if (op->e.v == (int8_t)op->e.v && !op->e.sym) {
|
||||
mod = 0x40;
|
||||
@@ -391,13 +409,13 @@ static inline void asm_modrm(int reg, Operand *op)
|
||||
reg2 = op->reg2;
|
||||
if (reg2 == -1)
|
||||
reg2 = 4; /* indicate no index */
|
||||
g((op->shift << 6) + (reg2 << 3) + op->reg);
|
||||
g((op->shift << 6) + (reg2 << 3) + sib_reg1);
|
||||
}
|
||||
|
||||
/* add offset */
|
||||
if (mod == 0x40) {
|
||||
g(op->e.v);
|
||||
} else if (mod == 0x80) {
|
||||
} else if (mod == 0x80 || op->reg == -1) {
|
||||
gen_expr32(&op->e);
|
||||
}
|
||||
}
|
||||
@@ -406,7 +424,7 @@ static inline void asm_modrm(int reg, Operand *op)
|
||||
static void asm_opcode(TCCState *s1, int opcode)
|
||||
{
|
||||
const ASMInstr *pa;
|
||||
int i, modrm_index, reg, v, op1, is_short_jmp;
|
||||
int i, modrm_index, reg, v, op1, is_short_jmp, seg_prefix;
|
||||
int nb_ops, s, ss;
|
||||
Operand ops[MAX_OPERANDS], *pop;
|
||||
int op_type[3]; /* decoded op type */
|
||||
@@ -414,6 +432,7 @@ static void asm_opcode(TCCState *s1, int opcode)
|
||||
/* get operands */
|
||||
pop = ops;
|
||||
nb_ops = 0;
|
||||
seg_prefix = 0;
|
||||
for(;;) {
|
||||
if (tok == ';' || tok == TOK_LINEFEED)
|
||||
break;
|
||||
@@ -421,6 +440,17 @@ static void asm_opcode(TCCState *s1, int opcode)
|
||||
error("incorrect number of operands");
|
||||
}
|
||||
parse_operand(s1, pop);
|
||||
if (tok == ':') {
|
||||
if (pop->type != OP_SEG || seg_prefix) {
|
||||
error("incorrect prefix");
|
||||
}
|
||||
seg_prefix = segment_prefixes[pop->reg];
|
||||
next();
|
||||
parse_operand(s1, pop);
|
||||
if (!(pop->type & OP_EA)) {
|
||||
error("segment prefix must be followed by memory reference");
|
||||
}
|
||||
}
|
||||
pop++;
|
||||
nb_ops++;
|
||||
if (tok != ',')
|
||||
@@ -517,7 +547,11 @@ static void asm_opcode(TCCState *s1, int opcode)
|
||||
s = reg_to_size[ops[i].type & OP_REG];
|
||||
}
|
||||
if (s == 3) {
|
||||
error("cannot infer opcode suffix");
|
||||
if ((opcode == TOK_ASM_push || opcode == TOK_ASM_pop) &&
|
||||
(ops[0].type & (OP_SEG | OP_IM8S | OP_IM32)))
|
||||
s = 2;
|
||||
else
|
||||
error("cannot infer opcode suffix");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,6 +564,8 @@ static void asm_opcode(TCCState *s1, int opcode)
|
||||
/* now generates the operation */
|
||||
if (pa->instr_type & OPC_FWAIT)
|
||||
g(0x9b);
|
||||
if (seg_prefix)
|
||||
g(seg_prefix);
|
||||
|
||||
v = pa->opcode;
|
||||
if (v == 0x69 || v == 0x69) {
|
||||
@@ -752,50 +788,56 @@ static const char *skip_constraint_modifiers(const char *p)
|
||||
return p;
|
||||
}
|
||||
|
||||
static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
ASMOperand *operands,
|
||||
int nb_operands1, int nb_outputs,
|
||||
int is_output,
|
||||
uint8_t *input_regs_allocated)
|
||||
#define REG_OUT_MASK 0x01
|
||||
#define REG_IN_MASK 0x02
|
||||
|
||||
#define is_reg_allocated(reg) (regs_allocated[reg] & reg_mask)
|
||||
|
||||
static void asm_compute_constraints(ASMOperand *operands,
|
||||
int nb_operands, int nb_outputs,
|
||||
const uint8_t *clobber_regs,
|
||||
int *pout_reg)
|
||||
{
|
||||
ASMOperand *op;
|
||||
int sorted_op[MAX_ASM_OPERANDS];
|
||||
int i, j, k, p1, p2, tmp, reg, c, base, nb_operands;
|
||||
int i, j, k, p1, p2, tmp, reg, c, reg_mask;
|
||||
const char *str;
|
||||
uint8_t regs_allocated[NB_ASM_REGS];
|
||||
|
||||
if (is_output) {
|
||||
base = 0;
|
||||
nb_operands = nb_outputs;
|
||||
} else {
|
||||
base = nb_outputs;
|
||||
nb_operands = nb_operands1 - nb_outputs;
|
||||
/* init fields */
|
||||
for(i=0;i<nb_operands;i++) {
|
||||
op = &operands[i];
|
||||
op->input_index = -1;
|
||||
op->ref_index = -1;
|
||||
op->reg = -1;
|
||||
op->is_memory = 0;
|
||||
op->is_rw = 0;
|
||||
}
|
||||
|
||||
/* compute constraint priority and evaluate references to output
|
||||
constraints if input constraints */
|
||||
for(i=0;i<nb_operands;i++) {
|
||||
j = base + i;
|
||||
op = &operands[j];
|
||||
op = &operands[i];
|
||||
str = op->constraint;
|
||||
op->ref_index = -1;
|
||||
op->reg = -1;
|
||||
str = skip_constraint_modifiers(str);
|
||||
if (!is_output && (isnum(*str) || *str == '[')) {
|
||||
if (isnum(*str) || *str == '[') {
|
||||
/* this is a reference to another constraint */
|
||||
k = find_constraint(operands, nb_operands1, str, NULL);
|
||||
if ((unsigned)k >= j)
|
||||
k = find_constraint(operands, nb_operands, str, NULL);
|
||||
if ((unsigned)k >= i || i < nb_outputs)
|
||||
error("invalid reference in constraint %d ('%s')",
|
||||
j, str);
|
||||
i, str);
|
||||
op->ref_index = k;
|
||||
str = operands[k].constraint;
|
||||
str = skip_constraint_modifiers(str);
|
||||
if (operands[k].input_index >= 0)
|
||||
error("cannot reference twice the same operand");
|
||||
operands[k].input_index = i;
|
||||
op->priority = 5;
|
||||
} else {
|
||||
op->priority = constraint_priority(str);
|
||||
}
|
||||
op->priority = constraint_priority(str);
|
||||
}
|
||||
|
||||
/* sort operands according to their priority */
|
||||
for(i=0;i<nb_operands;i++)
|
||||
sorted_op[i] = base + i;
|
||||
sorted_op[i] = i;
|
||||
for(i=0;i<nb_operands - 1;i++) {
|
||||
for(j=i+1;j<nb_operands;j++) {
|
||||
p1 = operands[sorted_op[i]].priority;
|
||||
@@ -808,32 +850,55 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
}
|
||||
}
|
||||
|
||||
memset(regs_allocated, 0, NB_ASM_REGS);
|
||||
regs_allocated[4] = 1; /* esp cannot be used */
|
||||
regs_allocated[5] = 1; /* ebp cannot be used yet */
|
||||
|
||||
for(i = 0;i < NB_ASM_REGS; i++) {
|
||||
if (clobber_regs[i])
|
||||
regs_allocated[i] = REG_IN_MASK | REG_OUT_MASK;
|
||||
else
|
||||
regs_allocated[i] = 0;
|
||||
}
|
||||
/* esp cannot be used */
|
||||
regs_allocated[4] = REG_IN_MASK | REG_OUT_MASK;
|
||||
/* ebp cannot be used yet */
|
||||
regs_allocated[5] = REG_IN_MASK | REG_OUT_MASK;
|
||||
|
||||
/* allocate registers and generate corresponding asm moves */
|
||||
for(i=0;i<nb_operands;i++) {
|
||||
j = sorted_op[i];
|
||||
op = &operands[j];
|
||||
str = op->constraint;
|
||||
|
||||
if (op->ref_index >= 0) {
|
||||
str = operands[op->ref_index].constraint;
|
||||
/* no need to allocate references */
|
||||
if (op->ref_index >= 0)
|
||||
continue;
|
||||
/* select if register is used for output, input or both */
|
||||
if (op->input_index >= 0) {
|
||||
reg_mask = REG_IN_MASK | REG_OUT_MASK;
|
||||
} else if (j < nb_outputs) {
|
||||
reg_mask = REG_OUT_MASK;
|
||||
} else {
|
||||
reg_mask = REG_IN_MASK;
|
||||
}
|
||||
|
||||
str = skip_constraint_modifiers(str);
|
||||
try_next:
|
||||
c = *str++;
|
||||
switch(c) {
|
||||
case '=':
|
||||
goto try_next;
|
||||
case '+':
|
||||
op->is_rw = 1;
|
||||
/* FALL THRU */
|
||||
case '&':
|
||||
if (j >= nb_outputs)
|
||||
error("'%c' modifier can only be applied to outputs", c);
|
||||
reg_mask = REG_IN_MASK | REG_OUT_MASK;
|
||||
goto try_next;
|
||||
case 'A':
|
||||
/* allocate both eax and edx */
|
||||
if (regs_allocated[TREG_EAX] || regs_allocated[TREG_EDX])
|
||||
if (is_reg_allocated(TREG_EAX) ||
|
||||
is_reg_allocated(TREG_EDX))
|
||||
goto try_next;
|
||||
op->is_llong = 1;
|
||||
op->reg = TREG_EAX;
|
||||
regs_allocated[TREG_EAX] = 1;
|
||||
regs_allocated[TREG_EDX] = 1;
|
||||
regs_allocated[TREG_EAX] |= reg_mask;
|
||||
regs_allocated[TREG_EDX] |= reg_mask;
|
||||
break;
|
||||
case 'a':
|
||||
reg = TREG_EAX;
|
||||
@@ -853,20 +918,20 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
case 'D':
|
||||
reg = 7;
|
||||
alloc_reg:
|
||||
if (regs_allocated[reg])
|
||||
if (is_reg_allocated(reg))
|
||||
goto try_next;
|
||||
goto reg_found;
|
||||
case 'q':
|
||||
/* eax, ebx, ecx or edx */
|
||||
for(reg = 0; reg < 4; reg++) {
|
||||
if (!regs_allocated[reg])
|
||||
if (!is_reg_allocated(reg))
|
||||
goto reg_found;
|
||||
}
|
||||
goto try_next;
|
||||
case 'r':
|
||||
/* any general register */
|
||||
for(reg = 0; reg < 8; reg++) {
|
||||
if (!regs_allocated[reg])
|
||||
if (!is_reg_allocated(reg))
|
||||
goto reg_found;
|
||||
}
|
||||
goto try_next;
|
||||
@@ -874,7 +939,7 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
/* now we can reload in the register */
|
||||
op->is_llong = 0;
|
||||
op->reg = reg;
|
||||
regs_allocated[reg] = 1;
|
||||
regs_allocated[reg] |= reg_mask;
|
||||
break;
|
||||
case 'i':
|
||||
if (!((op->vt->r & (VT_VALMASK | VT_LVAL)) == VT_CONST))
|
||||
@@ -888,25 +953,27 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
break;
|
||||
case 'm':
|
||||
case 'g':
|
||||
/* nothing special to do because the operand is
|
||||
already in memory */
|
||||
/* nothing special to do because the operand is already in
|
||||
memory, except if the pointer itself is stored in a
|
||||
memory variable (VT_LLOCAL case) */
|
||||
/* XXX: fix constant case */
|
||||
if (is_output) {
|
||||
/* if it is a reference to a memory zone, it must lie
|
||||
in a register, so we reserve the register in the
|
||||
input registers and a load will be generated
|
||||
later */
|
||||
/* if it is a reference to a memory zone, it must lie
|
||||
in a register, so we reserve the register in the
|
||||
input registers and a load will be generated
|
||||
later */
|
||||
if (j < nb_outputs || c == 'm') {
|
||||
if ((op->vt->r & VT_VALMASK) == VT_LLOCAL) {
|
||||
/* any general register */
|
||||
for(reg = 0; reg < 8; reg++) {
|
||||
if (!input_regs_allocated[reg])
|
||||
if (!(regs_allocated[reg] & REG_IN_MASK))
|
||||
goto reg_found1;
|
||||
}
|
||||
goto try_next;
|
||||
reg_found1:
|
||||
/* now we can reload in the register */
|
||||
input_regs_allocated[reg] = 1;
|
||||
regs_allocated[reg] |= REG_IN_MASK;
|
||||
op->reg = reg;
|
||||
op->is_memory = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -915,14 +982,34 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
j, op->constraint);
|
||||
break;
|
||||
}
|
||||
/* if a reference is present for that operand, we assign it too */
|
||||
if (op->input_index >= 0) {
|
||||
operands[op->input_index].reg = op->reg;
|
||||
operands[op->input_index].is_llong = op->is_llong;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* compute out_reg. It is used to store outputs registers to memory
|
||||
locations references by pointers (VT_LLOCAL case) */
|
||||
*pout_reg = -1;
|
||||
for(i=0;i<nb_operands;i++) {
|
||||
op = &operands[i];
|
||||
if (op->reg >= 0 &&
|
||||
(op->vt->r & VT_VALMASK) == VT_LLOCAL &&
|
||||
!op->is_memory) {
|
||||
for(reg = 0; reg < 8; reg++) {
|
||||
if (!(regs_allocated[reg] & REG_OUT_MASK))
|
||||
goto reg_found2;
|
||||
}
|
||||
error("could not find free output register for reloading");
|
||||
reg_found2:
|
||||
*pout_reg = reg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* print sorted constraints */
|
||||
#ifdef ASM_DEBUG
|
||||
if (is_output)
|
||||
printf("outputs=\n");
|
||||
else
|
||||
printf("inputs=\n");
|
||||
for(i=0;i<nb_operands;i++) {
|
||||
j = sorted_op[i];
|
||||
op = &operands[j];
|
||||
@@ -933,6 +1020,8 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
op->vt->r,
|
||||
op->reg);
|
||||
}
|
||||
if (*pout_reg >= 0)
|
||||
printf("out_reg=%d\n", *pout_reg);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1019,7 +1108,8 @@ static void subst_asm_operand(CString *add_str,
|
||||
/* generate prolog and epilog code for asm statment */
|
||||
static void asm_gen_code(ASMOperand *operands, int nb_operands,
|
||||
int nb_outputs, int is_output,
|
||||
uint8_t *clobber_regs)
|
||||
uint8_t *clobber_regs,
|
||||
int out_reg)
|
||||
{
|
||||
uint8_t regs_allocated[NB_ASM_REGS];
|
||||
ASMOperand *op;
|
||||
@@ -1042,39 +1132,52 @@ static void asm_gen_code(ASMOperand *operands, int nb_operands,
|
||||
}
|
||||
|
||||
/* generate load code */
|
||||
for(i = nb_outputs ; i < nb_operands; i++) {
|
||||
for(i = 0; i < nb_operands; i++) {
|
||||
op = &operands[i];
|
||||
if (op->reg >= 0) {
|
||||
load(op->reg, op->vt);
|
||||
if (op->is_llong) {
|
||||
if ((op->vt->r & VT_VALMASK) == VT_LLOCAL &&
|
||||
op->is_memory) {
|
||||
/* memory reference case (for both input and
|
||||
output cases) */
|
||||
SValue sv;
|
||||
sv = *op->vt;
|
||||
sv.c.ul += 4;
|
||||
load(TREG_EDX, &sv);
|
||||
sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
|
||||
load(op->reg, &sv);
|
||||
} else if (i >= nb_outputs || op->is_rw) {
|
||||
/* load value in register */
|
||||
load(op->reg, op->vt);
|
||||
if (op->is_llong) {
|
||||
SValue sv;
|
||||
sv = *op->vt;
|
||||
sv.c.ul += 4;
|
||||
load(TREG_EDX, &sv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* generate load code for output memory references */
|
||||
for(i = 0 ; i < nb_outputs; i++) {
|
||||
op = &operands[i];
|
||||
if (op->reg >= 0 && ((op->vt->r & VT_VALMASK) == VT_LLOCAL)) {
|
||||
SValue sv;
|
||||
sv = *op->vt;
|
||||
sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
|
||||
load(op->reg, &sv);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* generate save code */
|
||||
for(i = 0 ; i < nb_outputs; i++) {
|
||||
op = &operands[i];
|
||||
if (op->reg >= 0 && ((op->vt->r & VT_VALMASK) != VT_LLOCAL)) {
|
||||
store(op->reg, op->vt);
|
||||
if (op->is_llong) {
|
||||
SValue sv;
|
||||
sv = *op->vt;
|
||||
sv.c.ul += 4;
|
||||
store(TREG_EDX, &sv);
|
||||
if (op->reg >= 0) {
|
||||
if ((op->vt->r & VT_VALMASK) == VT_LLOCAL) {
|
||||
if (!op->is_memory) {
|
||||
SValue sv;
|
||||
sv = *op->vt;
|
||||
sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
|
||||
load(out_reg, &sv);
|
||||
|
||||
sv.r = (sv.r & ~VT_VALMASK) | out_reg;
|
||||
store(op->reg, &sv);
|
||||
}
|
||||
} else {
|
||||
store(op->reg, op->vt);
|
||||
if (op->is_llong) {
|
||||
SValue sv;
|
||||
sv = *op->vt;
|
||||
sv.c.ul += 4;
|
||||
store(TREG_EDX, &sv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
i386-asm.h
10
i386-asm.h
@@ -120,13 +120,13 @@ ALT(DEF_ASM_OP2(movzwl, 0x0fb7, 0, OPC_MODRM, OPT_REG16 | OPT_EA, OPT_REG32))
|
||||
|
||||
ALT(DEF_ASM_OP1(pushw, 0x50, 0, OPC_REG | OPC_WL, OPT_REGW))
|
||||
ALT(DEF_ASM_OP1(pushw, 0xff, 6, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA))
|
||||
ALT(DEF_ASM_OP1(push, 0x6a, 0, 0, OPT_IM8S))
|
||||
ALT(DEF_ASM_OP1(push, 0x68, 0, 0, OPT_IM32))
|
||||
ALT(DEF_ASM_OP1(push, 0x06, 0, 0, OPT_SEG))
|
||||
ALT(DEF_ASM_OP1(pushw, 0x6a, 0, OPC_WL, OPT_IM8S))
|
||||
ALT(DEF_ASM_OP1(pushw, 0x68, 0, OPC_WL, OPT_IM32))
|
||||
ALT(DEF_ASM_OP1(pushw, 0x06, 0, OPC_WL, OPT_SEG))
|
||||
|
||||
ALT(DEF_ASM_OP1(popw, 0x58, 0, OPC_REG | OPC_WL, OPT_REGW))
|
||||
ALT(DEF_ASM_OP1(popw, 0x8f, 0, OPC_MODRM | OPC_WL, OPT_REGW | OPT_EA))
|
||||
ALT(DEF_ASM_OP1(pop, 0x07, 0, 0, OPT_SEG))
|
||||
ALT(DEF_ASM_OP1(popw, 0x07, 0, OPC_WL, OPT_SEG))
|
||||
|
||||
ALT(DEF_ASM_OP2(xchgw, 0x90, 0, OPC_REG | OPC_WL, OPT_REG, OPT_EAX))
|
||||
ALT(DEF_ASM_OP2(xchgw, 0x90, 0, OPC_REG | OPC_WL, OPT_EAX, OPT_REG))
|
||||
@@ -330,6 +330,8 @@ ALT(DEF_ASM_OP1(fstsw, 0xdd, 7, OPC_MODRM | OPC_FWAIT, OPT_EA ))
|
||||
DEF_ASM_OP1(frstor, 0xdd, 4, OPC_MODRM, OPT_EA )
|
||||
DEF_ASM_OP1(ffree, 0xddc0, 4, OPC_REG, OPT_ST )
|
||||
DEF_ASM_OP1(ffreep, 0xdfc0, 4, OPC_REG, OPT_ST )
|
||||
DEF_ASM_OP1(fxsave, 0x0fae, 0, OPC_MODRM, OPT_EA )
|
||||
DEF_ASM_OP1(fxrstor, 0x0fae, 1, OPC_MODRM, OPT_EA )
|
||||
|
||||
/* segments */
|
||||
DEF_ASM_OP2(arpl, 0x63, 0, OPC_MODRM, OPT_REG16, OPT_REG16 | OPT_EA)
|
||||
|
||||
130
i386-gen.c
130
i386-gen.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* X86 code generator for TCC
|
||||
*
|
||||
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard
|
||||
* Copyright (c) 2001-2004 Fabrice Bellard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -70,8 +70,18 @@ int reg_classes[NB_REGS] = {
|
||||
/* maximum alignment (for aligned attribute support) */
|
||||
#define MAX_ALIGN 8
|
||||
|
||||
/******************************************************/
|
||||
/* ELF defines */
|
||||
|
||||
#define EM_TCC_TARGET EM_386
|
||||
|
||||
/* relocation type for 32 bit data relocation */
|
||||
#define R_DATA_32 R_386_32
|
||||
#define R_DATA_32 R_386_32
|
||||
#define R_JMP_SLOT R_386_JMP_SLOT
|
||||
#define R_COPY R_386_COPY
|
||||
|
||||
#define ELF_START_ADDR 0x08048000
|
||||
#define ELF_PAGE_SIZE 0x1000
|
||||
|
||||
/******************************************************/
|
||||
|
||||
@@ -90,11 +100,11 @@ void g(int c)
|
||||
ind = ind1;
|
||||
}
|
||||
|
||||
void o(int c)
|
||||
void o(unsigned int c)
|
||||
{
|
||||
while (c) {
|
||||
g(c);
|
||||
c = c / 256;
|
||||
c = c >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +272,7 @@ void store(int r, SValue *v)
|
||||
} else {
|
||||
if (bt == VT_SHORT)
|
||||
o(0x66);
|
||||
if (bt == VT_BYTE)
|
||||
if (bt == VT_BYTE || bt == VT_BOOL)
|
||||
o(0x88);
|
||||
else
|
||||
o(0x89);
|
||||
@@ -310,12 +320,15 @@ static void gcall_or_jmp(int is_jmp)
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t fastcall_regs[3] = { TREG_EAX, TREG_EDX, TREG_ECX };
|
||||
static uint8_t fastcallw_regs[2] = { TREG_ECX, TREG_EDX };
|
||||
|
||||
/* Generate function call. The function address is pushed first, then
|
||||
all the parameters in call order. This functions pops all the
|
||||
parameters and the function address. */
|
||||
void gfunc_call(int nb_args)
|
||||
{
|
||||
int size, align, r, args_size, i;
|
||||
int size, align, r, args_size, i, func_call;
|
||||
Sym *func_sym;
|
||||
|
||||
args_size = 0;
|
||||
@@ -367,34 +380,78 @@ void gfunc_call(int nb_args)
|
||||
}
|
||||
save_regs(0); /* save used temporary registers */
|
||||
func_sym = vtop->type.ref;
|
||||
func_call = FUNC_CALL(func_sym->r);
|
||||
/* fast call case */
|
||||
if ((func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) ||
|
||||
func_call == FUNC_FASTCALLW) {
|
||||
int fastcall_nb_regs;
|
||||
uint8_t *fastcall_regs_ptr;
|
||||
if (func_call == FUNC_FASTCALLW) {
|
||||
fastcall_regs_ptr = fastcallw_regs;
|
||||
fastcall_nb_regs = 2;
|
||||
} else {
|
||||
fastcall_regs_ptr = fastcall_regs;
|
||||
fastcall_nb_regs = func_call - FUNC_FASTCALL1 + 1;
|
||||
}
|
||||
for(i = 0;i < fastcall_nb_regs; i++) {
|
||||
if (args_size <= 0)
|
||||
break;
|
||||
o(0x58 + fastcall_regs_ptr[i]); /* pop r */
|
||||
/* XXX: incorrect for struct/floats */
|
||||
args_size -= 4;
|
||||
}
|
||||
}
|
||||
gcall_or_jmp(0);
|
||||
if (args_size && func_sym->r == FUNC_CDECL)
|
||||
if (args_size && func_call != FUNC_STDCALL)
|
||||
gadd_sp(args_size);
|
||||
vtop--;
|
||||
}
|
||||
|
||||
#ifdef TCC_TARGET_PE
|
||||
#define FUNC_PROLOG_SIZE 10
|
||||
#else
|
||||
#define FUNC_PROLOG_SIZE 9
|
||||
#endif
|
||||
|
||||
/* generate function prolog of type 't' */
|
||||
void gfunc_prolog(CType *func_type)
|
||||
{
|
||||
int addr, align, size, func_call;
|
||||
int addr, align, size, func_call, fastcall_nb_regs;
|
||||
int param_index, param_addr;
|
||||
uint8_t *fastcall_regs_ptr;
|
||||
Sym *sym;
|
||||
CType *type;
|
||||
|
||||
sym = func_type->ref;
|
||||
func_call = sym->r;
|
||||
func_call = FUNC_CALL(sym->r);
|
||||
addr = 8;
|
||||
loc = 0;
|
||||
if (func_call >= FUNC_FASTCALL1 && func_call <= FUNC_FASTCALL3) {
|
||||
fastcall_nb_regs = func_call - FUNC_FASTCALL1 + 1;
|
||||
fastcall_regs_ptr = fastcall_regs;
|
||||
} else if (func_call == FUNC_FASTCALLW) {
|
||||
fastcall_nb_regs = 2;
|
||||
fastcall_regs_ptr = fastcallw_regs;
|
||||
} else {
|
||||
fastcall_nb_regs = 0;
|
||||
fastcall_regs_ptr = NULL;
|
||||
}
|
||||
param_index = 0;
|
||||
|
||||
ind += FUNC_PROLOG_SIZE;
|
||||
func_sub_sp_offset = ind;
|
||||
/* if the function returns a structure, then add an
|
||||
implicit pointer parameter */
|
||||
func_vt = sym->type;
|
||||
if ((func_vt.t & VT_BTYPE) == VT_STRUCT) {
|
||||
/* XXX: fastcall case ? */
|
||||
func_vc = addr;
|
||||
addr += 4;
|
||||
param_index++;
|
||||
}
|
||||
/* define parameters */
|
||||
while ((sym = sym->next) != NULL) {
|
||||
type = &sym->type;
|
||||
sym_push(sym->v & ~SYM_FIELD, type,
|
||||
VT_LOCAL | VT_LVAL, addr);
|
||||
size = type_size(type, &align);
|
||||
size = (size + 3) & ~3;
|
||||
#ifdef FUNC_STRUCT_PARAM_AS_PTR
|
||||
@@ -403,16 +460,27 @@ void gfunc_prolog(CType *func_type)
|
||||
size = 4;
|
||||
}
|
||||
#endif
|
||||
addr += size;
|
||||
if (param_index < fastcall_nb_regs) {
|
||||
/* save FASTCALL register */
|
||||
loc -= 4;
|
||||
o(0x89); /* movl */
|
||||
gen_modrm(fastcall_regs_ptr[param_index], VT_LOCAL, NULL, loc);
|
||||
param_addr = loc;
|
||||
} else {
|
||||
param_addr = addr;
|
||||
addr += size;
|
||||
}
|
||||
sym_push(sym->v & ~SYM_FIELD, type,
|
||||
VT_LOCAL | lvalue_type(type->t), param_addr);
|
||||
param_index++;
|
||||
}
|
||||
func_ret_sub = 0;
|
||||
/* pascal type call ? */
|
||||
if (func_call == FUNC_STDCALL)
|
||||
func_ret_sub = addr - 8;
|
||||
o(0xe58955); /* push %ebp, mov %esp, %ebp */
|
||||
func_sub_sp_offset = oad(0xec81, 0); /* sub $xxx, %esp */
|
||||
|
||||
/* leave some room for bound checking code */
|
||||
if (do_bounds_check) {
|
||||
if (tcc_state->do_bounds_check) {
|
||||
oad(0xb8, 0); /* lbound section pointer */
|
||||
oad(0xb8, 0); /* call to function */
|
||||
func_bound_offset = lbounds_section->data_offset;
|
||||
@@ -422,8 +490,11 @@ void gfunc_prolog(CType *func_type)
|
||||
/* generate function epilog */
|
||||
void gfunc_epilog(void)
|
||||
{
|
||||
int v, saved_ind;
|
||||
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
if (do_bounds_check && func_bound_offset != lbounds_section->data_offset) {
|
||||
if (tcc_state->do_bounds_check
|
||||
&& func_bound_offset != lbounds_section->data_offset) {
|
||||
int saved_ind;
|
||||
int *bounds_ptr;
|
||||
Sym *sym, *sym_data;
|
||||
@@ -432,7 +503,7 @@ void gfunc_epilog(void)
|
||||
*bounds_ptr = 0;
|
||||
/* generate bound local allocation */
|
||||
saved_ind = ind;
|
||||
ind = func_sub_sp_offset + 4;
|
||||
ind = func_sub_sp_offset;
|
||||
sym_data = get_sym_ref(&char_pointer_type, lbounds_section,
|
||||
func_bound_offset, lbounds_section->data_offset);
|
||||
greloc(cur_text_section, sym_data,
|
||||
@@ -464,7 +535,27 @@ void gfunc_epilog(void)
|
||||
g(func_ret_sub >> 8);
|
||||
}
|
||||
/* align local size to word & save local variables */
|
||||
*(int *)(cur_text_section->data + func_sub_sp_offset) = (-loc + 3) & -4;
|
||||
|
||||
v = (-loc + 3) & -4;
|
||||
saved_ind = ind;
|
||||
ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
|
||||
#ifdef TCC_TARGET_PE
|
||||
if (v >= 4096) {
|
||||
Sym *sym = external_global_sym(TOK___chkstk, &func_old_type, 0);
|
||||
oad(0xb8, v); /* mov stacksize, %eax */
|
||||
oad(0xe8, -4); /* call __chkstk, (does the stackframe too) */
|
||||
greloc(cur_text_section, sym, ind-4, R_386_PC32);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
o(0xe58955); /* push %ebp, mov %esp, %ebp */
|
||||
o(0xec81); /* sub esp, stacksize */
|
||||
gen_le32(v);
|
||||
#if FUNC_PROLOG_SIZE == 10
|
||||
o(0x90); /* adjust to FUNC_PROLOG_SIZE */
|
||||
#endif
|
||||
}
|
||||
ind = saved_ind;
|
||||
}
|
||||
|
||||
/* generate a jump to a label */
|
||||
@@ -510,7 +601,8 @@ int gtst(int inv, int t)
|
||||
gsym(vtop->c.i);
|
||||
}
|
||||
} else {
|
||||
if (is_float(vtop->type.t)) {
|
||||
if (is_float(vtop->type.t) ||
|
||||
(vtop->type.t & VT_BTYPE) == VT_LLONG) {
|
||||
vpushi(0);
|
||||
gen_op(TOK_NE);
|
||||
}
|
||||
|
||||
24
il-gen.c
24
il-gen.c
@@ -3,19 +3,19 @@
|
||||
*
|
||||
* Copyright (c) 2002 Fabrice Bellard
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* number of available registers */
|
||||
@@ -449,7 +449,7 @@ void gfunc_prolog(int t)
|
||||
while ((sym = sym->next) != NULL) {
|
||||
u = sym->t;
|
||||
sym_push(sym->v & ~SYM_FIELD, u,
|
||||
VT_LOCAL | VT_LVAL, addr);
|
||||
VT_LOCAL | lvalue_type(sym->type.t), addr);
|
||||
addr++;
|
||||
}
|
||||
}
|
||||
|
||||
67
include/stdarg.h
Normal file
67
include/stdarg.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef _STDARG_H
|
||||
#define _STDARG_H
|
||||
|
||||
#ifdef __x86_64__
|
||||
#include <stdlib.h>
|
||||
|
||||
/* GCC compatible definition of va_list. */
|
||||
struct __va_list_struct {
|
||||
unsigned int gp_offset;
|
||||
unsigned int fp_offset;
|
||||
union {
|
||||
unsigned int overflow_offset;
|
||||
char *overflow_arg_area;
|
||||
};
|
||||
char *reg_save_area;
|
||||
};
|
||||
|
||||
typedef struct __va_list_struct *va_list;
|
||||
|
||||
/* we use __builtin_(malloc|free) to avoid #define malloc tcc_malloc */
|
||||
/* XXX: this lacks the support of aggregated types. */
|
||||
#define va_start(ap, last) \
|
||||
(ap = (va_list)__builtin_malloc(sizeof(struct __va_list_struct)), \
|
||||
*ap = *(struct __va_list_struct*)( \
|
||||
(char*)__builtin_frame_address(0) - 16), \
|
||||
ap->overflow_arg_area = ((char *)__builtin_frame_address(0) + \
|
||||
ap->overflow_offset), \
|
||||
ap->reg_save_area = (char *)__builtin_frame_address(0) - 176 - 16 \
|
||||
)
|
||||
#define va_arg(ap, type) \
|
||||
(*(type*)(__builtin_types_compatible_p(type, long double) \
|
||||
? (ap->overflow_arg_area += 16, \
|
||||
ap->overflow_arg_area - 16) \
|
||||
: __builtin_types_compatible_p(type, double) \
|
||||
? (ap->fp_offset < 128 + 48 \
|
||||
? (ap->fp_offset += 16, \
|
||||
ap->reg_save_area + ap->fp_offset - 16) \
|
||||
: (ap->overflow_arg_area += 8, \
|
||||
ap->overflow_arg_area - 8)) \
|
||||
: (ap->gp_offset < 48 \
|
||||
? (ap->gp_offset += 8, \
|
||||
ap->reg_save_area + ap->gp_offset - 8) \
|
||||
: (ap->overflow_arg_area += 8, \
|
||||
ap->overflow_arg_area - 8)) \
|
||||
))
|
||||
#define va_copy(dest, src) \
|
||||
((dest) = (va_list)malloc(sizeof(struct __va_list_struct)), \
|
||||
*(dest) = *(src))
|
||||
#define va_end(ap) __builtin_free(ap)
|
||||
|
||||
#else
|
||||
|
||||
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 /* _STDARG_H */
|
||||
20
include/stddef.h
Normal file
20
include/stddef.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _STDDEF_H
|
||||
#define _STDDEF_H
|
||||
|
||||
#define NULL ((void *)0)
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
typedef __WCHAR_TYPE__ wchar_t;
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
||||
|
||||
#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;
|
||||
#endif
|
||||
|
||||
void *alloca(size_t size);
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,7 @@ void *realloc(void *ptr, size_t size);
|
||||
int atoi(const char *nptr);
|
||||
long int strtol(const char *nptr, char **endptr, int base);
|
||||
unsigned long int strtoul(const char *nptr, char **endptr, int base);
|
||||
void exit(int);
|
||||
|
||||
/* stdio.h */
|
||||
typedef struct __FILE FILE;
|
||||
45
lib/alloca86-bt.S
Normal file
45
lib/alloca86-bt.S
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ---------------------------------------------- */
|
||||
/* alloca86b.S */
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
.globl __bound_alloca
|
||||
|
||||
__bound_alloca:
|
||||
pop %edx
|
||||
pop %eax
|
||||
mov %eax, %ecx
|
||||
add $3,%eax
|
||||
and $-4,%eax
|
||||
jz p6
|
||||
|
||||
#ifdef TCC_TARGET_PE
|
||||
p4:
|
||||
cmp $4096,%eax
|
||||
jle p5
|
||||
sub $4096,%esp
|
||||
sub $4096,%eax
|
||||
test %eax,(%esp)
|
||||
jmp p4
|
||||
|
||||
p5:
|
||||
#endif
|
||||
|
||||
sub %eax,%esp
|
||||
mov %esp,%eax
|
||||
|
||||
push %edx
|
||||
push %eax
|
||||
push %ecx
|
||||
push %eax
|
||||
call __bound_new_region
|
||||
add $8, %esp
|
||||
pop %eax
|
||||
pop %edx
|
||||
|
||||
p6:
|
||||
push %edx
|
||||
push %edx
|
||||
ret
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
33
lib/alloca86.S
Normal file
33
lib/alloca86.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/* ---------------------------------------------- */
|
||||
/* alloca86.S */
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
.globl alloca
|
||||
|
||||
alloca:
|
||||
pop %edx
|
||||
pop %eax
|
||||
add $3,%eax
|
||||
and $-4,%eax
|
||||
jz p3
|
||||
|
||||
#ifdef TCC_TARGET_PE
|
||||
p1:
|
||||
cmp $4096,%eax
|
||||
jle p2
|
||||
sub $4096,%esp
|
||||
sub $4096,%eax
|
||||
test %eax,(%esp)
|
||||
jmp p1
|
||||
p2:
|
||||
#endif
|
||||
|
||||
sub %eax,%esp
|
||||
mov %esp,%eax
|
||||
p3:
|
||||
push %edx
|
||||
push %edx
|
||||
ret
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
@@ -3,25 +3,25 @@
|
||||
*
|
||||
* Copyright (c) 2002 Fabrice Bellard
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#ifndef __FreeBSD__
|
||||
#if !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__OpenBSD__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
|
||||
#define HAVE_MEMALIGN
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#warning Bound checking not fully supported on FreeBSD
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__dietlibc__) \
|
||||
|| defined(__UCLIBC__) || defined(__OpenBSD__)
|
||||
#warning Bound checking not fully supported in this environment.
|
||||
#undef CONFIG_TCC_MALLOC_HOOKS
|
||||
#undef HAVE_MEMALIGN
|
||||
#endif
|
||||
@@ -74,19 +75,7 @@ void __bound_init(void);
|
||||
void __bound_new_region(void *p, unsigned long size);
|
||||
int __bound_delete_region(void *p);
|
||||
|
||||
/* currently, tcc cannot compile that because we use unsupported GNU C
|
||||
extensions */
|
||||
#if !defined(__TINYC__)
|
||||
void *__bound_ptr_add(void *p, int offset) __attribute__((regparm(2)));
|
||||
void *__bound_ptr_indir1(void *p, int offset) __attribute__((regparm(2)));
|
||||
void *__bound_ptr_indir2(void *p, int offset) __attribute__((regparm(2)));
|
||||
void *__bound_ptr_indir4(void *p, int offset) __attribute__((regparm(2)));
|
||||
void *__bound_ptr_indir8(void *p, int offset) __attribute__((regparm(2)));
|
||||
void *__bound_ptr_indir12(void *p, int offset) __attribute__((regparm(2)));
|
||||
void *__bound_ptr_indir16(void *p, int offset) __attribute__((regparm(2)));
|
||||
void __bound_local_new(void *p) __attribute__((regparm(1)));
|
||||
void __bound_local_delete(void *p) __attribute__((regparm(1)));
|
||||
#endif
|
||||
#define FASTCALL __attribute__((regparm(3)))
|
||||
|
||||
void *__bound_malloc(size_t size, const void *caller);
|
||||
void *__bound_memalign(size_t size, size_t align, const void *caller);
|
||||
@@ -168,7 +157,7 @@ static void bound_alloc_error(void)
|
||||
|
||||
/* return '(p + offset)' for pointer arithmetic (a pointer can reach
|
||||
the end of a region in this case */
|
||||
void *__bound_ptr_add(void *p, int offset)
|
||||
void * FASTCALL __bound_ptr_add(void *p, int offset)
|
||||
{
|
||||
unsigned long addr = (unsigned long)p;
|
||||
BoundEntry *e;
|
||||
@@ -194,7 +183,7 @@ void *__bound_ptr_add(void *p, int offset)
|
||||
/* return '(p + offset)' for pointer indirection (the resulting must
|
||||
be strictly inside the region */
|
||||
#define BOUND_PTR_INDIR(dsize) \
|
||||
void *__bound_ptr_indir ## dsize (void *p, int offset) \
|
||||
void * FASTCALL __bound_ptr_indir ## dsize (void *p, int offset) \
|
||||
{ \
|
||||
unsigned long addr = (unsigned long)p; \
|
||||
BoundEntry *e; \
|
||||
@@ -227,7 +216,7 @@ void *__bound_ptr_indir ## dsize (void *p, int offset) \
|
||||
#endif
|
||||
|
||||
/* called when entering a function to add all the local regions */
|
||||
void __bound_local_new(void *p1)
|
||||
void FASTCALL __bound_local_new(void *p1)
|
||||
{
|
||||
unsigned long addr, size, fp, *p = p1;
|
||||
GET_CALLER_FP(fp);
|
||||
@@ -243,7 +232,7 @@ void __bound_local_new(void *p1)
|
||||
}
|
||||
|
||||
/* called when leaving a function to delete all the local regions */
|
||||
void __bound_local_delete(void *p1)
|
||||
void FASTCALL __bound_local_delete(void *p1)
|
||||
{
|
||||
unsigned long addr, fp, *p = p1;
|
||||
GET_CALLER_FP(fp);
|
||||
@@ -782,7 +771,7 @@ void *__bound_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
size = size * nmemb;
|
||||
ptr = __bound_malloc(size);
|
||||
ptr = __bound_malloc(size, NULL);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
memset(ptr, 0, size);
|
||||
@@ -89,13 +89,13 @@ union double_long {
|
||||
double d;
|
||||
#if 1
|
||||
struct {
|
||||
unsigned long lower;
|
||||
long upper;
|
||||
unsigned int lower;
|
||||
int upper;
|
||||
} l;
|
||||
#else
|
||||
struct {
|
||||
long upper;
|
||||
unsigned long lower;
|
||||
int upper;
|
||||
unsigned int lower;
|
||||
} l;
|
||||
#endif
|
||||
long long ll;
|
||||
@@ -106,6 +106,9 @@ union float_long {
|
||||
long l;
|
||||
};
|
||||
|
||||
/* XXX: we don't support several builtin supports for now */
|
||||
#ifndef __x86_64__
|
||||
|
||||
/* XXX: use gcc/tcc intrinsic ? */
|
||||
#if defined(__i386__)
|
||||
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
|
||||
@@ -399,7 +402,7 @@ long long __moddi3(long long u, long long v)
|
||||
if (vv.s.high < 0)
|
||||
vv.ll = __negdi2 (vv.ll);
|
||||
|
||||
__udivmoddi4 (uu.ll, vv.ll, &w);
|
||||
__udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);
|
||||
if (c)
|
||||
w = __negdi2 (w);
|
||||
return w;
|
||||
@@ -419,7 +422,7 @@ unsigned long long __umoddi3(unsigned long long u, unsigned long long v)
|
||||
}
|
||||
|
||||
/* XXX: fix tcc's code generator to do this instead */
|
||||
long long __sardi3(long long a, int b)
|
||||
long long __ashrdi3(long long a, int b)
|
||||
{
|
||||
#ifdef __TINYC__
|
||||
DWunion u;
|
||||
@@ -438,7 +441,7 @@ long long __sardi3(long long a, int b)
|
||||
}
|
||||
|
||||
/* XXX: fix tcc's code generator to do this instead */
|
||||
unsigned long long __shrdi3(unsigned long long a, int b)
|
||||
unsigned long long __lshrdi3(unsigned long long a, int b)
|
||||
{
|
||||
#ifdef __TINYC__
|
||||
DWunion u;
|
||||
@@ -457,7 +460,7 @@ unsigned long long __shrdi3(unsigned long long a, int b)
|
||||
}
|
||||
|
||||
/* XXX: fix tcc's code generator to do this instead */
|
||||
long long __shldi3(long long a, int b)
|
||||
long long __ashldi3(long long a, int b)
|
||||
{
|
||||
#ifdef __TINYC__
|
||||
DWunion u;
|
||||
@@ -466,7 +469,7 @@ long long __shldi3(long long a, int b)
|
||||
u.s.high = (unsigned)u.s.low << (b - 32);
|
||||
u.s.low = 0;
|
||||
} else if (b != 0) {
|
||||
u.s.high = ((unsigned)u.s.high << b) | (u.s.low >> (32 - b));
|
||||
u.s.high = ((unsigned)u.s.high << b) | ((unsigned)u.s.low >> (32 - b));
|
||||
u.s.low = (unsigned)u.s.low << b;
|
||||
}
|
||||
return u.ll;
|
||||
@@ -482,8 +485,10 @@ unsigned short __tcc_fpu_control = 0x137f;
|
||||
unsigned short __tcc_int_fpu_control = 0x137f | 0x0c00;
|
||||
#endif
|
||||
|
||||
#endif /* !__x86_64__ */
|
||||
|
||||
/* XXX: fix tcc's code generator to do this instead */
|
||||
float __ulltof(unsigned long long a)
|
||||
float __floatundisf(unsigned long long a)
|
||||
{
|
||||
DWunion uu;
|
||||
XFtype r;
|
||||
@@ -498,7 +503,7 @@ float __ulltof(unsigned long long a)
|
||||
}
|
||||
}
|
||||
|
||||
double __ulltod(unsigned long long a)
|
||||
double __floatundidf(unsigned long long a)
|
||||
{
|
||||
DWunion uu;
|
||||
XFtype r;
|
||||
@@ -513,7 +518,7 @@ double __ulltod(unsigned long long a)
|
||||
}
|
||||
}
|
||||
|
||||
long double __ulltold(unsigned long long a)
|
||||
long double __floatundixf(unsigned long long a)
|
||||
{
|
||||
DWunion uu;
|
||||
XFtype r;
|
||||
59
libtcc.h
59
libtcc.h
@@ -1,6 +1,12 @@
|
||||
#ifndef LIBTCC_H
|
||||
#define LIBTCC_H
|
||||
|
||||
#ifdef LIBTCC_AS_DLL
|
||||
#define LIBTCCAPI __declspec(dllexport)
|
||||
#else
|
||||
#define LIBTCCAPI
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -10,46 +16,46 @@ struct TCCState;
|
||||
typedef struct TCCState TCCState;
|
||||
|
||||
/* create a new TCC compilation context */
|
||||
TCCState *tcc_new(void);
|
||||
LIBTCCAPI TCCState *tcc_new(void);
|
||||
|
||||
/* free a TCC compilation context */
|
||||
void tcc_delete(TCCState *s);
|
||||
LIBTCCAPI void tcc_delete(TCCState *s);
|
||||
|
||||
/* add debug information in the generated code */
|
||||
void tcc_enable_debug(TCCState *s);
|
||||
LIBTCCAPI void tcc_enable_debug(TCCState *s);
|
||||
|
||||
/* set error/warning display callback */
|
||||
void tcc_set_error_func(TCCState *s, void *error_opaque,
|
||||
LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque,
|
||||
void (*error_func)(void *opaque, const char *msg));
|
||||
|
||||
/* set/reset a warning */
|
||||
int tcc_set_warning(TCCState *s, const char *warning_name, int value);
|
||||
LIBTCCAPI int tcc_set_warning(TCCState *s, const char *warning_name, int value);
|
||||
|
||||
/*****************************/
|
||||
/* preprocessor */
|
||||
|
||||
/* add include path */
|
||||
int tcc_add_include_path(TCCState *s, const char *pathname);
|
||||
LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
|
||||
|
||||
/* add in system include path */
|
||||
int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
|
||||
LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
|
||||
|
||||
/* define preprocessor symbol 'sym'. Can put optional value */
|
||||
void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
|
||||
LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
|
||||
|
||||
/* undefine preprocess symbol 'sym' */
|
||||
void tcc_undefine_symbol(TCCState *s, const char *sym);
|
||||
LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym);
|
||||
|
||||
/*****************************/
|
||||
/* compiling */
|
||||
|
||||
/* add a file (either a C file, dll, an object, a library or an ld
|
||||
script). Return -1 if error. */
|
||||
int tcc_add_file(TCCState *s, const char *filename);
|
||||
LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename);
|
||||
|
||||
/* compile a string containing a C source. Return non zero if
|
||||
error. */
|
||||
int tcc_compile_string(TCCState *s, const char *buf);
|
||||
LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf);
|
||||
|
||||
/*****************************/
|
||||
/* linking commands */
|
||||
@@ -60,31 +66,40 @@ int tcc_compile_string(TCCState *s, const char *buf);
|
||||
#define TCC_OUTPUT_EXE 1 /* executable file */
|
||||
#define TCC_OUTPUT_DLL 2 /* dynamic library */
|
||||
#define TCC_OUTPUT_OBJ 3 /* object file */
|
||||
int tcc_set_output_type(TCCState *s, int output_type);
|
||||
#define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */
|
||||
LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
|
||||
|
||||
#define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */
|
||||
#define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */
|
||||
#define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */
|
||||
|
||||
/* equivalent to -Lpath option */
|
||||
int tcc_add_library_path(TCCState *s, const char *pathname);
|
||||
LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
|
||||
|
||||
/* the library name is the same as the argument of the '-l' option */
|
||||
int tcc_add_library(TCCState *s, const char *libraryname);
|
||||
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
|
||||
|
||||
/* add a symbol to the compiled program */
|
||||
int tcc_add_symbol(TCCState *s, const char *name, unsigned long val);
|
||||
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, void *val);
|
||||
|
||||
/* output an executable, library or object file. DO NOT call
|
||||
tcc_relocate() before. */
|
||||
int tcc_output_file(TCCState *s, const char *filename);
|
||||
LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename);
|
||||
|
||||
/* link and run main() function and return its value. DO NOT call
|
||||
tcc_relocate() before. */
|
||||
int tcc_run(TCCState *s, int argc, char **argv);
|
||||
LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv);
|
||||
|
||||
/* do all relocations (needed before using tcc_get_symbol()). Return
|
||||
non zero if link error. */
|
||||
int tcc_relocate(TCCState *s);
|
||||
/* copy code into memory passed in by the caller and do all relocations
|
||||
(needed before using tcc_get_symbol()).
|
||||
returns -1 on error and required size if ptr is NULL */
|
||||
LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr);
|
||||
|
||||
/* return symbol value or error */
|
||||
void *tcc_get_symbol(TCCState *s, const char *name);
|
||||
/* return symbol value or NULL if not found */
|
||||
LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name);
|
||||
|
||||
/* set CONFIG_TCCDIR at runtime */
|
||||
LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
212
tcc-doc.texi
212
tcc-doc.texi
@@ -16,11 +16,8 @@
|
||||
@headings double
|
||||
@end iftex
|
||||
|
||||
@c @ifhtml
|
||||
@contents
|
||||
@c @end ifhtml
|
||||
|
||||
@ifnothtml
|
||||
@node Top, Introduction, (dir), (dir)
|
||||
@top Tiny C Compiler Reference Documentation
|
||||
|
||||
@@ -29,10 +26,14 @@ This manual documents version @value{VERSION} of the Tiny C Compiler.
|
||||
@menu
|
||||
* Introduction:: Introduction to tcc.
|
||||
* Invoke:: Invocation of tcc (command line, options).
|
||||
* Clang:: ANSI C and extensions.
|
||||
* asm:: Assembler syntax.
|
||||
* linker:: Output file generation and supported targets.
|
||||
* Bounds:: Automatic bounds-checking of C code.
|
||||
* Libtcc:: The libtcc library.
|
||||
* devel:: Guide for Developers.
|
||||
@end menu
|
||||
@end ifnothtml
|
||||
|
||||
|
||||
@node Introduction
|
||||
@chapter Introduction
|
||||
@@ -42,7 +43,7 @@ compilers, it is meant to be self-relying: you do not need an
|
||||
external assembler or linker because TCC does that for you.
|
||||
|
||||
TCC compiles so @emph{fast} that even for big projects @code{Makefile}s may
|
||||
not be necessary.
|
||||
not be necessary.
|
||||
|
||||
TCC not only supports ANSI C, but also most of the new ISO C99
|
||||
standard and many GNUC extensions including inline assembly.
|
||||
@@ -58,11 +59,16 @@ these checks even if non patched libraries are used.
|
||||
With @code{libtcc}, you can use TCC as a backend for dynamic code
|
||||
generation (@pxref{Libtcc}).
|
||||
|
||||
TCC mainly supports the i386 target on Linux and Windows. There are alpha
|
||||
ports for the ARM (@code{arm-tcc}) and the TMS320C67xx targets
|
||||
(@code{c67-tcc}). More information about the ARM port is available at
|
||||
@url{http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html}.
|
||||
|
||||
For usage on Windows, see also tcc-win32.txt.
|
||||
|
||||
@node Invoke
|
||||
@chapter Command line invocation
|
||||
|
||||
[This manual documents version @value{VERSION} of the Tiny C Compiler]
|
||||
|
||||
@section Quick start
|
||||
|
||||
@example
|
||||
@@ -89,9 +95,11 @@ the @code{main()} of a.c.
|
||||
|
||||
@item @samp{tcc a.c -run b.c arg1}
|
||||
Compile @file{a.c} and @file{b.c}, link them together and execute them. arg1 is given
|
||||
as first argument to the @code{main()} of the resulting program. Because
|
||||
multiple C files are specified, @option{--} are necessary to clearly separate the
|
||||
program arguments from the TCC options.
|
||||
as first argument to the @code{main()} of the resulting program.
|
||||
@ignore
|
||||
Because multiple C files are specified, @option{--} are necessary to clearly
|
||||
separate the program arguments from the TCC options.
|
||||
@end ignore
|
||||
|
||||
@item @samp{tcc -o myprog a.c b.c}
|
||||
Compile @file{a.c} and @file{b.c}, link them and generate the executable @file{myprog}.
|
||||
@@ -130,6 +138,13 @@ int main()
|
||||
return 0;
|
||||
@}
|
||||
@end example
|
||||
|
||||
TCC can read C source code from @emph{standard input} when @option{-} is used in
|
||||
place of @option{infile}. Example:
|
||||
|
||||
@example
|
||||
echo 'main()@{puts("hello");@}' | tcc -run -
|
||||
@end example
|
||||
@c man end
|
||||
|
||||
@section Option summary
|
||||
@@ -139,7 +154,7 @@ General Options:
|
||||
@c man begin OPTIONS
|
||||
@table @option
|
||||
@item -v
|
||||
Display current TCC version.
|
||||
Display current TCC version, increase verbosity.
|
||||
|
||||
@item -c
|
||||
Generate an object file (@option{-o} option must also be given).
|
||||
@@ -154,8 +169,27 @@ Set the path where the tcc internal libraries can be found (default is
|
||||
@item -bench
|
||||
Output compilation statistics.
|
||||
|
||||
@item -run
|
||||
Run compiled source.
|
||||
@item -run source [args...]
|
||||
Compile file @var{source} and run it with the command line arguments
|
||||
@var{args}. In order to be able to give more than one argument to a
|
||||
script, several TCC options can be given @emph{after} the
|
||||
@option{-run} option, separated by spaces. Example:
|
||||
|
||||
@example
|
||||
tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
|
||||
@end example
|
||||
|
||||
In a script, it gives the following header:
|
||||
|
||||
@example
|
||||
#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
|
||||
#include <stdlib.h>
|
||||
int main(int argc, char **argv)
|
||||
@{
|
||||
...
|
||||
@}
|
||||
@end example
|
||||
|
||||
@end table
|
||||
|
||||
Preprocessor options:
|
||||
@@ -179,16 +213,46 @@ also be defined: @option{-DF(a)=a+1}
|
||||
Undefine preprocessor symbol @samp{sym}.
|
||||
@end table
|
||||
|
||||
Warning options:
|
||||
Compilation flags:
|
||||
|
||||
Note: each warning option has a negative form beginning with @option{-Wno-}.
|
||||
Note: each of the following warning options has a negative form beginning with
|
||||
@option{-fno-}.
|
||||
|
||||
@table @option
|
||||
@item -funsigned-char
|
||||
Let the @code{char} type be unsigned.
|
||||
|
||||
@item -fsigned-char
|
||||
Let the @code{char} type be signed.
|
||||
|
||||
@item -fno-common
|
||||
Do not generate common symbols for uninitialized data.
|
||||
|
||||
@item -fleading-underscore
|
||||
Add a leading underscore at the beginning of each C symbol.
|
||||
|
||||
@end table
|
||||
|
||||
Warning options:
|
||||
|
||||
@table @option
|
||||
@item -w
|
||||
Disable all warnings.
|
||||
|
||||
@end table
|
||||
|
||||
Note: each of the following warning options has a negative form beginning with
|
||||
@option{-Wno-}.
|
||||
|
||||
@table @option
|
||||
@item -Wimplicit-function-declaration
|
||||
Warn about implicit function declaration.
|
||||
|
||||
@item -Wunsupported
|
||||
Warn about unsupported GCC features that are ignored by TCC.
|
||||
|
||||
@item -Wwrite-strings
|
||||
Make string constants being of type @code{const char *} intead of @code{char
|
||||
Make string constants be of type @code{const char *} instead of @code{char
|
||||
*}.
|
||||
|
||||
@item -Werror
|
||||
@@ -196,7 +260,7 @@ Abort compilation if warnings are issued.
|
||||
|
||||
@item -Wall
|
||||
Activate all warnings, except @option{-Werror}, @option{-Wunusupported} and
|
||||
@option{-Wwrite-strings} (currently not useful).
|
||||
@option{-Wwrite-strings}.
|
||||
|
||||
@end table
|
||||
|
||||
@@ -228,6 +292,20 @@ opened with @code{dlopen()} needs to access executable symbols.
|
||||
Generate an object file combining all input files (@option{-o} option must
|
||||
also be given).
|
||||
|
||||
@item -Wl,-Ttext,address
|
||||
Set the start of the .text section to @var{address}.
|
||||
|
||||
@item -Wl,--oformat,fmt
|
||||
Use @var{fmt} as output format. The supported output formats are:
|
||||
@table @code
|
||||
@item elf32-i386
|
||||
ELF output format (default)
|
||||
@item binary
|
||||
Binary image (only for executable output)
|
||||
@item coff
|
||||
COFF output format (only for executable output for TMS320C67xx target)
|
||||
@end table
|
||||
|
||||
@end table
|
||||
|
||||
Debugger options:
|
||||
@@ -269,6 +347,7 @@ Fabrice Bellard
|
||||
|
||||
@end ignore
|
||||
|
||||
@node Clang
|
||||
@chapter C language support
|
||||
|
||||
@section ANSI C
|
||||
@@ -370,21 +449,41 @@ instead of
|
||||
@}
|
||||
@end example
|
||||
|
||||
@cindex aligned attribute
|
||||
@cindex packed attribute
|
||||
@cindex section attribute
|
||||
@cindex unused attribute
|
||||
@cindex cdecl attribute
|
||||
@cindex stdcall attribute
|
||||
@cindex regparm attribute
|
||||
@cindex dllexport attribute
|
||||
|
||||
@item The keyword @code{__attribute__} is handled to specify variable or
|
||||
function attributes. The following attributes are supported:
|
||||
@itemize
|
||||
@item @code{aligned(n)}: align data to n bytes (must be a power of two).
|
||||
|
||||
@item @code{section(name)}: generate function or data in assembly
|
||||
section name (name is a string containing the section name) instead
|
||||
of the default section.
|
||||
@item @code{aligned(n)}: align a variable or a structure field to n bytes
|
||||
(must be a power of two).
|
||||
|
||||
@item @code{packed}: force alignment of a variable or a structure field to
|
||||
1.
|
||||
|
||||
@item @code{section(name)}: generate function or data in assembly section
|
||||
name (name is a string containing the section name) instead of the default
|
||||
section.
|
||||
|
||||
@item @code{unused}: specify that the variable or the function is unused.
|
||||
|
||||
@item @code{cdecl}: use standard C calling convention.
|
||||
@item @code{cdecl}: use standard C calling convention (default).
|
||||
|
||||
@item @code{stdcall}: use Pascal-like calling convention.
|
||||
|
||||
@item @code{regparm(n)}: use fast i386 calling convention. @var{n} must be
|
||||
between 1 and 3. The first @var{n} function parameters are respectively put in
|
||||
registers @code{%eax}, @code{%edx} and @code{%ecx}.
|
||||
|
||||
@item @code{dllexport}: export function from dll/executable (win32 only)
|
||||
|
||||
@end itemize
|
||||
|
||||
Here are some examples:
|
||||
@@ -460,6 +559,8 @@ operands are supported.
|
||||
@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()}
|
||||
are supported.
|
||||
|
||||
@item @code{#pragma pack} is supported for win32 compatibility.
|
||||
|
||||
@end itemize
|
||||
|
||||
@section TinyCC extensions
|
||||
@@ -478,6 +579,7 @@ indicate that you use TCC.
|
||||
|
||||
@end itemize
|
||||
|
||||
@node asm
|
||||
@chapter TinyCC Assembler
|
||||
|
||||
Since version 0.9.16, TinyCC integrates its own assembler. TinyCC
|
||||
@@ -549,20 +651,27 @@ They can be defined several times in the same source. Use 'b'
|
||||
@section Directives
|
||||
@cindex assembler directives
|
||||
@cindex directives, assembler
|
||||
@cindex .align
|
||||
@cindex .skip
|
||||
@cindex .space
|
||||
@cindex .byte
|
||||
@cindex .word
|
||||
@cindex .short
|
||||
@cindex .int
|
||||
@cindex .long
|
||||
@cindex .string
|
||||
@cindex .globl
|
||||
@cindex .section
|
||||
@cindex .text
|
||||
@cindex .data
|
||||
@cindex .bss
|
||||
@cindex align directive
|
||||
@cindex skip directive
|
||||
@cindex space directive
|
||||
@cindex byte directive
|
||||
@cindex word directive
|
||||
@cindex short directive
|
||||
@cindex int directive
|
||||
@cindex long directive
|
||||
@cindex quad directive
|
||||
@cindex globl directive
|
||||
@cindex global directive
|
||||
@cindex section directive
|
||||
@cindex text directive
|
||||
@cindex data directive
|
||||
@cindex bss directive
|
||||
@cindex fill directive
|
||||
@cindex org directive
|
||||
@cindex previous directive
|
||||
@cindex string directive
|
||||
@cindex asciz directive
|
||||
@cindex ascii directive
|
||||
|
||||
All directives are preceeded by a '.'. The following directives are
|
||||
supported:
|
||||
@@ -571,17 +680,24 @@ supported:
|
||||
@item .align n[,value]
|
||||
@item .skip n[,value]
|
||||
@item .space n[,value]
|
||||
@item .byte value1[,value2...]
|
||||
@item .word value1[,value2...]
|
||||
@item .short value1[,value2...]
|
||||
@item .int value1[,value2...]
|
||||
@item .long value1[,value2...]
|
||||
@item .string string
|
||||
@item .byte value1[,...]
|
||||
@item .word value1[,...]
|
||||
@item .short value1[,...]
|
||||
@item .int value1[,...]
|
||||
@item .long value1[,...]
|
||||
@item .quad immediate_value1[,...]
|
||||
@item .globl symbol
|
||||
@item .global symbol
|
||||
@item .section section
|
||||
@item .text
|
||||
@item .data
|
||||
@item .bss
|
||||
@item .fill repeat[,size[,value]]
|
||||
@item .org n
|
||||
@item .previous
|
||||
@item .string string[,...]
|
||||
@item .asciz string[,...]
|
||||
@item .ascii string[,...]
|
||||
@end itemize
|
||||
|
||||
@section X86 Assembler
|
||||
@@ -593,6 +709,7 @@ tries to guess it from the operand sizes.
|
||||
|
||||
Currently, MMX opcodes are supported but not SSE ones.
|
||||
|
||||
@node linker
|
||||
@chapter TinyCC Linker
|
||||
@cindex linker
|
||||
|
||||
@@ -604,7 +721,7 @@ executable ELF files and dynamic ELF libraries without relying on an
|
||||
external linker.
|
||||
|
||||
Dynamic ELF libraries can be output but the C compiler does not generate
|
||||
position independent code (PIC). It means that the dynamic librairy
|
||||
position independent code (PIC). It means that the dynamic library
|
||||
code generated by TCC cannot be factorized among processes yet.
|
||||
|
||||
TCC linker eliminates unreferenced object code in libraries. A single pass is
|
||||
@@ -617,6 +734,14 @@ options (@option{--start-group} and @option{--end-group}) are supported.
|
||||
TCC can load ELF object files, archives (.a files) and dynamic
|
||||
libraries (.so).
|
||||
|
||||
@section PE-i386 file generation
|
||||
@cindex PE-i386
|
||||
|
||||
TCC for Windows supports the native Win32 executable file format (PE-i386). It
|
||||
generates EXE files (console and gui) and DLL files.
|
||||
|
||||
For usage on Windows, see also tcc-win32.txt.
|
||||
|
||||
@section GNU Linker Scripts
|
||||
@cindex scripts, linker
|
||||
@cindex linker scripts
|
||||
@@ -726,6 +851,7 @@ The idea consists in giving a C string containing the program you want
|
||||
to compile directly to @code{libtcc}. Then you can access to any global
|
||||
symbol (function or variable) defined.
|
||||
|
||||
@node devel
|
||||
@chapter Developer's guide
|
||||
|
||||
This chapter gives some hints to understand how TCC works. You can skip
|
||||
|
||||
766
tcc.h
Normal file
766
tcc.h
Normal file
@@ -0,0 +1,766 @@
|
||||
/*
|
||||
* TCC - Tiny C Compiler
|
||||
*
|
||||
* Copyright (c) 2001-2004 Fabrice Bellard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include "config.h"
|
||||
|
||||
#ifdef CONFIG_TCCBOOT
|
||||
|
||||
#include "tccboot.h"
|
||||
#define CONFIG_TCC_STATIC
|
||||
|
||||
#else
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <setjmp.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <io.h> /* open, close etc. */
|
||||
#include <direct.h> /* getcwd */
|
||||
#define inline __inline
|
||||
#define inp next_inp
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/ucontext.h>
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#endif /* !CONFIG_TCCBOOT */
|
||||
|
||||
#ifndef PAGESIZE
|
||||
#define PAGESIZE 4096
|
||||
#endif
|
||||
|
||||
#include "elf.h"
|
||||
#include "stab.h"
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#include "libtcc.h"
|
||||
|
||||
/* parser debug */
|
||||
//#define PARSE_DEBUG
|
||||
/* preprocessor debug */
|
||||
//#define PP_DEBUG
|
||||
/* include file debug */
|
||||
//#define INC_DEBUG
|
||||
|
||||
//#define MEM_DEBUG
|
||||
|
||||
/* assembler debug */
|
||||
//#define ASM_DEBUG
|
||||
|
||||
/* target selection */
|
||||
//#define TCC_TARGET_I386 /* i386 code generator */
|
||||
//#define TCC_TARGET_ARM /* ARMv4 code generator */
|
||||
//#define TCC_TARGET_C67 /* TMS320C67xx code generator */
|
||||
//#define TCC_TARGET_X86_64 /* x86-64 code generator */
|
||||
|
||||
/* default target is I386 */
|
||||
#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
|
||||
!defined(TCC_TARGET_C67) && !defined(TCC_TARGET_X86_64)
|
||||
#define TCC_TARGET_I386
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
|
||||
!defined(TCC_TARGET_C67) && !defined(TCC_TARGET_X86_64)
|
||||
#define CONFIG_TCC_BCHECK /* enable bound checking code */
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(TCC_TARGET_PE)
|
||||
#define CONFIG_TCC_STATIC
|
||||
#endif
|
||||
|
||||
/* define it to include assembler support */
|
||||
#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67) && \
|
||||
!defined(TCC_TARGET_X86_64)
|
||||
#define CONFIG_TCC_ASM
|
||||
#endif
|
||||
|
||||
/* object format selection */
|
||||
#if defined(TCC_TARGET_C67)
|
||||
#define TCC_TARGET_COFF
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(CONFIG_TCCBOOT)
|
||||
#define CONFIG_TCC_BACKTRACE
|
||||
#endif
|
||||
|
||||
#define FALSE 0
|
||||
#define false 0
|
||||
#define TRUE 1
|
||||
#define true 1
|
||||
typedef int BOOL;
|
||||
|
||||
/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
|
||||
executables or dlls */
|
||||
#define CONFIG_TCC_CRT_PREFIX CONFIG_SYSROOT "/usr/lib"
|
||||
|
||||
#define INCLUDE_STACK_SIZE 32
|
||||
#define IFDEF_STACK_SIZE 64
|
||||
#define VSTACK_SIZE 256
|
||||
#define STRING_MAX_SIZE 1024
|
||||
#define PACK_STACK_SIZE 8
|
||||
|
||||
#define TOK_HASH_SIZE 8192 /* must be a power of two */
|
||||
#define TOK_ALLOC_INCR 512 /* must be a power of two */
|
||||
#define TOK_MAX_SIZE 4 /* token max size in int unit when stored in string */
|
||||
|
||||
/* token symbol management */
|
||||
typedef struct TokenSym {
|
||||
struct TokenSym *hash_next;
|
||||
struct Sym *sym_define; /* direct pointer to define */
|
||||
struct Sym *sym_label; /* direct pointer to label */
|
||||
struct Sym *sym_struct; /* direct pointer to structure */
|
||||
struct Sym *sym_identifier; /* direct pointer to identifier */
|
||||
int tok; /* token number */
|
||||
int len;
|
||||
char str[1];
|
||||
} TokenSym;
|
||||
|
||||
#ifdef TCC_TARGET_PE
|
||||
typedef unsigned short nwchar_t;
|
||||
#else
|
||||
typedef int nwchar_t;
|
||||
#endif
|
||||
|
||||
typedef struct CString {
|
||||
int size; /* size in bytes */
|
||||
void *data; /* either 'char *' or 'nwchar_t *' */
|
||||
int size_allocated;
|
||||
void *data_allocated; /* if non NULL, data has been malloced */
|
||||
} CString;
|
||||
|
||||
/* type definition */
|
||||
typedef struct CType {
|
||||
int t;
|
||||
struct Sym *ref;
|
||||
} CType;
|
||||
|
||||
/* constant value */
|
||||
typedef union CValue {
|
||||
long double ld;
|
||||
double d;
|
||||
float f;
|
||||
int i;
|
||||
unsigned int ui;
|
||||
unsigned int ul; /* address (should be unsigned long on 64 bit cpu) */
|
||||
long long ll;
|
||||
unsigned long long ull;
|
||||
struct CString *cstr;
|
||||
void *ptr;
|
||||
int tab[1];
|
||||
} CValue;
|
||||
|
||||
/* value on stack */
|
||||
typedef struct SValue {
|
||||
CType type; /* type */
|
||||
unsigned short r; /* register + flags */
|
||||
unsigned short r2; /* second register, used for 'long long'
|
||||
type. If not used, set to VT_CONST */
|
||||
CValue c; /* constant, if VT_CONST */
|
||||
struct Sym *sym; /* symbol, if (VT_SYM | VT_CONST) */
|
||||
} SValue;
|
||||
|
||||
/* symbol management */
|
||||
typedef struct Sym {
|
||||
int v; /* symbol token */
|
||||
long r; /* associated register */
|
||||
long c; /* associated number */
|
||||
CType type; /* associated type */
|
||||
struct Sym *next; /* next related symbol */
|
||||
struct Sym *prev; /* prev symbol in stack */
|
||||
struct Sym *prev_tok; /* previous symbol for this token */
|
||||
} Sym;
|
||||
|
||||
/* section definition */
|
||||
/* XXX: use directly ELF structure for parameters ? */
|
||||
/* special flag to indicate that the section should not be linked to
|
||||
the other ones */
|
||||
#define SHF_PRIVATE 0x80000000
|
||||
|
||||
/* special flag, too */
|
||||
#define SECTION_ABS ((void *)1)
|
||||
|
||||
typedef struct Section {
|
||||
unsigned long data_offset; /* current data offset */
|
||||
unsigned char *data; /* section data */
|
||||
unsigned long data_allocated; /* used for realloc() handling */
|
||||
int sh_name; /* elf section name (only used during output) */
|
||||
int sh_num; /* elf section number */
|
||||
int sh_type; /* elf section type */
|
||||
int sh_flags; /* elf section flags */
|
||||
int sh_info; /* elf section info */
|
||||
int sh_addralign; /* elf section alignment */
|
||||
int sh_entsize; /* elf entry size */
|
||||
unsigned long sh_size; /* section size (only used during output) */
|
||||
unsigned long sh_addr; /* address at which the section is relocated */
|
||||
unsigned long sh_offset; /* file offset */
|
||||
int nb_hashed_syms; /* used to resize the hash table */
|
||||
struct Section *link; /* link to another section */
|
||||
struct Section *reloc; /* corresponding section for relocation, if any */
|
||||
struct Section *hash; /* hash table for symbols */
|
||||
struct Section *next;
|
||||
char name[1]; /* section name */
|
||||
} Section;
|
||||
|
||||
typedef struct DLLReference {
|
||||
int level;
|
||||
void *handle;
|
||||
char name[1];
|
||||
} DLLReference;
|
||||
|
||||
/* GNUC attribute definition */
|
||||
typedef struct AttributeDef {
|
||||
int aligned;
|
||||
int packed;
|
||||
Section *section;
|
||||
int func_attr; /* calling convention, exports, ... */
|
||||
} AttributeDef;
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* gr: wrappers for casting sym->r for other purposes */
|
||||
typedef struct {
|
||||
unsigned
|
||||
func_call : 8,
|
||||
func_args : 8,
|
||||
func_export : 1;
|
||||
} func_attr_t;
|
||||
|
||||
#define FUNC_CALL(r) (((func_attr_t*)&(r))->func_call)
|
||||
#define FUNC_EXPORT(r) (((func_attr_t*)&(r))->func_export)
|
||||
#define FUNC_ARGS(r) (((func_attr_t*)&(r))->func_args)
|
||||
#define INLINE_DEF(r) (*(int **)&(r))
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
#define SYM_STRUCT 0x40000000 /* struct/union/enum symbol space */
|
||||
#define SYM_FIELD 0x20000000 /* struct/union field symbol space */
|
||||
#define SYM_FIRST_ANOM 0x10000000 /* first anonymous sym */
|
||||
|
||||
/* stored in 'Sym.c' field */
|
||||
#define FUNC_NEW 1 /* ansi function prototype */
|
||||
#define FUNC_OLD 2 /* old function prototype */
|
||||
#define FUNC_ELLIPSIS 3 /* ansi function prototype with ... */
|
||||
|
||||
/* stored in 'Sym.r' field */
|
||||
#define FUNC_CDECL 0 /* standard c call */
|
||||
#define FUNC_STDCALL 1 /* pascal c call */
|
||||
#define FUNC_FASTCALL1 2 /* first param in %eax */
|
||||
#define FUNC_FASTCALL2 3 /* first parameters in %eax, %edx */
|
||||
#define FUNC_FASTCALL3 4 /* first parameter in %eax, %edx, %ecx */
|
||||
#define FUNC_FASTCALLW 5 /* first parameter in %ecx, %edx */
|
||||
|
||||
/* field 'Sym.t' for macros */
|
||||
#define MACRO_OBJ 0 /* object like macro */
|
||||
#define MACRO_FUNC 1 /* function like macro */
|
||||
|
||||
/* field 'Sym.r' for C labels */
|
||||
#define LABEL_DEFINED 0 /* label is defined */
|
||||
#define LABEL_FORWARD 1 /* label is forward defined */
|
||||
#define LABEL_DECLARED 2 /* label is declared but never used */
|
||||
|
||||
/* type_decl() types */
|
||||
#define TYPE_ABSTRACT 1 /* type without variable */
|
||||
#define TYPE_DIRECT 2 /* type with variable */
|
||||
|
||||
#define IO_BUF_SIZE 8192
|
||||
|
||||
typedef struct BufferedFile {
|
||||
uint8_t *buf_ptr;
|
||||
uint8_t *buf_end;
|
||||
int fd;
|
||||
int line_num; /* current line number - here to simplify code */
|
||||
int ifndef_macro; /* #ifndef macro / #endif search */
|
||||
int ifndef_macro_saved; /* saved ifndef_macro */
|
||||
int *ifdef_stack_ptr; /* ifdef_stack value at the start of the file */
|
||||
char inc_type; /* type of include */
|
||||
char inc_filename[512]; /* filename specified by the user */
|
||||
char filename[1024]; /* current filename - here to simplify code */
|
||||
unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
|
||||
} BufferedFile;
|
||||
|
||||
#define CH_EOB '\\' /* end of buffer or '\0' char in file */
|
||||
#define CH_EOF (-1) /* end of file */
|
||||
|
||||
/* parsing state (used to save parser state to reparse part of the
|
||||
source several times) */
|
||||
typedef struct ParseState {
|
||||
int *macro_ptr;
|
||||
int line_num;
|
||||
int tok;
|
||||
CValue tokc;
|
||||
} ParseState;
|
||||
|
||||
/* used to record tokens */
|
||||
typedef struct TokenString {
|
||||
int *str;
|
||||
int len;
|
||||
int allocated_len;
|
||||
int last_line_num;
|
||||
} TokenString;
|
||||
|
||||
/* include file cache, used to find files faster and also to eliminate
|
||||
inclusion if the include file is protected by #ifndef ... #endif */
|
||||
typedef struct CachedInclude {
|
||||
int ifndef_macro;
|
||||
int hash_next; /* -1 if none */
|
||||
char type; /* '"' or '>' to give include type */
|
||||
char filename[1]; /* path specified in #include */
|
||||
} CachedInclude;
|
||||
|
||||
#define CACHED_INCLUDES_HASH_SIZE 512
|
||||
|
||||
#ifdef CONFIG_TCC_ASM
|
||||
typedef struct ExprValue {
|
||||
uint32_t v;
|
||||
Sym *sym;
|
||||
} ExprValue;
|
||||
|
||||
#define MAX_ASM_OPERANDS 30
|
||||
typedef struct ASMOperand {
|
||||
int id; /* GCC 3 optionnal identifier (0 if number only supported */
|
||||
char *constraint;
|
||||
char asm_str[16]; /* computed asm string for operand */
|
||||
SValue *vt; /* C value of the expression */
|
||||
int ref_index; /* if >= 0, gives reference to a output constraint */
|
||||
int input_index; /* if >= 0, gives reference to an input constraint */
|
||||
int priority; /* priority, used to assign registers */
|
||||
int reg; /* if >= 0, register number used for this operand */
|
||||
int is_llong; /* true if double register value */
|
||||
int is_memory; /* true if memory operand */
|
||||
int is_rw; /* for '+' modifier */
|
||||
} ASMOperand;
|
||||
|
||||
#endif
|
||||
|
||||
struct TCCState {
|
||||
int output_type;
|
||||
|
||||
BufferedFile **include_stack_ptr;
|
||||
int *ifdef_stack_ptr;
|
||||
|
||||
/* include file handling */
|
||||
char **include_paths;
|
||||
int nb_include_paths;
|
||||
char **sysinclude_paths;
|
||||
int nb_sysinclude_paths;
|
||||
CachedInclude **cached_includes;
|
||||
int nb_cached_includes;
|
||||
|
||||
char **library_paths;
|
||||
int nb_library_paths;
|
||||
|
||||
/* array of all loaded dlls (including those referenced by loaded
|
||||
dlls) */
|
||||
DLLReference **loaded_dlls;
|
||||
int nb_loaded_dlls;
|
||||
|
||||
/* sections */
|
||||
Section **sections;
|
||||
int nb_sections; /* number of sections, including first dummy section */
|
||||
|
||||
Section **priv_sections;
|
||||
int nb_priv_sections; /* number of private sections */
|
||||
|
||||
/* got handling */
|
||||
Section *got;
|
||||
Section *plt;
|
||||
unsigned long *got_offsets;
|
||||
int nb_got_offsets;
|
||||
/* give the correspondance from symtab indexes to dynsym indexes */
|
||||
int *symtab_to_dynsym;
|
||||
|
||||
/* temporary dynamic symbol sections (for dll loading) */
|
||||
Section *dynsymtab_section;
|
||||
/* exported dynamic symbol section */
|
||||
Section *dynsym;
|
||||
|
||||
int nostdinc; /* if true, no standard headers are added */
|
||||
int nostdlib; /* if true, no standard libraries are added */
|
||||
int nocommon; /* if true, do not use common symbols for .bss data */
|
||||
|
||||
/* if true, static linking is performed */
|
||||
int static_link;
|
||||
|
||||
/* soname as specified on the command line (-soname) */
|
||||
const char *soname;
|
||||
|
||||
/* if true, all symbols are exported */
|
||||
int rdynamic;
|
||||
|
||||
/* if true, only link in referenced objects from archive */
|
||||
int alacarte_link;
|
||||
|
||||
/* address of text section */
|
||||
unsigned long text_addr;
|
||||
int has_text_addr;
|
||||
|
||||
/* output format, see TCC_OUTPUT_FORMAT_xxx */
|
||||
int output_format;
|
||||
|
||||
/* C language options */
|
||||
int char_is_unsigned;
|
||||
int leading_underscore;
|
||||
|
||||
/* warning switches */
|
||||
int warn_write_strings;
|
||||
int warn_unsupported;
|
||||
int warn_error;
|
||||
int warn_none;
|
||||
int warn_implicit_function_declaration;
|
||||
|
||||
/* display some information during compilation */
|
||||
int verbose;
|
||||
/* compile with debug symbol (and use them if error during execution) */
|
||||
int do_debug;
|
||||
/* compile with built-in memory and bounds checker */
|
||||
int do_bounds_check;
|
||||
/* give the path of the tcc libraries */
|
||||
const char *tcc_lib_path;
|
||||
|
||||
/* error handling */
|
||||
void *error_opaque;
|
||||
void (*error_func)(void *opaque, const char *msg);
|
||||
int error_set_jmp_enabled;
|
||||
jmp_buf error_jmp_buf;
|
||||
int nb_errors;
|
||||
|
||||
/* tiny assembler state */
|
||||
Sym *asm_labels;
|
||||
|
||||
/* see include_stack_ptr */
|
||||
BufferedFile *include_stack[INCLUDE_STACK_SIZE];
|
||||
|
||||
/* see ifdef_stack_ptr */
|
||||
int ifdef_stack[IFDEF_STACK_SIZE];
|
||||
|
||||
/* see cached_includes */
|
||||
int cached_includes_hash[CACHED_INCLUDES_HASH_SIZE];
|
||||
|
||||
/* pack stack */
|
||||
int pack_stack[PACK_STACK_SIZE];
|
||||
int *pack_stack_ptr;
|
||||
|
||||
/* output file for preprocessing */
|
||||
FILE *outfile;
|
||||
|
||||
/* for tcc_relocate */
|
||||
int runtime_added;
|
||||
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
/* write PLT and GOT here */
|
||||
char *runtime_plt_and_got;
|
||||
unsigned int runtime_plt_and_got_offset;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* The current value can be: */
|
||||
#define VT_VALMASK 0x00ff
|
||||
#define VT_CONST 0x00f0 /* constant in vc
|
||||
(must be first non register value) */
|
||||
#define VT_LLOCAL 0x00f1 /* lvalue, offset on stack */
|
||||
#define VT_LOCAL 0x00f2 /* offset on stack */
|
||||
#define VT_CMP 0x00f3 /* the value is stored in processor flags (in vc) */
|
||||
#define VT_JMP 0x00f4 /* value is the consequence of jmp true (even) */
|
||||
#define VT_JMPI 0x00f5 /* value is the consequence of jmp false (odd) */
|
||||
#define VT_LVAL 0x0100 /* var is an lvalue */
|
||||
#define VT_SYM 0x0200 /* a symbol value is added */
|
||||
#define VT_MUSTCAST 0x0400 /* value must be casted to be correct (used for
|
||||
char/short stored in integer registers) */
|
||||
#define VT_MUSTBOUND 0x0800 /* bound checking must be done before
|
||||
dereferencing value */
|
||||
#define VT_BOUNDED 0x8000 /* value is bounded. The address of the
|
||||
bounding function call point is in vc */
|
||||
#define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */
|
||||
#define VT_LVAL_SHORT 0x2000 /* lvalue is a short */
|
||||
#define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */
|
||||
#define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED)
|
||||
|
||||
/* types */
|
||||
#define VT_INT 0 /* integer type */
|
||||
#define VT_BYTE 1 /* signed byte type */
|
||||
#define VT_SHORT 2 /* short type */
|
||||
#define VT_VOID 3 /* void type */
|
||||
#define VT_PTR 4 /* pointer */
|
||||
#define VT_ENUM 5 /* enum definition */
|
||||
#define VT_FUNC 6 /* function type */
|
||||
#define VT_STRUCT 7 /* struct/union definition */
|
||||
#define VT_FLOAT 8 /* IEEE float */
|
||||
#define VT_DOUBLE 9 /* IEEE double */
|
||||
#define VT_LDOUBLE 10 /* IEEE long double */
|
||||
#define VT_BOOL 11 /* ISOC99 boolean type */
|
||||
#define VT_LLONG 12 /* 64 bit integer */
|
||||
#define VT_LONG 13 /* long integer (NEVER USED as type, only
|
||||
during parsing) */
|
||||
#define VT_BTYPE 0x000f /* mask for basic type */
|
||||
#define VT_UNSIGNED 0x0010 /* unsigned type */
|
||||
#define VT_ARRAY 0x0020 /* array type (also has VT_PTR) */
|
||||
#define VT_BITFIELD 0x0040 /* bitfield modifier */
|
||||
#define VT_CONSTANT 0x0800 /* const modifier */
|
||||
#define VT_VOLATILE 0x1000 /* volatile modifier */
|
||||
#define VT_SIGNED 0x2000 /* signed type */
|
||||
|
||||
/* storage */
|
||||
#define VT_EXTERN 0x00000080 /* extern definition */
|
||||
#define VT_STATIC 0x00000100 /* static variable */
|
||||
#define VT_TYPEDEF 0x00000200 /* typedef definition */
|
||||
#define VT_INLINE 0x00000400 /* inline definition */
|
||||
|
||||
#define VT_STRUCT_SHIFT 16 /* shift for bitfield shift values */
|
||||
|
||||
/* type mask (except storage) */
|
||||
#define VT_STORAGE (VT_EXTERN | VT_STATIC | VT_TYPEDEF | VT_INLINE)
|
||||
#define VT_TYPE (~(VT_STORAGE))
|
||||
|
||||
/* token values */
|
||||
|
||||
/* warning: the following compare tokens depend on i386 asm code */
|
||||
#define TOK_ULT 0x92
|
||||
#define TOK_UGE 0x93
|
||||
#define TOK_EQ 0x94
|
||||
#define TOK_NE 0x95
|
||||
#define TOK_ULE 0x96
|
||||
#define TOK_UGT 0x97
|
||||
#define TOK_Nset 0x98
|
||||
#define TOK_Nclear 0x99
|
||||
#define TOK_LT 0x9c
|
||||
#define TOK_GE 0x9d
|
||||
#define TOK_LE 0x9e
|
||||
#define TOK_GT 0x9f
|
||||
|
||||
#define TOK_LAND 0xa0
|
||||
#define TOK_LOR 0xa1
|
||||
|
||||
#define TOK_DEC 0xa2
|
||||
#define TOK_MID 0xa3 /* inc/dec, to void constant */
|
||||
#define TOK_INC 0xa4
|
||||
#define TOK_UDIV 0xb0 /* unsigned division */
|
||||
#define TOK_UMOD 0xb1 /* unsigned modulo */
|
||||
#define TOK_PDIV 0xb2 /* fast division with undefined rounding for pointers */
|
||||
#define TOK_CINT 0xb3 /* number in tokc */
|
||||
#define TOK_CCHAR 0xb4 /* char constant in tokc */
|
||||
#define TOK_STR 0xb5 /* pointer to string in tokc */
|
||||
#define TOK_TWOSHARPS 0xb6 /* ## preprocessing token */
|
||||
#define TOK_LCHAR 0xb7
|
||||
#define TOK_LSTR 0xb8
|
||||
#define TOK_CFLOAT 0xb9 /* float constant */
|
||||
#define TOK_LINENUM 0xba /* line number info */
|
||||
#define TOK_CDOUBLE 0xc0 /* double constant */
|
||||
#define TOK_CLDOUBLE 0xc1 /* long double constant */
|
||||
#define TOK_UMULL 0xc2 /* unsigned 32x32 -> 64 mul */
|
||||
#define TOK_ADDC1 0xc3 /* add with carry generation */
|
||||
#define TOK_ADDC2 0xc4 /* add with carry use */
|
||||
#define TOK_SUBC1 0xc5 /* add with carry generation */
|
||||
#define TOK_SUBC2 0xc6 /* add with carry use */
|
||||
#define TOK_CUINT 0xc8 /* unsigned int constant */
|
||||
#define TOK_CLLONG 0xc9 /* long long constant */
|
||||
#define TOK_CULLONG 0xca /* unsigned long long constant */
|
||||
#define TOK_ARROW 0xcb
|
||||
#define TOK_DOTS 0xcc /* three dots */
|
||||
#define TOK_SHR 0xcd /* unsigned shift right */
|
||||
#define TOK_PPNUM 0xce /* preprocessor number */
|
||||
|
||||
#define TOK_SHL 0x01 /* shift left */
|
||||
#define TOK_SAR 0x02 /* signed shift right */
|
||||
|
||||
/* assignement operators : normal operator or 0x80 */
|
||||
#define TOK_A_MOD 0xa5
|
||||
#define TOK_A_AND 0xa6
|
||||
#define TOK_A_MUL 0xaa
|
||||
#define TOK_A_ADD 0xab
|
||||
#define TOK_A_SUB 0xad
|
||||
#define TOK_A_DIV 0xaf
|
||||
#define TOK_A_XOR 0xde
|
||||
#define TOK_A_OR 0xfc
|
||||
#define TOK_A_SHL 0x81
|
||||
#define TOK_A_SAR 0x82
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
||||
#endif
|
||||
|
||||
#ifndef countof
|
||||
#define countof(tab) (sizeof(tab) / sizeof((tab)[0]))
|
||||
#endif
|
||||
|
||||
#define TOK_EOF (-1) /* end of file */
|
||||
#define TOK_LINEFEED 10 /* line feed */
|
||||
|
||||
/* all identificators and strings have token above that */
|
||||
#define TOK_IDENT 256
|
||||
|
||||
/* only used for i386 asm opcodes definitions */
|
||||
#define DEF_ASM(x) DEF(TOK_ASM_ ## x, #x)
|
||||
|
||||
#define DEF_BWL(x) \
|
||||
DEF(TOK_ASM_ ## x ## b, #x "b") \
|
||||
DEF(TOK_ASM_ ## x ## w, #x "w") \
|
||||
DEF(TOK_ASM_ ## x ## l, #x "l") \
|
||||
DEF(TOK_ASM_ ## x, #x)
|
||||
|
||||
#define DEF_WL(x) \
|
||||
DEF(TOK_ASM_ ## x ## w, #x "w") \
|
||||
DEF(TOK_ASM_ ## x ## l, #x "l") \
|
||||
DEF(TOK_ASM_ ## x, #x)
|
||||
|
||||
#define DEF_FP1(x) \
|
||||
DEF(TOK_ASM_ ## f ## x ## s, "f" #x "s") \
|
||||
DEF(TOK_ASM_ ## fi ## x ## l, "fi" #x "l") \
|
||||
DEF(TOK_ASM_ ## f ## x ## l, "f" #x "l") \
|
||||
DEF(TOK_ASM_ ## fi ## x ## s, "fi" #x "s")
|
||||
|
||||
#define DEF_FP(x) \
|
||||
DEF(TOK_ASM_ ## f ## x, "f" #x ) \
|
||||
DEF(TOK_ASM_ ## f ## x ## p, "f" #x "p") \
|
||||
DEF_FP1(x)
|
||||
|
||||
#define DEF_ASMTEST(x) \
|
||||
DEF_ASM(x ## o) \
|
||||
DEF_ASM(x ## no) \
|
||||
DEF_ASM(x ## b) \
|
||||
DEF_ASM(x ## c) \
|
||||
DEF_ASM(x ## nae) \
|
||||
DEF_ASM(x ## nb) \
|
||||
DEF_ASM(x ## nc) \
|
||||
DEF_ASM(x ## ae) \
|
||||
DEF_ASM(x ## e) \
|
||||
DEF_ASM(x ## z) \
|
||||
DEF_ASM(x ## ne) \
|
||||
DEF_ASM(x ## nz) \
|
||||
DEF_ASM(x ## be) \
|
||||
DEF_ASM(x ## na) \
|
||||
DEF_ASM(x ## nbe) \
|
||||
DEF_ASM(x ## a) \
|
||||
DEF_ASM(x ## s) \
|
||||
DEF_ASM(x ## ns) \
|
||||
DEF_ASM(x ## p) \
|
||||
DEF_ASM(x ## pe) \
|
||||
DEF_ASM(x ## np) \
|
||||
DEF_ASM(x ## po) \
|
||||
DEF_ASM(x ## l) \
|
||||
DEF_ASM(x ## nge) \
|
||||
DEF_ASM(x ## nl) \
|
||||
DEF_ASM(x ## ge) \
|
||||
DEF_ASM(x ## le) \
|
||||
DEF_ASM(x ## ng) \
|
||||
DEF_ASM(x ## nle) \
|
||||
DEF_ASM(x ## g)
|
||||
|
||||
#define TOK_ASM_int TOK_INT
|
||||
|
||||
enum tcc_token {
|
||||
TOK_LAST = TOK_IDENT - 1,
|
||||
#define DEF(id, str) id,
|
||||
#include "tcctok.h"
|
||||
#undef DEF
|
||||
};
|
||||
|
||||
#define TOK_UIDENT TOK_DEFINE
|
||||
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#ifndef __GNUC__
|
||||
#define strtold (long double)strtod
|
||||
#define strtof (float)strtod
|
||||
#define strtoll (long long)strtol
|
||||
#endif
|
||||
#elif defined(TCC_UCLIBC) || defined(__FreeBSD__) || defined(__DragonFly__) \
|
||||
|| defined(__OpenBSD__)
|
||||
/* currently incorrect */
|
||||
long double strtold(const char *nptr, char **endptr)
|
||||
{
|
||||
return (long double)strtod(nptr, endptr);
|
||||
}
|
||||
float strtof(const char *nptr, char **endptr)
|
||||
{
|
||||
return (float)strtod(nptr, endptr);
|
||||
}
|
||||
#else
|
||||
/* XXX: need to define this to use them in non ISOC99 context */
|
||||
extern float strtof (const char *__nptr, char **__endptr);
|
||||
extern long double strtold (const char *__nptr, char **__endptr);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define IS_PATHSEP(c) (c == '/' || c == '\\')
|
||||
#define IS_ABSPATH(p) (IS_PATHSEP(p[0]) || (p[0] && p[1] == ':' && IS_PATHSEP(p[2])))
|
||||
#define PATHCMP stricmp
|
||||
#else
|
||||
#define IS_PATHSEP(c) (c == '/')
|
||||
#define IS_ABSPATH(p) IS_PATHSEP(p[0])
|
||||
#define PATHCMP strcmp
|
||||
#endif
|
||||
|
||||
void error(const char *fmt, ...);
|
||||
void error_noabort(const char *fmt, ...);
|
||||
void warning(const char *fmt, ...);
|
||||
|
||||
void tcc_set_lib_path_w32(TCCState *s);
|
||||
int tcc_set_flag(TCCState *s, const char *flag_name, int value);
|
||||
void tcc_print_stats(TCCState *s, int64_t total_time);
|
||||
|
||||
void tcc_free(void *ptr);
|
||||
void *tcc_malloc(unsigned long size);
|
||||
void *tcc_mallocz(unsigned long size);
|
||||
void *tcc_realloc(void *ptr, unsigned long size);
|
||||
char *tcc_strdup(const char *str);
|
||||
|
||||
char *tcc_basename(const char *name);
|
||||
char *tcc_fileextension (const char *name);
|
||||
char *pstrcpy(char *buf, int buf_size, const char *s);
|
||||
char *pstrcat(char *buf, int buf_size, const char *s);
|
||||
void dynarray_add(void ***ptab, int *nb_ptr, void *data);
|
||||
void dynarray_reset(void *pp, int *n);
|
||||
|
||||
#ifdef CONFIG_TCC_BACKTRACE
|
||||
extern int num_callers;
|
||||
extern const char **rt_bound_error_msg;
|
||||
#endif
|
||||
|
||||
/* true if float/double/long double type */
|
||||
static inline int is_float(int t)
|
||||
{
|
||||
int bt;
|
||||
bt = t & VT_BTYPE;
|
||||
return bt == VT_LDOUBLE || bt == VT_DOUBLE || bt == VT_FLOAT;
|
||||
}
|
||||
|
||||
/* space exlcuding newline */
|
||||
static inline int is_space(int ch)
|
||||
{
|
||||
return ch == ' ' || ch == '\t' || ch == '\v' || ch == '\f' || ch == '\r';
|
||||
}
|
||||
|
||||
314
tccasm.c
314
tccasm.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* GAS like assembler for TCC
|
||||
*
|
||||
* Copyright (c) 2001, 2002 Fabrice Bellard
|
||||
* Copyright (c) 2001-2004 Fabrice Bellard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -28,6 +28,8 @@ static int asm_get_local_label_name(TCCState *s1, unsigned int n)
|
||||
return ts->tok;
|
||||
}
|
||||
|
||||
static void asm_expr(TCCState *s1, ExprValue *pe);
|
||||
|
||||
/* We do not use the C expression parser to handle symbols. Maybe the
|
||||
C expression parser could be tweaked to do so. */
|
||||
|
||||
@@ -91,6 +93,11 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
|
||||
pe->sym = NULL;
|
||||
next();
|
||||
break;
|
||||
case '(':
|
||||
next();
|
||||
asm_expr(s1, pe);
|
||||
skip(')');
|
||||
break;
|
||||
default:
|
||||
if (tok >= TOK_IDENT) {
|
||||
/* label case : if the label was not found, add one */
|
||||
@@ -100,8 +107,14 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
|
||||
/* NOTE: by default, the symbol is global */
|
||||
sym->type.t = VT_VOID;
|
||||
}
|
||||
pe->v = 0;
|
||||
pe->sym = sym;
|
||||
if (sym->r == SHN_ABS) {
|
||||
/* if absolute symbol, no need to put a symbol value */
|
||||
pe->v = (long)sym->next;
|
||||
pe->sym = NULL;
|
||||
} else {
|
||||
pe->v = 0;
|
||||
pe->sym = sym;
|
||||
}
|
||||
next();
|
||||
} else {
|
||||
error("bad expression syntax [%s]", get_tok_str(tok, &tokc));
|
||||
@@ -241,7 +254,8 @@ static int asm_int_expr(TCCState *s1)
|
||||
|
||||
/* NOTE: the same name space as C labels is used to avoid using too
|
||||
much memory when storing labels in TokenStrings */
|
||||
static void asm_new_label(TCCState *s1, int label, int is_local)
|
||||
static void asm_new_label1(TCCState *s1, int label, int is_local,
|
||||
int sh_num, int value)
|
||||
{
|
||||
Sym *sym;
|
||||
|
||||
@@ -262,33 +276,49 @@ static void asm_new_label(TCCState *s1, int label, int is_local)
|
||||
sym = label_push(&s1->asm_labels, label, 0);
|
||||
sym->type.t = VT_STATIC | VT_VOID;
|
||||
}
|
||||
sym->r = cur_text_section->sh_num;
|
||||
sym->next = (void *)ind;
|
||||
sym->r = sh_num;
|
||||
sym->next = (void *)value;
|
||||
}
|
||||
|
||||
static void asm_new_label(TCCState *s1, int label, int is_local)
|
||||
{
|
||||
asm_new_label1(s1, label, is_local, cur_text_section->sh_num, ind);
|
||||
}
|
||||
|
||||
static void asm_free_labels(TCCState *st)
|
||||
{
|
||||
Sym *s, *s1;
|
||||
Section *sec;
|
||||
|
||||
for(s = st->asm_labels; s != NULL; s = s1) {
|
||||
s1 = s->prev;
|
||||
/* define symbol value in object file */
|
||||
if (s->r) {
|
||||
put_extern_sym(s, st->sections[s->r], (long)s->next, 0);
|
||||
if (s->r == SHN_ABS)
|
||||
sec = SECTION_ABS;
|
||||
else
|
||||
sec = st->sections[s->r];
|
||||
put_extern_sym2(s, sec, (long)s->next, 0, 0);
|
||||
}
|
||||
/* remove label */
|
||||
table_ident[s->v - TOK_IDENT]->sym_label = NULL;
|
||||
tcc_free(s);
|
||||
sym_free(s);
|
||||
}
|
||||
st->asm_labels = NULL;
|
||||
}
|
||||
|
||||
static void use_section1(TCCState *s1, Section *sec)
|
||||
{
|
||||
cur_text_section->data_offset = ind;
|
||||
cur_text_section = sec;
|
||||
ind = cur_text_section->data_offset;
|
||||
}
|
||||
|
||||
static void use_section(TCCState *s1, const char *name)
|
||||
{
|
||||
Section *sec;
|
||||
sec = find_section(s1, name);
|
||||
cur_text_section->data_offset = ind;
|
||||
cur_text_section = sec;
|
||||
ind = cur_text_section->data_offset;
|
||||
use_section1(s1, sec);
|
||||
}
|
||||
|
||||
static void asm_parse_directive(TCCState *s1)
|
||||
@@ -312,6 +342,9 @@ static void asm_parse_directive(TCCState *s1)
|
||||
error("alignment must be a positive power of two");
|
||||
offset = (ind + n - 1) & -n;
|
||||
size = offset - ind;
|
||||
/* the section must have a compatible alignment */
|
||||
if (sec->sh_addralign < n)
|
||||
sec->sh_addralign = n;
|
||||
} else {
|
||||
size = n;
|
||||
}
|
||||
@@ -320,6 +353,7 @@ static void asm_parse_directive(TCCState *s1)
|
||||
next();
|
||||
v = asm_int_expr(s1);
|
||||
}
|
||||
zero_pad:
|
||||
if (sec->sh_type != SHT_NOBITS) {
|
||||
sec->data_offset = ind;
|
||||
ptr = section_ptr_add(sec, size);
|
||||
@@ -327,6 +361,33 @@ static void asm_parse_directive(TCCState *s1)
|
||||
}
|
||||
ind += size;
|
||||
break;
|
||||
case TOK_ASM_quad:
|
||||
next();
|
||||
for(;;) {
|
||||
uint64_t vl;
|
||||
const char *p;
|
||||
|
||||
p = tokc.cstr->data;
|
||||
if (tok != TOK_PPNUM) {
|
||||
error_constant:
|
||||
error("64 bit constant");
|
||||
}
|
||||
vl = strtoll(p, (char **)&p, 0);
|
||||
if (*p != '\0')
|
||||
goto error_constant;
|
||||
next();
|
||||
if (sec->sh_type != SHT_NOBITS) {
|
||||
/* XXX: endianness */
|
||||
gen_le32(vl);
|
||||
gen_le32(vl >> 32);
|
||||
} else {
|
||||
ind += 8;
|
||||
}
|
||||
if (tok != ',')
|
||||
break;
|
||||
next();
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_byte:
|
||||
size = 1;
|
||||
goto asm_data;
|
||||
@@ -361,7 +422,63 @@ static void asm_parse_directive(TCCState *s1)
|
||||
next();
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_fill:
|
||||
{
|
||||
int repeat, size, val, i, j;
|
||||
uint8_t repeat_buf[8];
|
||||
next();
|
||||
repeat = asm_int_expr(s1);
|
||||
if (repeat < 0) {
|
||||
error("repeat < 0; .fill ignored");
|
||||
break;
|
||||
}
|
||||
size = 1;
|
||||
val = 0;
|
||||
if (tok == ',') {
|
||||
next();
|
||||
size = asm_int_expr(s1);
|
||||
if (size < 0) {
|
||||
error("size < 0; .fill ignored");
|
||||
break;
|
||||
}
|
||||
if (size > 8)
|
||||
size = 8;
|
||||
if (tok == ',') {
|
||||
next();
|
||||
val = asm_int_expr(s1);
|
||||
}
|
||||
}
|
||||
/* XXX: endianness */
|
||||
repeat_buf[0] = val;
|
||||
repeat_buf[1] = val >> 8;
|
||||
repeat_buf[2] = val >> 16;
|
||||
repeat_buf[3] = val >> 24;
|
||||
repeat_buf[4] = 0;
|
||||
repeat_buf[5] = 0;
|
||||
repeat_buf[6] = 0;
|
||||
repeat_buf[7] = 0;
|
||||
for(i = 0; i < repeat; i++) {
|
||||
for(j = 0; j < size; j++) {
|
||||
g(repeat_buf[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_org:
|
||||
{
|
||||
unsigned long n;
|
||||
next();
|
||||
/* XXX: handle section symbols too */
|
||||
n = asm_int_expr(s1);
|
||||
if (n < ind)
|
||||
error("attempt to .org backwards");
|
||||
v = 0;
|
||||
size = n - ind;
|
||||
goto zero_pad;
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_globl:
|
||||
case TOK_ASM_global:
|
||||
{
|
||||
Sym *sym;
|
||||
|
||||
@@ -376,17 +493,30 @@ static void asm_parse_directive(TCCState *s1)
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_string:
|
||||
case TOK_ASM_ascii:
|
||||
case TOK_ASM_asciz:
|
||||
{
|
||||
const uint8_t *p;
|
||||
int i;
|
||||
int i, size, t;
|
||||
|
||||
t = tok;
|
||||
next();
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
p = tokc.cstr->data;
|
||||
for(i = 0; i < tokc.cstr->size; i++)
|
||||
g(p[i]);
|
||||
next();
|
||||
for(;;) {
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
p = tokc.cstr->data;
|
||||
size = tokc.cstr->size;
|
||||
if (t == TOK_ASM_ascii && size > 0)
|
||||
size--;
|
||||
for(i = 0; i < size; i++)
|
||||
g(p[i]);
|
||||
next();
|
||||
if (tok == ',') {
|
||||
next();
|
||||
} else if (tok != TOK_STR) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_text:
|
||||
@@ -419,9 +549,28 @@ static void asm_parse_directive(TCCState *s1)
|
||||
pstrcat(sname, sizeof(sname), get_tok_str(tok, NULL));
|
||||
next();
|
||||
}
|
||||
if (tok == ',') {
|
||||
/* skip section options */
|
||||
next();
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
next();
|
||||
}
|
||||
last_text_section = cur_text_section;
|
||||
use_section(s1, sname);
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_previous:
|
||||
{
|
||||
Section *sec;
|
||||
next();
|
||||
if (!last_text_section)
|
||||
error("no previous section referenced");
|
||||
sec = cur_text_section;
|
||||
use_section1(s1, last_text_section);
|
||||
last_text_section = sec;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error("unknown assembler directive '.%s'", get_tok_str(tok, NULL));
|
||||
break;
|
||||
@@ -470,7 +619,7 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess)
|
||||
|
||||
ch = file->buf_ptr[0];
|
||||
tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
|
||||
parse_flags = 0;
|
||||
parse_flags = PARSE_FLAG_ASM_COMMENTS;
|
||||
if (do_preprocess)
|
||||
parse_flags |= PARSE_FLAG_PREPROCESS;
|
||||
next();
|
||||
@@ -506,6 +655,12 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess)
|
||||
asm_new_label(s1, opcode, 0);
|
||||
next();
|
||||
goto redo;
|
||||
} else if (tok == '=') {
|
||||
int n;
|
||||
next();
|
||||
n = asm_int_expr(s1);
|
||||
asm_new_label1(s1, opcode, 0, SHN_ABS, n);
|
||||
goto redo;
|
||||
} else {
|
||||
asm_opcode(s1, opcode);
|
||||
}
|
||||
@@ -526,6 +681,7 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess)
|
||||
/* Assemble the current file */
|
||||
static int tcc_assemble(TCCState *s1, int do_preprocess)
|
||||
{
|
||||
Sym *define_start;
|
||||
int ret;
|
||||
|
||||
preprocess_init(s1);
|
||||
@@ -534,9 +690,14 @@ static int tcc_assemble(TCCState *s1, int do_preprocess)
|
||||
cur_text_section = text_section;
|
||||
ind = cur_text_section->data_offset;
|
||||
|
||||
define_start = define_stack;
|
||||
|
||||
ret = tcc_assemble_internal(s1, do_preprocess);
|
||||
|
||||
cur_text_section->data_offset = ind;
|
||||
|
||||
free_defines(define_start);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -645,7 +806,7 @@ static void subst_asm_operands(ASMOperand *operands, int nb_operands,
|
||||
sv = *op->vt;
|
||||
if (op->reg >= 0) {
|
||||
sv.r = op->reg;
|
||||
if ((op->vt->r & VT_VALMASK) == VT_LLOCAL)
|
||||
if ((op->vt->r & VT_VALMASK) == VT_LLOCAL && op->is_memory)
|
||||
sv.r |= VT_LVAL;
|
||||
}
|
||||
subst_asm_operand(out_str, &sv, modifier);
|
||||
@@ -690,12 +851,14 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
|
||||
if (is_output) {
|
||||
test_lvalue();
|
||||
} else {
|
||||
/* we want to avoid LLOCAL case. note that it may come
|
||||
from register storage, so we need to convert (reg)
|
||||
/* we want to avoid LLOCAL case, except when the 'm'
|
||||
constraint is used. Note that it may come from
|
||||
register storage, so we need to convert (reg)
|
||||
case */
|
||||
if ((vtop->r & VT_LVAL) &&
|
||||
((vtop->r & VT_VALMASK) == VT_LLOCAL ||
|
||||
(vtop->r & VT_VALMASK) < VT_CONST)) {
|
||||
(vtop->r & VT_VALMASK) < VT_CONST) &&
|
||||
!strchr(op->constraint, 'm')) {
|
||||
gv(RC_INT);
|
||||
}
|
||||
}
|
||||
@@ -711,14 +874,27 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_asm_str(CString *astr)
|
||||
{
|
||||
skip('(');
|
||||
/* read the string */
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
cstr_new(astr);
|
||||
while (tok == TOK_STR) {
|
||||
/* XXX: add \0 handling too ? */
|
||||
cstr_cat(astr, tokc.cstr->data);
|
||||
next();
|
||||
}
|
||||
cstr_ccat(astr, '\0');
|
||||
}
|
||||
|
||||
/* parse the GCC asm() instruction */
|
||||
static void asm_instr(void)
|
||||
{
|
||||
CString astr, astr1;
|
||||
ASMOperand operands[MAX_ASM_OPERANDS];
|
||||
int nb_inputs, nb_outputs, nb_operands, i;
|
||||
uint8_t input_regs_allocated[NB_ASM_REGS];
|
||||
uint8_t output_regs_allocated[NB_ASM_REGS];
|
||||
int nb_inputs, nb_outputs, nb_operands, i, must_subst, out_reg;
|
||||
uint8_t clobber_regs[NB_ASM_REGS];
|
||||
|
||||
next();
|
||||
@@ -727,42 +903,36 @@ static void asm_instr(void)
|
||||
if (tok == TOK_VOLATILE1 || tok == TOK_VOLATILE2 || tok == TOK_VOLATILE3) {
|
||||
next();
|
||||
}
|
||||
skip('(');
|
||||
/* read the string */
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
cstr_new(&astr);
|
||||
while (tok == TOK_STR) {
|
||||
/* XXX: add \0 handling too ? */
|
||||
cstr_cat(&astr, tokc.cstr->data);
|
||||
next();
|
||||
}
|
||||
cstr_ccat(&astr, '\0');
|
||||
parse_asm_str(&astr);
|
||||
nb_operands = 0;
|
||||
nb_outputs = 0;
|
||||
must_subst = 0;
|
||||
memset(clobber_regs, 0, sizeof(clobber_regs));
|
||||
if (tok == ':') {
|
||||
next();
|
||||
must_subst = 1;
|
||||
/* output args */
|
||||
parse_asm_operands(operands, &nb_operands, 1);
|
||||
nb_outputs = nb_operands;
|
||||
if (tok == ':') {
|
||||
next();
|
||||
/* input args */
|
||||
parse_asm_operands(operands, &nb_operands, 0);
|
||||
if (tok == ':') {
|
||||
/* clobber list */
|
||||
/* XXX: handle registers */
|
||||
next();
|
||||
for(;;) {
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
asm_clobber(clobber_regs, tokc.cstr->data);
|
||||
if (tok != ')') {
|
||||
/* input args */
|
||||
parse_asm_operands(operands, &nb_operands, 0);
|
||||
if (tok == ':') {
|
||||
/* clobber list */
|
||||
/* XXX: handle registers */
|
||||
next();
|
||||
if (tok == ',') {
|
||||
for(;;) {
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
asm_clobber(clobber_regs, tokc.cstr->data);
|
||||
next();
|
||||
} else {
|
||||
break;
|
||||
if (tok == ',') {
|
||||
next();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -779,19 +949,15 @@ static void asm_instr(void)
|
||||
save_regs(0);
|
||||
|
||||
/* compute constraints */
|
||||
asm_compute_constraints(input_regs_allocated,
|
||||
operands, nb_operands, nb_outputs, 0,
|
||||
NULL);
|
||||
asm_compute_constraints(output_regs_allocated,
|
||||
operands, nb_operands, nb_outputs, 1,
|
||||
input_regs_allocated);
|
||||
asm_compute_constraints(operands, nb_operands, nb_outputs,
|
||||
clobber_regs, &out_reg);
|
||||
|
||||
/* substitute the operands in the asm string. No substitution is
|
||||
done if no operands (GCC behaviour) */
|
||||
#ifdef ASM_DEBUG
|
||||
printf("asm: \"%s\"\n", (char *)astr.data);
|
||||
#endif
|
||||
if (nb_operands > 0) {
|
||||
if (must_subst) {
|
||||
subst_asm_operands(operands, nb_operands, nb_outputs, &astr1, &astr);
|
||||
cstr_free(&astr);
|
||||
} else {
|
||||
@@ -802,7 +968,8 @@ static void asm_instr(void)
|
||||
#endif
|
||||
|
||||
/* generate loads */
|
||||
asm_gen_code(operands, nb_operands, nb_outputs, 0, clobber_regs);
|
||||
asm_gen_code(operands, nb_operands, nb_outputs, 0,
|
||||
clobber_regs, out_reg);
|
||||
|
||||
/* assemble the string with tcc internal assembler */
|
||||
tcc_assemble_inline(tcc_state, astr1.data, astr1.size - 1);
|
||||
@@ -811,7 +978,8 @@ static void asm_instr(void)
|
||||
next();
|
||||
|
||||
/* store the output values if needed */
|
||||
asm_gen_code(operands, nb_operands, nb_outputs, 1, clobber_regs);
|
||||
asm_gen_code(operands, nb_operands, nb_outputs, 1,
|
||||
clobber_regs, out_reg);
|
||||
|
||||
/* free everything */
|
||||
for(i=0;i<nb_operands;i++) {
|
||||
@@ -823,3 +991,31 @@ static void asm_instr(void)
|
||||
cstr_free(&astr1);
|
||||
}
|
||||
|
||||
static void asm_global_instr(void)
|
||||
{
|
||||
CString astr;
|
||||
|
||||
next();
|
||||
parse_asm_str(&astr);
|
||||
skip(')');
|
||||
/* NOTE: we do not eat the ';' so that we can restore the current
|
||||
token after the assembler parsing */
|
||||
if (tok != ';')
|
||||
expect("';'");
|
||||
|
||||
#ifdef ASM_DEBUG
|
||||
printf("asm_global: \"%s\"\n", (char *)astr.data);
|
||||
#endif
|
||||
cur_text_section = text_section;
|
||||
ind = cur_text_section->data_offset;
|
||||
|
||||
/* assemble the string with tcc internal assembler */
|
||||
tcc_assemble_inline(tcc_state, astr.data, astr.size - 1);
|
||||
|
||||
cur_text_section->data_offset = ind;
|
||||
|
||||
/* restore the current C token */
|
||||
next();
|
||||
|
||||
cstr_free(&astr);
|
||||
}
|
||||
|
||||
957
tcccoff.c
Normal file
957
tcccoff.c
Normal file
@@ -0,0 +1,957 @@
|
||||
/*
|
||||
* COFF file handling for TCC
|
||||
*
|
||||
* Copyright (c) 2003, 2004 TK
|
||||
* Copyright (c) 2004 Fabrice Bellard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "coff.h"
|
||||
|
||||
#define MAXNSCNS 255 /* MAXIMUM NUMBER OF SECTIONS */
|
||||
#define MAX_STR_TABLE 1000000
|
||||
AOUTHDR o_filehdr; /* OPTIONAL (A.OUT) FILE HEADER */
|
||||
|
||||
SCNHDR section_header[MAXNSCNS];
|
||||
|
||||
#define MAX_FUNCS 1000
|
||||
#define MAX_FUNC_NAME_LENGTH 128
|
||||
|
||||
int nFuncs;
|
||||
char Func[MAX_FUNCS][MAX_FUNC_NAME_LENGTH];
|
||||
char AssociatedFile[MAX_FUNCS][MAX_FUNC_NAME_LENGTH];
|
||||
int LineNoFilePtr[MAX_FUNCS];
|
||||
int EndAddress[MAX_FUNCS];
|
||||
int LastLineNo[MAX_FUNCS];
|
||||
int FuncEntries[MAX_FUNCS];
|
||||
|
||||
BOOL OutputTheSection(Section * sect);
|
||||
short int GetCoffFlags(const char *s);
|
||||
void SortSymbolTable(void);
|
||||
Section *FindSection(TCCState * s1, const char *sname);
|
||||
|
||||
int C67_main_entry_point;
|
||||
|
||||
int FindCoffSymbolIndex(const char *func_name);
|
||||
int nb_syms;
|
||||
|
||||
typedef struct {
|
||||
long tag;
|
||||
long size;
|
||||
long fileptr;
|
||||
long nextsym;
|
||||
short int dummy;
|
||||
} AUXFUNC;
|
||||
|
||||
typedef struct {
|
||||
long regmask;
|
||||
unsigned short lineno;
|
||||
unsigned short nentries;
|
||||
int localframe;
|
||||
int nextentry;
|
||||
short int dummy;
|
||||
} AUXBF;
|
||||
|
||||
typedef struct {
|
||||
long dummy;
|
||||
unsigned short lineno;
|
||||
unsigned short dummy1;
|
||||
int dummy2;
|
||||
int dummy3;
|
||||
unsigned short dummy4;
|
||||
} AUXEF;
|
||||
|
||||
int tcc_output_coff(TCCState *s1, FILE *f)
|
||||
{
|
||||
Section *tcc_sect;
|
||||
SCNHDR *coff_sec;
|
||||
int file_pointer;
|
||||
char *Coff_str_table, *pCoff_str_table;
|
||||
int CoffTextSectionNo, coff_nb_syms;
|
||||
FILHDR file_hdr; /* FILE HEADER STRUCTURE */
|
||||
Section *stext, *sdata, *sbss;
|
||||
int i, NSectionsToOutput = 0;
|
||||
|
||||
Coff_str_table = pCoff_str_table = NULL;
|
||||
|
||||
stext = FindSection(s1, ".text");
|
||||
sdata = FindSection(s1, ".data");
|
||||
sbss = FindSection(s1, ".bss");
|
||||
|
||||
nb_syms = symtab_section->data_offset / sizeof(Elf32_Sym);
|
||||
coff_nb_syms = FindCoffSymbolIndex("XXXXXXXXXX1");
|
||||
|
||||
file_hdr.f_magic = COFF_C67_MAGIC; /* magic number */
|
||||
file_hdr.f_timdat = 0; /* time & date stamp */
|
||||
file_hdr.f_opthdr = sizeof(AOUTHDR); /* sizeof(optional hdr) */
|
||||
file_hdr.f_flags = 0x1143; /* flags (copied from what code composer does) */
|
||||
file_hdr.f_TargetID = 0x99; /* for C6x = 0x0099 */
|
||||
|
||||
o_filehdr.magic = 0x0108; /* see magic.h */
|
||||
o_filehdr.vstamp = 0x0190; /* version stamp */
|
||||
o_filehdr.tsize = stext->data_offset; /* text size in bytes, padded to FW bdry */
|
||||
o_filehdr.dsize = sdata->data_offset; /* initialized data " " */
|
||||
o_filehdr.bsize = sbss->data_offset; /* uninitialized data " " */
|
||||
o_filehdr.entrypt = C67_main_entry_point; /* entry pt. */
|
||||
o_filehdr.text_start = stext->sh_addr; /* base of text used for this file */
|
||||
o_filehdr.data_start = sdata->sh_addr; /* base of data used for this file */
|
||||
|
||||
|
||||
// create all the section headers
|
||||
|
||||
file_pointer = FILHSZ + sizeof(AOUTHDR);
|
||||
|
||||
CoffTextSectionNo = -1;
|
||||
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
if (OutputTheSection(tcc_sect)) {
|
||||
NSectionsToOutput++;
|
||||
|
||||
if (CoffTextSectionNo == -1 && tcc_sect == stext)
|
||||
CoffTextSectionNo = NSectionsToOutput; // rem which coff sect number the .text sect is
|
||||
|
||||
strcpy(coff_sec->s_name, tcc_sect->name); /* section name */
|
||||
|
||||
coff_sec->s_paddr = tcc_sect->sh_addr; /* physical address */
|
||||
coff_sec->s_vaddr = tcc_sect->sh_addr; /* virtual address */
|
||||
coff_sec->s_size = tcc_sect->data_offset; /* section size */
|
||||
coff_sec->s_scnptr = 0; /* file ptr to raw data for section */
|
||||
coff_sec->s_relptr = 0; /* file ptr to relocation */
|
||||
coff_sec->s_lnnoptr = 0; /* file ptr to line numbers */
|
||||
coff_sec->s_nreloc = 0; /* number of relocation entries */
|
||||
coff_sec->s_flags = GetCoffFlags(coff_sec->s_name); /* flags */
|
||||
coff_sec->s_reserved = 0; /* reserved byte */
|
||||
coff_sec->s_page = 0; /* memory page id */
|
||||
|
||||
file_pointer += sizeof(SCNHDR);
|
||||
}
|
||||
}
|
||||
|
||||
file_hdr.f_nscns = NSectionsToOutput; /* number of sections */
|
||||
|
||||
// now loop through and determine file pointer locations
|
||||
// for the raw data
|
||||
|
||||
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
if (OutputTheSection(tcc_sect)) {
|
||||
// put raw data
|
||||
coff_sec->s_scnptr = file_pointer; /* file ptr to raw data for section */
|
||||
file_pointer += coff_sec->s_size;
|
||||
}
|
||||
}
|
||||
|
||||
// now loop through and determine file pointer locations
|
||||
// for the relocation data
|
||||
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
if (OutputTheSection(tcc_sect)) {
|
||||
// put relocations data
|
||||
if (coff_sec->s_nreloc > 0) {
|
||||
coff_sec->s_relptr = file_pointer; /* file ptr to relocation */
|
||||
file_pointer += coff_sec->s_nreloc * sizeof(struct reloc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now loop through and determine file pointer locations
|
||||
// for the line number data
|
||||
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
coff_sec->s_nlnno = 0;
|
||||
coff_sec->s_lnnoptr = 0;
|
||||
|
||||
if (s1->do_debug && tcc_sect == stext) {
|
||||
// count how many line nos data
|
||||
|
||||
// also find association between source file name and function
|
||||
// so we can sort the symbol table
|
||||
|
||||
|
||||
Stab_Sym *sym, *sym_end;
|
||||
char func_name[MAX_FUNC_NAME_LENGTH],
|
||||
last_func_name[MAX_FUNC_NAME_LENGTH];
|
||||
unsigned long func_addr, last_pc, pc;
|
||||
const char *incl_files[INCLUDE_STACK_SIZE];
|
||||
int incl_index, len, last_line_num;
|
||||
const char *str, *p;
|
||||
|
||||
coff_sec->s_lnnoptr = file_pointer; /* file ptr to linno */
|
||||
|
||||
|
||||
func_name[0] = '\0';
|
||||
func_addr = 0;
|
||||
incl_index = 0;
|
||||
last_func_name[0] = '\0';
|
||||
last_pc = 0xffffffff;
|
||||
last_line_num = 1;
|
||||
sym = (Stab_Sym *) stab_section->data + 1;
|
||||
sym_end =
|
||||
(Stab_Sym *) (stab_section->data +
|
||||
stab_section->data_offset);
|
||||
|
||||
nFuncs = 0;
|
||||
while (sym < sym_end) {
|
||||
switch (sym->n_type) {
|
||||
/* function start or end */
|
||||
case N_FUN:
|
||||
if (sym->n_strx == 0) {
|
||||
// end of function
|
||||
|
||||
coff_sec->s_nlnno++;
|
||||
file_pointer += LINESZ;
|
||||
|
||||
pc = sym->n_value + func_addr;
|
||||
func_name[0] = '\0';
|
||||
func_addr = 0;
|
||||
EndAddress[nFuncs] = pc;
|
||||
FuncEntries[nFuncs] =
|
||||
(file_pointer -
|
||||
LineNoFilePtr[nFuncs]) / LINESZ - 1;
|
||||
LastLineNo[nFuncs++] = last_line_num + 1;
|
||||
} else {
|
||||
// beginning of function
|
||||
|
||||
LineNoFilePtr[nFuncs] = file_pointer;
|
||||
coff_sec->s_nlnno++;
|
||||
file_pointer += LINESZ;
|
||||
|
||||
str =
|
||||
(const char *) stabstr_section->data +
|
||||
sym->n_strx;
|
||||
|
||||
p = strchr(str, ':');
|
||||
if (!p) {
|
||||
pstrcpy(func_name, sizeof(func_name), str);
|
||||
pstrcpy(Func[nFuncs], sizeof(func_name), str);
|
||||
} else {
|
||||
len = p - str;
|
||||
if (len > sizeof(func_name) - 1)
|
||||
len = sizeof(func_name) - 1;
|
||||
memcpy(func_name, str, len);
|
||||
memcpy(Func[nFuncs], str, len);
|
||||
func_name[len] = '\0';
|
||||
}
|
||||
|
||||
// save the file that it came in so we can sort later
|
||||
pstrcpy(AssociatedFile[nFuncs], sizeof(func_name),
|
||||
incl_files[incl_index - 1]);
|
||||
|
||||
func_addr = sym->n_value;
|
||||
}
|
||||
break;
|
||||
|
||||
/* line number info */
|
||||
case N_SLINE:
|
||||
pc = sym->n_value + func_addr;
|
||||
|
||||
last_pc = pc;
|
||||
last_line_num = sym->n_desc;
|
||||
|
||||
/* XXX: slow! */
|
||||
strcpy(last_func_name, func_name);
|
||||
|
||||
coff_sec->s_nlnno++;
|
||||
file_pointer += LINESZ;
|
||||
break;
|
||||
/* include files */
|
||||
case N_BINCL:
|
||||
str =
|
||||
(const char *) stabstr_section->data + sym->n_strx;
|
||||
add_incl:
|
||||
if (incl_index < INCLUDE_STACK_SIZE) {
|
||||
incl_files[incl_index++] = str;
|
||||
}
|
||||
break;
|
||||
case N_EINCL:
|
||||
if (incl_index > 1)
|
||||
incl_index--;
|
||||
break;
|
||||
case N_SO:
|
||||
if (sym->n_strx == 0) {
|
||||
incl_index = 0; /* end of translation unit */
|
||||
} else {
|
||||
str =
|
||||
(const char *) stabstr_section->data +
|
||||
sym->n_strx;
|
||||
/* do not add path */
|
||||
len = strlen(str);
|
||||
if (len > 0 && str[len - 1] != '/')
|
||||
goto add_incl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sym++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
file_hdr.f_symptr = file_pointer; /* file pointer to symtab */
|
||||
|
||||
if (s1->do_debug)
|
||||
file_hdr.f_nsyms = coff_nb_syms; /* number of symtab entries */
|
||||
else
|
||||
file_hdr.f_nsyms = 0;
|
||||
|
||||
file_pointer += file_hdr.f_nsyms * SYMNMLEN;
|
||||
|
||||
// OK now we are all set to write the file
|
||||
|
||||
|
||||
fwrite(&file_hdr, FILHSZ, 1, f);
|
||||
fwrite(&o_filehdr, sizeof(o_filehdr), 1, f);
|
||||
|
||||
// write section headers
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
if (OutputTheSection(tcc_sect)) {
|
||||
fwrite(coff_sec, sizeof(SCNHDR), 1, f);
|
||||
}
|
||||
}
|
||||
|
||||
// write raw data
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
if (OutputTheSection(tcc_sect)) {
|
||||
fwrite(tcc_sect->data, tcc_sect->data_offset, 1, f);
|
||||
}
|
||||
}
|
||||
|
||||
// write relocation data
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
if (OutputTheSection(tcc_sect)) {
|
||||
// put relocations data
|
||||
if (coff_sec->s_nreloc > 0) {
|
||||
fwrite(tcc_sect->reloc,
|
||||
coff_sec->s_nreloc * sizeof(struct reloc), 1, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// group the symbols in order of filename, func1, func2, etc
|
||||
// finally global symbols
|
||||
|
||||
if (s1->do_debug)
|
||||
SortSymbolTable();
|
||||
|
||||
// write line no data
|
||||
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
coff_sec = §ion_header[i];
|
||||
tcc_sect = s1->sections[i];
|
||||
|
||||
if (s1->do_debug && tcc_sect == stext) {
|
||||
// count how many line nos data
|
||||
|
||||
|
||||
Stab_Sym *sym, *sym_end;
|
||||
char func_name[128], last_func_name[128];
|
||||
unsigned long func_addr, last_pc, pc;
|
||||
const char *incl_files[INCLUDE_STACK_SIZE];
|
||||
int incl_index, len, last_line_num;
|
||||
const char *str, *p;
|
||||
|
||||
LINENO CoffLineNo;
|
||||
|
||||
func_name[0] = '\0';
|
||||
func_addr = 0;
|
||||
incl_index = 0;
|
||||
last_func_name[0] = '\0';
|
||||
last_pc = 0;
|
||||
last_line_num = 1;
|
||||
sym = (Stab_Sym *) stab_section->data + 1;
|
||||
sym_end =
|
||||
(Stab_Sym *) (stab_section->data +
|
||||
stab_section->data_offset);
|
||||
|
||||
while (sym < sym_end) {
|
||||
switch (sym->n_type) {
|
||||
/* function start or end */
|
||||
case N_FUN:
|
||||
if (sym->n_strx == 0) {
|
||||
// end of function
|
||||
|
||||
CoffLineNo.l_addr.l_paddr = last_pc;
|
||||
CoffLineNo.l_lnno = last_line_num + 1;
|
||||
fwrite(&CoffLineNo, 6, 1, f);
|
||||
|
||||
pc = sym->n_value + func_addr;
|
||||
func_name[0] = '\0';
|
||||
func_addr = 0;
|
||||
} else {
|
||||
// beginning of function
|
||||
|
||||
str =
|
||||
(const char *) stabstr_section->data +
|
||||
sym->n_strx;
|
||||
|
||||
|
||||
p = strchr(str, ':');
|
||||
if (!p) {
|
||||
pstrcpy(func_name, sizeof(func_name), str);
|
||||
} else {
|
||||
len = p - str;
|
||||
if (len > sizeof(func_name) - 1)
|
||||
len = sizeof(func_name) - 1;
|
||||
memcpy(func_name, str, len);
|
||||
func_name[len] = '\0';
|
||||
}
|
||||
func_addr = sym->n_value;
|
||||
last_pc = func_addr;
|
||||
last_line_num = -1;
|
||||
|
||||
// output a function begin
|
||||
|
||||
CoffLineNo.l_addr.l_symndx =
|
||||
FindCoffSymbolIndex(func_name);
|
||||
CoffLineNo.l_lnno = 0;
|
||||
|
||||
fwrite(&CoffLineNo, 6, 1, f);
|
||||
}
|
||||
break;
|
||||
|
||||
/* line number info */
|
||||
case N_SLINE:
|
||||
pc = sym->n_value + func_addr;
|
||||
|
||||
|
||||
/* XXX: slow! */
|
||||
strcpy(last_func_name, func_name);
|
||||
|
||||
// output a line reference
|
||||
|
||||
CoffLineNo.l_addr.l_paddr = last_pc;
|
||||
|
||||
if (last_line_num == -1) {
|
||||
CoffLineNo.l_lnno = sym->n_desc;
|
||||
} else {
|
||||
CoffLineNo.l_lnno = last_line_num + 1;
|
||||
}
|
||||
|
||||
fwrite(&CoffLineNo, 6, 1, f);
|
||||
|
||||
last_pc = pc;
|
||||
last_line_num = sym->n_desc;
|
||||
|
||||
break;
|
||||
|
||||
/* include files */
|
||||
case N_BINCL:
|
||||
str =
|
||||
(const char *) stabstr_section->data + sym->n_strx;
|
||||
add_incl2:
|
||||
if (incl_index < INCLUDE_STACK_SIZE) {
|
||||
incl_files[incl_index++] = str;
|
||||
}
|
||||
break;
|
||||
case N_EINCL:
|
||||
if (incl_index > 1)
|
||||
incl_index--;
|
||||
break;
|
||||
case N_SO:
|
||||
if (sym->n_strx == 0) {
|
||||
incl_index = 0; /* end of translation unit */
|
||||
} else {
|
||||
str =
|
||||
(const char *) stabstr_section->data +
|
||||
sym->n_strx;
|
||||
/* do not add path */
|
||||
len = strlen(str);
|
||||
if (len > 0 && str[len - 1] != '/')
|
||||
goto add_incl2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sym++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write symbol table
|
||||
if (s1->do_debug) {
|
||||
int k;
|
||||
struct syment csym;
|
||||
AUXFUNC auxfunc;
|
||||
AUXBF auxbf;
|
||||
AUXEF auxef;
|
||||
int i;
|
||||
Elf32_Sym *p;
|
||||
const char *name;
|
||||
int nstr;
|
||||
int n = 0;
|
||||
|
||||
Coff_str_table = (char *) tcc_malloc(MAX_STR_TABLE);
|
||||
pCoff_str_table = Coff_str_table;
|
||||
nstr = 0;
|
||||
|
||||
p = (Elf32_Sym *) symtab_section->data;
|
||||
|
||||
|
||||
for (i = 0; i < nb_syms; i++) {
|
||||
|
||||
name = symtab_section->link->data + p->st_name;
|
||||
|
||||
for (k = 0; k < 8; k++)
|
||||
csym._n._n_name[k] = 0;
|
||||
|
||||
if (strlen(name) <= 8) {
|
||||
strcpy(csym._n._n_name, name);
|
||||
} else {
|
||||
if (pCoff_str_table - Coff_str_table + strlen(name) >
|
||||
MAX_STR_TABLE - 1)
|
||||
error("String table too large");
|
||||
|
||||
csym._n._n_n._n_zeroes = 0;
|
||||
csym._n._n_n._n_offset =
|
||||
pCoff_str_table - Coff_str_table + 4;
|
||||
|
||||
strcpy(pCoff_str_table, name);
|
||||
pCoff_str_table += strlen(name) + 1; // skip over null
|
||||
nstr++;
|
||||
}
|
||||
|
||||
if (p->st_info == 4) {
|
||||
// put a filename symbol
|
||||
csym.n_value = 33; // ?????
|
||||
csym.n_scnum = N_DEBUG;
|
||||
csym.n_type = 0;
|
||||
csym.n_sclass = C_FILE;
|
||||
csym.n_numaux = 0;
|
||||
fwrite(&csym, 18, 1, f);
|
||||
n++;
|
||||
|
||||
} else if (p->st_info == 0x12) {
|
||||
// find the function data
|
||||
|
||||
for (k = 0; k < nFuncs; k++) {
|
||||
if (strcmp(name, Func[k]) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (k >= nFuncs) {
|
||||
char s[256];
|
||||
|
||||
sprintf(s, "debug info can't find function: %s", name);
|
||||
|
||||
error(s);
|
||||
}
|
||||
// put a Function Name
|
||||
|
||||
csym.n_value = p->st_value; // physical address
|
||||
csym.n_scnum = CoffTextSectionNo;
|
||||
csym.n_type = MKTYPE(T_INT, DT_FCN, 0, 0, 0, 0, 0);
|
||||
csym.n_sclass = C_EXT;
|
||||
csym.n_numaux = 1;
|
||||
fwrite(&csym, 18, 1, f);
|
||||
|
||||
// now put aux info
|
||||
|
||||
auxfunc.tag = 0;
|
||||
auxfunc.size = EndAddress[k] - p->st_value;
|
||||
auxfunc.fileptr = LineNoFilePtr[k];
|
||||
auxfunc.nextsym = n + 6; // tktk
|
||||
auxfunc.dummy = 0;
|
||||
fwrite(&auxfunc, 18, 1, f);
|
||||
|
||||
// put a .bf
|
||||
|
||||
strcpy(csym._n._n_name, ".bf");
|
||||
csym.n_value = p->st_value; // physical address
|
||||
csym.n_scnum = CoffTextSectionNo;
|
||||
csym.n_type = 0;
|
||||
csym.n_sclass = C_FCN;
|
||||
csym.n_numaux = 1;
|
||||
fwrite(&csym, 18, 1, f);
|
||||
|
||||
// now put aux info
|
||||
|
||||
auxbf.regmask = 0;
|
||||
auxbf.lineno = 0;
|
||||
auxbf.nentries = FuncEntries[k];
|
||||
auxbf.localframe = 0;
|
||||
auxbf.nextentry = n + 6;
|
||||
auxbf.dummy = 0;
|
||||
fwrite(&auxbf, 18, 1, f);
|
||||
|
||||
// put a .ef
|
||||
|
||||
strcpy(csym._n._n_name, ".ef");
|
||||
csym.n_value = EndAddress[k]; // physical address
|
||||
csym.n_scnum = CoffTextSectionNo;
|
||||
csym.n_type = 0;
|
||||
csym.n_sclass = C_FCN;
|
||||
csym.n_numaux = 1;
|
||||
fwrite(&csym, 18, 1, f);
|
||||
|
||||
// now put aux info
|
||||
|
||||
auxef.dummy = 0;
|
||||
auxef.lineno = LastLineNo[k];
|
||||
auxef.dummy1 = 0;
|
||||
auxef.dummy2 = 0;
|
||||
auxef.dummy3 = 0;
|
||||
auxef.dummy4 = 0;
|
||||
fwrite(&auxef, 18, 1, f);
|
||||
|
||||
n += 6;
|
||||
|
||||
} else {
|
||||
// try an put some type info
|
||||
|
||||
if ((p->st_other & VT_BTYPE) == VT_DOUBLE) {
|
||||
csym.n_type = T_DOUBLE; // int
|
||||
csym.n_sclass = C_EXT;
|
||||
} else if ((p->st_other & VT_BTYPE) == VT_FLOAT) {
|
||||
csym.n_type = T_FLOAT;
|
||||
csym.n_sclass = C_EXT;
|
||||
} else if ((p->st_other & VT_BTYPE) == VT_INT) {
|
||||
csym.n_type = T_INT; // int
|
||||
csym.n_sclass = C_EXT;
|
||||
} else if ((p->st_other & VT_BTYPE) == VT_SHORT) {
|
||||
csym.n_type = T_SHORT;
|
||||
csym.n_sclass = C_EXT;
|
||||
} else if ((p->st_other & VT_BTYPE) == VT_BYTE) {
|
||||
csym.n_type = T_CHAR;
|
||||
csym.n_sclass = C_EXT;
|
||||
} else {
|
||||
csym.n_type = T_INT; // just mark as a label
|
||||
csym.n_sclass = C_LABEL;
|
||||
}
|
||||
|
||||
|
||||
csym.n_value = p->st_value;
|
||||
csym.n_scnum = 2;
|
||||
csym.n_numaux = 1;
|
||||
fwrite(&csym, 18, 1, f);
|
||||
|
||||
auxfunc.tag = 0;
|
||||
auxfunc.size = 0x20;
|
||||
auxfunc.fileptr = 0;
|
||||
auxfunc.nextsym = 0;
|
||||
auxfunc.dummy = 0;
|
||||
fwrite(&auxfunc, 18, 1, f);
|
||||
n++;
|
||||
n++;
|
||||
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
if (s1->do_debug) {
|
||||
// write string table
|
||||
|
||||
// first write the size
|
||||
i = pCoff_str_table - Coff_str_table;
|
||||
fwrite(&i, 4, 1, f);
|
||||
|
||||
// then write the strings
|
||||
fwrite(Coff_str_table, i, 1, f);
|
||||
|
||||
tcc_free(Coff_str_table);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// group the symbols in order of filename, func1, func2, etc
|
||||
// finally global symbols
|
||||
|
||||
void SortSymbolTable(void)
|
||||
{
|
||||
int i, j, k, n = 0;
|
||||
Elf32_Sym *p, *p2, *NewTable;
|
||||
char *name, *name2;
|
||||
|
||||
NewTable = (Elf32_Sym *) tcc_malloc(nb_syms * sizeof(Elf32_Sym));
|
||||
|
||||
p = (Elf32_Sym *) symtab_section->data;
|
||||
|
||||
|
||||
// find a file symbol, copy it over
|
||||
// then scan the whole symbol list and copy any function
|
||||
// symbols that match the file association
|
||||
|
||||
for (i = 0; i < nb_syms; i++) {
|
||||
if (p->st_info == 4) {
|
||||
name = (char *) symtab_section->link->data + p->st_name;
|
||||
|
||||
// this is a file symbol, copy it over
|
||||
|
||||
NewTable[n++] = *p;
|
||||
|
||||
p2 = (Elf32_Sym *) symtab_section->data;
|
||||
|
||||
for (j = 0; j < nb_syms; j++) {
|
||||
if (p2->st_info == 0x12) {
|
||||
// this is a func symbol
|
||||
|
||||
name2 =
|
||||
(char *) symtab_section->link->data + p2->st_name;
|
||||
|
||||
// find the function data index
|
||||
|
||||
for (k = 0; k < nFuncs; k++) {
|
||||
if (strcmp(name2, Func[k]) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (k >= nFuncs) {
|
||||
char s[256];
|
||||
|
||||
sprintf(s,
|
||||
"debug (sort) info can't find function: %s",
|
||||
name2);
|
||||
|
||||
error(s);
|
||||
}
|
||||
|
||||
if (strcmp(AssociatedFile[k], name) == 0) {
|
||||
// yes they match copy it over
|
||||
|
||||
NewTable[n++] = *p2;
|
||||
}
|
||||
}
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
// now all the filename and func symbols should have been copied over
|
||||
// copy all the rest over (all except file and funcs)
|
||||
|
||||
p = (Elf32_Sym *) symtab_section->data;
|
||||
for (i = 0; i < nb_syms; i++) {
|
||||
if (p->st_info != 4 && p->st_info != 0x12) {
|
||||
NewTable[n++] = *p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
if (n != nb_syms)
|
||||
error("Internal Compiler error, debug info");
|
||||
|
||||
// copy it all back
|
||||
|
||||
p = (Elf32_Sym *) symtab_section->data;
|
||||
for (i = 0; i < nb_syms; i++) {
|
||||
*p++ = NewTable[i];
|
||||
}
|
||||
|
||||
tcc_free(NewTable);
|
||||
}
|
||||
|
||||
|
||||
int FindCoffSymbolIndex(const char *func_name)
|
||||
{
|
||||
int i, n = 0;
|
||||
Elf32_Sym *p;
|
||||
char *name;
|
||||
|
||||
p = (Elf32_Sym *) symtab_section->data;
|
||||
|
||||
for (i = 0; i < nb_syms; i++) {
|
||||
|
||||
name = (char *) symtab_section->link->data + p->st_name;
|
||||
|
||||
if (p->st_info == 4) {
|
||||
// put a filename symbol
|
||||
n++;
|
||||
} else if (p->st_info == 0x12) {
|
||||
|
||||
if (strcmp(func_name, name) == 0)
|
||||
return n;
|
||||
|
||||
n += 6;
|
||||
|
||||
// put a Function Name
|
||||
|
||||
// now put aux info
|
||||
|
||||
// put a .bf
|
||||
|
||||
// now put aux info
|
||||
|
||||
// put a .ef
|
||||
|
||||
// now put aux info
|
||||
|
||||
} else {
|
||||
n += 2;
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
return n; // total number of symbols
|
||||
}
|
||||
|
||||
BOOL OutputTheSection(Section * sect)
|
||||
{
|
||||
const char *s = sect->name;
|
||||
|
||||
if (!strcmp(s, ".text"))
|
||||
return true;
|
||||
else if (!strcmp(s, ".data"))
|
||||
return true;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
short int GetCoffFlags(const char *s)
|
||||
{
|
||||
if (!strcmp(s, ".text"))
|
||||
return STYP_TEXT | STYP_DATA | STYP_ALIGN | 0x400;
|
||||
else if (!strcmp(s, ".data"))
|
||||
return STYP_DATA;
|
||||
else if (!strcmp(s, ".bss"))
|
||||
return STYP_BSS;
|
||||
else if (!strcmp(s, ".stack"))
|
||||
return STYP_BSS | STYP_ALIGN | 0x200;
|
||||
else if (!strcmp(s, ".cinit"))
|
||||
return STYP_COPY | STYP_DATA | STYP_ALIGN | 0x200;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Section *FindSection(TCCState * s1, const char *sname)
|
||||
{
|
||||
Section *s;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < s1->nb_sections; i++) {
|
||||
s = s1->sections[i];
|
||||
|
||||
if (!strcmp(sname, s->name))
|
||||
return s;
|
||||
}
|
||||
|
||||
error("could not find section %s", sname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tcc_load_coff(TCCState * s1, int fd)
|
||||
{
|
||||
// tktk TokenSym *ts;
|
||||
|
||||
FILE *f;
|
||||
unsigned int str_size;
|
||||
char *Coff_str_table, *name;
|
||||
int i, k;
|
||||
struct syment csym;
|
||||
char name2[9];
|
||||
FILHDR file_hdr; /* FILE HEADER STRUCTURE */
|
||||
|
||||
f = fdopen(fd, "rb");
|
||||
if (!f) {
|
||||
error("Unable to open .out file for input");
|
||||
}
|
||||
|
||||
if (fread(&file_hdr, FILHSZ, 1, f) != 1)
|
||||
error("error reading .out file for input");
|
||||
|
||||
if (fread(&o_filehdr, sizeof(o_filehdr), 1, f) != 1)
|
||||
error("error reading .out file for input");
|
||||
|
||||
// first read the string table
|
||||
|
||||
if (fseek(f, file_hdr.f_symptr + file_hdr.f_nsyms * SYMESZ, SEEK_SET))
|
||||
error("error reading .out file for input");
|
||||
|
||||
if (fread(&str_size, sizeof(int), 1, f) != 1)
|
||||
error("error reading .out file for input");
|
||||
|
||||
|
||||
Coff_str_table = (char *) tcc_malloc(str_size);
|
||||
|
||||
if (fread(Coff_str_table, str_size - 4, 1, f) != 1)
|
||||
error("error reading .out file for input");
|
||||
|
||||
// read/process all the symbols
|
||||
|
||||
// seek back to symbols
|
||||
|
||||
if (fseek(f, file_hdr.f_symptr, SEEK_SET))
|
||||
error("error reading .out file for input");
|
||||
|
||||
for (i = 0; i < file_hdr.f_nsyms; i++) {
|
||||
if (fread(&csym, SYMESZ, 1, f) != 1)
|
||||
error("error reading .out file for input");
|
||||
|
||||
if (csym._n._n_n._n_zeroes == 0) {
|
||||
name = Coff_str_table + csym._n._n_n._n_offset - 4;
|
||||
} else {
|
||||
name = csym._n._n_name;
|
||||
|
||||
if (name[7] != 0) {
|
||||
for (k = 0; k < 8; k++)
|
||||
name2[k] = name[k];
|
||||
|
||||
name2[8] = 0;
|
||||
|
||||
name = name2;
|
||||
}
|
||||
}
|
||||
// if (strcmp("_DAC_Buffer",name)==0) // tktk
|
||||
// name[0]=0;
|
||||
|
||||
if (((csym.n_type & 0x30) == 0x20 && csym.n_sclass == 0x2) || ((csym.n_type & 0x30) == 0x30 && csym.n_sclass == 0x2) || (csym.n_type == 0x4 && csym.n_sclass == 0x2) || (csym.n_type == 0x8 && csym.n_sclass == 0x2) || // structures
|
||||
(csym.n_type == 0x18 && csym.n_sclass == 0x2) || // pointer to structure
|
||||
(csym.n_type == 0x7 && csym.n_sclass == 0x2) || // doubles
|
||||
(csym.n_type == 0x6 && csym.n_sclass == 0x2)) // floats
|
||||
{
|
||||
// strip off any leading underscore (except for other main routine)
|
||||
|
||||
if (name[0] == '_' && strcmp(name, "_main") != 0)
|
||||
name++;
|
||||
|
||||
tcc_add_symbol(s1, name, (void*)csym.n_value);
|
||||
}
|
||||
// skip any aux records
|
||||
|
||||
if (csym.n_numaux == 1) {
|
||||
if (fread(&csym, SYMESZ, 1, f) != 1)
|
||||
error("error reading .out file for input");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
110
tcctok.h
110
tcctok.h
@@ -64,6 +64,7 @@
|
||||
/* preprocessor only */
|
||||
DEF(TOK_DEFINE, "define")
|
||||
DEF(TOK_INCLUDE, "include")
|
||||
DEF(TOK_INCLUDE_NEXT, "include_next")
|
||||
DEF(TOK_IFDEF, "ifdef")
|
||||
DEF(TOK_IFNDEF, "ifndef")
|
||||
DEF(TOK_ELIF, "elif")
|
||||
@@ -90,6 +91,8 @@
|
||||
DEF(TOK_SECTION2, "__section__")
|
||||
DEF(TOK_ALIGNED1, "aligned")
|
||||
DEF(TOK_ALIGNED2, "__aligned__")
|
||||
DEF(TOK_PACKED1, "packed")
|
||||
DEF(TOK_PACKED2, "__packed__")
|
||||
DEF(TOK_UNUSED1, "unused")
|
||||
DEF(TOK_UNUSED2, "__unused__")
|
||||
DEF(TOK_CDECL1, "cdecl")
|
||||
@@ -98,30 +101,111 @@
|
||||
DEF(TOK_STDCALL1, "stdcall")
|
||||
DEF(TOK_STDCALL2, "__stdcall")
|
||||
DEF(TOK_STDCALL3, "__stdcall__")
|
||||
DEF(TOK_FASTCALL1, "fastcall")
|
||||
DEF(TOK_FASTCALL2, "__fastcall")
|
||||
DEF(TOK_FASTCALL3, "__fastcall__")
|
||||
DEF(TOK_DLLEXPORT, "dllexport")
|
||||
DEF(TOK_NORETURN1, "noreturn")
|
||||
DEF(TOK_NORETURN2, "__noreturn__")
|
||||
DEF(TOK_builtin_types_compatible_p, "__builtin_types_compatible_p")
|
||||
DEF(TOK_builtin_constant_p, "__builtin_constant_p")
|
||||
DEF(TOK_builtin_frame_address, "__builtin_frame_address")
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
DEF(TOK_builtin_malloc, "__builtin_malloc")
|
||||
DEF(TOK_builtin_free, "__builtin_free")
|
||||
DEF(TOK_malloc, "malloc")
|
||||
DEF(TOK_free, "free")
|
||||
#endif
|
||||
DEF(TOK_REGPARM1, "regparm")
|
||||
DEF(TOK_REGPARM2, "__regparm__")
|
||||
|
||||
/* pragma */
|
||||
DEF(TOK_pack, "pack")
|
||||
#if !defined(TCC_TARGET_I386)
|
||||
/* already defined for assembler */
|
||||
DEF(TOK_ASM_push, "push")
|
||||
DEF(TOK_ASM_pop, "pop")
|
||||
#endif
|
||||
|
||||
/* builtin functions or variables */
|
||||
#ifdef TCC_ARM_EABI
|
||||
DEF(TOK_memcpy, "__aeabi_memcpy")
|
||||
DEF(TOK_memcpy4, "__aeabi_memcpy4")
|
||||
DEF(TOK_memcpy8, "__aeabi_memcpy8")
|
||||
DEF(TOK_memset, "__aeabi_memset")
|
||||
DEF(TOK___aeabi_ldivmod, "__aeabi_ldivmod")
|
||||
DEF(TOK___aeabi_uldivmod, "__aeabi_uldivmod")
|
||||
#else
|
||||
DEF(TOK_memcpy, "memcpy")
|
||||
DEF(TOK_memset, "memset")
|
||||
DEF(TOK_alloca, "alloca")
|
||||
DEF(TOK___divdi3, "__divdi3")
|
||||
DEF(TOK___moddi3, "__moddi3")
|
||||
DEF(TOK___udivdi3, "__udivdi3")
|
||||
DEF(TOK___umoddi3, "__umoddi3")
|
||||
DEF(TOK___sardi3, "__sardi3")
|
||||
DEF(TOK___shrdi3, "__shrdi3")
|
||||
DEF(TOK___shldi3, "__shldi3")
|
||||
#endif
|
||||
#if defined(TCC_TARGET_ARM)
|
||||
#ifdef TCC_ARM_EABI
|
||||
DEF(TOK___aeabi_idivmod, "__aeabi_idivmod")
|
||||
DEF(TOK___aeabi_uidivmod, "__aeabi_uidivmod")
|
||||
DEF(TOK___divsi3, "__aeabi_idiv")
|
||||
DEF(TOK___udivsi3, "__aeabi_uidiv")
|
||||
DEF(TOK___floatdisf, "__aeabi_l2f")
|
||||
DEF(TOK___floatdidf, "__aeabi_l2d")
|
||||
DEF(TOK___fixsfdi, "__aeabi_f2lz")
|
||||
DEF(TOK___fixdfdi, "__aeabi_d2lz")
|
||||
#else
|
||||
DEF(TOK___modsi3, "__modsi3")
|
||||
DEF(TOK___umodsi3, "__umodsi3")
|
||||
DEF(TOK___divsi3, "__divsi3")
|
||||
DEF(TOK___udivsi3, "__udivsi3")
|
||||
DEF(TOK___floatdisf, "__floatdisf")
|
||||
DEF(TOK___floatdidf, "__floatdidf")
|
||||
#ifndef TCC_ARM_VFP
|
||||
DEF(TOK___floatdixf, "__floatdixf")
|
||||
DEF(TOK___fixunssfsi, "__fixunssfsi")
|
||||
DEF(TOK___fixunsdfsi, "__fixunsdfsi")
|
||||
DEF(TOK___fixunsxfsi, "__fixunsxfsi")
|
||||
DEF(TOK___fixxfdi, "__fixxfdi")
|
||||
#endif
|
||||
DEF(TOK___fixsfdi, "__fixsfdi")
|
||||
DEF(TOK___fixdfdi, "__fixdfdi")
|
||||
#endif
|
||||
#elif defined(TCC_TARGET_C67)
|
||||
DEF(TOK__divi, "_divi")
|
||||
DEF(TOK__divu, "_divu")
|
||||
DEF(TOK__divf, "_divf")
|
||||
DEF(TOK__divd, "_divd")
|
||||
DEF(TOK__remi, "_remi")
|
||||
DEF(TOK__remu, "_remu")
|
||||
#endif
|
||||
#ifdef TCC_TARGET_I386
|
||||
DEF(TOK___tcc_int_fpu_control, "__tcc_int_fpu_control")
|
||||
DEF(TOK___tcc_fpu_control, "__tcc_fpu_control")
|
||||
DEF(TOK___ulltof, "__ulltof")
|
||||
DEF(TOK___ulltod, "__ulltod")
|
||||
DEF(TOK___ulltold, "__ulltold")
|
||||
#endif
|
||||
#ifdef TCC_ARM_EABI
|
||||
DEF(TOK___ashrdi3, "__aeabi_lasr")
|
||||
DEF(TOK___lshrdi3, "__aeabi_llsr")
|
||||
DEF(TOK___ashldi3, "__aeabi_llsl")
|
||||
DEF(TOK___floatundisf, "__aeabi_ul2f")
|
||||
DEF(TOK___floatundidf, "__aeabi_ul2d")
|
||||
DEF(TOK___fixunssfdi, "__aeabi_f2ulz")
|
||||
DEF(TOK___fixunsdfdi, "__aeabi_d2ulz")
|
||||
#else
|
||||
DEF(TOK___ashrdi3, "__ashrdi3")
|
||||
DEF(TOK___lshrdi3, "__lshrdi3")
|
||||
DEF(TOK___ashldi3, "__ashldi3")
|
||||
DEF(TOK___floatundisf, "__floatundisf")
|
||||
DEF(TOK___floatundidf, "__floatundidf")
|
||||
#ifndef TCC_ARM_VFP
|
||||
DEF(TOK___floatundixf, "__floatundixf")
|
||||
DEF(TOK___fixunsxfdi, "__fixunsxfdi")
|
||||
#endif
|
||||
DEF(TOK___fixunssfdi, "__fixunssfdi")
|
||||
DEF(TOK___fixunsdfdi, "__fixunsdfdi")
|
||||
DEF(TOK___fixunsxfdi, "__fixunsxfdi")
|
||||
#endif
|
||||
#ifdef TCC_TARGET_PE
|
||||
DEF(TOK___chkstk, "__chkstk")
|
||||
#endif
|
||||
|
||||
/* bound checking symbols */
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
@@ -134,14 +218,17 @@
|
||||
DEF(TOK___bound_ptr_indir16, "__bound_ptr_indir16")
|
||||
DEF(TOK___bound_local_new, "__bound_local_new")
|
||||
DEF(TOK___bound_local_delete, "__bound_local_delete")
|
||||
#if 0
|
||||
DEF(TOK_malloc, "malloc")
|
||||
DEF(TOK_free, "free")
|
||||
DEF(TOK_realloc, "realloc")
|
||||
DEF(TOK_memalign, "memalign")
|
||||
DEF(TOK_calloc, "calloc")
|
||||
#endif
|
||||
DEF(TOK_memmove, "memmove")
|
||||
DEF(TOK_strlen, "strlen")
|
||||
DEF(TOK_strcpy, "strcpy")
|
||||
DEF(TOK_alloca, "alloca")
|
||||
#endif
|
||||
|
||||
/* Tiny Assembler */
|
||||
@@ -151,10 +238,17 @@
|
||||
DEF_ASM(skip)
|
||||
DEF_ASM(space)
|
||||
DEF_ASM(string)
|
||||
DEF_ASM(asciz)
|
||||
DEF_ASM(ascii)
|
||||
DEF_ASM(globl)
|
||||
DEF_ASM(global)
|
||||
DEF_ASM(text)
|
||||
DEF_ASM(data)
|
||||
DEF_ASM(bss)
|
||||
DEF_ASM(previous)
|
||||
DEF_ASM(fill)
|
||||
DEF_ASM(org)
|
||||
DEF_ASM(quad)
|
||||
|
||||
#ifdef TCC_TARGET_I386
|
||||
|
||||
|
||||
145
tests/Makefile
Normal file
145
tests/Makefile
Normal file
@@ -0,0 +1,145 @@
|
||||
#
|
||||
# Tiny C Compiler Makefile - tests
|
||||
#
|
||||
|
||||
# what tests to run
|
||||
TESTS = libtest test3
|
||||
|
||||
# these should work too
|
||||
# TESTS += test1 test2 speed
|
||||
|
||||
# these don't work as they should
|
||||
# TESTS += test4 btest asmtest
|
||||
|
||||
|
||||
TOP = ..
|
||||
include $(TOP)/Makefile
|
||||
|
||||
# run local version of tcc with local libraries and includes
|
||||
TCC = ../tcc -B..
|
||||
RUN_TCC = $(NATIVE_TARGET) -run ../tcc.c -B..
|
||||
DISAS=objdump -d
|
||||
|
||||
all test : $(TESTS)
|
||||
|
||||
# make sure that tcc exists
|
||||
$(TESTS) : ../tcc
|
||||
../tcc ../libtcc.a :
|
||||
$(MAKE) -C ..
|
||||
|
||||
# libtcc test
|
||||
libtest: libtcc_test$(EXESUF)
|
||||
@echo ------------ $@ ------------
|
||||
./libtcc_test lib_path=..
|
||||
|
||||
libtcc_test$(EXESUF): libtcc_test.c ../libtcc.a
|
||||
$(CC) -o $@ $^ -I.. $(CFLAGS) $(LIBS)
|
||||
|
||||
# test.ref - generate using gcc
|
||||
test.ref: tcctest.c
|
||||
cp -u ../include/tcclib.h .
|
||||
$(CC) -o tcctest.gcc $< -I. -w $(CFLAGS)
|
||||
./tcctest.gcc > $@
|
||||
|
||||
# auto test
|
||||
test1: test.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) -run tcctest.c > test.out1
|
||||
@if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi
|
||||
|
||||
# iterated test2 (compile tcc then compile tcctest.c !)
|
||||
test2: test.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out2
|
||||
@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
|
||||
|
||||
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
|
||||
test3: test.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out3
|
||||
@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
|
||||
|
||||
# binary output test
|
||||
test4: test.ref
|
||||
@echo ------------ $@ ------------
|
||||
# dynamic output
|
||||
$(TCC) -o tcctest1 tcctest.c
|
||||
./tcctest1 > test1.out
|
||||
@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
|
||||
# object + link output
|
||||
$(TCC) -c -o tcctest3.o tcctest.c
|
||||
$(TCC) -o tcctest3 tcctest3.o
|
||||
./tcctest3 > test3.out
|
||||
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
|
||||
# static output
|
||||
$(TCC) -static -o tcctest2 tcctest.c
|
||||
./tcctest2 > test2.out
|
||||
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
|
||||
# dynamic output + bound check
|
||||
$(TCC) -b -o tcctest4 tcctest.c
|
||||
./tcctest4 > test4.out
|
||||
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
|
||||
|
||||
# memory and bound check auto test
|
||||
BOUNDS_OK = 1 4 8 10
|
||||
BOUNDS_FAIL= 2 5 7 9 11 12 13
|
||||
|
||||
btest: boundtest.c
|
||||
@echo ------------ $@ ------------
|
||||
@for i in $(BOUNDS_OK); do \
|
||||
if $(TCC) -b -run boundtest.c $$i ; then \
|
||||
/bin/true ; \
|
||||
else\
|
||||
echo Failed positive test $$i ; exit 1 ; \
|
||||
fi ;\
|
||||
done ;\
|
||||
for i in $(BOUNDS_FAIL); do \
|
||||
if $(TCC) -b -run boundtest.c $$i ; then \
|
||||
echo Failed negative test $$i ; exit 1 ;\
|
||||
else\
|
||||
/bin/true ; \
|
||||
fi ;\
|
||||
done ;\
|
||||
echo Bound test OK
|
||||
|
||||
# speed test
|
||||
speed: ex2 ex3
|
||||
@echo ------------ $@ ------------
|
||||
time ./ex2 1238 2 3 4 10 13 4
|
||||
time $(TCC) -run ../examples/ex2.c 1238 2 3 4 10 13 4
|
||||
time ./ex3 35
|
||||
time $(TCC) -run ../examples/ex3.c 35
|
||||
|
||||
ex%: ../examples/ex%.c
|
||||
$(CC) -o $@ $< $(CFLAGS)
|
||||
|
||||
# tiny assembler testing
|
||||
asmtest.ref: asmtest.S
|
||||
$(CC) -o asmtest.ref.o -c asmtest.S
|
||||
objdump -D asmtest.ref.o > $@
|
||||
|
||||
asmtest: asmtest.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) -c asmtest.S
|
||||
objdump -D asmtest.o > $@
|
||||
@if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
|
||||
|
||||
# targets for development
|
||||
%.bin: %.c tcc
|
||||
$(TCC) -g -o $@ $<
|
||||
$(DISAS) $@
|
||||
|
||||
instr: instr.o
|
||||
objdump -d instr.o
|
||||
|
||||
instr.o: instr.S
|
||||
$(CC) -o $@ -c $< -O2 -Wall -g
|
||||
|
||||
cache: tcc_g
|
||||
cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
|
||||
vg_annotate tcc.c > /tmp/linpack.cache.log
|
||||
|
||||
# clean
|
||||
clean:
|
||||
rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.gcc \
|
||||
tcctest[1234] ex? libtcc_test$(EXESUF) tcc_g tcclib.h
|
||||
@@ -43,6 +43,8 @@ movl $2, 0x100(%ebx,%edx,2)
|
||||
movl %eax, 0x100(%ebx,%edx,2)
|
||||
movl 0x100(%ebx,%edx,2), %edx
|
||||
movw %ax, 0x100(%ebx,%edx,2)
|
||||
|
||||
mov %eax, 0x12(,%edx,2)
|
||||
|
||||
mov %cr3, %edx
|
||||
mov %ecx, %cr3
|
||||
@@ -520,6 +522,8 @@ int $0x10
|
||||
bts %edx, 0x1000
|
||||
btsl $2, 0x1000
|
||||
|
||||
|
||||
|
||||
boundl %edx, 0x10000
|
||||
boundw %bx, 0x1000
|
||||
|
||||
@@ -540,3 +544,15 @@ int $0x10
|
||||
|
||||
verr 0x1000
|
||||
verw 0x1000
|
||||
|
||||
push %ds
|
||||
pushw %ds
|
||||
pushl %ds
|
||||
pop %ds
|
||||
popw %ds
|
||||
popl %ds
|
||||
fxsave 1(%ebx)
|
||||
fxrstor 1(%ecx)
|
||||
pushl $1
|
||||
pushw $1
|
||||
push $1
|
||||
33
tests/gcctestsuite.sh
Normal file
33
tests/gcctestsuite.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
TESTSUITE_PATH=$HOME/gcc/gcc-3.2/gcc/testsuite/gcc.c-torture
|
||||
TCC="./tcc -B. -I. -DNO_TRAMPOLINES"
|
||||
rm -f tcc.sum tcc.log
|
||||
nb_failed="0"
|
||||
|
||||
for src in $TESTSUITE_PATH/compile/*.c ; do
|
||||
echo $TCC -o /tmp/test.o -c $src
|
||||
$TCC -o /tmp/test.o -c $src >> tcc.log 2>&1
|
||||
if [ "$?" == "0" ] ; then
|
||||
result="PASS"
|
||||
else
|
||||
result="FAIL"
|
||||
nb_failed=$[ $nb_failed + 1 ]
|
||||
fi
|
||||
echo "$result: $src" >> tcc.sum
|
||||
done
|
||||
|
||||
for src in $TESTSUITE_PATH/execute/*.c ; do
|
||||
echo $TCC $src
|
||||
$TCC $src >> tcc.log 2>&1
|
||||
if [ "$?" == "0" ] ; then
|
||||
result="PASS"
|
||||
else
|
||||
result="FAIL"
|
||||
nb_failed=$[ $nb_failed + 1 ]
|
||||
fi
|
||||
echo "$result: $src" >> tcc.sum
|
||||
done
|
||||
|
||||
echo "$nb_failed test(s) failed." >> tcc.sum
|
||||
echo "$nb_failed test(s) failed."
|
||||
@@ -5,8 +5,9 @@
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libtcc.h>
|
||||
#include "libtcc.h"
|
||||
|
||||
/* this function is called by the generated code */
|
||||
int add(int a, int b)
|
||||
@@ -14,7 +15,7 @@ int add(int a, int b)
|
||||
return a + b;
|
||||
}
|
||||
|
||||
char my_program[] =
|
||||
char my_program[] =
|
||||
"int fib(int n)\n"
|
||||
"{\n"
|
||||
" if (n <= 2)\n"
|
||||
@@ -35,6 +36,8 @@ int main(int argc, char **argv)
|
||||
{
|
||||
TCCState *s;
|
||||
int (*func)(int);
|
||||
void *mem;
|
||||
int size;
|
||||
|
||||
s = tcc_new();
|
||||
if (!s) {
|
||||
@@ -42,22 +45,40 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* MUST BE CALLED before any compilation or file loading */
|
||||
/* if tcclib.h and libtcc1.a are not installed, where can we find them */
|
||||
if (argc == 2 && !memcmp(argv[1], "lib_path=",9))
|
||||
tcc_set_lib_path(s, argv[1]+9);
|
||||
|
||||
/* MUST BE CALLED before any compilation */
|
||||
tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
|
||||
|
||||
tcc_compile_string(s, my_program);
|
||||
if (tcc_compile_string(s, my_program) == -1)
|
||||
return 1;
|
||||
|
||||
/* as a test, we add a symbol that the compiled program can be
|
||||
linked with. You can have a similar result by opening a dll
|
||||
with tcc_add_dll(() and using its symbols directly. */
|
||||
tcc_add_symbol(s, "add", (unsigned long)&add);
|
||||
|
||||
tcc_relocate(s);
|
||||
/* as a test, we add a symbol that the compiled program can use.
|
||||
You may also open a dll with tcc_add_dll() and use symbols from that */
|
||||
tcc_add_symbol(s, "add", add);
|
||||
|
||||
/* get needed size of the code */
|
||||
size = tcc_relocate(s, NULL);
|
||||
if (size == -1)
|
||||
return 1;
|
||||
|
||||
/* allocate memory and copy the code into it */
|
||||
mem = malloc(size);
|
||||
tcc_relocate(s, mem);
|
||||
|
||||
/* get entry symbol */
|
||||
func = tcc_get_symbol(s, "foo");
|
||||
|
||||
if (!func)
|
||||
return 1;
|
||||
|
||||
/* delete the state */
|
||||
tcc_delete(s);
|
||||
|
||||
/* run the code */
|
||||
func(32);
|
||||
|
||||
tcc_delete(s);
|
||||
free(mem);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* TCC auto test program
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "../config.h"
|
||||
|
||||
#if GCC_MAJOR >= 3
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* deprecated and no longer supported in gcc 3.3 */
|
||||
//#define ACCEPT_CR_IN_STRINGS
|
||||
|
||||
/* __VA_ARGS__ and __func__ support */
|
||||
#define C99_MACROS
|
||||
|
||||
@@ -67,10 +70,12 @@ void bitfield_test(void);
|
||||
void c99_bool_test(void);
|
||||
void float_test(void);
|
||||
void longlong_test(void);
|
||||
void manyarg_test(void);
|
||||
void stdarg_test(void);
|
||||
void whitespace_test(void);
|
||||
void relocation_test(void);
|
||||
void old_style_function(void);
|
||||
void alloca_test(void);
|
||||
void sizeof_test(void);
|
||||
void typeof_test(void);
|
||||
void local_label_test(void);
|
||||
@@ -129,6 +134,10 @@ int qq(int x)
|
||||
}
|
||||
#define qq(x) x
|
||||
|
||||
#define spin_lock(lock) do { } while (0)
|
||||
#define wq_spin_lock spin_lock
|
||||
#define TEST2() wq_spin_lock(a)
|
||||
|
||||
void macro_test(void)
|
||||
{
|
||||
printf("macro:\n");
|
||||
@@ -216,7 +225,7 @@ void macro_test(void)
|
||||
#line 203 "test"
|
||||
printf("__LINE__=%d __FILE__=%s\n",
|
||||
__LINE__, __FILE__);
|
||||
#line 220 "tcctest.c"
|
||||
#line 227 "tcctest.c"
|
||||
|
||||
/* not strictly preprocessor, but we test it there */
|
||||
#ifdef C99_MACROS
|
||||
@@ -265,6 +274,10 @@ void macro_test(void)
|
||||
/* this is a valid comment *\*/
|
||||
// this is a valid\
|
||||
comment
|
||||
|
||||
/* test function macro substitution when the function name is
|
||||
substituted */
|
||||
TEST2();
|
||||
}
|
||||
|
||||
int op(a,b)
|
||||
@@ -300,7 +313,7 @@ test\14\
|
||||
|
||||
void string_test()
|
||||
{
|
||||
int b;
|
||||
unsigned int b;
|
||||
printf("string:\n");
|
||||
printf("\141\1423\143\n");/* dezdez test */
|
||||
printf("\x41\x42\x43\x3a\n");
|
||||
@@ -430,14 +443,21 @@ void enum_test()
|
||||
|
||||
typedef int *my_ptr;
|
||||
|
||||
typedef int mytype1;
|
||||
typedef int mytype2;
|
||||
|
||||
void typedef_test()
|
||||
{
|
||||
my_ptr a;
|
||||
mytype1 mytype2;
|
||||
int b;
|
||||
|
||||
a = &b;
|
||||
*a = 1234;
|
||||
printf("typedef:\n");
|
||||
printf("a=%d\n", *a);
|
||||
mytype2 = 2;
|
||||
printf("mytype2=%d\n", mytype2);
|
||||
}
|
||||
|
||||
void forward_test()
|
||||
@@ -505,10 +525,12 @@ int main(int argc, char **argv)
|
||||
c99_bool_test();
|
||||
float_test();
|
||||
longlong_test();
|
||||
manyarg_test();
|
||||
stdarg_test();
|
||||
whitespace_test();
|
||||
relocation_test();
|
||||
old_style_function();
|
||||
alloca_test();
|
||||
sizeof_test();
|
||||
typeof_test();
|
||||
statement_expr_test();
|
||||
@@ -677,6 +699,7 @@ int tab4[10];
|
||||
void expr_ptr_test()
|
||||
{
|
||||
int *p, *q;
|
||||
int i = -1;
|
||||
|
||||
printf("expr_ptr:\n");
|
||||
p = tab4;
|
||||
@@ -692,6 +715,37 @@ void expr_ptr_test()
|
||||
printf("dec=%d\n", p - tab4);
|
||||
printf("add=%d\n", p + 3 - tab4);
|
||||
printf("add=%d\n", 3 + p - tab4);
|
||||
|
||||
/* check if 64bit support is ok */
|
||||
q = p = 0;
|
||||
q += i;
|
||||
printf("%p %p %ld\n", q, p, p-q);
|
||||
printf("%d %d %d %d %d %d\n",
|
||||
p == q, p != q, p < q, p <= q, p >= q, p > q);
|
||||
i = 0xf0000000;
|
||||
p += i;
|
||||
printf("%p %p %ld\n", q, p, p-q);
|
||||
printf("%d %d %d %d %d %d\n",
|
||||
p == q, p != q, p < q, p <= q, p >= q, p > q);
|
||||
p = (int *)((char *)p + 0xf0000000);
|
||||
printf("%p %p %ld\n", q, p, p-q);
|
||||
printf("%d %d %d %d %d %d\n",
|
||||
p == q, p != q, p < q, p <= q, p >= q, p > q);
|
||||
p += 0xf0000000;
|
||||
printf("%p %p %ld\n", q, p, p-q);
|
||||
printf("%d %d %d %d %d %d\n",
|
||||
p == q, p != q, p < q, p <= q, p >= q, p > q);
|
||||
{
|
||||
struct size12 {
|
||||
int i, j, k;
|
||||
};
|
||||
struct size12 s[2], *sp = s;
|
||||
int i, j;
|
||||
sp->i = 42;
|
||||
sp++;
|
||||
j = -1;
|
||||
printf("%d\n", sp[j].i);
|
||||
}
|
||||
}
|
||||
|
||||
void expr_cmp_test()
|
||||
@@ -1055,6 +1109,10 @@ void cast_test()
|
||||
int a;
|
||||
char c;
|
||||
char tab[10];
|
||||
unsigned b,d;
|
||||
short s;
|
||||
char *p = NULL;
|
||||
p -= 0x700000000042;
|
||||
|
||||
printf("cast_test:\n");
|
||||
a = 0xfffff;
|
||||
@@ -1077,7 +1135,15 @@ void cast_test()
|
||||
printf("%d\n", a);
|
||||
|
||||
printf("sizeof(c) = %d, sizeof((int)c) = %d\n", sizeof(c), sizeof((int)c));
|
||||
|
||||
|
||||
/* test cast from unsigned to signed short to int */
|
||||
b = 0xf000;
|
||||
d = (short)b;
|
||||
printf("((unsigned)(short)0x%08x) = 0x%08x\n", b, d);
|
||||
b = 0xf0f0;
|
||||
d = (char)b;
|
||||
printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d);
|
||||
|
||||
/* test implicit int casting for array accesses */
|
||||
c = 0;
|
||||
tab[1] = 2;
|
||||
@@ -1088,6 +1154,16 @@ void cast_test()
|
||||
printf("sizeof(+(char)'a') = %d\n", sizeof(+(char)'a'));
|
||||
printf("sizeof(-(char)'a') = %d\n", sizeof(-(char)'a'));
|
||||
printf("sizeof(~(char)'a') = %d\n", sizeof(-(char)'a'));
|
||||
|
||||
/* from pointer to integer types */
|
||||
printf("%d %d %ld %ld %lld %lld\n",
|
||||
(int)p, (unsigned int)p,
|
||||
(long)p, (unsigned long)p,
|
||||
(long long)p, (unsigned long long)p);
|
||||
|
||||
/* from integers to pointers */
|
||||
printf("%p %p %p %p\n",
|
||||
(void *)a, (void *)b, (void *)c, (void *)d);
|
||||
}
|
||||
|
||||
/* initializers tests */
|
||||
@@ -1303,8 +1379,45 @@ void bitfield_test(void)
|
||||
st1.f5++;
|
||||
printf("%d %d %d %d %d\n",
|
||||
st1.f1, st1.f2, st1.f3, st1.f4, st1.f5);
|
||||
|
||||
st1.f1 = 7;
|
||||
if (st1.f1 == -1)
|
||||
printf("st1.f1 == -1\n");
|
||||
else
|
||||
printf("st1.f1 != -1\n");
|
||||
if (st1.f2 == -1)
|
||||
printf("st1.f2 == -1\n");
|
||||
else
|
||||
printf("st1.f2 != -1\n");
|
||||
|
||||
/* bit sizes below must be bigger than 32 since GCC doesn't allow
|
||||
long-long bitfields whose size is not bigger than int */
|
||||
struct sbf2 {
|
||||
long long f1 : 45;
|
||||
long long : 2;
|
||||
long long f2 : 35;
|
||||
unsigned long long f3 : 38;
|
||||
} st2;
|
||||
st2.f1 = 0x123456789ULL;
|
||||
a = 120;
|
||||
st2.f2 = (long long)a << 25;
|
||||
st2.f3 = a;
|
||||
st2.f2++;
|
||||
printf("%lld %lld %lld\n", st2.f1, st2.f2, st2.f3);
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define FLOAT_FMT "%f\n"
|
||||
#else
|
||||
/* x86's float isn't compatible with GCC */
|
||||
#define FLOAT_FMT "%.5f\n"
|
||||
#endif
|
||||
|
||||
/* declare strto* functions as they are C99 */
|
||||
double strtod(const char *nptr, char **endptr);
|
||||
float strtof(const char *nptr, char **endptr);
|
||||
long double strtold(const char *nptr, char **endptr);
|
||||
|
||||
#define FTEST(prefix, type, fmt)\
|
||||
void prefix ## cmp(type a, type b)\
|
||||
{\
|
||||
@@ -1326,6 +1439,8 @@ void prefix ## cmp(type a, type b)\
|
||||
printf(fmt "\n", ++a);\
|
||||
printf(fmt "\n", a++);\
|
||||
printf(fmt "\n", a);\
|
||||
b = 0;\
|
||||
printf("%d %d\n", !a, !b);\
|
||||
}\
|
||||
void prefix ## fcast(type a)\
|
||||
{\
|
||||
@@ -1350,6 +1465,18 @@ void prefix ## fcast(type a)\
|
||||
printf("utof: " fmt "\n", b);\
|
||||
}\
|
||||
\
|
||||
float prefix ## retf(type a) { return a; }\
|
||||
double prefix ## retd(type a) { return a; }\
|
||||
long double prefix ## retld(type a) { return a; }\
|
||||
\
|
||||
void prefix ## call(void)\
|
||||
{\
|
||||
printf("float: " FLOAT_FMT, prefix ## retf(42.123456789));\
|
||||
printf("double: %f\n", prefix ## retd(42.123456789));\
|
||||
printf("long double: %Lf\n", prefix ## retld(42.123456789));\
|
||||
printf("strto%s: %f\n", #prefix, (double)strto ## prefix("1.2", NULL));\
|
||||
}\
|
||||
\
|
||||
void prefix ## test(void)\
|
||||
{\
|
||||
printf("testing '%s'\n", #type);\
|
||||
@@ -1358,6 +1485,7 @@ void prefix ## test(void)\
|
||||
prefix ## cmp(1, 1);\
|
||||
prefix ## fcast(234.6);\
|
||||
prefix ## fcast(-2334.6);\
|
||||
prefix ## call();\
|
||||
}
|
||||
|
||||
FTEST(f, float, "%f")
|
||||
@@ -1477,6 +1605,8 @@ void lloptest(long long a, long long b)
|
||||
printf("arith2: %Ld %Ld\n", a++, b++);
|
||||
printf("arith2: %Ld %Ld\n", --a, --b);
|
||||
printf("arith2: %Ld %Ld\n", a, b);
|
||||
b = ub = 0;
|
||||
printf("not: %d %d %d %d\n", !a, !ua, !b, !ub);
|
||||
}
|
||||
|
||||
void llshift(long long a, int b)
|
||||
@@ -1589,6 +1719,59 @@ void longlong_test(void)
|
||||
printf("%lld\n", value(&a));
|
||||
}
|
||||
lloptest(0x80000000, 0);
|
||||
|
||||
/* another long long spill test */
|
||||
{
|
||||
long long *p, v;
|
||||
v = 1;
|
||||
p = &v;
|
||||
p[0]++;
|
||||
printf("%lld\n", *p);
|
||||
}
|
||||
|
||||
a = 68719476720LL;
|
||||
b = 4294967295LL;
|
||||
printf("%d %d %d %d\n", a > b, a < b, a >= b, a <= b);
|
||||
|
||||
printf("%Ld\n", 0x123456789LLU);
|
||||
}
|
||||
|
||||
void manyarg_test(void)
|
||||
{
|
||||
long double ld = 1234567891234LL;
|
||||
printf("manyarg_test:\n");
|
||||
printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);
|
||||
printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Ld %Ld %f %f\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0);
|
||||
printf("%Lf %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Ld %Ld %f %f\n",
|
||||
ld, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0);
|
||||
/* XXX: known bug of x86-64 */
|
||||
#ifndef __x86_64__
|
||||
printf("%d %d %d %d %d %d %d %d %Lf\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8, ld);
|
||||
printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Ld %Ld %f %f %Lf\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0, ld);
|
||||
printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Lf %Ld %Ld %f %f %Lf\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
ld, 1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0, ld);
|
||||
#endif
|
||||
}
|
||||
|
||||
void vprintf1(const char *fmt, ...)
|
||||
@@ -1598,6 +1781,7 @@ void vprintf1(const char *fmt, ...)
|
||||
int c, i;
|
||||
double d;
|
||||
long long ll;
|
||||
long double ld;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
@@ -1624,6 +1808,10 @@ void vprintf1(const char *fmt, ...)
|
||||
ll = va_arg(ap, long long);
|
||||
printf("%Ld", ll);
|
||||
break;
|
||||
case 'F':
|
||||
ld = va_arg(ap, long double);
|
||||
printf("%Lf", ld);
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
} else {
|
||||
@@ -1637,9 +1825,48 @@ void vprintf1(const char *fmt, ...)
|
||||
|
||||
void stdarg_test(void)
|
||||
{
|
||||
long double ld = 1234567891234LL;
|
||||
vprintf1("%d %d %d\n", 1, 2, 3);
|
||||
vprintf1("%f %d %f\n", 1.0, 2, 3.0);
|
||||
vprintf1("%l %l %d %f\n", 1234567891234LL, 987654321986LL, 3, 1234.0);
|
||||
vprintf1("%F %F %F\n", 1.2L, 2.3L, 3.4L);
|
||||
#ifdef __x86_64__
|
||||
/* a bug of x86's TCC */
|
||||
vprintf1("%d %f %l %F %d %f %l %F\n",
|
||||
1, 1.2, 3L, 4.5L, 6, 7.8, 9L, 0.1L);
|
||||
#endif
|
||||
vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8);
|
||||
vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);
|
||||
vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%l %l %f %f\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0);
|
||||
vprintf1("%F %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%l %l %f %f\n",
|
||||
ld, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0);
|
||||
vprintf1("%d %d %d %d %d %d %d %d %F\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8, ld);
|
||||
vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%l %l %f %f %F\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0, ld);
|
||||
vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%F %l %l %f %f %F\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
ld, 1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0, ld);
|
||||
}
|
||||
|
||||
void whitespace_test(void)
|
||||
@@ -1660,6 +1887,8 @@ ntf("aaa=%d\n", 3);
|
||||
pri\
|
||||
\
|
||||
ntf("min=%d\n", 4);
|
||||
|
||||
#ifdef ACCEPT_CR_IN_STRINGS
|
||||
printf("len1=%d\n", strlen("
|
||||
"));
|
||||
#ifdef CORRECT_CR_HANDLING
|
||||
@@ -1669,6 +1898,7 @@ ntf("min=%d\n", 4);
|
||||
#endif
|
||||
printf("len1=%d\n", strlen("
a
|
||||
"));
|
||||
#endif /* ACCEPT_CR_IN_STRINGS */
|
||||
}
|
||||
|
||||
int reltab[3] = { 1, 2, 3 };
|
||||
@@ -1707,6 +1937,18 @@ void old_style_function(void)
|
||||
decl_func2(NULL);
|
||||
}
|
||||
|
||||
void alloca_test()
|
||||
{
|
||||
#if defined __i386__ || defined __x86_64__
|
||||
char *p = alloca(16);
|
||||
strcpy(p,"123456789012345");
|
||||
printf("alloca: p is %s\n", p);
|
||||
char *demo = "This is only a test.\n";
|
||||
/* Test alloca embedded in a larger expression */
|
||||
printf("alloca: %s\n", strcpy(alloca(strlen(demo)+1),demo) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void sizeof_test(void)
|
||||
{
|
||||
int a;
|
||||
@@ -1714,6 +1956,8 @@ void sizeof_test(void)
|
||||
|
||||
printf("sizeof(int) = %d\n", sizeof(int));
|
||||
printf("sizeof(unsigned int) = %d\n", sizeof(unsigned int));
|
||||
printf("sizeof(long) = %d\n", sizeof(long));
|
||||
printf("sizeof(unsigned long) = %d\n", sizeof(unsigned long));
|
||||
printf("sizeof(short) = %d\n", sizeof(short));
|
||||
printf("sizeof(unsigned short) = %d\n", sizeof(unsigned short));
|
||||
printf("sizeof(char) = %d\n", sizeof(char));
|
||||
@@ -1770,14 +2014,14 @@ void local_label_test(void)
|
||||
goto l1;
|
||||
l2:
|
||||
a = 1 + ({
|
||||
__label__ l1, l2, l3;
|
||||
goto l4;
|
||||
l5:
|
||||
printf("aa1\n");
|
||||
__label__ l1, l2, l3, l4;
|
||||
goto l1;
|
||||
l4:
|
||||
printf("aa1\n");
|
||||
goto l3;
|
||||
l2:
|
||||
printf("aa3\n");
|
||||
goto l3;
|
||||
goto l4;
|
||||
l1:
|
||||
printf("aa2\n");
|
||||
goto l2;
|
||||
@@ -1786,12 +2030,12 @@ void local_label_test(void)
|
||||
});
|
||||
printf("a=%d\n", a);
|
||||
return;
|
||||
l1:
|
||||
l4:
|
||||
printf("bb1\n");
|
||||
goto l2;
|
||||
l4:
|
||||
l1:
|
||||
printf("bb2\n");
|
||||
goto l5;
|
||||
goto l4;
|
||||
}
|
||||
|
||||
/* inline assembler test */
|
||||
@@ -1899,6 +2143,9 @@ void asm_test(void)
|
||||
goto label1;
|
||||
label2:
|
||||
__asm__("btsl %1,%0" : "=m"(set) : "Ir"(20) : "cc");
|
||||
#ifdef __GNUC__ // works strange with GCC 4.3
|
||||
set=0x1080fd;
|
||||
#endif
|
||||
printf("set=0x%x\n", set);
|
||||
val = 0x01020304;
|
||||
printf("swab32(0x%08x) = 0x%0x\n", val, swab32(val));
|
||||
@@ -1943,3 +2190,13 @@ void builtin_test(void)
|
||||
printf("res = %d\n", __builtin_constant_p(&constant_p_var));
|
||||
printf("res = %d\n", __builtin_constant_p(constant_p_var));
|
||||
}
|
||||
|
||||
|
||||
void const_func(const int a)
|
||||
{
|
||||
}
|
||||
|
||||
void const_warn_test(void)
|
||||
{
|
||||
const_func(1);
|
||||
}
|
||||
28
win32/build-tcc.bat
Normal file
28
win32/build-tcc.bat
Normal file
@@ -0,0 +1,28 @@
|
||||
@rem ----------------------------------------------------
|
||||
@rem batch file to build tcc using gcc and ar from mingw
|
||||
@rem ----------------------------------------------------
|
||||
:
|
||||
@echo>..\config.h #define TCC_VERSION "0.9.25"
|
||||
@echo>>..\config.h #define TCC_TARGET_PE 1
|
||||
@echo>>..\config.h #define CONFIG_TCCDIR "."
|
||||
@echo>>..\config.h #define CONFIG_SYSROOT ""
|
||||
:
|
||||
gcc -Os -fno-strict-aliasing ../tcc.c -o tcc.exe -s
|
||||
gcc -Os -fno-strict-aliasing ../libtcc.c -c -o libtcc.o
|
||||
gcc -Os tools/tiny_impdef.c -o tiny_impdef.exe -s
|
||||
gcc -Os tools/tiny_libmaker.c -o tiny_libmaker.exe -s
|
||||
mkdir libtcc
|
||||
ar rcs libtcc/libtcc.a libtcc.o
|
||||
del libtcc.o
|
||||
copy ..\libtcc.h libtcc
|
||||
:
|
||||
.\tcc -c lib/crt1.c
|
||||
.\tcc -c lib/wincrt1.c
|
||||
.\tcc -c lib/dllcrt1.c
|
||||
.\tcc -c lib/dllmain.c
|
||||
.\tcc -c lib/chkstk.S
|
||||
.\tcc -c ../lib/libtcc1.c
|
||||
.\tcc -c ../lib/alloca86.S
|
||||
.\tcc -c ../lib/alloca86-bt.S
|
||||
ar rcs lib/libtcc1.a crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o libtcc1.o alloca86.o alloca86-bt.o
|
||||
del *.o
|
||||
15
win32/examples/dll.c
Normal file
15
win32/examples/dll.c
Normal file
@@ -0,0 +1,15 @@
|
||||
//+---------------------------------------------------------------------------
|
||||
//
|
||||
// dll.c - Windows DLL example - dynamically linked part
|
||||
//
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
|
||||
|
||||
DLL_EXPORT void HelloWorld (void)
|
||||
{
|
||||
MessageBox (0, "Hello World!", "From DLL", MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
23
win32/examples/fib.c
Normal file
23
win32/examples/fib.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int fib(n)
|
||||
{
|
||||
if (n <= 2)
|
||||
return 1;
|
||||
else
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int n;
|
||||
if (argc < 2) {
|
||||
printf("usage: fib n\n"
|
||||
"Compute nth Fibonacci number\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
n = atoi(argv[1]);
|
||||
printf("fib(%d) = %d\n", n, fib(n));
|
||||
return 0;
|
||||
}
|
||||
19
win32/examples/hello_dll.c
Normal file
19
win32/examples/hello_dll.c
Normal file
@@ -0,0 +1,19 @@
|
||||
//+---------------------------------------------------------------------------
|
||||
//
|
||||
// HELLO_DLL.C - Windows DLL example - main application part
|
||||
//
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
void HelloWorld (void);
|
||||
|
||||
int WINAPI WinMain(
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
HelloWorld();
|
||||
return 0;
|
||||
}
|
||||
|
||||
159
win32/examples/hello_win.c
Normal file
159
win32/examples/hello_win.c
Normal file
@@ -0,0 +1,159 @@
|
||||
//+---------------------------------------------------------------------------
|
||||
//
|
||||
// HELLO_WIN.C - Windows GUI 'Hello World!' Example
|
||||
//
|
||||
//+---------------------------------------------------------------------------
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define APPNAME "HELLO_WIN"
|
||||
|
||||
char szAppName[] = APPNAME; // The name of this application
|
||||
char szTitle[] = APPNAME; // The title bar text
|
||||
char *pWindowText;
|
||||
|
||||
HINSTANCE g_hInst; // current instance
|
||||
|
||||
void CenterWindow(HWND hWnd);
|
||||
|
||||
//+---------------------------------------------------------------------------
|
||||
//
|
||||
// Function: WndProc
|
||||
//
|
||||
// Synopsis: very unusual type of function - gets called by system to
|
||||
// process windows messages.
|
||||
//
|
||||
// Arguments: same as always.
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
// ----------------------- first and last
|
||||
case WM_CREATE:
|
||||
CenterWindow(hwnd);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
|
||||
// ----------------------- get out of it...
|
||||
case WM_RBUTTONUP:
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
if (VK_ESCAPE == wParam)
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
|
||||
|
||||
// ----------------------- display our minimal info
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
RECT rc;
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
GetClientRect(hwnd, &rc);
|
||||
SetTextColor(hdc, RGB(240,240,96));
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
DrawText(hdc, pWindowText, -1, &rc, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
break;
|
||||
}
|
||||
|
||||
// ----------------------- let windows do all other stuff
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//+---------------------------------------------------------------------------
|
||||
//
|
||||
// Function: WinMain
|
||||
//
|
||||
// Synopsis: standard entrypoint for GUI Win32 apps
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
int APIENTRY WinMain(
|
||||
HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
WNDCLASS wc;
|
||||
|
||||
HWND hwnd;
|
||||
|
||||
// Fill in window class structure with parameters that describe
|
||||
// the main window.
|
||||
|
||||
ZeroMemory(&wc, sizeof wc);
|
||||
wc.hInstance = hInstance;
|
||||
wc.lpszClassName = szAppName;
|
||||
wc.lpfnWndProc = (WNDPROC)WndProc;
|
||||
wc.style = CS_DBLCLKS|CS_VREDRAW|CS_HREDRAW;
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
|
||||
if (FALSE == RegisterClass(&wc)) return 0;
|
||||
|
||||
// create the browser
|
||||
hwnd = CreateWindow(
|
||||
szAppName,
|
||||
szTitle,
|
||||
WS_OVERLAPPEDWINDOW|WS_VISIBLE,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
360,//CW_USEDEFAULT,
|
||||
240,//CW_USEDEFAULT,
|
||||
0,
|
||||
0,
|
||||
g_hInst,
|
||||
0);
|
||||
|
||||
if (NULL == hwnd) return 0;
|
||||
|
||||
pWindowText = lpCmdLine[0] ? lpCmdLine : "Hello Windows!";
|
||||
|
||||
// Main message loop:
|
||||
while (GetMessage(&msg, NULL, 0, 0) > 0)
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
//+---------------------------------------------------------------------------
|
||||
|
||||
//+---------------------------------------------------------------------------
|
||||
|
||||
void CenterWindow(HWND hwnd_self)
|
||||
{
|
||||
RECT rw_self, rc_parent, rw_parent; HWND hwnd_parent;
|
||||
hwnd_parent = GetParent(hwnd_self);
|
||||
if (NULL==hwnd_parent) hwnd_parent = GetDesktopWindow();
|
||||
GetWindowRect(hwnd_parent, &rw_parent);
|
||||
GetClientRect(hwnd_parent, &rc_parent);
|
||||
GetWindowRect(hwnd_self, &rw_self);
|
||||
SetWindowPos(hwnd_self, NULL,
|
||||
rw_parent.left + (rc_parent.right + rw_self.left - rw_self.right) / 2,
|
||||
rw_parent.top + (rc_parent.bottom + rw_self.top - rw_self.bottom) / 2,
|
||||
0, 0,
|
||||
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE
|
||||
);
|
||||
}
|
||||
|
||||
//+---------------------------------------------------------------------------
|
||||
54
win32/include/_mingw.h
Normal file
54
win32/include/_mingw.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* _mingw.h
|
||||
*
|
||||
* This file is for TCC-PE and not part of the Mingw32 package.
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MINGW_H
|
||||
#define __MINGW_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define __int64 long long
|
||||
#define __int32 long
|
||||
#define __int16 short
|
||||
#define __int8 char
|
||||
#define __cdecl __attribute__((__cdecl__))
|
||||
#define __stdcall __attribute__((__stdcall__))
|
||||
#define __declspec(x) __attribute__((x))
|
||||
|
||||
#define __MINGW32_VERSION 2.0
|
||||
#define __MINGW32_MAJOR_VERSION 2
|
||||
#define __MINGW32_MINOR_VERSION 0
|
||||
|
||||
#define __MSVCRT__ 1
|
||||
#define __MINGW_IMPORT extern
|
||||
#define _CRTIMP
|
||||
#define __CRT_INLINE extern __inline__
|
||||
|
||||
#define WIN32 1
|
||||
|
||||
#ifndef _WINT_T
|
||||
#define _WINT_T
|
||||
typedef unsigned int wint_t;
|
||||
#endif
|
||||
|
||||
/* for winapi */
|
||||
#define _ANONYMOUS_UNION
|
||||
#define _ANONYMOUS_STRUCT
|
||||
#define DECLSPEC_NORETURN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define DECLARE_STDCALL_P(type) __stdcall type
|
||||
|
||||
#endif /* __MINGW_H */
|
||||
71
win32/include/assert.h
Normal file
71
win32/include/assert.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* assert.h
|
||||
*
|
||||
* Define the assert macro for debug output.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ASSERT_H_
|
||||
#define _ASSERT_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
/*
|
||||
* If not debugging, assert does nothing.
|
||||
*/
|
||||
#define assert(x) ((void)0)
|
||||
|
||||
#else /* debugging enabled */
|
||||
|
||||
/*
|
||||
* CRTDLL nicely supplies a function which does the actual output and
|
||||
* call to abort.
|
||||
*/
|
||||
void _assert (const char*, const char*, int)
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((noreturn))
|
||||
#endif
|
||||
;
|
||||
|
||||
/*
|
||||
* Definition of the assert macro.
|
||||
*/
|
||||
#define assert(e) ((e) ? (void)0 : _assert(#e, __FILE__, __LINE__))
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _ASSERT_H_ */
|
||||
|
||||
159
win32/include/conio.h
Normal file
159
win32/include/conio.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/* A conio implementation for Mingw/Dev-C++.
|
||||
*
|
||||
* Written by:
|
||||
* Hongli Lai <hongli@telekabel.nl>
|
||||
* tkorrovi <tkorrovi@altavista.net> on 2002/02/26.
|
||||
* Andrew Westcott <ajwestco@users.sourceforge.net>
|
||||
*
|
||||
* Offered for use in the public domain without any warranty.
|
||||
*/
|
||||
|
||||
#ifndef _CONIO_H_
|
||||
#define _CONIO_H_
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLINK 0
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BLACK,
|
||||
BLUE,
|
||||
GREEN,
|
||||
CYAN,
|
||||
RED,
|
||||
MAGENTA,
|
||||
BROWN,
|
||||
LIGHTGRAY,
|
||||
DARKGRAY,
|
||||
LIGHTBLUE,
|
||||
LIGHTGREEN,
|
||||
LIGHTCYAN,
|
||||
LIGHTRED,
|
||||
LIGHTMAGENTA,
|
||||
YELLOW,
|
||||
WHITE
|
||||
} COLORS;
|
||||
|
||||
|
||||
#define cgets _cgets
|
||||
#define cprintf _cprintf
|
||||
#define cputs _cputs
|
||||
#define cscanf _cscanf
|
||||
#define ScreenClear clrscr
|
||||
|
||||
/* blinkvideo */
|
||||
|
||||
void clreol (void);
|
||||
void clrscr (void);
|
||||
|
||||
int _conio_gettext (int left, int top, int right, int bottom,
|
||||
char *str);
|
||||
/* _conio_kbhit */
|
||||
|
||||
void delline (void);
|
||||
|
||||
/* gettextinfo */
|
||||
void gotoxy(int x, int y);
|
||||
/*
|
||||
highvideo
|
||||
insline
|
||||
intensevideo
|
||||
lowvideo
|
||||
movetext
|
||||
normvideo
|
||||
*/
|
||||
|
||||
void puttext (int left, int top, int right, int bottom, char *str);
|
||||
|
||||
// Screen Variables
|
||||
|
||||
/* ScreenCols
|
||||
ScreenGetChar
|
||||
ScreenGetCursor
|
||||
ScreenMode
|
||||
ScreenPutChar
|
||||
ScreenPutString
|
||||
ScreenRetrieve
|
||||
ScreenRows
|
||||
ScreenSetCursor
|
||||
ScreenUpdate
|
||||
ScreenUpdateLine
|
||||
ScreenVisualBell
|
||||
_set_screen_lines */
|
||||
|
||||
void _setcursortype (int type);
|
||||
|
||||
void textattr (int _attr);
|
||||
|
||||
void textbackground (int color);
|
||||
|
||||
void textcolor (int color);
|
||||
|
||||
/* textmode */
|
||||
|
||||
int wherex (void);
|
||||
|
||||
int wherey (void);
|
||||
|
||||
/* window */
|
||||
|
||||
|
||||
|
||||
/* The code below was part of Mingw's conio.h */
|
||||
/*
|
||||
* conio.h
|
||||
*
|
||||
* Low level console I/O functions. Pretty please try to use the ANSI
|
||||
* standard ones if you are writing new code.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
char* _cgets (char*);
|
||||
int _cprintf (const char*, ...);
|
||||
int _cputs (const char*);
|
||||
int _cscanf (char*, ...);
|
||||
|
||||
int _getch (void);
|
||||
int _getche (void);
|
||||
int _kbhit (void);
|
||||
int _putch (int);
|
||||
int _ungetch (int);
|
||||
|
||||
|
||||
int getch (void);
|
||||
int getche (void);
|
||||
int kbhit (void);
|
||||
int putch (int);
|
||||
int ungetch (int);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CONIO_H_ */
|
||||
232
win32/include/ctype.h
Normal file
232
win32/include/ctype.h
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* ctype.h
|
||||
*
|
||||
* Functions for testing character types and converting characters.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CTYPE_H_
|
||||
#define _CTYPE_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#define __need_wint_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
|
||||
/*
|
||||
* The following flags are used to tell iswctype and _isctype what character
|
||||
* types you are looking for.
|
||||
*/
|
||||
#define _UPPER 0x0001
|
||||
#define _LOWER 0x0002
|
||||
#define _DIGIT 0x0004
|
||||
#define _SPACE 0x0008 /* HT LF VT FF CR SP */
|
||||
#define _PUNCT 0x0010
|
||||
#define _CONTROL 0x0020
|
||||
#define _BLANK 0x0040 /* this is SP only, not SP and HT as in C99 */
|
||||
#define _HEX 0x0080
|
||||
#define _LEADBYTE 0x8000
|
||||
|
||||
#define _ALPHA 0x0103
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int isalnum(int);
|
||||
int isalpha(int);
|
||||
int iscntrl(int);
|
||||
int isdigit(int);
|
||||
int isgraph(int);
|
||||
int islower(int);
|
||||
int isprint(int);
|
||||
int ispunct(int);
|
||||
int isspace(int);
|
||||
int isupper(int);
|
||||
int isxdigit(int);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
int _isctype (int, int);
|
||||
#endif
|
||||
|
||||
/* These are the ANSI versions, with correct checking of argument */
|
||||
int tolower(int);
|
||||
int toupper(int);
|
||||
|
||||
/*
|
||||
* NOTE: The above are not old name type wrappers, but functions exported
|
||||
* explicitly by MSVCRT/CRTDLL. However, underscored versions are also
|
||||
* exported.
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
/*
|
||||
* These are the cheap non-std versions: The return values are undefined
|
||||
* if the argument is not ASCII char or is not of appropriate case
|
||||
*/
|
||||
int _tolower(int);
|
||||
int _toupper(int);
|
||||
#endif
|
||||
|
||||
/* Also defined in stdlib.h */
|
||||
#ifndef MB_CUR_MAX
|
||||
# ifdef __MSVCRT__
|
||||
# define MB_CUR_MAX __mb_cur_max
|
||||
__MINGW_IMPORT int __mb_cur_max;
|
||||
# else /* not __MSVCRT */
|
||||
# define MB_CUR_MAX __mb_cur_max_dll
|
||||
__MINGW_IMPORT int __mb_cur_max_dll;
|
||||
# endif /* not __MSVCRT */
|
||||
#endif /* MB_CUR_MAX */
|
||||
|
||||
__MINGW_IMPORT unsigned short _ctype[];
|
||||
#ifdef __MSVCRT__
|
||||
__MINGW_IMPORT unsigned short* _pctype;
|
||||
#else /* CRTDLL */
|
||||
__MINGW_IMPORT unsigned short* _pctype_dll;
|
||||
#define _pctype _pctype_dll
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use inlines here rather than macros, because macros will upset
|
||||
* C++ usage (eg, ::isalnum), and so usually get undefined
|
||||
*
|
||||
* According to standard for SB chars, these function are defined only
|
||||
* for input values representable by unsigned char or EOF.
|
||||
* Thus, there is no range test.
|
||||
* This reproduces behaviour of MSVCRT.dll lib implemention for SB chars.
|
||||
*
|
||||
* If no MB char support is needed, these can be simplified even
|
||||
* more by command line define -DMB_CUR_MAX=1. The compiler will then
|
||||
* optimise away the constant condition.
|
||||
*/
|
||||
|
||||
|
||||
#if ! (defined (__NO_CTYPE_INLINES) || defined (__STRICT_ANSI__ ))
|
||||
/* use simple lookup if SB locale, else _isctype() */
|
||||
#define __ISCTYPE(c, mask) (MB_CUR_MAX == 1 ? (_pctype[c] & mask) : _isctype(c, mask))
|
||||
extern __inline__ int isalnum(int c) {return __ISCTYPE(c, (_ALPHA|_DIGIT));}
|
||||
extern __inline__ int isalpha(int c) {return __ISCTYPE(c, _ALPHA);}
|
||||
extern __inline__ int iscntrl(int c) {return __ISCTYPE(c, _CONTROL);}
|
||||
extern __inline__ int isdigit(int c) {return __ISCTYPE(c, _DIGIT);}
|
||||
extern __inline__ int isgraph(int c) {return __ISCTYPE(c, (_PUNCT|_ALPHA|_DIGIT));}
|
||||
extern __inline__ int islower(int c) {return __ISCTYPE(c, _LOWER);}
|
||||
extern __inline__ int isprint(int c) {return __ISCTYPE(c, (_BLANK|_PUNCT|_ALPHA|_DIGIT));}
|
||||
extern __inline__ int ispunct(int c) {return __ISCTYPE(c, _PUNCT);}
|
||||
extern __inline__ int isspace(int c) {return __ISCTYPE(c, _SPACE);}
|
||||
extern __inline__ int isupper(int c) {return __ISCTYPE(c, _UPPER);}
|
||||
extern __inline__ int isxdigit(int c) {return __ISCTYPE(c, _HEX);}
|
||||
|
||||
/* these reproduce behaviour of lib underscored versions */
|
||||
extern __inline__ int _tolower(int c) {return ( c -'A'+'a');}
|
||||
extern __inline__ int _toupper(int c) {return ( c -'a'+'A');}
|
||||
|
||||
/* TODO? Is it worth inlining ANSI tolower, toupper? Probably only
|
||||
if we only want C-locale. */
|
||||
|
||||
#endif /* _NO_CTYPE_INLINES */
|
||||
|
||||
/* Wide character equivalents */
|
||||
|
||||
#ifndef WEOF
|
||||
#define WEOF (wchar_t)(0xFFFF)
|
||||
#endif
|
||||
|
||||
#ifndef _WCTYPE_T_DEFINED
|
||||
typedef wchar_t wctype_t;
|
||||
#define _WCTYPE_T_DEFINED
|
||||
#endif
|
||||
|
||||
int iswalnum(wint_t);
|
||||
int iswalpha(wint_t);
|
||||
int iswascii(wint_t);
|
||||
int iswcntrl(wint_t);
|
||||
int iswctype(wint_t, wctype_t);
|
||||
int is_wctype(wint_t, wctype_t); /* Obsolete! */
|
||||
int iswdigit(wint_t);
|
||||
int iswgraph(wint_t);
|
||||
int iswlower(wint_t);
|
||||
int iswprint(wint_t);
|
||||
int iswpunct(wint_t);
|
||||
int iswspace(wint_t);
|
||||
int iswupper(wint_t);
|
||||
int iswxdigit(wint_t);
|
||||
|
||||
wchar_t towlower(wchar_t);
|
||||
wchar_t towupper(wchar_t);
|
||||
|
||||
int isleadbyte (int);
|
||||
|
||||
/* Also in wctype.h */
|
||||
#if ! (defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED))
|
||||
#define __WCTYPE_INLINES_DEFINED
|
||||
extern __inline__ int iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));}
|
||||
extern __inline__ int iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));}
|
||||
extern __inline__ int iswascii(wint_t wc) {return (((unsigned)wc & 0x7F) ==0);}
|
||||
extern __inline__ int iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));}
|
||||
extern __inline__ int iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));}
|
||||
extern __inline__ int iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));}
|
||||
extern __inline__ int iswlower(wint_t wc) {return (iswctype(wc,_LOWER));}
|
||||
extern __inline__ int iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));}
|
||||
extern __inline__ int iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));}
|
||||
extern __inline__ int iswspace(wint_t wc) {return (iswctype(wc,_SPACE));}
|
||||
extern __inline__ int iswupper(wint_t wc) {return (iswctype(wc,_UPPER));}
|
||||
extern __inline__ int iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));}
|
||||
extern __inline__ int isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);}
|
||||
#endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
int __isascii (int);
|
||||
int __toascii (int);
|
||||
int __iscsymf (int); /* Valid first character in C symbol */
|
||||
int __iscsym (int); /* Valid character in C symbol (after first) */
|
||||
|
||||
#ifndef __NO_CTYPE_INLINES
|
||||
extern __inline__ int __isascii(int c) {return (((unsigned)c & ~0x7F) == 0);}
|
||||
extern __inline__ int __toascii(int c) {return (c & 0x7F);}
|
||||
extern __inline__ int __iscsymf(int c) {return (isalpha(c) || (c == '_'));}
|
||||
extern __inline__ int __iscsym(int c) {return (isalnum(c) || (c == '_'));}
|
||||
#endif /* __NO_CTYPE_INLINES */
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
int isascii (int);
|
||||
int toascii (int);
|
||||
int iscsymf (int);
|
||||
int iscsym (int);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _CTYPE_H_ */
|
||||
|
||||
26
win32/include/dir.h
Normal file
26
win32/include/dir.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* dir.h
|
||||
*
|
||||
* This file OBSOLESCENT and only provided for backward compatibility.
|
||||
* Please use io.h instead.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
* Mumit Khan <khan@xraylith.wisc.edu>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <io.h>
|
||||
|
||||
95
win32/include/direct.h
Normal file
95
win32/include/direct.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* direct.h
|
||||
*
|
||||
* Functions for manipulating paths and directories (included from io.h)
|
||||
* plus functions for setting the current drive.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _DIRECT_H_
|
||||
#define _DIRECT_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#include <io.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _DISKFREE_T_DEFINED
|
||||
/* needed by _getdiskfree (also in dos.h) */
|
||||
struct _diskfree_t {
|
||||
unsigned total_clusters;
|
||||
unsigned avail_clusters;
|
||||
unsigned sectors_per_cluster;
|
||||
unsigned bytes_per_sector;
|
||||
};
|
||||
#define _DISKFREE_T_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* You really shouldn't be using these. Use the Win32 API functions instead.
|
||||
* However, it does make it easier to port older code.
|
||||
*/
|
||||
int _getdrive (void);
|
||||
unsigned long _getdrives(void);
|
||||
int _chdrive (int);
|
||||
char* _getdcwd (int, char*, int);
|
||||
unsigned _getdiskfree (unsigned, struct _diskfree_t *);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
# define diskfree_t _diskfree_t
|
||||
#endif
|
||||
|
||||
#ifndef _WDIRECT_DEFINED
|
||||
/* wide character versions. Also in wchar.h */
|
||||
#ifdef __MSVCRT__
|
||||
int _wchdir(const wchar_t*);
|
||||
wchar_t* _wgetcwd(wchar_t*, int);
|
||||
wchar_t* _wgetdcwd(int, wchar_t*, int);
|
||||
int _wmkdir(const wchar_t*);
|
||||
int _wrmdir(const wchar_t*);
|
||||
#endif /* __MSVCRT__ */
|
||||
#define _WDIRECT_DEFINED
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _DIRECT_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
96
win32/include/dirent.h
Normal file
96
win32/include/dirent.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* DIRENT.H (formerly DIRLIB.H)
|
||||
*
|
||||
* by M. J. Weinstein Released to public domain 1-Jan-89
|
||||
*
|
||||
* Because I have heard that this feature (opendir, readdir, closedir)
|
||||
* it so useful for programmers coming from UNIX or attempting to port
|
||||
* UNIX code, and because it is reasonably light weight, I have included
|
||||
* it in the Mingw32 package. I have also added an implementation of
|
||||
* rewinddir, seekdir and telldir.
|
||||
* - Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* This code is distributed in the hope that is will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includeds but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _DIRENT_H_
|
||||
#define _DIRENT_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#include <io.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dirent
|
||||
{
|
||||
long d_ino; /* Always zero. */
|
||||
unsigned short d_reclen; /* Always zero. */
|
||||
unsigned short d_namlen; /* Length of name in d_name. */
|
||||
char* d_name; /* File name. */
|
||||
/* NOTE: The name in the dirent structure points to the name in the
|
||||
* finddata_t structure in the DIR. */
|
||||
};
|
||||
|
||||
/*
|
||||
* This is an internal data structure. Good programmers will not use it
|
||||
* except as an argument to one of the functions below.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* disk transfer area for this dir */
|
||||
struct _finddata_t dd_dta;
|
||||
|
||||
/* dirent struct to return from dir (NOTE: this makes this thread
|
||||
* safe as long as only one thread uses a particular DIR struct at
|
||||
* a time) */
|
||||
struct dirent dd_dir;
|
||||
|
||||
/* _findnext handle */
|
||||
long dd_handle;
|
||||
|
||||
/*
|
||||
* Status of search:
|
||||
* 0 = not started yet (next entry to read is first entry)
|
||||
* -1 = off the end
|
||||
* positive = 0 based index of next entry
|
||||
*/
|
||||
short dd_stat;
|
||||
|
||||
/* given path for dir with search pattern (struct is extended) */
|
||||
char dd_name[1];
|
||||
} DIR;
|
||||
|
||||
|
||||
DIR* opendir (const char*);
|
||||
struct dirent* readdir (DIR*);
|
||||
int closedir (DIR*);
|
||||
void rewinddir (DIR*);
|
||||
long telldir (DIR*);
|
||||
void seekdir (DIR*, long);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _DIRENT_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
110
win32/include/dos.h
Normal file
110
win32/include/dos.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* dos.h
|
||||
*
|
||||
* DOS-specific functions and structures.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by J.J. van der Heijden <J.J.vanderHeijden@student.utwente.nl>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _DOS_H_
|
||||
#define _DOS_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
/* For DOS file attributes */
|
||||
#include <io.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MSVCRT__ /* these are in CRTDLL, but not MSVCRT */
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
extern unsigned int *__imp__basemajor_dll;
|
||||
extern unsigned int *__imp__baseminor_dll;
|
||||
extern unsigned int *__imp__baseversion_dll;
|
||||
extern unsigned int *__imp__osmajor_dll;
|
||||
extern unsigned int *__imp__osminor_dll;
|
||||
extern unsigned int *__imp__osmode_dll;
|
||||
|
||||
#define _basemajor (*__imp__basemajor_dll)
|
||||
#define _baseminor (*__imp__baseminor_dll)
|
||||
#define _baseversion (*__imp__baseversion_dll)
|
||||
#define _osmajor (*__imp__osmajor_dll)
|
||||
#define _osminor (*__imp__osminor_dll)
|
||||
#define _osmode (*__imp__osmode_dll)
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
__MINGW_IMPORT unsigned int _basemajor_dll;
|
||||
__MINGW_IMPORT unsigned int _baseminor_dll;
|
||||
__MINGW_IMPORT unsigned int _baseversion_dll;
|
||||
__MINGW_IMPORT unsigned int _osmajor_dll;
|
||||
__MINGW_IMPORT unsigned int _osminor_dll;
|
||||
__MINGW_IMPORT unsigned int _osmode_dll;
|
||||
|
||||
#define _basemajor _basemajor_dll
|
||||
#define _baseminor _baseminor_dll
|
||||
#define _baseversion _baseversion_dll
|
||||
#define _osmajor _osmajor_dll
|
||||
#define _osminor _osminor_dll
|
||||
#define _osmode _osmode_dll
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
#endif /* ! __MSVCRT__ */
|
||||
|
||||
#ifndef _DISKFREE_T_DEFINED
|
||||
/* needed by _getdiskfree (also in direct.h) */
|
||||
struct _diskfree_t {
|
||||
unsigned total_clusters;
|
||||
unsigned avail_clusters;
|
||||
unsigned sectors_per_cluster;
|
||||
unsigned bytes_per_sector;
|
||||
};
|
||||
#define _DISKFREE_T_DEFINED
|
||||
#endif
|
||||
|
||||
unsigned _getdiskfree (unsigned, struct _diskfree_t *);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
# define diskfree_t _diskfree_t
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _DOS_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
117
win32/include/errno.h
Normal file
117
win32/include/errno.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* errno.h
|
||||
*
|
||||
* Error numbers and access to error reporting.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ERRNO_H_
|
||||
#define _ERRNO_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* Error numbers.
|
||||
* TODO: Can't be sure of some of these assignments, I guessed from the
|
||||
* names given by strerror and the defines in the Cygnus errno.h. A lot
|
||||
* of the names from the Cygnus errno.h are not represented, and a few
|
||||
* of the descriptions returned by strerror do not obviously match
|
||||
* their error naming.
|
||||
*/
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOFILE 2 /* No such file or directory */
|
||||
#define ENOENT 2
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted function call */
|
||||
#define EIO 5 /* Input/output 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 descriptor */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Resource temporarily unavailable */
|
||||
#define ENOMEM 12 /* Not enough space */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
/* 15 - Unknown Error */
|
||||
#define EBUSY 16 /* strerror reports "Resource device" */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Improper link (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 /* Inappropriate I/O control operation */
|
||||
/* 26 - Unknown Error */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Domain error (math functions) */
|
||||
#define ERANGE 34 /* Result too large (possibly too small) */
|
||||
/* 35 - Unknown Error */
|
||||
#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
|
||||
#define EDEADLK 36
|
||||
/* 37 - Unknown Error */
|
||||
#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
|
||||
#define ENOLCK 39 /* No locks available (46 in Cyg?) */
|
||||
#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
|
||||
#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
|
||||
#define EILSEQ 42 /* Illegal byte sequence */
|
||||
|
||||
/*
|
||||
* NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the
|
||||
* sockets.h header provided with windows32api-0.1.2.
|
||||
* You should go and put an #if 0 ... #endif around the whole block
|
||||
* of errors (look at the comment above them).
|
||||
*/
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see
|
||||
* stdlib.h.
|
||||
*/
|
||||
#ifdef _UWIN
|
||||
#undef errno
|
||||
extern int errno;
|
||||
#else
|
||||
int* _errno(void);
|
||||
#define errno (*_errno())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _ERRNO_H_ */
|
||||
20
win32/include/excpt.h
Normal file
20
win32/include/excpt.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _EXCPT_H
|
||||
#define _EXCPT_H
|
||||
#if __GNUC__ >=3
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
/* FIXME: This will make some code compile. The programs will most
|
||||
likely crash when an exception is raised, but at least they will
|
||||
compile. */
|
||||
#ifdef __GNUC__
|
||||
#define __try
|
||||
#define __except(x) if (0) /* don't execute handler */
|
||||
#define __finally
|
||||
|
||||
#define _try __try
|
||||
#define _except __except
|
||||
#define _finally __finally
|
||||
#endif
|
||||
|
||||
#endif
|
||||
135
win32/include/fcntl.h
Normal file
135
win32/include/fcntl.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* fcntl.h
|
||||
*
|
||||
* Access constants for _open. Note that the permissions constants are
|
||||
* in sys/stat.h (ick).
|
||||
*
|
||||
* This code is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _FCNTL_H_
|
||||
#define _FCNTL_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* It appears that fcntl.h should include io.h for compatibility...
|
||||
*/
|
||||
#include <io.h>
|
||||
|
||||
/* Specifiy one of these flags to define the access mode. */
|
||||
#define _O_RDONLY 0
|
||||
#define _O_WRONLY 1
|
||||
#define _O_RDWR 2
|
||||
|
||||
/* Mask for access mode bits in the _open flags. */
|
||||
#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
|
||||
|
||||
#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */
|
||||
|
||||
#define _O_RANDOM 0x0010
|
||||
#define _O_SEQUENTIAL 0x0020
|
||||
#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing.
|
||||
* WARNING: Even if not created by _open! */
|
||||
#define _O_NOINHERIT 0x0080
|
||||
|
||||
#define _O_CREAT 0x0100 /* Create the file if it does not exist. */
|
||||
#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */
|
||||
#define _O_EXCL 0x0400 /* Open only if the file does not exist. */
|
||||
|
||||
/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */
|
||||
#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */
|
||||
#define _O_BINARY 0x8000 /* Input and output is not translated. */
|
||||
#define _O_RAW _O_BINARY
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
/* POSIX/Non-ANSI names for increased portability */
|
||||
#define O_RDONLY _O_RDONLY
|
||||
#define O_WRONLY _O_WRONLY
|
||||
#define O_RDWR _O_RDWR
|
||||
#define O_ACCMODE _O_ACCMODE
|
||||
#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_TEMPORARY _O_TEMPORARY
|
||||
#define O_NOINHERIT _O_NOINHERIT
|
||||
#define O_SEQENTIAL _O_SEQUENTIAL
|
||||
#define O_RANDOM _O_RANDOM
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* This variable determines the default file mode.
|
||||
* TODO: Which flags work?
|
||||
*/
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
extern unsigned int* __imp__fmode;
|
||||
#define _fmode (*__imp__fmode)
|
||||
#else
|
||||
/* CRTDLL */
|
||||
extern unsigned int* __imp__fmode_dll;
|
||||
#define _fmode (*__imp__fmode_dll)
|
||||
#endif
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
__MINGW_IMPORT unsigned int _fmode;
|
||||
#else /* ! __MSVCRT__ */
|
||||
__MINGW_IMPORT unsigned int _fmode_dll;
|
||||
#define _fmode _fmode_dll
|
||||
#endif /* ! __MSVCRT__ */
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int _setmode (int, int);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
int setmode (int, int);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _FCNTL_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
85
win32/include/fenv.h
Normal file
85
win32/include/fenv.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef _FENV_H
|
||||
#define _FENV_H
|
||||
|
||||
/*
|
||||
For now, support only for the basic abstraction of flags that are
|
||||
either set or clear. fexcept_t could be structure that holds more info
|
||||
about the fp environment.
|
||||
*/
|
||||
typedef unsigned short fexcept_t;
|
||||
|
||||
/* This 28-byte struct represents the entire floating point
|
||||
environment as stored by fnstenv or fstenv */
|
||||
typedef struct
|
||||
{
|
||||
unsigned short __control_word;
|
||||
unsigned short __unused0;
|
||||
unsigned short __status_word;
|
||||
unsigned short __unused1;
|
||||
unsigned short __tag_word;
|
||||
unsigned short __unused2;
|
||||
unsigned int __ip_offset; /* instruction pointer offset */
|
||||
unsigned short __ip_selector;
|
||||
unsigned short __opcode;
|
||||
unsigned int __data_offset;
|
||||
unsigned short __data_selector;
|
||||
unsigned short __unused3;
|
||||
} fenv_t;
|
||||
|
||||
|
||||
/* FPU status word exception flags */
|
||||
#define FE_INVALID 0x01
|
||||
#define FE_DENORMAL 0x02
|
||||
#define FE_DIVBYZERO 0x04
|
||||
#define FE_OVERFLOW 0x08
|
||||
#define FE_UNDERFLOW 0x10
|
||||
#define FE_INEXACT 0x20
|
||||
#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \
|
||||
| FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
|
||||
|
||||
/* FPU control word rounding flags */
|
||||
#define FE_TONEAREST 0x0000
|
||||
#define FE_DOWNWARD 0x0400
|
||||
#define FE_UPWARD 0x0800
|
||||
#define FE_TOWARDZERO 0x0c00
|
||||
|
||||
|
||||
/* The default floating point environment */
|
||||
#define FE_DFL_ENV ((const fenv_t *)-1)
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*TODO: Some of these could be inlined */
|
||||
/* 7.6.2 Exception */
|
||||
|
||||
extern int feclearexcept (int);
|
||||
extern int fegetexceptflag (fexcept_t * flagp, int excepts);
|
||||
extern int feraiseexcept (int excepts );
|
||||
extern int fesetexceptflag (const fexcept_t *, int);
|
||||
extern int fetestexcept (int excepts);
|
||||
|
||||
|
||||
/* 7.6.3 Rounding */
|
||||
|
||||
extern int fegetround (void);
|
||||
extern int fesetround (int mode);
|
||||
|
||||
|
||||
/* 7.6.4 Environment */
|
||||
|
||||
extern int fegetenv (fenv_t * envp);
|
||||
extern int fesetenv (const fenv_t * );
|
||||
extern int feupdateenv (const fenv_t *);
|
||||
extern int feholdexcept (fenv_t *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* ndef _FENV_H */
|
||||
224
win32/include/float.h
Normal file
224
win32/include/float.h
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* float.h
|
||||
*
|
||||
* Constants related to floating point arithmetic.
|
||||
*
|
||||
* Also included here are some non-ANSI bits for accessing the floating
|
||||
* point controller.
|
||||
*
|
||||
* NOTE: GCC provides float.h, and it is probably more accurate than this,
|
||||
* but it doesn't include the non-standard stuff for accessing the
|
||||
* fp controller. (TODO: Move those bits elsewhere?) Thus it is
|
||||
* probably not a good idea to use the GCC supplied version instead
|
||||
* of this header.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FLOAT_H_
|
||||
#define _FLOAT_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define FLT_ROUNDS 1
|
||||
#define FLT_GUARD 1
|
||||
#define FLT_NORMALIZE 1
|
||||
|
||||
/*
|
||||
* The characteristics of float.
|
||||
*/
|
||||
|
||||
/* The radix for floating point representation. */
|
||||
#define FLT_RADIX 2
|
||||
|
||||
/* Decimal digits of precision. */
|
||||
#define FLT_DIG 6
|
||||
|
||||
/* Smallest number such that 1+x != 1 */
|
||||
#define FLT_EPSILON 1.19209290e-07F
|
||||
|
||||
/* The number of base FLT_RADIX digits in the mantissa. */
|
||||
#define FLT_MANT_DIG 24
|
||||
|
||||
/* The maximum floating point number. */
|
||||
#define FLT_MAX 3.40282347e+38F
|
||||
|
||||
/* Maximum n such that FLT_RADIX^n - 1 is representable. */
|
||||
#define FLT_MAX_EXP 128
|
||||
|
||||
/* Maximum n such that 10^n is representable. */
|
||||
#define FLT_MAX_10_EXP 38
|
||||
|
||||
/* Minimum normalized floating-point number. */
|
||||
#define FLT_MIN 1.17549435e-38F
|
||||
|
||||
/* Minimum n such that FLT_RADIX^n is a normalized number. */
|
||||
#define FLT_MIN_EXP (-125)
|
||||
|
||||
/* Minimum n such that 10^n is a normalized number. */
|
||||
#define FLT_MIN_10_EXP (-37)
|
||||
|
||||
|
||||
/*
|
||||
* The characteristics of double.
|
||||
*/
|
||||
#define DBL_DIG 15
|
||||
#define DBL_EPSILON 1.1102230246251568e-16
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_MAX 1.7976931348623157e+308
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define DBL_MIN 2.2250738585072014e-308
|
||||
#define DBL_MIN_EXP (-1021)
|
||||
#define DBL_MIN_10_EXP (-307)
|
||||
|
||||
|
||||
/*
|
||||
* The characteristics of long double.
|
||||
* NOTE: long double is the same as double.
|
||||
*/
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_EPSILON 1.1102230246251568e-16L
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MAX 1.7976931348623157e+308L
|
||||
#define LDBL_MAX_EXP 1024
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
#define LDBL_MIN 2.2250738585072014e-308L
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
|
||||
|
||||
/*
|
||||
* Functions and definitions for controlling the FPU.
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
/* TODO: These constants are only valid for x86 machines */
|
||||
|
||||
/* Control word masks for unMask */
|
||||
#define _MCW_EM 0x0008001F /* Error masks */
|
||||
#define _MCW_IC 0x00040000 /* Infinity */
|
||||
#define _MCW_RC 0x00000300 /* Rounding */
|
||||
#define _MCW_PC 0x00030000 /* Precision */
|
||||
|
||||
/* Control word values for unNew (use with related unMask above) */
|
||||
#define _EM_INVALID 0x00000010
|
||||
#define _EM_DENORMAL 0x00080000
|
||||
#define _EM_ZERODIVIDE 0x00000008
|
||||
#define _EM_OVERFLOW 0x00000004
|
||||
#define _EM_UNDERFLOW 0x00000002
|
||||
#define _EM_INEXACT 0x00000001
|
||||
#define _IC_AFFINE 0x00040000
|
||||
#define _IC_PROJECTIVE 0x00000000
|
||||
#define _RC_CHOP 0x00000300
|
||||
#define _RC_UP 0x00000200
|
||||
#define _RC_DOWN 0x00000100
|
||||
#define _RC_NEAR 0x00000000
|
||||
#define _PC_24 0x00020000
|
||||
#define _PC_53 0x00010000
|
||||
#define _PC_64 0x00000000
|
||||
|
||||
/* These are also defined in Mingw math.h, needed to work around
|
||||
GCC build issues. */
|
||||
/* Return values for fpclass. */
|
||||
#ifndef __MINGW_FPCLASS_DEFINED
|
||||
#define __MINGW_FPCLASS_DEFINED 1
|
||||
#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
|
||||
#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
|
||||
#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
|
||||
#define _FPCLASS_NN 0x0008 /* Negative Normal */
|
||||
#define _FPCLASS_ND 0x0010 /* Negative Denormal */
|
||||
#define _FPCLASS_NZ 0x0020 /* Negative Zero */
|
||||
#define _FPCLASS_PZ 0x0040 /* Positive Zero */
|
||||
#define _FPCLASS_PD 0x0080 /* Positive Denormal */
|
||||
#define _FPCLASS_PN 0x0100 /* Positive Normal */
|
||||
#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
|
||||
#endif /* __MINGW_FPCLASS_DEFINED */
|
||||
|
||||
/* invalid subconditions (_SW_INVALID also set) */
|
||||
#define _SW_UNEMULATED 0x0040 /* unemulated instruction */
|
||||
#define _SW_SQRTNEG 0x0080 /* square root of a neg number */
|
||||
#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
|
||||
#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
|
||||
|
||||
/* Floating point error signals and return codes */
|
||||
#define _FPE_INVALID 0x81
|
||||
#define _FPE_DENORMAL 0x82
|
||||
#define _FPE_ZERODIVIDE 0x83
|
||||
#define _FPE_OVERFLOW 0x84
|
||||
#define _FPE_UNDERFLOW 0x85
|
||||
#define _FPE_INEXACT 0x86
|
||||
#define _FPE_UNEMULATED 0x87
|
||||
#define _FPE_SQRTNEG 0x88
|
||||
#define _FPE_STACKOVERFLOW 0x8a
|
||||
#define _FPE_STACKUNDERFLOW 0x8b
|
||||
#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
|
||||
* i.e. change the bits in unMask to have the values they have in unNew,
|
||||
* leaving other bits unchanged. */
|
||||
unsigned int _controlfp (unsigned int unNew, unsigned int unMask);
|
||||
unsigned int _control87 (unsigned int unNew, unsigned int unMask);
|
||||
|
||||
|
||||
unsigned int _clearfp (void); /* Clear the FPU status word */
|
||||
unsigned int _statusfp (void); /* Report the FPU status word */
|
||||
#define _clear87 _clearfp
|
||||
#define _status87 _statusfp
|
||||
|
||||
void _fpreset (void); /* Reset the FPU */
|
||||
void fpreset (void);
|
||||
|
||||
/* Global 'variable' for the current floating point error code. */
|
||||
int * __fpecode(void);
|
||||
#define _fpecode (*(__fpecode()))
|
||||
|
||||
/*
|
||||
* IEEE recommended functions
|
||||
*/
|
||||
|
||||
double _chgsign (double);
|
||||
double _copysign (double, double);
|
||||
double _logb (double);
|
||||
double _nextafter (double, double);
|
||||
double _scalb (double, long);
|
||||
|
||||
int _finite (double);
|
||||
int _fpclass (double);
|
||||
int _isnan (double);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
#endif /* _FLOAT_H_ */
|
||||
|
||||
275
win32/include/inttypes.h
Normal file
275
win32/include/inttypes.h
Normal file
@@ -0,0 +1,275 @@
|
||||
/* 7.8 Format conversion of integer types <inttypes.h> */
|
||||
|
||||
#ifndef _INTTYPES_H
|
||||
#define _INTTYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#define __need_wchar_t
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
intmax_t quot;
|
||||
intmax_t rem;
|
||||
} imaxdiv_t;
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
|
||||
|
||||
/* 7.8.1 Macros for format specifiers
|
||||
*
|
||||
* MS runtime does not yet understand C9x standard "ll"
|
||||
* length specifier. It appears to treat "ll" as "l".
|
||||
* The non-standard I64 length specifier causes warning in GCC,
|
||||
* but understood by MS runtime functions.
|
||||
*/
|
||||
|
||||
/* fprintf macros for signed types */
|
||||
#define PRId8 "d"
|
||||
#define PRId16 "d"
|
||||
#define PRId32 "d"
|
||||
#define PRId64 "I64d"
|
||||
|
||||
#define PRIdLEAST8 "d"
|
||||
#define PRIdLEAST16 "d"
|
||||
#define PRIdLEAST32 "d"
|
||||
#define PRIdLEAST64 "I64d"
|
||||
|
||||
#define PRIdFAST8 "d"
|
||||
#define PRIdFAST16 "d"
|
||||
#define PRIdFAST32 "d"
|
||||
#define PRIdFAST64 "I64d"
|
||||
|
||||
#define PRIdMAX "I64d"
|
||||
#define PRIdPTR "d"
|
||||
|
||||
#define PRIi8 "i"
|
||||
#define PRIi16 "i"
|
||||
#define PRIi32 "i"
|
||||
#define PRIi64 "I64i"
|
||||
|
||||
#define PRIiLEAST8 "i"
|
||||
#define PRIiLEAST16 "i"
|
||||
#define PRIiLEAST32 "i"
|
||||
#define PRIiLEAST64 "I64i"
|
||||
|
||||
#define PRIiFAST8 "i"
|
||||
#define PRIiFAST16 "i"
|
||||
#define PRIiFAST32 "i"
|
||||
#define PRIiFAST64 "I64i"
|
||||
|
||||
#define PRIiMAX "I64i"
|
||||
#define PRIiPTR "i"
|
||||
|
||||
#define PRIo8 "o"
|
||||
#define PRIo16 "o"
|
||||
#define PRIo32 "o"
|
||||
#define PRIo64 "I64o"
|
||||
|
||||
#define PRIoLEAST8 "o"
|
||||
#define PRIoLEAST16 "o"
|
||||
#define PRIoLEAST32 "o"
|
||||
#define PRIoLEAST64 "I64o"
|
||||
|
||||
#define PRIoFAST8 "o"
|
||||
#define PRIoFAST16 "o"
|
||||
#define PRIoFAST32 "o"
|
||||
#define PRIoFAST64 "I64o"
|
||||
|
||||
#define PRIoMAX "I64o"
|
||||
|
||||
#define PRIoPTR "o"
|
||||
|
||||
/* fprintf macros for unsigned types */
|
||||
#define PRIu8 "u"
|
||||
#define PRIu16 "u"
|
||||
#define PRIu32 "u"
|
||||
#define PRIu64 "I64u"
|
||||
|
||||
|
||||
#define PRIuLEAST8 "u"
|
||||
#define PRIuLEAST16 "u"
|
||||
#define PRIuLEAST32 "u"
|
||||
#define PRIuLEAST64 "I64u"
|
||||
|
||||
#define PRIuFAST8 "u"
|
||||
#define PRIuFAST16 "u"
|
||||
#define PRIuFAST32 "u"
|
||||
#define PRIuFAST64 "I64u"
|
||||
|
||||
#define PRIuMAX "I64u"
|
||||
#define PRIuPTR "u"
|
||||
|
||||
#define PRIx8 "x"
|
||||
#define PRIx16 "x"
|
||||
#define PRIx32 "x"
|
||||
#define PRIx64 "I64x"
|
||||
|
||||
#define PRIxLEAST8 "x"
|
||||
#define PRIxLEAST16 "x"
|
||||
#define PRIxLEAST32 "x"
|
||||
#define PRIxLEAST64 "I64x"
|
||||
|
||||
#define PRIxFAST8 "x"
|
||||
#define PRIxFAST16 "x"
|
||||
#define PRIxFAST32 "x"
|
||||
#define PRIxFAST64 "I64x"
|
||||
|
||||
#define PRIxMAX "I64x"
|
||||
#define PRIxPTR "x"
|
||||
|
||||
#define PRIX8 "X"
|
||||
#define PRIX16 "X"
|
||||
#define PRIX32 "X"
|
||||
#define PRIX64 "I64X"
|
||||
|
||||
#define PRIXLEAST8 "X"
|
||||
#define PRIXLEAST16 "X"
|
||||
#define PRIXLEAST32 "X"
|
||||
#define PRIXLEAST64 "I64X"
|
||||
|
||||
#define PRIXFAST8 "X"
|
||||
#define PRIXFAST16 "X"
|
||||
#define PRIXFAST32 "X"
|
||||
#define PRIXFAST64 "I64X"
|
||||
|
||||
#define PRIXMAX "I64X"
|
||||
#define PRIXPTR "X"
|
||||
|
||||
/*
|
||||
* fscanf macros for signed int types
|
||||
* NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
|
||||
* (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
|
||||
* no length identifiers
|
||||
*/
|
||||
|
||||
#define SCNd16 "hd"
|
||||
#define SCNd32 "d"
|
||||
#define SCNd64 "I64d"
|
||||
|
||||
#define SCNdLEAST16 "hd"
|
||||
#define SCNdLEAST32 "d"
|
||||
#define SCNdLEAST64 "I64d"
|
||||
|
||||
#define SCNdFAST16 "hd"
|
||||
#define SCNdFAST32 "d"
|
||||
#define SCNdFAST64 "I64d"
|
||||
|
||||
#define SCNdMAX "I64d"
|
||||
#define SCNdPTR "d"
|
||||
|
||||
#define SCNi16 "hi"
|
||||
#define SCNi32 "i"
|
||||
#define SCNi64 "I64i"
|
||||
|
||||
#define SCNiLEAST16 "hi"
|
||||
#define SCNiLEAST32 "i"
|
||||
#define SCNiLEAST64 "I64i"
|
||||
|
||||
#define SCNiFAST16 "hi"
|
||||
#define SCNiFAST32 "i"
|
||||
#define SCNiFAST64 "I64i"
|
||||
|
||||
#define SCNiMAX "I64i"
|
||||
#define SCNiPTR "i"
|
||||
|
||||
#define SCNo16 "ho"
|
||||
#define SCNo32 "o"
|
||||
#define SCNo64 "I64o"
|
||||
|
||||
#define SCNoLEAST16 "ho"
|
||||
#define SCNoLEAST32 "o"
|
||||
#define SCNoLEAST64 "I64o"
|
||||
|
||||
#define SCNoFAST16 "ho"
|
||||
#define SCNoFAST32 "o"
|
||||
#define SCNoFAST64 "I64o"
|
||||
|
||||
#define SCNoMAX "I64o"
|
||||
#define SCNoPTR "o"
|
||||
|
||||
#define SCNx16 "hx"
|
||||
#define SCNx32 "x"
|
||||
#define SCNx64 "I64x"
|
||||
|
||||
#define SCNxLEAST16 "hx"
|
||||
#define SCNxLEAST32 "x"
|
||||
#define SCNxLEAST64 "I64x"
|
||||
|
||||
#define SCNxFAST16 "hx"
|
||||
#define SCNxFAST32 "x"
|
||||
#define SCNxFAST64 "I64x"
|
||||
|
||||
#define SCNxMAX "I64x"
|
||||
#define SCNxPTR "x"
|
||||
|
||||
|
||||
/* fscanf macros for unsigned int types */
|
||||
|
||||
#define SCNu16 "hu"
|
||||
#define SCNu32 "u"
|
||||
#define SCNu64 "I64u"
|
||||
|
||||
#define SCNuLEAST16 "hu"
|
||||
#define SCNuLEAST32 "u"
|
||||
#define SCNuLEAST64 "I64u"
|
||||
|
||||
#define SCNuFAST16 "hu"
|
||||
#define SCNuFAST32 "u"
|
||||
#define SCNuFAST64 "I64u"
|
||||
|
||||
#define SCNuMAX "I64u"
|
||||
#define SCNuPTR "u"
|
||||
|
||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
/*
|
||||
* no length modifier for char types prior to C9x
|
||||
* MS runtime scanf appears to treat "hh" as "h"
|
||||
*/
|
||||
|
||||
/* signed char */
|
||||
#define SCNd8 "hhd"
|
||||
#define SCNdLEAST8 "hhd"
|
||||
#define SCNdFAST8 "hhd"
|
||||
|
||||
#define SCNi8 "hhi"
|
||||
#define SCNiLEAST8 "hhi"
|
||||
#define SCNiFAST8 "hhi"
|
||||
|
||||
#define SCNo8 "hho"
|
||||
#define SCNoLEAST8 "hho"
|
||||
#define SCNoFAST8 "hho"
|
||||
|
||||
#define SCNx8 "hhx"
|
||||
#define SCNxLEAST8 "hhx"
|
||||
#define SCNxFAST8 "hhx"
|
||||
|
||||
/* unsigned char */
|
||||
#define SCNu8 "hhu"
|
||||
#define SCNuLEAST8 "hhu"
|
||||
#define SCNuFAST8 "hhu"
|
||||
#endif /* __STDC_VERSION__ >= 199901 */
|
||||
|
||||
#endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */
|
||||
|
||||
extern inline intmax_t imaxabs (intmax_t j)
|
||||
{return (j >= 0 ? j : -j);}
|
||||
imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom);
|
||||
|
||||
/* 7.8.2 Conversion functions for greatest-width integer types */
|
||||
|
||||
intmax_t strtoimax (const char* __restrict__ nptr, char** __restrict__ endptr, int base);
|
||||
uintmax_t strtoumax (const char* __restrict__ nptr, char** __restrict__ endptr, int base);
|
||||
|
||||
intmax_t wcstoimax (const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr,
|
||||
int base);
|
||||
uintmax_t wcstoumax (const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr,
|
||||
int base);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ndef _INTTYPES_H */
|
||||
296
win32/include/io.h
Normal file
296
win32/include/io.h
Normal file
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* io.h
|
||||
*
|
||||
* System level I/O functions and types.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _IO_H_
|
||||
#define _IO_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/* We need the definition of FILE anyway... */
|
||||
#include <stdio.h>
|
||||
|
||||
/* MSVC's io.h contains the stuff from dir.h, so I will too.
|
||||
* NOTE: This also defines off_t, the file offset type, through
|
||||
* an inclusion of sys/types.h */
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#include <sys/types.h> /* To get time_t. */
|
||||
|
||||
/*
|
||||
* Attributes of files as returned by _findfirst et al.
|
||||
*/
|
||||
#define _A_NORMAL 0x00000000
|
||||
#define _A_RDONLY 0x00000001
|
||||
#define _A_HIDDEN 0x00000002
|
||||
#define _A_SYSTEM 0x00000004
|
||||
#define _A_VOLID 0x00000008
|
||||
#define _A_SUBDIR 0x00000010
|
||||
#define _A_ARCH 0x00000020
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifndef _FSIZE_T_DEFINED
|
||||
typedef unsigned long _fsize_t;
|
||||
#define _FSIZE_T_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following structure is filled in by _findfirst or _findnext when
|
||||
* they succeed in finding a match.
|
||||
*/
|
||||
struct _finddata_t
|
||||
{
|
||||
unsigned attrib; /* Attributes, see constants above. */
|
||||
time_t time_create;
|
||||
time_t time_access; /* always midnight local time */
|
||||
time_t time_write;
|
||||
_fsize_t size;
|
||||
char name[FILENAME_MAX]; /* may include spaces. */
|
||||
};
|
||||
|
||||
struct _finddatai64_t {
|
||||
unsigned attrib;
|
||||
time_t time_create;
|
||||
time_t time_access;
|
||||
time_t time_write;
|
||||
__int64 size;
|
||||
char name[FILENAME_MAX];
|
||||
};
|
||||
|
||||
|
||||
#ifndef _WFINDDATA_T_DEFINED
|
||||
struct _wfinddata_t {
|
||||
unsigned attrib;
|
||||
time_t time_create; /* -1 for FAT file systems */
|
||||
time_t time_access; /* -1 for FAT file systems */
|
||||
time_t time_write;
|
||||
_fsize_t size;
|
||||
wchar_t name[FILENAME_MAX]; /* may include spaces. */
|
||||
};
|
||||
struct _wfinddatai64_t {
|
||||
unsigned attrib;
|
||||
time_t time_create;
|
||||
time_t time_access;
|
||||
time_t time_write;
|
||||
__int64 size;
|
||||
wchar_t name[FILENAME_MAX];
|
||||
};
|
||||
|
||||
#define _WFINDDATA_T_DEFINED
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Functions for searching for files. _findfirst returns -1 if no match
|
||||
* is found. Otherwise it returns a handle to be used in _findnext and
|
||||
* _findclose calls. _findnext also returns -1 if no match could be found,
|
||||
* and 0 if a match was found. Call _findclose when you are finished.
|
||||
*/
|
||||
int _findfirst (const char*, struct _finddata_t*);
|
||||
int _findnext (int, struct _finddata_t*);
|
||||
int _findclose (int);
|
||||
|
||||
int _chdir (const char*);
|
||||
char* _getcwd (char*, int);
|
||||
int _mkdir (const char*);
|
||||
char* _mktemp (char*);
|
||||
int _rmdir (const char*);
|
||||
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
__int64 _filelengthi64(int);
|
||||
long _findfirsti64(const char*, struct _finddatai64_t*);
|
||||
int _findnexti64(long, struct _finddatai64_t*);
|
||||
__int64 _lseeki64(int, __int64, int);
|
||||
__int64 _telli64(int);
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
#ifndef _UWIN
|
||||
int chdir (const char*);
|
||||
char* getcwd (char*, int);
|
||||
int mkdir (const char*);
|
||||
char* mktemp (char*);
|
||||
int rmdir (const char*);
|
||||
#endif /* _UWIN */
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
/* TODO: Maximum number of open handles has not been tested, I just set
|
||||
* it the same as FOPEN_MAX. */
|
||||
#define HANDLE_MAX FOPEN_MAX
|
||||
|
||||
|
||||
/* Some defines for _access nAccessMode (MS doesn't define them, but
|
||||
* it doesn't seem to hurt to add them). */
|
||||
#define F_OK 0 /* Check for file existence */
|
||||
#define X_OK 1 /* Check for execute permission. */
|
||||
#define W_OK 2 /* Check for write permission */
|
||||
#define R_OK 4 /* Check for read permission */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int _access (const char*, int);
|
||||
int _chsize (int, long);
|
||||
int _close (int);
|
||||
int _commit(int);
|
||||
|
||||
/* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
|
||||
* the "owner write permission" bit (on FAT). */
|
||||
int _creat (const char*, unsigned);
|
||||
|
||||
int _dup (int);
|
||||
int _dup2 (int, int);
|
||||
long _filelength (int);
|
||||
int _fileno (FILE*);
|
||||
long _get_osfhandle (int);
|
||||
int _isatty (int);
|
||||
|
||||
/* In a very odd turn of events this function is excluded from those
|
||||
* files which define _STREAM_COMPAT. This is required in order to
|
||||
* build GNU libio because of a conflict with _eof in streambuf.h
|
||||
* line 107. Actually I might just be able to change the name of
|
||||
* the enum member in streambuf.h... we'll see. TODO */
|
||||
#ifndef _STREAM_COMPAT
|
||||
int _eof (int);
|
||||
#endif
|
||||
|
||||
/* LK_... locking commands defined in sys/locking.h. */
|
||||
int _locking (int, int, long);
|
||||
|
||||
long _lseek (int, long, int);
|
||||
|
||||
/* Optional third argument is unsigned unPermissions. */
|
||||
int _open (const char*, int, ...);
|
||||
|
||||
int _open_osfhandle (long, int);
|
||||
int _pipe (int *, unsigned int, int);
|
||||
int _read (int, void*, unsigned int);
|
||||
|
||||
/* SH_... flags for nShFlags defined in share.h
|
||||
* Optional fourth argument is unsigned unPermissions */
|
||||
int _sopen (const char*, int, int, ...);
|
||||
|
||||
long _tell (int);
|
||||
/* Should umask be in sys/stat.h and/or sys/types.h instead? */
|
||||
int _umask (int);
|
||||
int _unlink (const char*);
|
||||
int _write (int, const void*, unsigned int);
|
||||
|
||||
/* Wide character versions. Also declared in wchar.h. */
|
||||
/* Not in crtdll.dll */
|
||||
#if !defined (_WIO_DEFINED)
|
||||
#if defined (__MSVCRT__)
|
||||
int _waccess(const wchar_t*, int);
|
||||
int _wchmod(const wchar_t*, int);
|
||||
int _wcreat(const wchar_t*, int);
|
||||
long _wfindfirst(wchar_t*, struct _wfinddata_t*);
|
||||
int _wfindnext(long, struct _wfinddata_t *);
|
||||
int _wunlink(const wchar_t*);
|
||||
int _wopen(const wchar_t*, int, ...);
|
||||
int _wsopen(const wchar_t*, int, int, ...);
|
||||
wchar_t * _wmktemp(wchar_t*);
|
||||
long _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
|
||||
int _wfindnexti64(long, struct _wfinddatai64_t*);
|
||||
#endif /* defined (__MSVCRT__) */
|
||||
#define _WIO_DEFINED
|
||||
#endif /* _WIO_DEFINED */
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
/*
|
||||
* Non-underscored versions of non-ANSI functions to improve portability.
|
||||
* These functions live in libmoldname.a.
|
||||
*/
|
||||
|
||||
#ifndef _UWIN
|
||||
int access (const char*, int);
|
||||
int chsize (int, long );
|
||||
int close (int);
|
||||
int creat (const char*, int);
|
||||
int dup (int);
|
||||
int dup2 (int, int);
|
||||
int eof (int);
|
||||
long filelength (int);
|
||||
int fileno (FILE*);
|
||||
int isatty (int);
|
||||
long lseek (int, long, int);
|
||||
int open (const char*, int, ...);
|
||||
int read (int, void*, unsigned int);
|
||||
int sopen (const char*, int, int, ...);
|
||||
long tell (int);
|
||||
int umask (int);
|
||||
int unlink (const char*);
|
||||
int write (int, const void*, unsigned int);
|
||||
#endif /* _UWIN */
|
||||
|
||||
/* Wide character versions. Also declared in wchar.h. */
|
||||
/* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
|
||||
#if 0
|
||||
int waccess(const wchar_t *, int);
|
||||
int wchmod(const wchar_t *, int);
|
||||
int wcreat(const wchar_t *, int);
|
||||
long wfindfirst(wchar_t *, struct _wfinddata_t *);
|
||||
int wfindnext(long, struct _wfinddata_t *);
|
||||
int wunlink(const wchar_t *);
|
||||
int wrename(const wchar_t *, const wchar_t *);
|
||||
int wopen(const wchar_t *, int, ...);
|
||||
int wsopen(const wchar_t *, int, int, ...);
|
||||
wchar_t * wmktemp(wchar_t *);
|
||||
#endif
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* _IO_H_ not defined */
|
||||
|
||||
#endif /* Not strict ANSI */
|
||||
|
||||
115
win32/include/limits.h
Normal file
115
win32/include/limits.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* limits.h
|
||||
*
|
||||
* Defines constants for the sizes of integral types.
|
||||
*
|
||||
* NOTE: GCC should supply a version of this header and it should be safe to
|
||||
* use that version instead of this one (maybe safer).
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LIMITS_H_
|
||||
#define _LIMITS_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* File system limits
|
||||
*
|
||||
* TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
|
||||
* same as FILENAME_MAX and FOPEN_MAX from stdio.h?
|
||||
* NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
|
||||
* required for the NUL. TODO: Test?
|
||||
*/
|
||||
#define PATH_MAX (259)
|
||||
|
||||
/*
|
||||
* Characteristics of the char data type.
|
||||
*
|
||||
* TODO: Is MB_LEN_MAX correct?
|
||||
*/
|
||||
#define CHAR_BIT 8
|
||||
#define MB_LEN_MAX 2
|
||||
|
||||
#define SCHAR_MIN (-128)
|
||||
#define SCHAR_MAX 127
|
||||
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
/* TODO: Is this safe? I think it might just be testing the preprocessor,
|
||||
* not the compiler itself... */
|
||||
#if ('\x80' < 0)
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#else
|
||||
#define CHAR_MIN 0
|
||||
#define CHAR_MAX UCHAR_MAX
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum and minimum values for ints.
|
||||
*/
|
||||
#define INT_MAX 2147483647
|
||||
#define INT_MIN (-INT_MAX-1)
|
||||
|
||||
#define UINT_MAX 0xffffffff
|
||||
|
||||
/*
|
||||
* Maximum and minimum values for shorts.
|
||||
*/
|
||||
#define SHRT_MAX 32767
|
||||
#define SHRT_MIN (-SHRT_MAX-1)
|
||||
|
||||
#define USHRT_MAX 0xffff
|
||||
|
||||
/*
|
||||
* Maximum and minimum values for longs and unsigned longs.
|
||||
*
|
||||
* TODO: This is not correct for Alphas, which have 64 bit longs.
|
||||
*/
|
||||
#define LONG_MAX 2147483647L
|
||||
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
|
||||
#define ULONG_MAX 0xffffffffUL
|
||||
|
||||
|
||||
/*
|
||||
* The GNU C compiler also allows 'long long int'
|
||||
*/
|
||||
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
||||
|
||||
#define LONG_LONG_MAX 9223372036854775807LL
|
||||
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
|
||||
|
||||
#define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1)
|
||||
|
||||
/* ISO C9x macro names */
|
||||
#define LLONG_MAX LONG_LONG_MAX
|
||||
#define LLONG_MIN LONG_LONG_MIN
|
||||
#define ULLONG_MAX ULONG_LONG_MAX
|
||||
|
||||
#endif /* Not Strict ANSI and GNU C compiler */
|
||||
|
||||
|
||||
#endif /* not _LIMITS_H_ */
|
||||
100
win32/include/locale.h
Normal file
100
win32/include/locale.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* locale.h
|
||||
*
|
||||
* Functions and types for localization (ie. changing the appearance of
|
||||
* output based on the standards of a certain country).
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LOCALE_H_
|
||||
#define _LOCALE_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* NOTE: I have tried to test this, but I am limited by my knowledge of
|
||||
* locale issues. The structure does not bomb if you look at the
|
||||
* values, and 'decimal_point' even seems to be correct. But the
|
||||
* rest of the values are, by default, not particularly useful
|
||||
* (read meaningless and not related to the international settings
|
||||
* of the system).
|
||||
*/
|
||||
|
||||
#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_MIN LC_ALL
|
||||
#define LC_MAX LC_TIME
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* The structure returned by 'localeconv'.
|
||||
*/
|
||||
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;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char* setlocale (int, const char*);
|
||||
struct lconv* localeconv (void);
|
||||
|
||||
#ifndef _WLOCALE_DEFINED /* also declared in wchar.h */
|
||||
# define __need_wchar_t
|
||||
# include <stddef.h>
|
||||
wchar_t* _wsetlocale(int, const wchar_t*);
|
||||
# define _WLOCALE_DEFINED
|
||||
#endif /* ndef _WLOCALE_DEFINED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _LOCALE_H_ */
|
||||
|
||||
87
win32/include/malloc.h
Normal file
87
win32/include/malloc.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* malloc.h
|
||||
*
|
||||
* Support for programs which want to use malloc.h to get memory management
|
||||
* functions. Unless you absolutely need some of these functions and they are
|
||||
* not in the ANSI headers you should use the ANSI standard header files
|
||||
* instead.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _MALLOC_H_
|
||||
#define _MALLOC_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* The structure used to walk through the heap with _heapwalk.
|
||||
*/
|
||||
typedef struct _heapinfo
|
||||
{
|
||||
int* _pentry;
|
||||
size_t _size;
|
||||
int _useflag;
|
||||
} _HEAPINFO;
|
||||
|
||||
/* Values for _heapinfo.useflag */
|
||||
#define _USEDENTRY 0
|
||||
#define _FREEENTRY 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
The _heap* memory allocation functions are supported on NT
|
||||
but not W9x. On latter, they always set errno to ENOSYS.
|
||||
*/
|
||||
int _heapwalk (_HEAPINFO*);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
int heapwalk (_HEAPINFO*);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
int _heapchk (void); /* Verify heap integrety. */
|
||||
int _heapmin (void); /* Return unused heap to the OS. */
|
||||
int _heapset (unsigned int);
|
||||
|
||||
size_t _msize (void*);
|
||||
size_t _get_sbh_threshold (void);
|
||||
int _set_sbh_threshold (size_t);
|
||||
void * _expand (void*, size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RC_INVOKED */
|
||||
|
||||
#endif /* Not _MALLOC_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
438
win32/include/math.h
Normal file
438
win32/include/math.h
Normal file
@@ -0,0 +1,438 @@
|
||||
/*
|
||||
* math.h
|
||||
*
|
||||
* Mathematical functions.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _MATH_H_
|
||||
#define _MATH_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* Types for the _exception structure.
|
||||
*/
|
||||
|
||||
#define _DOMAIN 1 /* domain error in argument */
|
||||
#define _SING 2 /* singularity */
|
||||
#define _OVERFLOW 3 /* range overflow */
|
||||
#define _UNDERFLOW 4 /* range underflow */
|
||||
#define _TLOSS 5 /* total loss of precision */
|
||||
#define _PLOSS 6 /* partial loss of precision */
|
||||
|
||||
/*
|
||||
* Exception types with non-ANSI names for compatibility.
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
#define DOMAIN _DOMAIN
|
||||
#define SING _SING
|
||||
#define OVERFLOW _OVERFLOW
|
||||
#define UNDERFLOW _UNDERFLOW
|
||||
#define TLOSS _TLOSS
|
||||
#define PLOSS _PLOSS
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
|
||||
/* These are also defined in Mingw float.h; needed here as well to work
|
||||
around GCC build issues. */
|
||||
#ifndef __STRICT_ANSI__
|
||||
#ifndef __MINGW_FPCLASS_DEFINED
|
||||
#define __MINGW_FPCLASS_DEFINED 1
|
||||
/* IEEE 754 classication */
|
||||
#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
|
||||
#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
|
||||
#define _FPCLASS_NINF 0x0004 /* Negative Infinity */
|
||||
#define _FPCLASS_NN 0x0008 /* Negative Normal */
|
||||
#define _FPCLASS_ND 0x0010 /* Negative Denormal */
|
||||
#define _FPCLASS_NZ 0x0020 /* Negative Zero */
|
||||
#define _FPCLASS_PZ 0x0040 /* Positive Zero */
|
||||
#define _FPCLASS_PD 0x0080 /* Positive Denormal */
|
||||
#define _FPCLASS_PN 0x0100 /* Positive Normal */
|
||||
#define _FPCLASS_PINF 0x0200 /* Positive Infinity */
|
||||
#endif /* __MINGW_FPCLASS_DEFINED */
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* HUGE_VAL is returned by strtod when the value would overflow the
|
||||
* representation of 'double'. There are other uses as well.
|
||||
*
|
||||
* __imp__HUGE is a pointer to the actual variable _HUGE in
|
||||
* MSVCRT.DLL. If we used _HUGE directly we would get a pointer
|
||||
* to a thunk function.
|
||||
*
|
||||
* NOTE: The CRTDLL version uses _HUGE_dll instead.
|
||||
*/
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
extern double* __imp__HUGE;
|
||||
#define HUGE_VAL (*__imp__HUGE)
|
||||
#else
|
||||
/* CRTDLL */
|
||||
extern double* __imp__HUGE_dll;
|
||||
#define HUGE_VAL (*__imp__HUGE_dll)
|
||||
#endif
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
__MINGW_IMPORT double _HUGE;
|
||||
#define HUGE_VAL _HUGE
|
||||
#else
|
||||
/* CRTDLL */
|
||||
__MINGW_IMPORT double _HUGE_dll;
|
||||
#define HUGE_VAL _HUGE_dll
|
||||
#endif
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
struct _exception
|
||||
{
|
||||
int type;
|
||||
char *name;
|
||||
double arg1;
|
||||
double arg2;
|
||||
double retval;
|
||||
};
|
||||
|
||||
|
||||
double sin (double);
|
||||
double cos (double);
|
||||
double tan (double);
|
||||
double sinh (double);
|
||||
double cosh (double);
|
||||
double tanh (double);
|
||||
double asin (double);
|
||||
double acos (double);
|
||||
double atan (double);
|
||||
double atan2 (double, double);
|
||||
double exp (double);
|
||||
double log (double);
|
||||
double log10 (double);
|
||||
double pow (double, double);
|
||||
double sqrt (double);
|
||||
double ceil (double);
|
||||
double floor (double);
|
||||
double fabs (double);
|
||||
double ldexp (double, int);
|
||||
double frexp (double, int*);
|
||||
double modf (double, double*);
|
||||
double fmod (double, double);
|
||||
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
/* Complex number (for cabs) */
|
||||
struct _complex
|
||||
{
|
||||
double x; /* Real part */
|
||||
double y; /* Imaginary part */
|
||||
};
|
||||
|
||||
double _cabs (struct _complex);
|
||||
double _hypot (double, double);
|
||||
double _j0 (double);
|
||||
double _j1 (double);
|
||||
double _jn (int, double);
|
||||
double _y0 (double);
|
||||
double _y1 (double);
|
||||
double _yn (int, double);
|
||||
int _matherr (struct _exception *);
|
||||
|
||||
/* These are also declared in Mingw float.h; needed here as well to work
|
||||
around GCC build issues. */
|
||||
/* BEGIN FLOAT.H COPY */
|
||||
/*
|
||||
* IEEE recommended functions
|
||||
*/
|
||||
|
||||
double _chgsign (double);
|
||||
double _copysign (double, double);
|
||||
double _logb (double);
|
||||
double _nextafter (double, double);
|
||||
double _scalb (double, long);
|
||||
|
||||
int _finite (double);
|
||||
int _fpclass (double);
|
||||
int _isnan (double);
|
||||
|
||||
/* END FLOAT.H COPY */
|
||||
|
||||
#if !defined (_NO_OLDNAMES) \
|
||||
|| (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L )
|
||||
|
||||
/*
|
||||
* Non-underscored versions of non-ANSI functions. These reside in
|
||||
* liboldnames.a. They are now also ISO C99 standand names.
|
||||
* Provided for extra portability.
|
||||
*/
|
||||
|
||||
double cabs (struct _complex);
|
||||
double hypot (double, double);
|
||||
double j0 (double);
|
||||
double j1 (double);
|
||||
double jn (int, double);
|
||||
double y0 (double);
|
||||
double y1 (double);
|
||||
double yn (int, double);
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
|
||||
#ifndef __NO_ISOCEXT
|
||||
|
||||
#define INFINITY HUGE_VAL
|
||||
#define NAN (0.0F/0.0F)
|
||||
|
||||
/*
|
||||
Return values for fpclassify.
|
||||
These are based on Intel x87 fpu condition codes
|
||||
in the high byte of status word and differ from
|
||||
the return values for MS IEEE 754 extension _fpclass()
|
||||
*/
|
||||
#define FP_NAN 0x0100
|
||||
#define FP_NORMAL 0x0400
|
||||
#define FP_INFINITE (FP_NAN | FP_NORMAL)
|
||||
#define FP_ZERO 0x4000
|
||||
#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO)
|
||||
/* 0x0200 is signbit mask */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
double nan(const char *tagp);
|
||||
float nanf(const char *tagp);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#define nan() nan("")
|
||||
#define nanf() nanf("")
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
We can't inline float, because we want to ensure truncation
|
||||
to semantic type before classification. If we extend to long
|
||||
double, we will also need to make double extern only.
|
||||
(A normal long double value might become subnormal when
|
||||
converted to double, and zero when converted to float.)
|
||||
*/
|
||||
extern __inline__ int __fpclassify (double x){
|
||||
unsigned short sw;
|
||||
__asm__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x));
|
||||
return sw & (FP_NAN | FP_NORMAL | FP_ZERO );
|
||||
}
|
||||
|
||||
extern int __fpclassifyf (float);
|
||||
|
||||
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) \
|
||||
: __fpclassify(x))
|
||||
|
||||
/* We don't need to worry about trucation here:
|
||||
A NaN stays a NaN. */
|
||||
|
||||
extern __inline__ int __isnan (double _x)
|
||||
{
|
||||
unsigned short sw;
|
||||
__asm__ ("fxam;"
|
||||
"fstsw %%ax": "=a" (sw) : "t" (_x));
|
||||
return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
|
||||
== FP_NAN;
|
||||
}
|
||||
|
||||
extern __inline__ int __isnanf (float _x)
|
||||
{
|
||||
unsigned short sw;
|
||||
__asm__ ("fxam;"
|
||||
"fstsw %%ax": "=a" (sw) : "t" (_x));
|
||||
return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
|
||||
== FP_NAN;
|
||||
}
|
||||
|
||||
#define isnan(x) ((sizeof(x) == sizeof(float)) ? __isnanf(x) \
|
||||
: __isnan(x))
|
||||
|
||||
|
||||
#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
|
||||
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
||||
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
|
||||
|
||||
|
||||
extern __inline__ int __signbit (double x) {
|
||||
unsigned short stw;
|
||||
__asm__ ( "fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
|
||||
return stw & 0x0200;
|
||||
}
|
||||
|
||||
extern __inline__ int __signbitf (float x) {
|
||||
unsigned short stw;
|
||||
__asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x));
|
||||
return stw & 0x0200;
|
||||
}
|
||||
|
||||
#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) \
|
||||
: __signbit(x))
|
||||
/*
|
||||
* With these functions, comparisons involving quiet NaNs set the FP
|
||||
* condition code to "unordered". The IEEE floating-point spec
|
||||
* dictates that the result of floating-point comparisons should be
|
||||
* false whenever a NaN is involved, with the exception of the !=,
|
||||
* which always returns true.
|
||||
*/
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
|
||||
#define isgreater(x, y) __builtin_isgreater(x, y)
|
||||
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
|
||||
#define isless(x, y) __builtin_isless(x, y)
|
||||
#define islessequal(x, y) __builtin_islessequal(x, y)
|
||||
#define islessgreater(x, y) __builtin_islessgreater(x, y)
|
||||
#define isunordered(x, y) __builtin_isunordered(x, y)
|
||||
|
||||
#else
|
||||
/* helper */
|
||||
extern __inline__ int __fp_unordered_compare (double x, double y){
|
||||
unsigned short retval;
|
||||
__asm__ ("fucom %%st(1);"
|
||||
"fnstsw;": "=a" (retval) : "t" (x), "u" (y));
|
||||
return retval;
|
||||
}
|
||||
|
||||
#define isgreater(x, y) ((__fp_unordered_compare(x, y) \
|
||||
& 0x4500) == 0)
|
||||
#define isless(x, y) ((__fp_unordered_compare (y, x) \
|
||||
& 0x4500) == 0)
|
||||
#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y) \
|
||||
& FP_INFINITE) == 0)
|
||||
#define islessequal(x, y) ((__fp_unordered_compare(y, x) \
|
||||
& FP_INFINITE) == 0)
|
||||
#define islessgreater(x, y) ((__fp_unordered_compare(x, y) \
|
||||
& FP_SUBNORMAL) == 0)
|
||||
#define isunordered(x, y) ((__fp_unordered_compare(x, y) \
|
||||
& 0x4500) == 0x4500)
|
||||
|
||||
#endif
|
||||
|
||||
/* round, using fpu control word settings */
|
||||
extern __inline__ double rint (double x)
|
||||
{
|
||||
double retval;
|
||||
__asm__ ("frndint;": "=t" (retval) : "0" (x));
|
||||
return retval;
|
||||
}
|
||||
|
||||
extern __inline__ float rintf (float x)
|
||||
{
|
||||
float retval;
|
||||
__asm__ ("frndint;" : "=t" (retval) : "0" (x) );
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* round away from zero, regardless of fpu control word settings */
|
||||
extern double round (double);
|
||||
extern float roundf (float);
|
||||
|
||||
/* round towards zero, regardless of fpu control word settings */
|
||||
extern double trunc (double);
|
||||
extern float truncf (float);
|
||||
|
||||
|
||||
/* fmax and fmin.
|
||||
NaN arguments are treated as missing data: if one argument is a NaN and the other numeric, then the
|
||||
these functions choose the numeric value.
|
||||
*/
|
||||
|
||||
extern double fmax (double, double);
|
||||
extern double fmin (double, double);
|
||||
extern float fmaxf (float, float);
|
||||
float fminf (float, float);
|
||||
|
||||
/* return x * y + z as a ternary op */
|
||||
extern double fma (double, double, double);
|
||||
extern float fmaf (float, float, float);
|
||||
|
||||
/* one lonely transcendental */
|
||||
extern double log2 (double _x);
|
||||
extern float log2f (float _x);
|
||||
|
||||
/* The underscored versions are in MSVCRT.dll.
|
||||
The stubs for these are in libmingwex.a */
|
||||
|
||||
double copysign (double, double);
|
||||
float copysignf (float, float);
|
||||
double logb (double);
|
||||
float logbf (float);
|
||||
double nextafter (double, double);
|
||||
float nextafterf (float, float);
|
||||
double scalb (double, long);
|
||||
float scalbf (float, long);
|
||||
|
||||
#if !defined (__STRICT_ANSI__) /* inline using non-ANSI functions */
|
||||
extern __inline__ double copysign (double x, double y)
|
||||
{ return _copysign(x, y); }
|
||||
extern __inline__ float copysignf (float x, float y)
|
||||
{ return _copysign(x, y); }
|
||||
extern __inline__ double logb (double x)
|
||||
{ return _logb(x); }
|
||||
extern __inline__ float logbf (float x)
|
||||
{ return _logb(x); }
|
||||
extern __inline__ double nextafter(double x, double y)
|
||||
{ return _nextafter(x, y); }
|
||||
extern __inline__ float nextafterf(float x, float y)
|
||||
{ return _nextafter(x, y); }
|
||||
extern __inline__ double scalb (double x, long i)
|
||||
{ return _scalb (x, i); }
|
||||
extern __inline__ float scalbf (float x, long i)
|
||||
{ return _scalb(x, i); }
|
||||
#endif /* (__STRICT_ANSI__) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* __NO_ISOCEXT */
|
||||
|
||||
#endif /* Not _MATH_H_ */
|
||||
|
||||
8
win32/include/mem.h
Normal file
8
win32/include/mem.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* mem.h maps to string.h
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include <string.h>
|
||||
#endif
|
||||
9
win32/include/memory.h
Normal file
9
win32/include/memory.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* memory.h maps to the standard string.h header.
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
158
win32/include/process.h
Normal file
158
win32/include/process.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* process.h
|
||||
*
|
||||
* Function calls for spawning child processes.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _PROCESS_H_
|
||||
#define _PROCESS_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/* Includes a definition of _pid_t and pid_t */
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Constants for cwait actions.
|
||||
* Obsolete for Win32.
|
||||
*/
|
||||
#define _WAIT_CHILD 0
|
||||
#define _WAIT_GRANDCHILD 1
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
#define WAIT_CHILD _WAIT_CHILD
|
||||
#define WAIT_GRANDCHILD _WAIT_GRANDCHILD
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
/*
|
||||
* Mode constants for spawn functions.
|
||||
*/
|
||||
#define _P_WAIT 0
|
||||
#define _P_NOWAIT 1
|
||||
#define _P_OVERLAY 2
|
||||
#define _OLD_P_OVERLAY _P_OVERLAY
|
||||
#define _P_NOWAITO 3
|
||||
#define _P_DETACH 4
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
#define P_WAIT _P_WAIT
|
||||
#define P_NOWAIT _P_NOWAIT
|
||||
#define P_OVERLAY _P_OVERLAY
|
||||
#define OLD_P_OVERLAY _OLD_P_OVERLAY
|
||||
#define P_NOWAITO _P_NOWAITO
|
||||
#define P_DETACH _P_DETACH
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void _cexit(void);
|
||||
void _c_exit(void);
|
||||
|
||||
int _cwait (int*, _pid_t, int);
|
||||
|
||||
_pid_t _getpid(void);
|
||||
|
||||
int _execl (const char*, const char*, ...);
|
||||
int _execle (const char*, const char*, ...);
|
||||
int _execlp (const char*, const char*, ...);
|
||||
int _execlpe (const char*, const char*, ...);
|
||||
int _execv (const char*, char* const*);
|
||||
int _execve (const char*, char* const*, char* const*);
|
||||
int _execvp (const char*, char* const*);
|
||||
int _execvpe (const char*, char* const*, char* const*);
|
||||
|
||||
int _spawnl (int, const char*, const char*, ...);
|
||||
int _spawnle (int, const char*, const char*, ...);
|
||||
int _spawnlp (int, const char*, const char*, ...);
|
||||
int _spawnlpe (int, const char*, const char*, ...);
|
||||
int _spawnv (int, const char*, char* const*);
|
||||
int _spawnve (int, const char*, char* const*, char* const*);
|
||||
int _spawnvp (int, const char*, char* const*);
|
||||
int _spawnvpe (int, const char*, char* const*, char* const*);
|
||||
|
||||
/*
|
||||
* The functions _beginthreadex and _endthreadex are not provided by CRTDLL.
|
||||
* They are provided by MSVCRT.
|
||||
*
|
||||
* NOTE: Apparently _endthread calls CloseHandle on the handle of the thread,
|
||||
* making for race conditions if you are not careful. Basically you have to
|
||||
* make sure that no-one is going to do *anything* with the thread handle
|
||||
* after the thread calls _endthread or returns from the thread function.
|
||||
*
|
||||
* NOTE: No old names for these functions. Use the underscore.
|
||||
*/
|
||||
unsigned long
|
||||
_beginthread (void (*)(void *), unsigned, void*);
|
||||
void _endthread (void);
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
unsigned long
|
||||
_beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *),
|
||||
void*, unsigned, unsigned*);
|
||||
void _endthreadex (unsigned);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
/*
|
||||
* Functions without the leading underscore, for portability. These functions
|
||||
* live in liboldnames.a.
|
||||
*/
|
||||
int cwait (int*, pid_t, int);
|
||||
pid_t getpid (void);
|
||||
int execl (const char*, const char*, ...);
|
||||
int execle (const char*, const char*, ...);
|
||||
int execlp (const char*, const char*, ...);
|
||||
int execlpe (const char*, const char*, ...);
|
||||
int execv (const char*, char* const*);
|
||||
int execve (const char*, char* const*, char* const*);
|
||||
int execvp (const char*, char* const*);
|
||||
int execvpe (const char*, char* const*, char* const*);
|
||||
int spawnl (int, const char*, const char*, ...);
|
||||
int spawnle (int, const char*, const char*, ...);
|
||||
int spawnlp (int, const char*, const char*, ...);
|
||||
int spawnlpe (int, const char*, const char*, ...);
|
||||
int spawnv (int, const char*, char* const*);
|
||||
int spawnve (int, const char*, char* const*, char* const*);
|
||||
int spawnvp (int, const char*, char* const*);
|
||||
int spawnvpe (int, const char*, char* const*, char* const*);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* _PROCESS_H_ not defined */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
72
win32/include/setjmp.h
Normal file
72
win32/include/setjmp.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* setjmp.h
|
||||
*
|
||||
* Declarations supporting setjmp and longjump, a method for avoiding
|
||||
* the normal function call return sequence. (Bleah!)
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SETJMP_H_
|
||||
#define _SETJMP_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The buffer used by setjmp to store the information used by longjmp
|
||||
* to perform it's evil goto-like work. The size of this buffer was
|
||||
* determined through experimentation; it's contents are a mystery.
|
||||
* NOTE: This was determined on an i386 (actually a Pentium). The
|
||||
* contents could be different on an Alpha or something else.
|
||||
*/
|
||||
#define _JBLEN 16
|
||||
#define _JBTYPE int
|
||||
typedef _JBTYPE jmp_buf[_JBLEN];
|
||||
|
||||
/*
|
||||
* The function provided by CRTDLL which appears to do the actual work
|
||||
* of setjmp.
|
||||
*/
|
||||
int _setjmp (jmp_buf);
|
||||
|
||||
#define setjmp(x) _setjmp(x)
|
||||
|
||||
/*
|
||||
* Return to the last setjmp call and act as if setjmp had returned
|
||||
* nVal (which had better be non-zero!).
|
||||
*/
|
||||
void longjmp (jmp_buf, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _SETJMP_H_ */
|
||||
|
||||
44
win32/include/share.h
Normal file
44
win32/include/share.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* share.h
|
||||
*
|
||||
* Constants for file sharing functions.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _SHARE_H_
|
||||
#define _SHARE_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define SH_COMPAT 0x00 /* Compatibility */
|
||||
#define SH_DENYRW 0x10 /* Deny read/write */
|
||||
#define SH_DENYWR 0x20 /* Deny write */
|
||||
#define SH_DENYRD 0x30 /* Deny read */
|
||||
#define SH_DENYNO 0x40 /* Deny nothing */
|
||||
|
||||
#endif /* Not _SHARE_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
111
win32/include/signal.h
Normal file
111
win32/include/signal.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* signal.h
|
||||
*
|
||||
* A way to set handlers for exceptional conditions (also known as signals).
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SIGNAL_H_
|
||||
#define _SIGNAL_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* The actual signal values. Using other values with signal
|
||||
* produces a SIG_ERR return value.
|
||||
*
|
||||
* NOTE: SIGINT is produced when the user presses Ctrl-C.
|
||||
* SIGILL has not been tested.
|
||||
* SIGFPE doesn't seem to work?
|
||||
* SIGSEGV does not catch writing to a NULL pointer (that shuts down
|
||||
* your app; can you say "segmentation violation core dump"?).
|
||||
* SIGTERM comes from what kind of termination request exactly?
|
||||
* SIGBREAK is indeed produced by pressing Ctrl-Break.
|
||||
* SIGABRT is produced by calling abort.
|
||||
* TODO: The above results may be related to not installing an appropriate
|
||||
* structured exception handling frame. Results may be better if I ever
|
||||
* manage to get the SEH stuff down.
|
||||
*/
|
||||
#define SIGINT 2 /* Interactive attention */
|
||||
#define SIGILL 4 /* Illegal instruction */
|
||||
#define SIGFPE 8 /* Floating point error */
|
||||
#define SIGSEGV 11 /* Segmentation violation */
|
||||
#define SIGTERM 15 /* Termination request */
|
||||
#define SIGBREAK 21 /* Control-break */
|
||||
#define SIGABRT 22 /* Abnormal termination (abort) */
|
||||
|
||||
#define NSIG 23 /* maximum signal number + 1 */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifndef _SIG_ATOMIC_T_DEFINED
|
||||
typedef int sig_atomic_t;
|
||||
#define _SIG_ATOMIC_T_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The prototypes (below) are the easy part. The hard part is figuring
|
||||
* out what signals are available and what numbers they are assigned
|
||||
* along with appropriate values of SIG_DFL and SIG_IGN.
|
||||
*/
|
||||
|
||||
/*
|
||||
* A pointer to a signal handler function. A signal handler takes a
|
||||
* single int, which is the signal it handles.
|
||||
*/
|
||||
typedef void (*__p_sig_fn_t)(int);
|
||||
|
||||
/*
|
||||
* These are special values of signal handler pointers which are
|
||||
* used to send a signal to the default handler (SIG_DFL), ignore
|
||||
* the signal (SIG_IGN), or indicate an error return (SIG_ERR).
|
||||
*/
|
||||
#define SIG_DFL ((__p_sig_fn_t) 0)
|
||||
#define SIG_IGN ((__p_sig_fn_t) 1)
|
||||
#define SIG_ERR ((__p_sig_fn_t) -1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Call signal to set the signal handler for signal sig to the
|
||||
* function pointed to by handler. Returns a pointer to the
|
||||
* previous handler, or SIG_ERR if an error occurs. Initially
|
||||
* unhandled signals defined above will return SIG_DFL.
|
||||
*/
|
||||
__p_sig_fn_t signal(int, __p_sig_fn_t);
|
||||
|
||||
/*
|
||||
* Raise the signal indicated by sig. Returns non-zero on success.
|
||||
*/
|
||||
int raise (int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _SIGNAL_H_ */
|
||||
|
||||
@@ -6,6 +6,7 @@ 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)
|
||||
|
||||
/* fix a buggy dependency on GCC in libio.h */
|
||||
10
win32/include/stdbool.h
Normal file
10
win32/include/stdbool.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _STDBOOL_H
|
||||
#define _STDBOOL_H
|
||||
|
||||
/* ISOC99 boolean */
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#endif /* _STDBOOL_H */
|
||||
@@ -10,12 +10,14 @@ typedef __PTRDIFF_TYPE__ ptrdiff_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__ ? */
|
||||
#ifndef __int8_t_defined
|
||||
#if !defined(__int8_t_defined) && !defined(__dietlibc__)
|
||||
#define __int8_t_defined
|
||||
typedef char int8_t;
|
||||
typedef short int int16_t;
|
||||
typedef int int32_t;
|
||||
typedef char int8_t;
|
||||
typedef short int int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long long int int64_t;
|
||||
#endif
|
||||
|
||||
void *alloca(size_t);
|
||||
|
||||
#endif
|
||||
184
win32/include/stdint.h
Normal file
184
win32/include/stdint.h
Normal file
@@ -0,0 +1,184 @@
|
||||
/* ISO C9x 7.18 Integer types <stdint.h>
|
||||
* Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Date: 2000-12-02
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _STDINT_H
|
||||
#define _STDINT_H
|
||||
|
||||
/* 7.18.1.1 Exact-width integer types */
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned uint32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
/* 7.18.1.2 Minimum-width integer types */
|
||||
typedef signed char int_least8_t;
|
||||
typedef unsigned char uint_least8_t;
|
||||
typedef short int_least16_t;
|
||||
typedef unsigned short uint_least16_t;
|
||||
typedef int int_least32_t;
|
||||
typedef unsigned uint_least32_t;
|
||||
typedef long long int_least64_t;
|
||||
typedef unsigned long long uint_least64_t;
|
||||
|
||||
/* 7.18.1.3 Fastest minimum-width integer types
|
||||
* Not actually guaranteed to be fastest for all purposes
|
||||
* Here we use the exact-width types for 8 and 16-bit ints.
|
||||
*/
|
||||
typedef char int_fast8_t;
|
||||
typedef unsigned char uint_fast8_t;
|
||||
typedef short int_fast16_t;
|
||||
typedef unsigned short uint_fast16_t;
|
||||
typedef int int_fast32_t;
|
||||
typedef unsigned int uint_fast32_t;
|
||||
typedef long long int_fast64_t;
|
||||
typedef unsigned long long uint_fast64_t;
|
||||
|
||||
/* 7.18.1.4 Integer types capable of holding object pointers */
|
||||
typedef int intptr_t;
|
||||
typedef unsigned uintptr_t;
|
||||
|
||||
/* 7.18.1.5 Greatest-width integer types */
|
||||
typedef long long intmax_t;
|
||||
typedef unsigned long long uintmax_t;
|
||||
|
||||
/* 7.18.2 Limits of specified-width integer types */
|
||||
#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
|
||||
|
||||
/* 7.18.2.1 Limits of exact-width integer types */
|
||||
#define INT8_MIN (-128)
|
||||
#define INT16_MIN (-32768)
|
||||
#define INT32_MIN (-2147483647 - 1)
|
||||
#define INT64_MIN (-9223372036854775807LL - 1)
|
||||
|
||||
#define INT8_MAX 127
|
||||
#define INT16_MAX 32767
|
||||
#define INT32_MAX 2147483647
|
||||
#define INT64_MAX 9223372036854775807LL
|
||||
|
||||
#define UINT8_MAX 0xff /* 255U */
|
||||
#define UINT16_MAX 0xffff /* 65535U */
|
||||
#define UINT32_MAX 0xffffffff /* 4294967295U */
|
||||
#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
|
||||
|
||||
/* 7.18.2.2 Limits of minimum-width integer types */
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
/* 7.18.2.3 Limits of fastest minimum-width integer types */
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
/* 7.18.2.4 Limits of integer types capable of holding
|
||||
object pointers */
|
||||
#define INTPTR_MIN INT32_MIN
|
||||
#define INTPTR_MAX INT32_MAX
|
||||
#define UINTPTR_MAX UINT32_MAX
|
||||
|
||||
/* 7.18.2.5 Limits of greatest-width integer types */
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
/* 7.18.3 Limits of other integer types */
|
||||
#define PTRDIFF_MIN INT32_MIN
|
||||
#define PTRDIFF_MAX INT32_MAX
|
||||
|
||||
#define SIG_ATOMIC_MIN INT32_MIN
|
||||
#define SIG_ATOMIC_MAX INT32_MAX
|
||||
|
||||
#define SIZE_MAX UINT32_MAX
|
||||
|
||||
#ifndef WCHAR_MIN /* also in wchar.h */
|
||||
#define WCHAR_MIN 0
|
||||
#define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wint_t is unsigned int in __MINGW32__,
|
||||
* but unsigned short in MS runtime
|
||||
*/
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX UINT32_MAX
|
||||
|
||||
#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
|
||||
|
||||
|
||||
/* 7.18.4 Macros for integer constants */
|
||||
#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
|
||||
|
||||
/* 7.18.4.1 Macros for minimum-width integer constants
|
||||
|
||||
Accoding to Douglas Gwyn <gwyn@arl.mil>:
|
||||
"This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
|
||||
9899:1999 as initially published, the expansion was required
|
||||
to be an integer constant of precisely matching type, which
|
||||
is impossible to accomplish for the shorter types on most
|
||||
platforms, because C99 provides no standard way to designate
|
||||
an integer constant with width less than that of type int.
|
||||
TC1 changed this to require just an integer constant
|
||||
*expression* with *promoted* type."
|
||||
|
||||
The trick used here is from Clive D W Feather.
|
||||
*/
|
||||
|
||||
#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val))
|
||||
#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val))
|
||||
#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val))
|
||||
#define INT64_C(val) (INT_LEAST64_MAX-INT_LEAST64_MAX+(val))
|
||||
|
||||
#define UINT8_C(val) (UINT_LEAST8_MAX-UINT_LEAST8_MAX+(val))
|
||||
#define UINT16_C(val) (UINT_LEAST16_MAX-UINT_LEAST16_MAX+(val))
|
||||
#define UINT32_C(val) (UINT_LEAST32_MAX-UINT_LEAST32_MAX+(val))
|
||||
#define UINT64_C(val) (UINT_LEAST64_MAX-UINT_LEAST64_MAX+(val))
|
||||
|
||||
/* 7.18.4.2 Macros for greatest-width integer constants */
|
||||
#define INTMAX_C(val) (INTMAX_MAX-INTMAX_MAX+(val))
|
||||
#define UINTMAX_C(val) (UINTMAX_MAX-UINTMAX_MAX+(val))
|
||||
|
||||
#endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
|
||||
|
||||
#endif
|
||||
413
win32/include/stdio.h
Normal file
413
win32/include/stdio.h
Normal file
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
* stdio.h
|
||||
*
|
||||
* Definitions of types and prototypes of functions for standard input and
|
||||
* output.
|
||||
*
|
||||
* NOTE: The file manipulation functions provided by Microsoft seem to
|
||||
* work with either slash (/) or backslash (\) as the path separator.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STDIO_H_
|
||||
#define _STDIO_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#define __need_wchar_t
|
||||
#define __need_wint_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
|
||||
/* Flags for the iobuf structure */
|
||||
#define _IOREAD 1
|
||||
#define _IOWRT 2
|
||||
#define _IORW 0x0080 /* opened as "r+w" */
|
||||
|
||||
|
||||
/*
|
||||
* The three standard file pointers provided by the run time library.
|
||||
* NOTE: These will go to the bit-bucket silently in GUI applications!
|
||||
*/
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
|
||||
/* Returned by various functions on end of file condition or error. */
|
||||
#define EOF (-1)
|
||||
|
||||
/*
|
||||
* The maximum length of a file name. You should use GetVolumeInformation
|
||||
* instead of this constant. But hey, this works.
|
||||
*
|
||||
* NOTE: This is used in the structure _finddata_t (see io.h) so changing it
|
||||
* is probably not a good idea.
|
||||
*/
|
||||
#define FILENAME_MAX (260)
|
||||
|
||||
/*
|
||||
* The maximum number of files that may be open at once. I have set this to
|
||||
* a conservative number. The actual value may be higher.
|
||||
*/
|
||||
#define FOPEN_MAX (20)
|
||||
|
||||
/* After creating this many names, tmpnam and tmpfile return NULL */
|
||||
#define TMP_MAX 32767
|
||||
/*
|
||||
* Tmpnam, tmpfile and, sometimes, _tempnam try to create
|
||||
* temp files in the root directory of the current drive
|
||||
* (not in pwd, as suggested by some older MS doc's).
|
||||
* Redefining these macros does not effect the CRT functions.
|
||||
*/
|
||||
#define _P_tmpdir "\\"
|
||||
#define _wP_tmpdir L"\\"
|
||||
|
||||
/*
|
||||
* The maximum size of name (including NUL) that will be put in the user
|
||||
* supplied buffer caName for tmpnam.
|
||||
* Inferred from the size of the static buffer returned by tmpnam
|
||||
* when passed a NULL argument. May actually be smaller.
|
||||
*/
|
||||
#define L_tmpnam (16)
|
||||
|
||||
#define _IOFBF 0x0000
|
||||
#define _IOLBF 0x0040
|
||||
#define _IONBF 0x0004
|
||||
|
||||
/*
|
||||
* The buffer size as used by setbuf such that it is equivalent to
|
||||
* (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
|
||||
*/
|
||||
#define BUFSIZ 512
|
||||
|
||||
/* Constants for nOrigin indicating the position relative to which fseek
|
||||
* sets the file position. Enclosed in ifdefs because io.h could also
|
||||
* define them. (Though not anymore since io.h includes this file now.) */
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET (0)
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR (1)
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END (2)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* I used to include stdarg.h at this point, in order to allow for the
|
||||
* functions later on in the file which use va_list. That conflicts with
|
||||
* using stdio.h and varargs.h in the same file, so I do the typedef myself.
|
||||
*/
|
||||
#ifndef _VA_LIST
|
||||
#define _VA_LIST
|
||||
#if defined __GNUC__ && __GNUC__ >= 3
|
||||
typedef __builtin_va_list va_list;
|
||||
#else
|
||||
typedef char* va_list;
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* The structure underlying the FILE type.
|
||||
*
|
||||
* I still believe that nobody in their right mind should make use of the
|
||||
* internals of this structure. Provided by Pedro A. Aranda Gutiirrez
|
||||
* <paag@tid.es>.
|
||||
*/
|
||||
#ifndef _FILE_DEFINED
|
||||
#define _FILE_DEFINED
|
||||
typedef struct _iobuf
|
||||
{
|
||||
char* _ptr;
|
||||
int _cnt;
|
||||
char* _base;
|
||||
int _flag;
|
||||
int _file;
|
||||
int _charbuf;
|
||||
int _bufsiz;
|
||||
char* _tmpfname;
|
||||
} FILE;
|
||||
#endif /* Not _FILE_DEFINED */
|
||||
|
||||
|
||||
/*
|
||||
* The standard file handles
|
||||
*/
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
|
||||
extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */
|
||||
|
||||
#define _iob (*__imp__iob) /* An array of FILE */
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
__MINGW_IMPORT FILE _iob[]; /* An array of FILE imported from DLL. */
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#define stdin (&_iob[STDIN_FILENO])
|
||||
#define stdout (&_iob[STDOUT_FILENO])
|
||||
#define stderr (&_iob[STDERR_FILENO])
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* File Operations
|
||||
*/
|
||||
FILE* fopen (const char*, const char*);
|
||||
FILE* freopen (const char*, const char*, FILE*);
|
||||
int fflush (FILE*);
|
||||
int fclose (FILE*);
|
||||
/* MS puts remove & rename (but not wide versions) in io.h also */
|
||||
int remove (const char*);
|
||||
int rename (const char*, const char*);
|
||||
FILE* tmpfile (void);
|
||||
char* tmpnam (char*);
|
||||
char* _tempnam (const char*, const char*);
|
||||
|
||||
#ifndef NO_OLDNAMES
|
||||
char* tempnam (const char*, const char*);
|
||||
#endif
|
||||
|
||||
int setvbuf (FILE*, char*, int, size_t);
|
||||
|
||||
void setbuf (FILE*, char*);
|
||||
|
||||
/*
|
||||
* Formatted Output
|
||||
*/
|
||||
|
||||
int fprintf (FILE*, const char*, ...);
|
||||
int printf (const char*, ...);
|
||||
int sprintf (char*, const char*, ...);
|
||||
int _snprintf (char*, size_t, const char*, ...);
|
||||
int vfprintf (FILE*, const char*, va_list);
|
||||
int vprintf (const char*, va_list);
|
||||
int vsprintf (char*, const char*, va_list);
|
||||
int _vsnprintf (char*, size_t, const char*, va_list);
|
||||
|
||||
#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
|
||||
int snprintf(char* s, size_t n, const char* format, ...);
|
||||
extern inline int vsnprintf (char* s, size_t n, const char* format,
|
||||
va_list arg)
|
||||
{ return _vsnprintf ( s, n, format, arg); }
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Formatted Input
|
||||
*/
|
||||
|
||||
int fscanf (FILE*, const char*, ...);
|
||||
int scanf (const char*, ...);
|
||||
int sscanf (const char*, const char*, ...);
|
||||
/*
|
||||
* Character Input and Output Functions
|
||||
*/
|
||||
|
||||
int fgetc (FILE*);
|
||||
char* fgets (char*, int, FILE*);
|
||||
int fputc (int, FILE*);
|
||||
int fputs (const char*, FILE*);
|
||||
int getc (FILE*);
|
||||
int getchar (void);
|
||||
char* gets (char*);
|
||||
int putc (int, FILE*);
|
||||
int putchar (int);
|
||||
int puts (const char*);
|
||||
int ungetc (int, FILE*);
|
||||
|
||||
/*
|
||||
* Direct Input and Output Functions
|
||||
*/
|
||||
|
||||
size_t fread (void*, size_t, size_t, FILE*);
|
||||
size_t fwrite (const void*, size_t, size_t, FILE*);
|
||||
|
||||
/*
|
||||
* File Positioning Functions
|
||||
*/
|
||||
|
||||
int fseek (FILE*, long, int);
|
||||
long ftell (FILE*);
|
||||
void rewind (FILE*);
|
||||
|
||||
#ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
|
||||
/*
|
||||
* Workaround for limitations on win9x where a file contents are
|
||||
* not zero'd out if you seek past the end and then write.
|
||||
*/
|
||||
|
||||
int __mingw_fseek (FILE *, long, int);
|
||||
int __mingw_fwrite (const void*, size_t, size_t, FILE*);
|
||||
#define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
|
||||
#define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
|
||||
#endif /* __USE_MINGW_FSEEK */
|
||||
|
||||
|
||||
/*
|
||||
* An opaque data type used for storing file positions... The contents of
|
||||
* this type are unknown, but we (the compiler) need to know the size
|
||||
* because the programmer using fgetpos and fsetpos will be setting aside
|
||||
* storage for fpos_t structres. Actually I tested using a byte array and
|
||||
* it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
|
||||
* Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
|
||||
* MSVCRT however, and for now `long long' will do.
|
||||
*/
|
||||
#ifdef __MSVCRT__
|
||||
typedef long long fpos_t;
|
||||
#else
|
||||
typedef long fpos_t;
|
||||
#endif
|
||||
|
||||
int fgetpos (FILE*, fpos_t*);
|
||||
int fsetpos (FILE*, const fpos_t*);
|
||||
|
||||
/*
|
||||
* Error Functions
|
||||
*/
|
||||
|
||||
void clearerr (FILE*);
|
||||
int feof (FILE*);
|
||||
int ferror (FILE*);
|
||||
void perror (const char*);
|
||||
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
/*
|
||||
* Pipes
|
||||
*/
|
||||
FILE* _popen (const char*, const char*);
|
||||
int _pclose (FILE*);
|
||||
|
||||
#ifndef NO_OLDNAMES
|
||||
FILE* popen (const char*, const char*);
|
||||
int pclose (FILE*);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Other Non ANSI functions
|
||||
*/
|
||||
int _flushall (void);
|
||||
int _fgetchar (void);
|
||||
int _fputchar (int);
|
||||
FILE* _fdopen (int, const char*);
|
||||
int _fileno (FILE*);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
int fgetchar (void);
|
||||
int fputchar (int);
|
||||
FILE* fdopen (int, const char*);
|
||||
int fileno (FILE*);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
/* Wide versions */
|
||||
|
||||
#ifndef _WSTDIO_DEFINED
|
||||
/* also in wchar.h - keep in sync */
|
||||
int fwprintf (FILE*, const wchar_t*, ...);
|
||||
int wprintf (const wchar_t*, ...);
|
||||
int swprintf (wchar_t*, const wchar_t*, ...);
|
||||
int _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
|
||||
int vfwprintf (FILE*, const wchar_t*, va_list);
|
||||
int vwprintf (const wchar_t*, va_list);
|
||||
int vswprintf (wchar_t*, const wchar_t*, va_list);
|
||||
int _vsnwprintf (wchar_t*, size_t, const wchar_t*, va_list);
|
||||
int fwscanf (FILE*, const wchar_t*, ...);
|
||||
int wscanf (const wchar_t*, ...);
|
||||
int swscanf (const wchar_t*, const wchar_t*, ...);
|
||||
wint_t fgetwc (FILE*);
|
||||
wint_t fputwc (wchar_t, FILE*);
|
||||
wint_t ungetwc (wchar_t, FILE*);
|
||||
#ifdef __MSVCRT__
|
||||
wchar_t* fgetws (wchar_t*, int, FILE*);
|
||||
int fputws (const wchar_t*, FILE*);
|
||||
wint_t getwc (FILE*);
|
||||
wint_t getwchar (void);
|
||||
wchar_t* _getws (wchar_t*);
|
||||
wint_t putwc (wint_t, FILE*);
|
||||
int _putws (const wchar_t*);
|
||||
wint_t putwchar (wint_t);
|
||||
FILE* _wfopen (const wchar_t*, const wchar_t*);
|
||||
FILE* _wfreopen (const wchar_t*, const wchar_t*, FILE*);
|
||||
FILE* _wfsopen (const wchar_t*, const wchar_t*, int);
|
||||
wchar_t* _wtmpnam (wchar_t*);
|
||||
wchar_t* _wtempnam (const wchar_t*, const wchar_t*);
|
||||
int _wrename (const wchar_t*, const wchar_t*);
|
||||
int _wremove (const wchar_t*);
|
||||
void _wperror (const wchar_t*);
|
||||
FILE* _wpopen (const wchar_t*, const wchar_t*);
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
|
||||
int snwprintf(wchar_t* s, size_t n, const wchar_t* format, ...);
|
||||
extern inline int vsnwprintf (wchar_t* s, size_t n, const wchar_t* format,
|
||||
va_list arg)
|
||||
{ return _vsnwprintf ( s, n, format, arg); }
|
||||
#endif
|
||||
|
||||
#define _WSTDIO_DEFINED
|
||||
#endif /* _WSTDIO_DEFINED */
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#ifdef __MSVCRT__
|
||||
#ifndef NO_OLDNAMES
|
||||
FILE* wpopen (const wchar_t*, const wchar_t*);
|
||||
#endif /* not NO_OLDNAMES */
|
||||
#endif /* MSVCRT runtime */
|
||||
|
||||
/*
|
||||
* Other Non ANSI wide functions
|
||||
*/
|
||||
wint_t _fgetwchar (void);
|
||||
wint_t _fputwchar (wint_t);
|
||||
int _getw (FILE*);
|
||||
int _putw (int, FILE*);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
wint_t fgetwchar (void);
|
||||
wint_t fputwchar (wint_t);
|
||||
int getw (FILE*);
|
||||
int putw (int, FILE*);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#endif /* __STRICT_ANSI */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* _STDIO_H_ */
|
||||
482
win32/include/stdlib.h
Normal file
482
win32/include/stdlib.h
Normal file
@@ -0,0 +1,482 @@
|
||||
/*
|
||||
* stdlib.h
|
||||
*
|
||||
* Definitions for common types, variables, and functions.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STDLIB_H_
|
||||
#define _STDLIB_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_wchar_t
|
||||
#define __need_NULL
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* RC_INVOKED */
|
||||
|
||||
/*
|
||||
* RAND_MAX is the maximum value that may be returned by rand.
|
||||
* The minimum is zero.
|
||||
*/
|
||||
#define RAND_MAX 0x7FFF
|
||||
|
||||
/*
|
||||
* These values may be used as exit status codes.
|
||||
*/
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
/*
|
||||
* Definitions for path name functions.
|
||||
* NOTE: All of these values have simply been chosen to be conservatively high.
|
||||
* Remember that with long file names we can no longer depend on
|
||||
* extensions being short.
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH (260)
|
||||
#endif
|
||||
|
||||
#define _MAX_PATH MAX_PATH
|
||||
#define _MAX_DRIVE (3)
|
||||
#define _MAX_DIR 256
|
||||
#define _MAX_FNAME 256
|
||||
#define _MAX_EXT 256
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This seems like a convenient place to declare these variables, which
|
||||
* give programs using WinMain (or main for that matter) access to main-ish
|
||||
* argc and argv. environ is a pointer to a table of environment variables.
|
||||
* NOTE: Strings in _argv and environ are ANSI strings.
|
||||
*/
|
||||
extern int _argc;
|
||||
extern char** _argv;
|
||||
|
||||
/* imports from runtime dll of the above variables */
|
||||
#ifdef __MSVCRT__
|
||||
|
||||
extern int* __p___argc(void);
|
||||
extern char*** __p___argv(void);
|
||||
extern wchar_t*** __p___wargv(void);
|
||||
|
||||
#define __argc (*__p___argc())
|
||||
#define __argv (*__p___argv())
|
||||
#define __wargv (*__p___wargv())
|
||||
|
||||
#else /* !MSVCRT */
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
|
||||
extern int* __imp___argc_dll;
|
||||
extern char*** __imp___argv_dll;
|
||||
#define __argc (*__imp___argc_dll)
|
||||
#define __argv (*__imp___argv_dll)
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
__MINGW_IMPORT int __argc_dll;
|
||||
__MINGW_IMPORT char** __argv_dll;
|
||||
#define __argc __argc_dll
|
||||
#define __argv __argv_dll
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#endif /* __MSVCRT */
|
||||
|
||||
/*
|
||||
* Also defined in ctype.h.
|
||||
*/
|
||||
|
||||
#ifndef MB_CUR_MAX
|
||||
# ifdef __MSVCRT__
|
||||
# define MB_CUR_MAX __mb_cur_max
|
||||
__MINGW_IMPORT int __mb_cur_max;
|
||||
# else /* not __MSVCRT */
|
||||
# define MB_CUR_MAX __mb_cur_max_dll
|
||||
__MINGW_IMPORT int __mb_cur_max_dll;
|
||||
# endif /* not __MSVCRT */
|
||||
#endif /* MB_CUR_MAX */
|
||||
|
||||
/*
|
||||
* MS likes to declare errno in stdlib.h as well.
|
||||
*/
|
||||
|
||||
#ifdef _UWIN
|
||||
#undef errno
|
||||
extern int errno;
|
||||
#else
|
||||
int* _errno(void);
|
||||
#define errno (*_errno())
|
||||
#endif
|
||||
int* __doserrno(void);
|
||||
#define _doserrno (*__doserrno())
|
||||
|
||||
/*
|
||||
* Use environ from the DLL, not as a global.
|
||||
*/
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
extern char *** __p__environ(void);
|
||||
extern wchar_t *** __p__wenviron(void);
|
||||
# define _environ (*__p__environ())
|
||||
# define _wenviron (*__p__wenviron())
|
||||
#else /* ! __MSVCRT__ */
|
||||
# ifndef __DECLSPEC_SUPPORTED
|
||||
extern char *** __imp__environ_dll;
|
||||
# define _environ (*__imp__environ_dll)
|
||||
# else /* __DECLSPEC_SUPPORTED */
|
||||
__MINGW_IMPORT char ** _environ_dll;
|
||||
# define _environ _environ_dll
|
||||
# endif /* __DECLSPEC_SUPPORTED */
|
||||
#endif /* ! __MSVCRT__ */
|
||||
|
||||
#define environ _environ
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
/* One of the MSVCRTxx libraries */
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
extern int* __imp__sys_nerr;
|
||||
# define sys_nerr (*__imp__sys_nerr)
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
__MINGW_IMPORT int _sys_nerr;
|
||||
# ifndef _UWIN
|
||||
# define sys_nerr _sys_nerr
|
||||
# endif /* _UWIN */
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#else /* ! __MSVCRT__ */
|
||||
|
||||
/* CRTDLL run time library */
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
extern int* __imp__sys_nerr_dll;
|
||||
# define sys_nerr (*__imp__sys_nerr_dll)
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
__MINGW_IMPORT int _sys_nerr_dll;
|
||||
# define sys_nerr _sys_nerr_dll
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#endif /* ! __MSVCRT__ */
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
extern char*** __imp__sys_errlist;
|
||||
#define sys_errlist (*__imp__sys_errlist)
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
__MINGW_IMPORT char* _sys_errlist[];
|
||||
#ifndef _UWIN
|
||||
#define sys_errlist _sys_errlist
|
||||
#endif /* _UWIN */
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
/*
|
||||
* OS version and such constants.
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
/* msvcrtxx.dll */
|
||||
|
||||
extern unsigned int* __p__osver(void);
|
||||
extern unsigned int* __p__winver(void);
|
||||
extern unsigned int* __p__winmajor(void);
|
||||
extern unsigned int* __p__winminor(void);
|
||||
|
||||
#define _osver (*__p__osver())
|
||||
#define _winver (*__p__winver())
|
||||
#define _winmajor (*__p__winmajor())
|
||||
#define _winminor (*__p__winminor())
|
||||
|
||||
#else
|
||||
/* Not msvcrtxx.dll, thus crtdll.dll */
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
|
||||
extern unsigned int* _imp___osver_dll;
|
||||
extern unsigned int* _imp___winver_dll;
|
||||
extern unsigned int* _imp___winmajor_dll;
|
||||
extern unsigned int* _imp___winminor_dll;
|
||||
|
||||
#define _osver (*_imp___osver_dll)
|
||||
#define _winver (*_imp___winver_dll)
|
||||
#define _winmajor (*_imp___winmajor_dll)
|
||||
#define _winminor (*_imp___winminor_dll)
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
__MINGW_IMPORT unsigned int _osver_dll;
|
||||
__MINGW_IMPORT unsigned int _winver_dll;
|
||||
__MINGW_IMPORT unsigned int _winmajor_dll;
|
||||
__MINGW_IMPORT unsigned int _winminor_dll;
|
||||
|
||||
#define _osver _osver_dll
|
||||
#define _winver _winver_dll
|
||||
#define _winmajor _winmajor_dll
|
||||
#define _winminor _winminor_dll
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#endif
|
||||
|
||||
#if defined __MSVCRT__
|
||||
/* although the _pgmptr is exported as DATA,
|
||||
* be safe and use the access function __p__pgmptr() to get it. */
|
||||
char** __p__pgmptr(void);
|
||||
#define _pgmptr (*__p__pgmptr())
|
||||
wchar_t** __p__wpgmptr(void);
|
||||
#define _wpgmptr (*__p__wpgmptr())
|
||||
#else /* ! __MSVCRT__ */
|
||||
# ifndef __DECLSPEC_SUPPORTED
|
||||
extern char** __imp__pgmptr_dll;
|
||||
# define _pgmptr (*__imp__pgmptr_dll)
|
||||
# else /* __DECLSPEC_SUPPORTED */
|
||||
__MINGW_IMPORT char* _pgmptr_dll;
|
||||
# define _pgmptr _pgmptr_dll
|
||||
# endif /* __DECLSPEC_SUPPORTED */
|
||||
/* no wide version in CRTDLL */
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _ATTRIB_NORETURN __attribute__ ((noreturn))
|
||||
#else /* Not __GNUC__ */
|
||||
#define _ATTRIB_NORETURN
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
double atof (const char*);
|
||||
int atoi (const char*);
|
||||
long atol (const char*);
|
||||
int _wtoi (const wchar_t *);
|
||||
long _wtol (const wchar_t *);
|
||||
|
||||
double strtod (const char*, char**);
|
||||
#if !defined __NO_ISOCEXT /* extern stubs in static libmingwex.a */
|
||||
extern __inline__ float strtof (const char *nptr, char **endptr)
|
||||
{ return (strtod (nptr, endptr));}
|
||||
#endif /* __NO_ISOCEXT */
|
||||
|
||||
long strtol (const char*, char**, int);
|
||||
unsigned long strtoul (const char*, char**, int);
|
||||
|
||||
#ifndef _WSTDLIB_DEFINED
|
||||
/* also declared in wchar.h */
|
||||
double wcstod (const wchar_t*, wchar_t**);
|
||||
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
|
||||
extern __inline__ float wcstof( const wchar_t *nptr, wchar_t **endptr)
|
||||
{ return (wcstod(nptr, endptr)); }
|
||||
#endif /* __NO_ISOCEXT */
|
||||
|
||||
long wcstol (const wchar_t*, wchar_t**, int);
|
||||
unsigned long wcstoul (const wchar_t*, wchar_t**, int);
|
||||
#define _WSTDLIB_DEFINED
|
||||
#endif
|
||||
|
||||
size_t wcstombs (char*, const wchar_t*, size_t);
|
||||
int wctomb (char*, wchar_t);
|
||||
|
||||
int mblen (const char*, size_t);
|
||||
size_t mbstowcs (wchar_t*, const char*, size_t);
|
||||
int mbtowc (wchar_t*, const char*, size_t);
|
||||
|
||||
int rand (void);
|
||||
void srand (unsigned int);
|
||||
|
||||
void* calloc (size_t, size_t);
|
||||
void* malloc (size_t);
|
||||
void* realloc (void*, size_t);
|
||||
void free (void*);
|
||||
|
||||
void abort (void) _ATTRIB_NORETURN;
|
||||
void exit (int) _ATTRIB_NORETURN;
|
||||
int atexit (void (*)(void));
|
||||
|
||||
int system (const char*);
|
||||
char* getenv (const char*);
|
||||
|
||||
void* bsearch (const void*, const void*, size_t, size_t,
|
||||
int (*)(const void*, const void*));
|
||||
void qsort (const void*, size_t, size_t,
|
||||
int (*)(const void*, const void*));
|
||||
|
||||
int abs (int);
|
||||
long labs (long);
|
||||
|
||||
/*
|
||||
* div_t and ldiv_t are structures used to return the results of div and
|
||||
* ldiv.
|
||||
*
|
||||
* NOTE: div and ldiv appear not to work correctly unless
|
||||
* -fno-pcc-struct-return is specified. This is included in the
|
||||
* mingw32 specs file.
|
||||
*/
|
||||
typedef struct { int quot, rem; } div_t;
|
||||
typedef struct { long quot, rem; } ldiv_t;
|
||||
|
||||
div_t div (int, int);
|
||||
ldiv_t ldiv (long, long);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
/*
|
||||
* NOTE: Officially the three following functions are obsolete. The Win32 API
|
||||
* functions SetErrorMode, Beep and Sleep are their replacements.
|
||||
*/
|
||||
void _beep (unsigned int, unsigned int);
|
||||
void _seterrormode (int);
|
||||
void _sleep (unsigned long);
|
||||
|
||||
void _exit (int) _ATTRIB_NORETURN;
|
||||
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
|
||||
/* C99 function name */
|
||||
void _Exit(int) _ATTRIB_NORETURN; /* Declare to get noreturn attribute. */
|
||||
extern __inline__ void _Exit(int status)
|
||||
{ _exit(status); }
|
||||
#endif
|
||||
/* _onexit is MS extension. Use atexit for portability. */
|
||||
typedef int (* _onexit_t)(void);
|
||||
_onexit_t _onexit( _onexit_t );
|
||||
|
||||
int _putenv (const char*);
|
||||
void _searchenv (const char*, const char*, char*);
|
||||
|
||||
|
||||
char* _ecvt (double, int, int*, int*);
|
||||
char* _fcvt (double, int, int*, int*);
|
||||
char* _gcvt (double, int, char*);
|
||||
|
||||
void _makepath (char*, const char*, const char*, const char*, const char*);
|
||||
void _splitpath (const char*, char*, char*, char*, char*);
|
||||
char* _fullpath (char*, const char*, size_t);
|
||||
|
||||
|
||||
char* _itoa (int, char*, int);
|
||||
char* _ltoa (long, char*, int);
|
||||
char* _ultoa(unsigned long, char*, int);
|
||||
wchar_t* _itow (int, wchar_t*, int);
|
||||
wchar_t* _ltow (long, wchar_t*, int);
|
||||
wchar_t* _ultow (unsigned long, wchar_t*, int);
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
__int64 _atoi64(const char *);
|
||||
char* _i64toa(__int64, char *, int);
|
||||
char* _ui64toa(unsigned __int64, char *, int);
|
||||
__int64 _wtoi64(const wchar_t *);
|
||||
wchar_t* _i64tow(__int64, wchar_t *, int);
|
||||
wchar_t* _ui64tow(unsigned __int64, wchar_t *, int);
|
||||
|
||||
wchar_t* _wgetenv(const wchar_t*);
|
||||
int _wputenv(const wchar_t*);
|
||||
void _wsearchenv(const wchar_t*, const wchar_t*, wchar_t*);
|
||||
void _wmakepath(wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*);
|
||||
void _wsplitpath (const wchar_t*, wchar_t*, wchar_t*, wchar_t*, wchar_t*);
|
||||
wchar_t* _wfullpath (wchar_t*, const wchar_t*, size_t);
|
||||
#endif
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
int putenv (const char*);
|
||||
void searchenv (const char*, const char*, char*);
|
||||
|
||||
char* itoa (int, char*, int);
|
||||
char* ltoa (long, char*, int);
|
||||
|
||||
#ifndef _UWIN
|
||||
char* ecvt (double, int, int*, int*);
|
||||
char* fcvt (double, int, int*, int*);
|
||||
char* gcvt (double, int, char*);
|
||||
#endif /* _UWIN */
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
/* C99 names */
|
||||
|
||||
#if !defined __NO_ISOCEXT /* externs in static libmingwex.a */
|
||||
|
||||
typedef struct { long long quot, rem; } lldiv_t;
|
||||
|
||||
lldiv_t lldiv (long long, long long);
|
||||
|
||||
extern __inline__ long long llabs(long long _j)
|
||||
{return (_j >= 0 ? _j : -_j);}
|
||||
|
||||
long long strtoll (const char* __restrict__, char** __restrict, int);
|
||||
unsigned long long strtoull (const char* __restrict__, char** __restrict__, int);
|
||||
|
||||
#if defined (__MSVCRT__) /* these are stubs for MS _i64 versions */
|
||||
long long atoll (const char *);
|
||||
|
||||
#if !defined (__STRICT_ANSI__)
|
||||
long long wtoll(const wchar_t *);
|
||||
char* lltoa(long long, char *, int);
|
||||
char* ulltoa(unsigned long long , char *, int);
|
||||
wchar_t* lltow(long long, wchar_t *, int);
|
||||
wchar_t* ulltow(unsigned long long, wchar_t *, int);
|
||||
|
||||
/* inline using non-ansi functions */
|
||||
extern __inline__ long long atoll (const char * _c)
|
||||
{ return _atoi64 (_c); }
|
||||
extern __inline__ char* lltoa(long long _n, char * _c, int _i)
|
||||
{ return _i64toa (_n, _c, _i); }
|
||||
extern __inline__ char* ulltoa(unsigned long long _n, char * _c, int _i)
|
||||
{ return _ui64toa (_n, _c, _i); }
|
||||
extern __inline__ long long wtoll(const wchar_t * _w)
|
||||
{ return _wtoi64 (_w); }
|
||||
extern __inline__ wchar_t* lltow(long long _n, wchar_t * _w, int _i)
|
||||
{ return _i64tow (_n, _w, _i); }
|
||||
extern __inline__ wchar_t* ulltow(unsigned long long _n, wchar_t * _w, int _i)
|
||||
{ return _ui64tow (_n, _w, _i); }
|
||||
#endif /* (__STRICT_ANSI__) */
|
||||
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
#endif /* !__NO_ISOCEXT */
|
||||
|
||||
/*
|
||||
* Undefine the no return attribute used in some function definitions
|
||||
*/
|
||||
#undef _ATTRIB_NORETURN
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _STDLIB_H_ */
|
||||
|
||||
206
win32/include/string.h
Normal file
206
win32/include/string.h
Normal file
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* string.h
|
||||
*
|
||||
* Definitions for memory and string functions.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STRING_H_
|
||||
#define _STRING_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* Define size_t, wchar_t and NULL
|
||||
*/
|
||||
#define __need_size_t
|
||||
#define __need_wchar_t
|
||||
#define __need_NULL
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Prototypes of the ANSI Standard C library string functions.
|
||||
*/
|
||||
void* memchr (const void*, int, size_t);
|
||||
int memcmp (const void*, const void*, size_t);
|
||||
void* memcpy (void*, const void*, size_t);
|
||||
void* memmove (void*, const void*, size_t);
|
||||
void* memset (void*, int, size_t);
|
||||
char* strcat (char*, const char*);
|
||||
char* strchr (const char*, int);
|
||||
int strcmp (const char*, const char*);
|
||||
int strcoll (const char*, const char*); /* Compare using locale */
|
||||
char* strcpy (char*, const char*);
|
||||
size_t strcspn (const char*, const char*);
|
||||
char* strerror (int); /* NOTE: NOT an old name wrapper. */
|
||||
char* _strerror (const char *);
|
||||
size_t strlen (const char*);
|
||||
char* strncat (char*, const char*, size_t);
|
||||
int strncmp (const char*, const char*, size_t);
|
||||
char* strncpy (char*, const char*, size_t);
|
||||
char* strpbrk (const char*, const char*);
|
||||
char* strrchr (const char*, int);
|
||||
size_t strspn (const char*, const char*);
|
||||
char* strstr (const char*, const char*);
|
||||
char* strtok (char*, const char*);
|
||||
size_t strxfrm (char*, const char*, size_t);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
/*
|
||||
* Extra non-ANSI functions provided by the CRTDLL library
|
||||
*/
|
||||
void* _memccpy (void*, const void*, int, size_t);
|
||||
int _memicmp (const void*, const void*, size_t);
|
||||
char* _strdup (const char*);
|
||||
int _strcmpi (const char*, const char*);
|
||||
int _stricmp (const char*, const char*);
|
||||
int _stricoll (const char*, const char*);
|
||||
char* _strlwr (char*);
|
||||
int _strnicmp (const char*, const char*, size_t);
|
||||
char* _strnset (char*, int, size_t);
|
||||
char* _strrev (char*);
|
||||
char* _strset (char*, int);
|
||||
char* _strupr (char*);
|
||||
void _swab (const char*, char*, size_t);
|
||||
|
||||
/*
|
||||
* Multi-byte character functions
|
||||
*/
|
||||
unsigned char* _mbschr (unsigned char*, unsigned char*);
|
||||
unsigned char* _mbsncat (unsigned char*, const unsigned char*, size_t);
|
||||
unsigned char* _mbstok (unsigned char*, unsigned char*);
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
int _strncoll(const char*, const char*, size_t);
|
||||
int _strnicoll(const char*, const char*, size_t);
|
||||
#endif
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
/*
|
||||
* Unicode versions of the standard calls.
|
||||
*/
|
||||
wchar_t* wcscat (wchar_t*, const wchar_t*);
|
||||
wchar_t* wcschr (const wchar_t*, wchar_t);
|
||||
int wcscmp (const wchar_t*, const wchar_t*);
|
||||
int wcscoll (const wchar_t*, const wchar_t*);
|
||||
wchar_t* wcscpy (wchar_t*, const wchar_t*);
|
||||
size_t wcscspn (const wchar_t*, const wchar_t*);
|
||||
/* Note: No wcserror in CRTDLL. */
|
||||
size_t wcslen (const wchar_t*);
|
||||
wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t);
|
||||
int wcsncmp(const wchar_t*, const wchar_t*, size_t);
|
||||
wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
|
||||
wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
|
||||
wchar_t* wcsrchr(const wchar_t*, wchar_t);
|
||||
size_t wcsspn(const wchar_t*, const wchar_t*);
|
||||
wchar_t* wcsstr(const wchar_t*, const wchar_t*);
|
||||
wchar_t* wcstok(wchar_t*, const wchar_t*);
|
||||
size_t wcsxfrm(wchar_t*, const wchar_t*, size_t);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
/*
|
||||
* Unicode versions of non-ANSI functions provided by CRTDLL.
|
||||
*/
|
||||
|
||||
/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
|
||||
#define _wcscmpi _wcsicmp
|
||||
|
||||
wchar_t* _wcsdup (wchar_t*);
|
||||
int _wcsicmp (const wchar_t*, const wchar_t*);
|
||||
int _wcsicoll (const wchar_t*, const wchar_t*);
|
||||
wchar_t* _wcslwr (wchar_t*);
|
||||
int _wcsnicmp (const wchar_t*, const wchar_t*, size_t);
|
||||
wchar_t* _wcsnset (wchar_t*, wchar_t, size_t);
|
||||
wchar_t* _wcsrev (wchar_t*);
|
||||
wchar_t* _wcsset (wchar_t*, wchar_t);
|
||||
wchar_t* _wcsupr (wchar_t*);
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
int _wcsncoll(const wchar_t*, const wchar_t*, size_t);
|
||||
int _wcsnicoll(const wchar_t*, const wchar_t*, size_t);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
/*
|
||||
* Non-underscored versions of non-ANSI functions. They live in liboldnames.a
|
||||
* and provide a little extra portability. Also a few extra UNIX-isms like
|
||||
* strcasecmp.
|
||||
*/
|
||||
|
||||
void* memccpy (void*, const void*, int, size_t);
|
||||
int memicmp (const void*, const void*, size_t);
|
||||
char* strdup (const char*);
|
||||
int strcmpi (const char*, const char*);
|
||||
int stricmp (const char*, const char*);
|
||||
int strcasecmp (const char*, const char*);
|
||||
int stricoll (const char*, const char*);
|
||||
char* strlwr (char*);
|
||||
int strnicmp (const char*, const char*, size_t);
|
||||
int strncasecmp (const char*, const char*, size_t);
|
||||
char* strnset (char*, int, size_t);
|
||||
char* strrev (char*);
|
||||
char* strset (char*, int);
|
||||
char* strupr (char*);
|
||||
#ifndef _UWIN
|
||||
void swab (const char*, char*, size_t);
|
||||
#endif /* _UWIN */
|
||||
|
||||
/* NOTE: There is no _wcscmpi, but this is for compatibility. */
|
||||
int wcscmpi (const wchar_t*, const wchar_t*);
|
||||
wchar_t* wcsdup (wchar_t*);
|
||||
int wcsicmp (const wchar_t*, const wchar_t*);
|
||||
int wcsicoll (const wchar_t*, const wchar_t*);
|
||||
wchar_t* wcslwr (wchar_t*);
|
||||
int wcsnicmp (const wchar_t*, const wchar_t*, size_t);
|
||||
wchar_t* wcsnset (wchar_t*, wchar_t, size_t);
|
||||
wchar_t* wcsrev (wchar_t*);
|
||||
wchar_t* wcsset (wchar_t*, wchar_t);
|
||||
wchar_t* wcsupr (wchar_t*);
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
#endif /* Not strict ANSI */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _STRING_H_ */
|
||||
|
||||
8
win32/include/sys/fcntl.h
Normal file
8
win32/include/sys/fcntl.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* This fcntl.h maps to the root fcntl.h
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
9
win32/include/sys/file.h
Normal file
9
win32/include/sys/file.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* This file.h maps to the root fcntl.h
|
||||
* TODO?
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
52
win32/include/sys/locking.h
Normal file
52
win32/include/sys/locking.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* locking.h
|
||||
*
|
||||
* Constants for the mode parameter of the locking function.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _LOCKING_H_
|
||||
#define _LOCKING_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define _LK_UNLCK 0 /* Unlock */
|
||||
#define _LK_LOCK 1 /* Lock */
|
||||
#define _LK_NBLCK 2 /* Non-blocking lock */
|
||||
#define _LK_RLCK 3 /* Lock for read only */
|
||||
#define _LK_NBRLCK 4 /* Non-blocking lock for read only */
|
||||
|
||||
#ifndef NO_OLDNAMES
|
||||
#define LK_UNLCK _LK_UNLCK
|
||||
#define LK_LOCK _LK_LOCK
|
||||
#define LK_NBLCK _LK_NBLCK
|
||||
#define LK_RLCK _LK_RLCK
|
||||
#define LK_NBRLCK _LK_NBRLCK
|
||||
#endif /* Not NO_OLDNAMES */
|
||||
|
||||
#endif /* Not _LOCKING_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
190
win32/include/sys/stat.h
Normal file
190
win32/include/sys/stat.h
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* stat.h
|
||||
*
|
||||
* Symbolic constants for opening and creating files, also stat, fstat and
|
||||
* chmod functions.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _STAT_H_
|
||||
#define _STAT_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_wchar_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Constants for the stat st_mode member.
|
||||
*/
|
||||
#define _S_IFIFO 0x1000 /* FIFO */
|
||||
#define _S_IFCHR 0x2000 /* Character */
|
||||
#define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
|
||||
#define _S_IFDIR 0x4000 /* Directory */
|
||||
#define _S_IFREG 0x8000 /* Regular */
|
||||
|
||||
#define _S_IFMT 0xF000 /* File type mask */
|
||||
|
||||
#define _S_IEXEC 0x0040
|
||||
#define _S_IWRITE 0x0080
|
||||
#define _S_IREAD 0x0100
|
||||
|
||||
#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
|
||||
#define _S_IXUSR _S_IEXEC
|
||||
#define _S_IWUSR _S_IWRITE
|
||||
#define _S_IRUSR _S_IREAD
|
||||
|
||||
#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
|
||||
#define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
|
||||
#define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
|
||||
#define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
|
||||
#define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#define S_IFCHR _S_IFCHR
|
||||
#define S_IFBLK _S_IFBLK
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#define S_IFREG _S_IFREG
|
||||
#define S_IFMT _S_IFMT
|
||||
#define S_IEXEC _S_IEXEC
|
||||
#define S_IWRITE _S_IWRITE
|
||||
#define S_IREAD _S_IREAD
|
||||
#define S_IRWXU _S_IRWXU
|
||||
#define S_IXUSR _S_IXUSR
|
||||
#define S_IWUSR _S_IWUSR
|
||||
#define S_IRUSR _S_IRUSR
|
||||
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifndef _STAT_DEFINED
|
||||
/*
|
||||
* The structure manipulated and returned by stat and fstat.
|
||||
*
|
||||
* NOTE: If called on a directory the values in the time fields are not only
|
||||
* invalid, they will cause localtime et. al. to return NULL. And calling
|
||||
* asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
|
||||
*/
|
||||
struct _stat
|
||||
{
|
||||
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
|
||||
_ino_t st_ino; /* Always zero ? */
|
||||
_mode_t st_mode; /* See above constants */
|
||||
short st_nlink; /* Number of links. */
|
||||
short st_uid; /* User: Maybe significant on NT ? */
|
||||
short st_gid; /* Group: Ditto */
|
||||
_dev_t st_rdev; /* Seems useless (not even filled in) */
|
||||
_off_t st_size; /* File size in bytes */
|
||||
time_t st_atime; /* Accessed date (always 00:00 hrs local
|
||||
* on FAT) */
|
||||
time_t st_mtime; /* Modified time */
|
||||
time_t st_ctime; /* Creation time */
|
||||
};
|
||||
|
||||
struct stat
|
||||
{
|
||||
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
|
||||
_ino_t st_ino; /* Always zero ? */
|
||||
_mode_t st_mode; /* See above constants */
|
||||
short st_nlink; /* Number of links. */
|
||||
short st_uid; /* User: Maybe significant on NT ? */
|
||||
short st_gid; /* Group: Ditto */
|
||||
_dev_t st_rdev; /* Seems useless (not even filled in) */
|
||||
_off_t st_size; /* File size in bytes */
|
||||
time_t st_atime; /* Accessed date (always 00:00 hrs local
|
||||
* on FAT) */
|
||||
time_t st_mtime; /* Modified time */
|
||||
time_t st_ctime; /* Creation time */
|
||||
};
|
||||
#if defined (__MSVCRT__)
|
||||
struct _stati64 {
|
||||
_dev_t st_dev;
|
||||
_ino_t st_ino;
|
||||
unsigned short st_mode;
|
||||
short st_nlink;
|
||||
short st_uid;
|
||||
short st_gid;
|
||||
_dev_t st_rdev;
|
||||
__int64 st_size;
|
||||
time_t st_atime;
|
||||
time_t st_mtime;
|
||||
time_t st_ctime;
|
||||
};
|
||||
#endif /* __MSVCRT__ */
|
||||
#define _STAT_DEFINED
|
||||
#endif /* _STAT_DEFINED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int _fstat (int, struct _stat*);
|
||||
int _chmod (const char*, int);
|
||||
int _stat (const char*, struct _stat*);
|
||||
|
||||
#if defined (__MSVCRT__)
|
||||
int _fstati64(int, struct _stati64 *);
|
||||
int _stati64(const char *, struct _stati64 *);
|
||||
#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
|
||||
int _wstat(const wchar_t*, struct _stat*);
|
||||
int _wstati64 (const wchar_t*, struct _stati64*);
|
||||
#define _WSTAT_DEFINED
|
||||
#endif /* _WSTAT_DEFIND */
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
/* These functions live in liboldnames.a. */
|
||||
int fstat (int, struct stat*);
|
||||
int chmod (const char*, int);
|
||||
int stat (const char*, struct stat*);
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _STAT_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
3
win32/include/sys/time.h
Normal file
3
win32/include/sys/time.h
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
82
win32/include/sys/timeb.h
Normal file
82
win32/include/sys/timeb.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* timeb.h
|
||||
*
|
||||
* Support for the UNIX System V ftime system call.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _TIMEB_H_
|
||||
#define _TIMEB_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* TODO: Structure not tested.
|
||||
*/
|
||||
struct _timeb
|
||||
{
|
||||
long time;
|
||||
short millitm;
|
||||
short timezone;
|
||||
short dstflag;
|
||||
};
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
/*
|
||||
* TODO: Structure not tested.
|
||||
*/
|
||||
struct timeb
|
||||
{
|
||||
long time;
|
||||
short millitm;
|
||||
short timezone;
|
||||
short dstflag;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* TODO: Not tested. */
|
||||
void _ftime (struct _timeb*);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
void ftime (struct timeb*);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _TIMEB_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
118
win32/include/sys/types.h
Normal file
118
win32/include/sys/types.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* types.h
|
||||
*
|
||||
* The definition of constants, data types and global variables.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
* Lots of types supplied by Pedro A. Aranda <paag@tid.es>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warrenties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TYPES_H_
|
||||
#define _TYPES_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#define __need_size_t
|
||||
#define __need_ptrdiff_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifndef _TIME_T_DEFINED
|
||||
typedef long time_t;
|
||||
#define _TIME_T_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _OFF_T_
|
||||
#define _OFF_T_
|
||||
typedef long _off_t;
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
typedef _off_t off_t;
|
||||
#endif
|
||||
#endif /* Not _OFF_T_ */
|
||||
|
||||
|
||||
#ifndef _DEV_T_
|
||||
#define _DEV_T_
|
||||
#ifdef __MSVCRT__
|
||||
typedef unsigned int _dev_t;
|
||||
#else
|
||||
typedef short _dev_t;
|
||||
#endif
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
typedef _dev_t dev_t;
|
||||
#endif
|
||||
#endif /* Not _DEV_T_ */
|
||||
|
||||
|
||||
#ifndef _INO_T_
|
||||
#define _INO_T_
|
||||
typedef short _ino_t;
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
typedef _ino_t ino_t;
|
||||
#endif
|
||||
#endif /* Not _INO_T_ */
|
||||
|
||||
|
||||
#ifndef _PID_T_
|
||||
#define _PID_T_
|
||||
typedef int _pid_t;
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
typedef _pid_t pid_t;
|
||||
#endif
|
||||
#endif /* Not _PID_T_ */
|
||||
|
||||
|
||||
#ifndef _MODE_T_
|
||||
#define _MODE_T_
|
||||
typedef unsigned short _mode_t;
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
typedef _mode_t mode_t;
|
||||
#endif
|
||||
#endif /* Not _MODE_T_ */
|
||||
|
||||
|
||||
#ifndef _SIGSET_T_
|
||||
#define _SIGSET_T_
|
||||
typedef int _sigset_t;
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
typedef _sigset_t sigset_t;
|
||||
#endif
|
||||
#endif /* Not _SIGSET_T_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _TYPES_H_ */
|
||||
9
win32/include/sys/unistd.h
Normal file
9
win32/include/sys/unistd.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* unistd.h maps (roughly) to io.h
|
||||
*/
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
89
win32/include/sys/utime.h
Normal file
89
win32/include/sys/utime.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* utime.h
|
||||
*
|
||||
* Support for the utime function.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _UTIME_H_
|
||||
#define _UTIME_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#define __need_size_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* Structure used by _utime function.
|
||||
*/
|
||||
struct _utimbuf
|
||||
{
|
||||
time_t actime; /* Access time */
|
||||
time_t modtime; /* Modification time */
|
||||
};
|
||||
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
/* NOTE: Must be the same as _utimbuf above. */
|
||||
struct utimbuf
|
||||
{
|
||||
time_t actime;
|
||||
time_t modtime;
|
||||
};
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int _utime (const char*, struct _utimbuf*);
|
||||
int _futime (int, struct _utimbuf*);
|
||||
|
||||
/* The wide character version, only available for MSVCRT versions of the
|
||||
* C runtime library. */
|
||||
#ifdef __MSVCRT__
|
||||
int _wutime (const wchar_t*, struct _utimbuf*);
|
||||
#endif /* MSVCRT runtime */
|
||||
#ifndef _NO_OLDNAMES
|
||||
int utime (const char*, struct utimbuf*);
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _UTIME_H_ */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
367
win32/include/tchar.h
Normal file
367
win32/include/tchar.h
Normal file
@@ -0,0 +1,367 @@
|
||||
/*
|
||||
* tchar.h
|
||||
*
|
||||
* Unicode mapping layer for the standard C library. By including this
|
||||
* file and using the 't' names for string functions
|
||||
* (eg. _tprintf) you can make code which can be easily adapted to both
|
||||
* Unicode and non-unicode environments. In a unicode enabled compile define
|
||||
* _UNICODE before including tchar.h, otherwise the standard non-unicode
|
||||
* library functions will be used.
|
||||
*
|
||||
* Note that you still need to include string.h or stdlib.h etc. to define
|
||||
* the appropriate functions. Also note that there are several defines
|
||||
* included for non-ANSI functions which are commonly available (but using
|
||||
* the convention of prepending an underscore to non-ANSI library function
|
||||
* names).
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TCHAR_H_
|
||||
#define _TCHAR_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
/*
|
||||
* NOTE: This tests _UNICODE, which is different from the UNICODE define
|
||||
* used to differentiate Win32 API calls.
|
||||
*/
|
||||
#ifdef _UNICODE
|
||||
|
||||
|
||||
/*
|
||||
* Use TCHAR instead of char or wchar_t. It will be appropriately translated
|
||||
* if _UNICODE is correctly defined (or not).
|
||||
*/
|
||||
#ifndef _TCHAR_DEFINED
|
||||
#ifndef RC_INVOKED
|
||||
typedef wchar_t TCHAR;
|
||||
typedef wchar_t _TCHAR;
|
||||
#endif /* Not RC_INVOKED */
|
||||
#define _TCHAR_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* __TEXT is a private macro whose specific use is to force the expansion of a
|
||||
* macro passed as an argument to the macros _T or _TEXT. DO NOT use this
|
||||
* macro within your programs. It's name and function could change without
|
||||
* notice.
|
||||
*/
|
||||
#define __TEXT(x) L##x
|
||||
|
||||
/* for porting from other Windows compilers */
|
||||
#if 0 // no wide startup module
|
||||
#define _tmain wmain
|
||||
#define _tWinMain wWinMain
|
||||
#define _tenviron _wenviron
|
||||
#define __targv __wargv
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Unicode functions
|
||||
*/
|
||||
#define _tprintf wprintf
|
||||
#define _ftprintf fwprintf
|
||||
#define _stprintf swprintf
|
||||
#define _sntprintf _snwprintf
|
||||
#define _vtprintf vwprintf
|
||||
#define _vftprintf vfwprintf
|
||||
#define _vstprintf vswprintf
|
||||
#define _vsntprintf _vsnwprintf
|
||||
#define _tscanf wscanf
|
||||
#define _ftscanf fwscanf
|
||||
#define _stscanf swscanf
|
||||
#define _fgettc fgetwc
|
||||
#define _fgettchar _fgetwchar
|
||||
#define _fgetts fgetws
|
||||
#define _fputtc fputwc
|
||||
#define _fputtchar _fputwchar
|
||||
#define _fputts fputws
|
||||
#define _gettc getwc
|
||||
#define _getts getws
|
||||
#define _puttc putwc
|
||||
#define _putts putws
|
||||
#define _ungettc ungetwc
|
||||
#define _tcstod wcstod
|
||||
#define _tcstol wcstol
|
||||
#define _tcstoul wcstoul
|
||||
#define _itot _itow
|
||||
#define _ltot _ltow
|
||||
#define _ultot _ultow
|
||||
#define _ttoi _wtoi
|
||||
#define _ttol _wtol
|
||||
#define _tcscat wcscat
|
||||
#define _tcschr wcschr
|
||||
#define _tcscmp wcscmp
|
||||
#define _tcscpy wcscpy
|
||||
#define _tcscspn wcscspn
|
||||
#define _tcslen wcslen
|
||||
#define _tcsncat wcsncat
|
||||
#define _tcsncmp wcsncmp
|
||||
#define _tcsncpy wcsncpy
|
||||
#define _tcspbrk wcspbrk
|
||||
#define _tcsrchr wcsrchr
|
||||
#define _tcsspn wcsspn
|
||||
#define _tcsstr wcsstr
|
||||
#define _tcstok wcstok
|
||||
#define _tcsdup _wcsdup
|
||||
#define _tcsicmp _wcsicmp
|
||||
#define _tcsnicmp _wcsnicmp
|
||||
#define _tcsnset _wcsnset
|
||||
#define _tcsrev _wcsrev
|
||||
#define _tcsset _wcsset
|
||||
#define _tcslwr _wcslwr
|
||||
#define _tcsupr _wcsupr
|
||||
#define _tcsxfrm wcsxfrm
|
||||
#define _tcscoll wcscoll
|
||||
#define _tcsicoll _wcsicoll
|
||||
#define _istalpha iswalpha
|
||||
#define _istupper iswupper
|
||||
#define _istlower iswlower
|
||||
#define _istdigit iswdigit
|
||||
#define _istxdigit iswxdigit
|
||||
#define _istspace iswspace
|
||||
#define _istpunct iswpunct
|
||||
#define _istalnum iswalnum
|
||||
#define _istprint iswprint
|
||||
#define _istgraph iswgraph
|
||||
#define _istcntrl iswcntrl
|
||||
#define _istascii iswascii
|
||||
#define _totupper towupper
|
||||
#define _totlower towlower
|
||||
#define _tcsftime wcsftime
|
||||
/* Macro functions */
|
||||
#define _tcsdec _wcsdec
|
||||
#define _tcsinc _wcsinc
|
||||
#define _tcsnbcnt _wcsncnt
|
||||
#define _tcsnccnt _wcsncnt
|
||||
#define _tcsnextc _wcsnextc
|
||||
#define _tcsninc _wcsninc
|
||||
#define _tcsspnp _wcsspnp
|
||||
#define _wcsdec(_wcs1, _wcs2) ((_wcs1)>=(_wcs2) ? NULL : (_wcs2)-1)
|
||||
#define _wcsinc(_wcs) ((_wcs)+1)
|
||||
#define _wcsnextc(_wcs) ((unsigned int) *(_wcs))
|
||||
#define _wcsninc(_wcs, _inc) (((_wcs)+(_inc)))
|
||||
#define _wcsncnt(_wcs, _cnt) ((wcslen(_wcs)>_cnt) ? _count : wcslen(_wcs))
|
||||
#define _wcsspnp(_wcs1, _wcs2) ((*((_wcs1)+wcsspn(_wcs1,_wcs2))) ? ((_wcs1)+wcsspn(_wcs1,_wcs2)) : NULL)
|
||||
|
||||
#if 1 // defined __MSVCRT__
|
||||
/*
|
||||
* These wide functions not in crtdll.dll.
|
||||
* Define macros anyway so that _wfoo rather than _tfoo is undefined
|
||||
*/
|
||||
#define _ttoi64 _wtoi64
|
||||
#define _i64tot _i64tow
|
||||
#define _ui64tot _ui64tow
|
||||
#define _tasctime _wasctime
|
||||
#define _tctime _wctime
|
||||
#define _tstrdate _wstrdate
|
||||
#define _tstrtime _wstrtime
|
||||
#define _tutime _wutime
|
||||
#define _tcsnccoll _wcsncoll
|
||||
#define _tcsncoll _wcsncoll
|
||||
#define _tcsncicoll _wcsnicoll
|
||||
#define _tcsnicoll _wcsnicoll
|
||||
#define _taccess _waccess
|
||||
#define _tchmod _wchmod
|
||||
#define _tcreat _wcreat
|
||||
#define _tfindfirst _wfindfirst
|
||||
#define _tfindnext _wfindnext
|
||||
#define _tfopen _wfopen
|
||||
#define _tgetenv _wgetenv
|
||||
#define _tmktemp _wmktemp
|
||||
#define _topen _wopen
|
||||
#define _tremove _wremove
|
||||
#define _trename _wrename
|
||||
#define _tsopen _wsopen
|
||||
#define _tsetlocale _wsetlocale
|
||||
#define _tunlink _wunlink
|
||||
#define _tfinddata_t _wfinddata_t
|
||||
#define _tfindfirsti64 _wfindfirsti64
|
||||
#define _tfindnexti64 _wfindnexti64
|
||||
#define _tfinddatai64_t _wfinddatai64_t
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
#else /* Not _UNICODE */
|
||||
|
||||
/*
|
||||
* TCHAR, the type you should use instead of char.
|
||||
*/
|
||||
#ifndef _TCHAR_DEFINED
|
||||
#ifndef RC_INVOKED
|
||||
typedef char TCHAR;
|
||||
typedef char _TCHAR;
|
||||
#endif
|
||||
#define _TCHAR_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* __TEXT is a private macro whose specific use is to force the expansion of a
|
||||
* macro passed as an argument to the macros _T or _TEXT. DO NOT use this
|
||||
* macro within your programs. It's name and function could change without
|
||||
* notice.
|
||||
*/
|
||||
#define __TEXT(x) x
|
||||
|
||||
/* for porting from other Windows compilers */
|
||||
#define _tmain main
|
||||
#define _tWinMain WinMain
|
||||
#define _tenviron _environ
|
||||
#define __targv __argv
|
||||
|
||||
/*
|
||||
* Non-unicode (standard) functions
|
||||
*/
|
||||
|
||||
#define _tprintf printf
|
||||
#define _ftprintf fprintf
|
||||
#define _stprintf sprintf
|
||||
#define _sntprintf _snprintf
|
||||
#define _vtprintf vprintf
|
||||
#define _vftprintf vfprintf
|
||||
#define _vstprintf vsprintf
|
||||
#define _vsntprintf _vsnprintf
|
||||
#define _tscanf scanf
|
||||
#define _ftscanf fscanf
|
||||
#define _stscanf sscanf
|
||||
#define _fgettc fgetc
|
||||
#define _fgettchar _fgetchar
|
||||
#define _fgetts fgets
|
||||
#define _fputtc fputc
|
||||
#define _fputtchar _fputchar
|
||||
#define _fputts fputs
|
||||
#define _tfopen fopen
|
||||
#define _tgetenv getenv
|
||||
#define _gettc getc
|
||||
#define _getts gets
|
||||
#define _puttc putc
|
||||
#define _putts puts
|
||||
#define _ungettc ungetc
|
||||
#define _tcstod strtod
|
||||
#define _tcstol strtol
|
||||
#define _tcstoul strtoul
|
||||
#define _itot _itoa
|
||||
#define _ltot _ltoa
|
||||
#define _ultot _ultoa
|
||||
#define _ttoi atoi
|
||||
#define _ttol atol
|
||||
#define _tcscat strcat
|
||||
#define _tcschr strchr
|
||||
#define _tcscmp strcmp
|
||||
#define _tcscpy strcpy
|
||||
#define _tcscspn strcspn
|
||||
#define _tcslen strlen
|
||||
#define _tcsncat strncat
|
||||
#define _tcsncmp strncmp
|
||||
#define _tcsncpy strncpy
|
||||
#define _tcspbrk strpbrk
|
||||
#define _tcsrchr strrchr
|
||||
#define _tcsspn strspn
|
||||
#define _tcsstr strstr
|
||||
#define _tcstok strtok
|
||||
#define _tcsdup _strdup
|
||||
#define _tcsicmp _stricmp
|
||||
#define _tcsnicmp _strnicmp
|
||||
#define _tcsnset _strnset
|
||||
#define _tcsrev _strrev
|
||||
#define _tcsset _strset
|
||||
#define _tcslwr _strlwr
|
||||
#define _tcsupr _strupr
|
||||
#define _tcsxfrm strxfrm
|
||||
#define _tcscoll strcoll
|
||||
#define _tcsicoll _stricoll
|
||||
#define _istalpha isalpha
|
||||
#define _istupper isupper
|
||||
#define _istlower islower
|
||||
#define _istdigit isdigit
|
||||
#define _istxdigit isxdigit
|
||||
#define _istspace isspace
|
||||
#define _istpunct ispunct
|
||||
#define _istalnum isalnum
|
||||
#define _istprint isprint
|
||||
#define _istgraph isgraph
|
||||
#define _istcntrl iscntrl
|
||||
#define _istascii isascii
|
||||
#define _totupper toupper
|
||||
#define _totlower tolower
|
||||
#define _tasctime asctime
|
||||
#define _tctime ctime
|
||||
#define _tstrdate _strdate
|
||||
#define _tstrtime _strtime
|
||||
#define _tutime _utime
|
||||
#define _tcsftime strftime
|
||||
/* Macro functions */
|
||||
#define _tcsdec _strdec
|
||||
#define _tcsinc _strinc
|
||||
#define _tcsnbcnt _strncnt
|
||||
#define _tcsnccnt _strncnt
|
||||
#define _tcsnextc _strnextc
|
||||
#define _tcsninc _strninc
|
||||
#define _tcsspnp _strspnp
|
||||
#define _strdec(_str1, _str2) ((_str1)>=(_str2) ? NULL : (_str2)-1)
|
||||
#define _strinc(_str) ((_str)+1)
|
||||
#define _strnextc(_str) ((unsigned int) *(_str))
|
||||
#define _strninc(_str, _inc) (((_str)+(_inc)))
|
||||
#define _strncnt(_str, _cnt) ((strlen(_str)>_cnt) ? _count : strlen(_str))
|
||||
#define _strspnp(_str1, _str2) ((*((_str1)+strspn(_str1,_str2))) ? ((_str1)+strspn(_str1,_str2)) : NULL)
|
||||
|
||||
#define _tchmod _chmod
|
||||
#define _tcreat _creat
|
||||
#define _tfindfirst _findfirst
|
||||
#define _tfindnext _findnext
|
||||
#define _tmktemp _mktemp
|
||||
#define _topen _open
|
||||
#define _taccess _access
|
||||
#define _tremove remove
|
||||
#define _trename rename
|
||||
#define _tsopen _sopen
|
||||
#define _tsetlocale setlocale
|
||||
#define _tunlink _unlink
|
||||
#define _tfinddata_t _finddata_t
|
||||
|
||||
|
||||
#if 1 // defined __MSVCRT__
|
||||
/* Not in crtdll.dll. Define macros anyway? */
|
||||
#define _ttoi64 _atoi64
|
||||
#define _i64tot _i64toa
|
||||
#define _ui64tot _ui64toa
|
||||
#define _tcsnccoll _strncoll
|
||||
#define _tcsncoll _strncoll
|
||||
#define _tcsncicoll _strnicoll
|
||||
#define _tcsnicoll _strnicoll
|
||||
#define _tfindfirsti64 _findfirsti64
|
||||
#define _tfindnexti64 _findnexti64
|
||||
#define _tfinddatai64_t _finddatai64_t
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
#endif /* Not _UNICODE */
|
||||
|
||||
/*
|
||||
* UNICODE a constant string when _UNICODE is defined else returns the string
|
||||
* unmodified. Also defined in w32api/winnt.h.
|
||||
*/
|
||||
#define _TEXT(x) __TEXT(x)
|
||||
#define _T(x) __TEXT(x)
|
||||
|
||||
#endif /* Not _TCHAR_H_ */
|
||||
|
||||
219
win32/include/time.h
Normal file
219
win32/include/time.h
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* time.h
|
||||
*
|
||||
* Date and time functions and types.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TIME_H_
|
||||
#define _TIME_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#define __need_size_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
/*
|
||||
* Need a definition of time_t.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Number of clock ticks per second. A clock tick is the unit by which
|
||||
* processor time is measured and is returned by 'clock'.
|
||||
*/
|
||||
#define CLOCKS_PER_SEC ((clock_t)1000)
|
||||
#define CLK_TCK CLOCKS_PER_SEC
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* A type for storing the current time and date. This is the number of
|
||||
* seconds since midnight Jan 1, 1970.
|
||||
* NOTE: Normally this is defined by the above include of sys/types.h
|
||||
*/
|
||||
#ifndef _TIME_T_DEFINED
|
||||
typedef long time_t;
|
||||
#define _TIME_T_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A type for measuring processor time (in clock ticks).
|
||||
*/
|
||||
#ifndef _CLOCK_T_DEFINED
|
||||
typedef long clock_t;
|
||||
#define _CLOCK_T_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* A structure for storing all kinds of useful information about the
|
||||
* current (or another) time.
|
||||
*/
|
||||
struct tm
|
||||
{
|
||||
int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
|
||||
int tm_min; /* Minutes: 0-59 */
|
||||
int tm_hour; /* Hours since midnight: 0-23 */
|
||||
int tm_mday; /* Day of the month: 1-31 */
|
||||
int tm_mon; /* Months *since* january: 0-11 */
|
||||
int tm_year; /* Years since 1900 */
|
||||
int tm_wday; /* Days since Sunday (0-6) */
|
||||
int tm_yday; /* Days since Jan. 1: 0-365 */
|
||||
int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
|
||||
* -1 don't know */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
clock_t clock (void);
|
||||
time_t time (time_t*);
|
||||
double difftime (time_t, time_t);
|
||||
time_t mktime (struct tm*);
|
||||
|
||||
/*
|
||||
* These functions write to and return pointers to static buffers that may
|
||||
* be overwritten by other function calls. Yikes!
|
||||
*
|
||||
* NOTE: localtime, and perhaps the others of the four functions grouped
|
||||
* below may return NULL if their argument is not 'acceptable'. Also note
|
||||
* that calling asctime with a NULL pointer will produce an Invalid Page
|
||||
* Fault and crap out your program. Guess how I know. Hint: stat called on
|
||||
* a directory gives 'invalid' times in st_atime etc...
|
||||
*/
|
||||
char* asctime (const struct tm*);
|
||||
char* ctime (const time_t*);
|
||||
struct tm* gmtime (const time_t*);
|
||||
struct tm* localtime (const time_t*);
|
||||
|
||||
|
||||
size_t strftime (char*, size_t, const char*, const struct tm*);
|
||||
|
||||
size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
extern void _tzset (void);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
extern void tzset (void);
|
||||
#endif
|
||||
|
||||
size_t strftime(char*, size_t, const char*, const struct tm*);
|
||||
char* _strdate(char*);
|
||||
char* _strtime(char*);
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
/*
|
||||
* _daylight: non zero if daylight savings time is used.
|
||||
* _timezone: difference in seconds between GMT and local time.
|
||||
* _tzname: standard/daylight savings time zone names (an array with two
|
||||
* elements).
|
||||
*/
|
||||
#ifdef __MSVCRT__
|
||||
|
||||
/* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
|
||||
extern int* __p__daylight (void);
|
||||
extern long* __p__timezone (void);
|
||||
extern char** __p__tzname (void);
|
||||
|
||||
__MINGW_IMPORT int _daylight;
|
||||
__MINGW_IMPORT long _timezone;
|
||||
__MINGW_IMPORT char *_tzname[2];
|
||||
|
||||
#else /* not __MSVCRT (ie. crtdll) */
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
|
||||
extern int* __imp__daylight_dll;
|
||||
extern long* __imp__timezone_dll;
|
||||
extern char** __imp__tzname;
|
||||
|
||||
#define _daylight (*__imp__daylight_dll)
|
||||
#define _timezone (*__imp__timezone_dll)
|
||||
#define _tzname (__imp__tzname)
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
__MINGW_IMPORT int _daylight_dll;
|
||||
__MINGW_IMPORT long _timezone_dll;
|
||||
__MINGW_IMPORT char* _tzname[2];
|
||||
|
||||
#define _daylight _daylight_dll
|
||||
#define _timezone _timezone_dll
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
|
||||
#endif /* not __MSVCRT__ */
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
|
||||
/* These go in the oldnames import library for MSVCRT. */
|
||||
__MINGW_IMPORT int daylight;
|
||||
__MINGW_IMPORT long timezone;
|
||||
__MINGW_IMPORT char *tzname[2];
|
||||
|
||||
#ifndef _WTIME_DEFINED
|
||||
|
||||
/* wide function prototypes, also declared in wchar.h */
|
||||
|
||||
wchar_t * _wasctime(const struct tm*);
|
||||
wchar_t * _wctime(const time_t*);
|
||||
wchar_t* _wstrdate(wchar_t*);
|
||||
wchar_t* _wstrtime(wchar_t*);
|
||||
|
||||
#define _WTIME_DEFINED
|
||||
#endif /* _WTIME_DEFINED */
|
||||
|
||||
|
||||
#else /* not __MSVCRT__ */
|
||||
|
||||
/* CRTDLL is royally messed up when it comes to these macros.
|
||||
TODO: import and alias these via oldnames import library instead
|
||||
of macros. */
|
||||
|
||||
#define daylight _daylight
|
||||
/* NOTE: timezone not defined because it would conflict with sys/timeb.h.
|
||||
Also, tzname used to a be macro, but now it's in moldname. */
|
||||
__MINGW_IMPORT char *tzname[2];
|
||||
|
||||
#endif /* not __MSVCRT__ */
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* Not _TIME_H_ */
|
||||
|
||||
10
win32/include/unistd.h
Normal file
10
win32/include/unistd.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* unistd.h maps (roughly) to io.h
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
4
win32/include/values.h
Normal file
4
win32/include/values.h
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
* TODO: Nothing here yet. Should provide UNIX compatibility constants
|
||||
* comparible to those in limits.h and float.h.
|
||||
*/
|
||||
11
win32/include/varargs.h
Normal file
11
win32/include/varargs.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef _VARARGS_H
|
||||
#define _VARARGS_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define va_dcl
|
||||
#define va_alist __va_alist
|
||||
#undef va_start
|
||||
#define va_start(ap) ap = __builtin_varargs_start
|
||||
|
||||
#endif
|
||||
318
win32/include/wchar.h
Normal file
318
win32/include/wchar.h
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* wchar.h
|
||||
*
|
||||
* Defines of all functions for supporting wide characters. Actually it
|
||||
* just includes all those headers, which is not a good thing to do from a
|
||||
* processing time point of view, but it does mean that everything will be
|
||||
* in sync.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _WCHAR_H_
|
||||
#define _WCHAR_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_wint_t
|
||||
#define __need_wchar_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#define WCHAR_MIN 0
|
||||
#define WCHAR_MAX ((wchar_t)-1)
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#ifndef _FSIZE_T_DEFINED
|
||||
typedef unsigned long _fsize_t;
|
||||
#define _FSIZE_T_DEFINED
|
||||
#endif
|
||||
|
||||
#ifndef _WFINDDATA_T_DEFINED
|
||||
struct _wfinddata_t {
|
||||
unsigned attrib;
|
||||
time_t time_create; /* -1 for FAT file systems */
|
||||
time_t time_access; /* -1 for FAT file systems */
|
||||
time_t time_write;
|
||||
_fsize_t size;
|
||||
wchar_t name[FILENAME_MAX]; /* may include spaces. */
|
||||
};
|
||||
struct _wfinddatai64_t {
|
||||
unsigned attrib;
|
||||
time_t time_create;
|
||||
time_t time_access;
|
||||
time_t time_write;
|
||||
__int64 size;
|
||||
wchar_t name[FILENAME_MAX];
|
||||
};
|
||||
#define _WFINDDATA_T_DEFINED
|
||||
#endif
|
||||
|
||||
/* Wide character versions. Also defined in io.h. */
|
||||
/* CHECK: I believe these only exist in MSVCRT, and not in CRTDLL. Also
|
||||
applies to other wide character versions? */
|
||||
#if !defined (_WIO_DEFINED)
|
||||
#if defined (__MSVCRT__)
|
||||
int _waccess (const wchar_t*, int);
|
||||
int _wchmod (const wchar_t*, int);
|
||||
int _wcreat (const wchar_t*, int);
|
||||
long _wfindfirst (wchar_t*, struct _wfinddata_t *);
|
||||
int _wfindnext (long, struct _wfinddata_t *);
|
||||
int _wunlink (const wchar_t*);
|
||||
int _wopen (const wchar_t*, int, ...);
|
||||
int _wsopen (const wchar_t*, int, int, ...);
|
||||
wchar_t* _wmktemp (wchar_t*);
|
||||
long _wfindfirsti64 (const wchar_t*, struct _wfinddatai64_t*);
|
||||
int _wfindnexti64 (long, struct _wfinddatai64_t*);
|
||||
#endif /* defined (__MSVCRT__) */
|
||||
#define _WIO_DEFINED
|
||||
#endif /* _WIO_DEFINED */
|
||||
|
||||
#ifndef _WSTDIO_DEFINED
|
||||
/* also in stdio.h - keep in sync */
|
||||
int fwprintf (FILE*, const wchar_t*, ...);
|
||||
int wprintf (const wchar_t*, ...);
|
||||
int swprintf (wchar_t*, const wchar_t*, ...);
|
||||
int _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
|
||||
int vfwprintf (FILE*, const wchar_t*, va_list);
|
||||
int vwprintf (const wchar_t*, va_list);
|
||||
int vswprintf (wchar_t*, const wchar_t*, va_list);
|
||||
int _vsnwprintf (wchar_t*, size_t, const wchar_t*, va_list);
|
||||
int fwscanf (FILE*, const wchar_t*, ...);
|
||||
int wscanf (const wchar_t*, ...);
|
||||
int swscanf (const wchar_t*, const wchar_t*, ...);
|
||||
wint_t fgetwc (FILE*);
|
||||
wint_t fputwc (wchar_t, FILE*);
|
||||
wint_t ungetwc (wchar_t, FILE*);
|
||||
|
||||
#ifndef __NO_ISOCEXT /* externs in libmingwex.a */
|
||||
int snwprintf(wchar_t* s, size_t n, const wchar_t* format, ...);
|
||||
extern inline int vsnwprintf (wchar_t* s, size_t n, const wchar_t* format,
|
||||
va_list arg)
|
||||
{ return _vsnwprintf ( s, n, format, arg); }
|
||||
#endif
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
wchar_t* fgetws (wchar_t*, int, FILE*);
|
||||
int fputws (const wchar_t*, FILE*);
|
||||
wint_t getwc (FILE*);
|
||||
wint_t getwchar (void);
|
||||
wchar_t* _getws (wchar_t*);
|
||||
wint_t putwc (wint_t, FILE*);
|
||||
int _putws (const wchar_t*);
|
||||
wint_t putwchar (wint_t);
|
||||
|
||||
FILE* _wfopen (const wchar_t*, const wchar_t*);
|
||||
FILE* _wfreopen (const wchar_t*, const wchar_t*, FILE*);
|
||||
FILE* _wfsopen (const wchar_t*, const wchar_t*, int);
|
||||
wchar_t* _wtmpnam (wchar_t*);
|
||||
wchar_t* _wtempnam (const wchar_t*, const wchar_t*);
|
||||
int _wrename (const wchar_t*, const wchar_t*);
|
||||
int _wremove (const wchar_t*)
|
||||
|
||||
FILE* _wpopen (const wchar_t*, const wchar_t*)
|
||||
void _wperror (const wchar_t*);
|
||||
#endif /* __MSVCRT__ */
|
||||
#define _WSTDIO_DEFINED
|
||||
#endif /* _WSTDIO_DEFINED */
|
||||
|
||||
#ifndef _WDIRECT_DEFINED
|
||||
/* Also in direct.h */
|
||||
#ifdef __MSVCRT__
|
||||
int _wchdir (const wchar_t*);
|
||||
wchar_t* _wgetcwd (wchar_t*, int);
|
||||
wchar_t* _wgetdcwd (int, wchar_t*, int);
|
||||
int _wmkdir (const wchar_t*);
|
||||
int _wrmdir (const wchar_t*);
|
||||
#endif /* __MSVCRT__ */
|
||||
#define _WDIRECT_DEFINED
|
||||
#endif /* _WDIRECT_DEFINED */
|
||||
|
||||
#ifndef _STAT_DEFINED
|
||||
/*
|
||||
* The structure manipulated and returned by stat and fstat.
|
||||
*
|
||||
* NOTE: If called on a directory the values in the time fields are not only
|
||||
* invalid, they will cause localtime et. al. to return NULL. And calling
|
||||
* asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
|
||||
*/
|
||||
struct _stat
|
||||
{
|
||||
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
|
||||
_ino_t st_ino; /* Always zero ? */
|
||||
_mode_t st_mode; /* See above constants */
|
||||
short st_nlink; /* Number of links. */
|
||||
short st_uid; /* User: Maybe significant on NT ? */
|
||||
short st_gid; /* Group: Ditto */
|
||||
_dev_t st_rdev; /* Seems useless (not even filled in) */
|
||||
_off_t st_size; /* File size in bytes */
|
||||
time_t st_atime; /* Accessed date (always 00:00 hrs local
|
||||
* on FAT) */
|
||||
time_t st_mtime; /* Modified time */
|
||||
time_t st_ctime; /* Creation time */
|
||||
};
|
||||
|
||||
struct stat
|
||||
{
|
||||
_dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
|
||||
_ino_t st_ino; /* Always zero ? */
|
||||
_mode_t st_mode; /* See above constants */
|
||||
short st_nlink; /* Number of links. */
|
||||
short st_uid; /* User: Maybe significant on NT ? */
|
||||
short st_gid; /* Group: Ditto */
|
||||
_dev_t st_rdev; /* Seems useless (not even filled in) */
|
||||
_off_t st_size; /* File size in bytes */
|
||||
time_t st_atime; /* Accessed date (always 00:00 hrs local
|
||||
* on FAT) */
|
||||
time_t st_mtime; /* Modified time */
|
||||
time_t st_ctime; /* Creation time */
|
||||
};
|
||||
#if defined (__MSVCRT__)
|
||||
struct _stati64 {
|
||||
_dev_t st_dev;
|
||||
_ino_t st_ino;
|
||||
unsigned short st_mode;
|
||||
short st_nlink;
|
||||
short st_uid;
|
||||
short st_gid;
|
||||
_dev_t st_rdev;
|
||||
__int64 st_size;
|
||||
time_t st_atime;
|
||||
time_t st_mtime;
|
||||
time_t st_ctime;
|
||||
};
|
||||
#endif /* __MSVCRT__ */
|
||||
#define _STAT_DEFINED
|
||||
#endif /* _STAT_DEFINED */
|
||||
|
||||
#if !defined ( _WSTAT_DEFINED)
|
||||
/* also declared in sys/stat.h */
|
||||
#if defined __MSVCRT__
|
||||
int _wstat (const wchar_t*, struct _stat*);
|
||||
int _wstati64 (const wchar_t*, struct _stati64*);
|
||||
#endif /* __MSVCRT__ */
|
||||
#define _WSTAT_DEFINED
|
||||
#endif /* ! _WSTAT_DEFIND */
|
||||
|
||||
#ifndef _WTIME_DEFINED
|
||||
#ifdef __MSVCRT__
|
||||
/* wide function prototypes, also declared in time.h */
|
||||
wchar_t* _wasctime (const struct tm*);
|
||||
wchar_t* _wctime (const time_t*);
|
||||
wchar_t* _wstrdate (wchar_t*);
|
||||
wchar_t* _wstrtime (wchar_t*);
|
||||
#endif /* __MSVCRT__ */
|
||||
size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
|
||||
#define _WTIME_DEFINED
|
||||
#endif /* _WTIME_DEFINED */
|
||||
|
||||
#ifndef _WLOCALE_DEFINED /* also declared in locale.h */
|
||||
wchar_t* _wsetlocale (int, const wchar_t*);
|
||||
#define _WLOCALE_DEFINED
|
||||
#endif
|
||||
|
||||
#ifndef _WSTDLIB_DEFINED /* also declared in stdlib.h */
|
||||
long wcstol (const wchar_t*, wchar_t**, int);
|
||||
unsigned long wcstoul (const wchar_t*, wchar_t**, int);
|
||||
double wcstod (const wchar_t*, wchar_t**);
|
||||
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
|
||||
extern __inline__ float wcstof( const wchar_t *nptr, wchar_t **endptr)
|
||||
{ return (wcstod(nptr, endptr)); }
|
||||
#endif /* __NO_ISOCEXT */
|
||||
#define _WSTDLIB_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
/* Wide character versions. Also declared in io.h. */
|
||||
/* CHECK: Are these in the oldnames??? NO! */
|
||||
#if (0)
|
||||
int waccess (const wchar_t *, int);
|
||||
int wchmod (const wchar_t *, int);
|
||||
int wcreat (const wchar_t *, int);
|
||||
long wfindfirst (wchar_t *, struct _wfinddata_t *);
|
||||
int wfindnext (long, struct _wfinddata_t *);
|
||||
int wunlink (const wchar_t *);
|
||||
int wrename (const wchar_t *, const wchar_t *);
|
||||
int wremove (const wchar_t *);
|
||||
int wopen (const wchar_t *, int, ...);
|
||||
int wsopen (const wchar_t *, int, int, ...);
|
||||
wchar_t* wmktemp (wchar_t *);
|
||||
#endif
|
||||
#endif /* _NO_OLDNAMES */
|
||||
|
||||
#endif /* not __STRICT_ANSI__ */
|
||||
|
||||
/* These are resolved by -lmsvcp60 */
|
||||
/* If you don't have msvcp60.dll in your windows system directory, you can
|
||||
easily obtain it with a search from your favorite search engine. */
|
||||
typedef int mbstate_t;
|
||||
typedef wchar_t _Wint_t;
|
||||
|
||||
wint_t btowc(int);
|
||||
size_t mbrlen(const char *, size_t, mbstate_t *);
|
||||
size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
|
||||
size_t mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
|
||||
|
||||
size_t wcrtomb(char *, wchar_t, mbstate_t *);
|
||||
size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
|
||||
int wctob(wint_t);
|
||||
|
||||
#ifndef __NO_ISOCEXT /* these need static lib libmingwex.a */
|
||||
extern inline int fwide(FILE* stream, int mode) {return -1;} /* limited to byte orientation */
|
||||
extern inline int mbsinit(const mbstate_t* ps) {return 1;}
|
||||
wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
|
||||
wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
|
||||
int wmemcmp(const wchar_t* s1, const wchar_t * s2, size_t n);
|
||||
wchar_t* wmemcpy(wchar_t* __restrict__ s1, const wchar_t* __restrict__ s2,
|
||||
size_t n);
|
||||
wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
|
||||
long long wcstoll(const wchar_t* __restrict__ nptr,
|
||||
wchar_t** __restrict__ endptr, int base);
|
||||
unsigned long long wcstoull(const wchar_t* __restrict__ nptr,
|
||||
wchar_t ** __restrict__ endptr, int base);
|
||||
|
||||
#endif /* __NO_ISOCEXT */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
#endif /* not _WCHAR_H_ */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user