├── VERSION ├── win32 ├── include │ ├── sys │ │ ├── time.h │ │ ├── fcntl.h │ │ ├── unistd.h │ │ ├── file.h │ │ ├── locking.h │ │ ├── timeb.h │ │ ├── utime.h │ │ ├── types.h │ │ └── stat.h │ ├── values.h │ ├── mem.h │ ├── stdbool.h │ ├── unistd.h │ ├── memory.h │ ├── varargs.h │ ├── stdarg.h │ ├── excpt.h │ ├── stddef.h │ ├── dir.h │ ├── share.h │ ├── _mingw.h │ ├── assert.h │ ├── setjmp.h │ ├── malloc.h │ ├── fenv.h │ ├── direct.h │ ├── dirent.h │ ├── locale.h │ ├── dos.h │ ├── limits.h │ ├── conio.h │ ├── signal.h │ ├── fcntl.h │ ├── wctype.h │ ├── errno.h │ ├── winapi │ │ ├── basetsd.h │ │ ├── winver.h │ │ ├── windows.h │ │ ├── basetyps.h │ │ ├── windef.h │ │ └── winreg.h │ ├── process.h │ ├── time.h │ ├── stdint.h │ ├── inttypes.h │ ├── string.h │ ├── float.h │ └── ctype.h ├── lib │ ├── dllmain.c │ ├── dllcrt1.c │ ├── chkstk.S │ ├── crt1.c │ ├── wincrt1.c │ └── gdi32.def ├── examples │ ├── dll.c │ ├── fib.c │ ├── hello_dll.c │ └── hello_win.c ├── build-tcc.bat └── tcc-win32.txt ├── Changelog ├── arm-gen.c ├── examples ├── ex5.c ├── ex1.c ├── ex3.c ├── ex4.c └── ex2.c ├── config.h.in ├── include ├── stdbool.h ├── varargs.h ├── stddef.h ├── float.h ├── tcclib.h └── stdarg.h ├── dist.info ├── stab.h ├── lib ├── alloca86.S └── alloca86-bt.S ├── tests ├── gcctestsuite.sh ├── libtcc_test.c ├── boundtest.c └── Makefile ├── .travis.yml ├── README ├── TODO ├── libtcc.h ├── CMakeLists.txt └── Makefile /VERSION: -------------------------------------------------------------------------------- 1 | 0.9.25 -------------------------------------------------------------------------------- /win32/include/sys/time.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | -------------------------------------------------------------------------------- /Changelog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuaDist/tcc/HEAD/Changelog -------------------------------------------------------------------------------- /arm-gen.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuaDist/tcc/HEAD/arm-gen.c -------------------------------------------------------------------------------- /examples/ex5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | printf("Hello World\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /examples/ex1.c: -------------------------------------------------------------------------------- 1 | #! /usr/local/bin/tcc -run 2 | #include 3 | 4 | int main() 5 | { 6 | printf("Hello World\n"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /win32/include/values.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TODO: Nothing here yet. Should provide UNIX compatibility constants 3 | * comparible to those in limits.h and float.h. 4 | */ 5 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* ok? */ 2 | #define TCC_VERSION "0.9.25" 3 | #define TCC_TARGET_PE 1 4 | #define CONFIG_SYSROOT "" 5 | #define CONFIG_TCCDIR "." 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /win32/include/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Mingw32 package. 3 | * 4 | * mem.h maps to string.h 5 | */ 6 | #ifndef __STRICT_ANSI__ 7 | #include 8 | #endif 9 | -------------------------------------------------------------------------------- /win32/include/sys/fcntl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Mingw32 package. 3 | * 4 | * This fcntl.h maps to the root fcntl.h 5 | */ 6 | #ifndef __STRICT_ANSI__ 7 | #include 8 | #endif 9 | -------------------------------------------------------------------------------- /include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDBOOL_H 2 | #define _STDBOOL_H 3 | 4 | /* ISOC99 boolean */ 5 | 6 | #define bool _Bool 7 | #define true 1 8 | #define false 0 9 | 10 | #endif /* _STDBOOL_H */ 11 | -------------------------------------------------------------------------------- /win32/include/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDBOOL_H 2 | #define _STDBOOL_H 3 | 4 | /* ISOC99 boolean */ 5 | 6 | #define bool _Bool 7 | #define true 1 8 | #define false 0 9 | 10 | #endif /* _STDBOOL_H */ 11 | -------------------------------------------------------------------------------- /win32/include/sys/unistd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Mingw32 package. 3 | * 4 | * unistd.h maps (roughly) to io.h 5 | */ 6 | #ifndef __STRICT_ANSI__ 7 | #include 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /win32/include/unistd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Mingw32 package. 3 | * 4 | * unistd.h maps (roughly) to io.h 5 | */ 6 | 7 | #ifndef __STRICT_ANSI__ 8 | #include 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /win32/include/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Mingw32 package. 3 | * 4 | * memory.h maps to the standard string.h header. 5 | */ 6 | #ifndef __STRICT_ANSI__ 7 | #include 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /win32/include/sys/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Mingw32 package. 3 | * 4 | * This file.h maps to the root fcntl.h 5 | * TODO? 6 | */ 7 | #ifndef __STRICT_ANSI__ 8 | #include 9 | #endif 10 | -------------------------------------------------------------------------------- /include/varargs.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARARGS_H 2 | #define _VARARGS_H 3 | 4 | #include 5 | 6 | #define va_dcl 7 | #define va_alist __va_alist 8 | #undef va_start 9 | #define va_start(ap) ap = __builtin_varargs_start 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /win32/include/varargs.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARARGS_H 2 | #define _VARARGS_H 3 | 4 | #include 5 | 6 | #define va_dcl 7 | #define va_alist __va_alist 8 | #undef va_start 9 | #define va_start(ap) ap = __builtin_varargs_start 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /win32/lib/dllmain.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | 3 | #include 4 | 5 | BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) 6 | { 7 | return TRUE; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /dist.info: -------------------------------------------------------------------------------- 1 | name = "tcc" 2 | version = "0.9.25" 3 | 4 | desc = "Small but fast C compiler. Supports ANSI C, most of the new ISO C99 standard, and many GNUC extensions, including inline assembly." 5 | author = "Fabrice Bellard" 6 | license = "LGPL" 7 | url = "http://bellard.org/tcc/" 8 | maintainer = "Peter Drahoš" 9 | -------------------------------------------------------------------------------- /stab.h: -------------------------------------------------------------------------------- 1 | #ifndef __GNU_STAB__ 2 | 3 | /* Indicate the GNU stab.h is in use. */ 4 | 5 | #define __GNU_STAB__ 6 | 7 | #define __define_stab(NAME, CODE, STRING) NAME=CODE, 8 | 9 | enum __stab_debug_code 10 | { 11 | #include "stab.def" 12 | LAST_UNUSED_STAB_CODE 13 | }; 14 | 15 | #undef __define_stab 16 | 17 | #endif /* __GNU_STAB_ */ 18 | -------------------------------------------------------------------------------- /win32/lib/dllcrt1.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | 3 | #include 4 | 5 | BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved); 6 | 7 | BOOL WINAPI _dllstart(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) 8 | { 9 | BOOL bRet; 10 | bRet = DllMain (hDll, dwReason, lpReserved); 11 | return bRet; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /win32/examples/dll.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | // 3 | // dll.c - Windows DLL example - dynamically linked part 4 | // 5 | 6 | #include 7 | 8 | #define DLL_EXPORT __declspec(dllexport) 9 | 10 | 11 | DLL_EXPORT void HelloWorld (void) 12 | { 13 | MessageBox (0, "Hello World!", "From DLL", MB_ICONINFORMATION); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /win32/examples/fib.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fib(n) 4 | { 5 | if (n <= 2) 6 | return 1; 7 | else 8 | return fib(n-1) + fib(n-2); 9 | } 10 | 11 | int main(int argc, char **argv) 12 | { 13 | int n; 14 | if (argc < 2) { 15 | printf("usage: fib n\n" 16 | "Compute nth Fibonacci number\n"); 17 | return 1; 18 | } 19 | 20 | n = atoi(argv[1]); 21 | printf("fib(%d) = %d\n", n, fib(n)); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /win32/examples/hello_dll.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | // 3 | // HELLO_DLL.C - Windows DLL example - main application part 4 | // 5 | 6 | #include 7 | 8 | void HelloWorld (void); 9 | 10 | int WINAPI WinMain( 11 | HINSTANCE hInstance, 12 | HINSTANCE hPrevInstance, 13 | LPSTR lpCmdLine, 14 | int nCmdShow) 15 | { 16 | HelloWorld(); 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /examples/ex3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fib(n) 5 | { 6 | if (n <= 2) 7 | return 1; 8 | else 9 | return fib(n-1) + fib(n-2); 10 | } 11 | 12 | int main(int argc, char **argv) 13 | { 14 | int n; 15 | if (argc < 2) { 16 | printf("usage: fib n\n" 17 | "Compute nth Fibonacci number\n"); 18 | return 1; 19 | } 20 | 21 | n = atoi(argv[1]); 22 | printf("fib(%d) = %d\n", n, fib(n, 2)); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #define NULL ((void *)0) 5 | typedef __SIZE_TYPE__ size_t; 6 | typedef __WCHAR_TYPE__ wchar_t; 7 | typedef __PTRDIFF_TYPE__ ptrdiff_t; 8 | #define offsetof(type, field) ((size_t) &((type *)0)->field) 9 | 10 | #ifndef __int8_t_defined 11 | #define __int8_t_defined 12 | typedef char int8_t; 13 | typedef short int int16_t; 14 | typedef int int32_t; 15 | typedef long long int int64_t; 16 | #endif 17 | 18 | void *alloca(size_t size); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /win32/include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDARG_H 2 | #define _STDARG_H 3 | 4 | typedef char *va_list; 5 | 6 | /* only correct for i386 */ 7 | #define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) 8 | #define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3))) 9 | #define va_copy(dest, src) (dest) = (src) 10 | #define va_end(ap) 11 | 12 | /* fix a buggy dependency on GCC in libio.h */ 13 | typedef va_list __gnuc_va_list; 14 | #define _VA_LIST_DEFINED 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /win32/include/excpt.h: -------------------------------------------------------------------------------- 1 | #ifndef _EXCPT_H 2 | #define _EXCPT_H 3 | #if __GNUC__ >=3 4 | #pragma GCC system_header 5 | #endif 6 | 7 | /* FIXME: This will make some code compile. The programs will most 8 | likely crash when an exception is raised, but at least they will 9 | compile. */ 10 | #ifdef __GNUC__ 11 | #define __try 12 | #define __except(x) if (0) /* don't execute handler */ 13 | #define __finally 14 | 15 | #define _try __try 16 | #define _except __except 17 | #define _finally __finally 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /lib/alloca86.S: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------- */ 2 | /* alloca86.S */ 3 | 4 | #include "../config.h" 5 | 6 | .globl alloca 7 | 8 | alloca: 9 | pop %edx 10 | pop %eax 11 | add $3,%eax 12 | and $-4,%eax 13 | jz p3 14 | 15 | #ifdef TCC_TARGET_PE 16 | p1: 17 | cmp $4096,%eax 18 | jle p2 19 | sub $4096,%esp 20 | sub $4096,%eax 21 | test %eax,(%esp) 22 | jmp p1 23 | p2: 24 | #endif 25 | 26 | sub %eax,%esp 27 | mov %esp,%eax 28 | p3: 29 | push %edx 30 | push %edx 31 | ret 32 | 33 | /* ---------------------------------------------- */ 34 | -------------------------------------------------------------------------------- /win32/lib/chkstk.S: -------------------------------------------------------------------------------- 1 | // ================================================= 2 | // chkstk.s 3 | 4 | .text 5 | .globl __chkstk 6 | 7 | __chkstk: 8 | xchg (%esp), %ebp // store ebp, get ret.addr 9 | push %ebp // push ret.addr 10 | lea 4(%esp), %ebp // setup frame ptr 11 | push %ecx // save ecx 12 | mov %ebp, %ecx 13 | P0: 14 | sub $4096,%ecx 15 | test %eax,(%ecx) 16 | sub $4096,%eax 17 | cmp $4096,%eax 18 | jge P0 19 | 20 | sub %eax,%ecx 21 | mov %esp,%eax 22 | test %eax,(%ecx) 23 | mov %ecx,%esp 24 | 25 | mov (%eax),%ecx // restore ecx 26 | mov 4(%eax),%eax 27 | push %eax 28 | ret 29 | 30 | -------------------------------------------------------------------------------- /win32/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDDEF_H 2 | #define _STDDEF_H 3 | 4 | #define NULL ((void *)0) 5 | typedef __SIZE_TYPE__ size_t; 6 | typedef __WCHAR_TYPE__ wchar_t; 7 | typedef __PTRDIFF_TYPE__ ptrdiff_t; 8 | #define offsetof(type, field) ((size_t) &((type *)0)->field) 9 | 10 | /* need to do that because of glibc 2.1 bug (should have a way to test 11 | presence of 'long long' without __GNUC__, or TCC should define 12 | __GNUC__ ? */ 13 | #if !defined(__int8_t_defined) && !defined(__dietlibc__) 14 | #define __int8_t_defined 15 | typedef char int8_t; 16 | typedef short int int16_t; 17 | typedef int int32_t; 18 | typedef long long int int64_t; 19 | #endif 20 | 21 | void *alloca(size_t); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /examples/ex4.c: -------------------------------------------------------------------------------- 1 | #!./tcc -run -L/usr/X11R6/lib -lX11 2 | #include 3 | #include 4 | #include 5 | 6 | /* Yes, TCC can use X11 too ! */ 7 | 8 | int main(int argc, char **argv) 9 | { 10 | Display *display; 11 | Screen *screen; 12 | 13 | display = XOpenDisplay(""); 14 | if (!display) { 15 | fprintf(stderr, "Could not open X11 display\n"); 16 | exit(1); 17 | } 18 | printf("X11 display opened.\n"); 19 | screen = XScreenOfDisplay(display, 0); 20 | printf("width = %d\nheight = %d\ndepth = %d\n", 21 | screen->width, 22 | screen->height, 23 | screen->root_depth); 24 | XCloseDisplay(display); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /win32/include/dir.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dir.h 3 | * 4 | * This file OBSOLESCENT and only provided for backward compatibility. 5 | * Please use io.h instead. 6 | * 7 | * This file is part of the Mingw32 package. 8 | * 9 | * Contributors: 10 | * Created by Colin Peters 11 | * Mumit Khan 12 | * 13 | * THIS SOFTWARE IS NOT COPYRIGHTED 14 | * 15 | * This source code is offered for use in the public domain. You may 16 | * use, modify or distribute it freely. 17 | * 18 | * This code is distributed in the hope that it will be useful but 19 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 20 | * DISCLAIMED. This includes but is not limited to warranties of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * 23 | */ 24 | 25 | #include 26 | 27 | -------------------------------------------------------------------------------- /win32/lib/crt1.c: -------------------------------------------------------------------------------- 1 | // ============================================= 2 | // crt1.c 3 | 4 | #include 5 | 6 | #define __UNKNOWN_APP 0 7 | #define __CONSOLE_APP 1 8 | #define __GUI_APP 2 9 | void __set_app_type(int); 10 | void _controlfp(unsigned a, unsigned b); 11 | 12 | typedef struct 13 | { 14 | int newmode; 15 | } _startupinfo; 16 | 17 | void __getmainargs(int *pargc, char ***pargv, char ***penv, int globb, _startupinfo*); 18 | 19 | int main(int argc, char **argv, char **env); 20 | 21 | int _start(void) 22 | { 23 | int argc; char **argv; char **env; int ret; 24 | _startupinfo start_info = {0}; 25 | 26 | _controlfp(0x10000, 0x30000); 27 | __set_app_type(__CONSOLE_APP); 28 | __getmainargs(&argc, &argv, &env, 0, &start_info); 29 | 30 | ret = main(argc, argv, env); 31 | exit(ret); 32 | } 33 | 34 | // ============================================= 35 | 36 | -------------------------------------------------------------------------------- /tests/gcctestsuite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TESTSUITE_PATH=$HOME/gcc/gcc-3.2/gcc/testsuite/gcc.c-torture 4 | TCC="./tcc -B. -I. -DNO_TRAMPOLINES" 5 | rm -f tcc.sum tcc.log 6 | nb_failed="0" 7 | 8 | for src in $TESTSUITE_PATH/compile/*.c ; do 9 | echo $TCC -o /tmp/test.o -c $src 10 | $TCC -o /tmp/test.o -c $src >> tcc.log 2>&1 11 | if [ "$?" == "0" ] ; then 12 | result="PASS" 13 | else 14 | result="FAIL" 15 | nb_failed=$[ $nb_failed + 1 ] 16 | fi 17 | echo "$result: $src" >> tcc.sum 18 | done 19 | 20 | for src in $TESTSUITE_PATH/execute/*.c ; do 21 | echo $TCC $src 22 | $TCC $src >> tcc.log 2>&1 23 | if [ "$?" == "0" ] ; then 24 | result="PASS" 25 | else 26 | result="FAIL" 27 | nb_failed=$[ $nb_failed + 1 ] 28 | fi 29 | echo "$result: $src" >> tcc.sum 30 | done 31 | 32 | echo "$nb_failed test(s) failed." >> tcc.sum 33 | echo "$nb_failed test(s) failed." 34 | -------------------------------------------------------------------------------- /lib/alloca86-bt.S: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------- */ 2 | /* alloca86b.S */ 3 | 4 | #include "../config.h" 5 | 6 | .globl __bound_alloca 7 | 8 | __bound_alloca: 9 | pop %edx 10 | pop %eax 11 | mov %eax, %ecx 12 | add $3,%eax 13 | and $-4,%eax 14 | jz p6 15 | 16 | #ifdef TCC_TARGET_PE 17 | p4: 18 | cmp $4096,%eax 19 | jle p5 20 | sub $4096,%esp 21 | sub $4096,%eax 22 | test %eax,(%esp) 23 | jmp p4 24 | 25 | p5: 26 | #endif 27 | 28 | sub %eax,%esp 29 | mov %esp,%eax 30 | 31 | push %edx 32 | push %eax 33 | push %ecx 34 | push %eax 35 | call __bound_new_region 36 | add $8, %esp 37 | pop %eax 38 | pop %edx 39 | 40 | p6: 41 | push %edx 42 | push %edx 43 | ret 44 | 45 | /* ---------------------------------------------- */ 46 | -------------------------------------------------------------------------------- /win32/build-tcc.bat: -------------------------------------------------------------------------------- 1 | @rem ---------------------------------------------------- 2 | @rem batch file to build tcc using gcc and ar from mingw 3 | @rem ---------------------------------------------------- 4 | : 5 | @echo>..\config.h #define TCC_VERSION "0.9.25" 6 | @echo>>..\config.h #define TCC_TARGET_PE 1 7 | @echo>>..\config.h #define CONFIG_TCCDIR "." 8 | @echo>>..\config.h #define CONFIG_SYSROOT "" 9 | : 10 | gcc -Os -fno-strict-aliasing ../tcc.c -o tcc.exe -s 11 | gcc -Os -fno-strict-aliasing ../libtcc.c -c -o libtcc.o 12 | gcc -Os tools/tiny_impdef.c -o tiny_impdef.exe -s 13 | gcc -Os tools/tiny_libmaker.c -o tiny_libmaker.exe -s 14 | mkdir libtcc 15 | ar rcs libtcc/libtcc.a libtcc.o 16 | del libtcc.o 17 | copy ..\libtcc.h libtcc 18 | : 19 | .\tcc -c lib/crt1.c 20 | .\tcc -c lib/wincrt1.c 21 | .\tcc -c lib/dllcrt1.c 22 | .\tcc -c lib/dllmain.c 23 | .\tcc -c lib/chkstk.S 24 | .\tcc -c ../lib/libtcc1.c 25 | .\tcc -c ../lib/alloca86.S 26 | .\tcc -c ../lib/alloca86-bt.S 27 | ar rcs lib/libtcc1.a crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o libtcc1.o alloca86.o alloca86-bt.o 28 | del *.o 29 | -------------------------------------------------------------------------------- /win32/include/share.h: -------------------------------------------------------------------------------- 1 | /* 2 | * share.h 3 | * 4 | * Constants for file sharing functions. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef __STRICT_ANSI__ 28 | 29 | #ifndef _SHARE_H_ 30 | #define _SHARE_H_ 31 | 32 | /* All the headers include this file. */ 33 | #include <_mingw.h> 34 | 35 | #define SH_COMPAT 0x00 /* Compatibility */ 36 | #define SH_DENYRW 0x10 /* Deny read/write */ 37 | #define SH_DENYWR 0x20 /* Deny write */ 38 | #define SH_DENYRD 0x30 /* Deny read */ 39 | #define SH_DENYNO 0x40 /* Deny nothing */ 40 | 41 | #endif /* Not _SHARE_H_ */ 42 | 43 | #endif /* Not __STRICT_ANSI__ */ 44 | 45 | -------------------------------------------------------------------------------- /win32/lib/wincrt1.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | 3 | #include 4 | 5 | #define __UNKNOWN_APP 0 6 | #define __CONSOLE_APP 1 7 | #define __GUI_APP 2 8 | void __set_app_type(int); 9 | void _controlfp(unsigned a, unsigned b); 10 | 11 | int _winstart(void) 12 | { 13 | char *szCmd; STARTUPINFO startinfo; 14 | 15 | __set_app_type(__GUI_APP); 16 | _controlfp(0x10000, 0x30000); 17 | 18 | szCmd = GetCommandLine(); 19 | if (szCmd) 20 | { 21 | while (' ' == *szCmd) szCmd++; 22 | if ('\"' == *szCmd) 23 | { 24 | while (*++szCmd) 25 | if ('\"' == *szCmd) { szCmd++; break; } 26 | } 27 | else 28 | { 29 | while (*szCmd && ' ' != *szCmd) szCmd++; 30 | } 31 | while (' ' == *szCmd) szCmd++; 32 | } 33 | 34 | GetStartupInfo(&startinfo); 35 | exit(WinMain(GetModuleHandle(NULL), NULL, szCmd, 36 | (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? 37 | startinfo.wShowWindow : SW_SHOWDEFAULT)); 38 | } 39 | 40 | int _runwinmain(int argc, char **argv) 41 | { 42 | char *szCmd = NULL; 43 | char *p = GetCommandLine(); 44 | if (argc > 1) szCmd = strstr(p, argv[1]); 45 | if (NULL == szCmd) szCmd = ""; 46 | else if (szCmd > p && szCmd[-1] == '\"') --szCmd; 47 | return WinMain(GetModuleHandle(NULL), NULL, szCmd, SW_SHOWDEFAULT); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # 2 | # LuaDist Travis-CI Hook 3 | # 4 | 5 | # We assume C build environments 6 | language: C 7 | 8 | # Try using multiple Lua Implementations 9 | env: 10 | - TOOL="gcc" # Use native compiler (GCC usually) 11 | - TOOL="clang" # Use clang 12 | - TOOL="i686-w64-mingw32" # 32bit MinGW 13 | - TOOL="x86_64-w64-mingw32" # 64bit MinGW 14 | - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux 15 | 16 | # Crosscompile builds may fail 17 | matrix: 18 | allow_failures: 19 | - env: TOOL="i686-w64-mingw32" 20 | - env: TOOL="x86_64-w64-mingw32" 21 | - env: TOOL="arm-linux-gnueabihf" 22 | 23 | # Install dependencies 24 | install: 25 | - git clone git://github.com/LuaDist/Tools.git ~/_tools 26 | - ~/_tools/travis/travis install 27 | 28 | # Bootstap 29 | before_script: 30 | - ~/_tools/travis/travis bootstrap 31 | 32 | # Build the module 33 | script: 34 | - ~/_tools/travis/travis build 35 | 36 | # Execute additional tests or commands 37 | after_script: 38 | - ~/_tools/travis/travis test 39 | 40 | # Only watch the master branch 41 | branches: 42 | only: 43 | - master 44 | 45 | # Notify the LuaDist Dev group if needed 46 | notifications: 47 | recipients: 48 | - luadist-dev@googlegroups.com 49 | email: 50 | on_success: change 51 | on_failure: always 52 | -------------------------------------------------------------------------------- /win32/include/_mingw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * _mingw.h 3 | * 4 | * This file is for TCC-PE and not part of the Mingw32 package. 5 | * 6 | * THIS SOFTWARE IS NOT COPYRIGHTED 7 | * 8 | * This source code is offered for use in the public domain. You may 9 | * use, modify or distribute it freely. 10 | * 11 | * This code is distributed in the hope that it will be useful but 12 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 13 | * DISCLAIMED. This includes but is not limited to warranties of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * 16 | */ 17 | 18 | #ifndef __MINGW_H 19 | #define __MINGW_H 20 | 21 | #include 22 | 23 | #define __int64 long long 24 | #define __int32 long 25 | #define __int16 short 26 | #define __int8 char 27 | #define __cdecl __attribute__((__cdecl__)) 28 | #define __stdcall __attribute__((__stdcall__)) 29 | #define __declspec(x) __attribute__((x)) 30 | 31 | #define __MINGW32_VERSION 2.0 32 | #define __MINGW32_MAJOR_VERSION 2 33 | #define __MINGW32_MINOR_VERSION 0 34 | 35 | #define __MSVCRT__ 1 36 | #define __MINGW_IMPORT extern 37 | #define _CRTIMP 38 | #define __CRT_INLINE extern __inline__ 39 | 40 | #define WIN32 1 41 | 42 | #ifndef _WINT_T 43 | #define _WINT_T 44 | typedef unsigned int wint_t; 45 | #endif 46 | 47 | /* for winapi */ 48 | #define _ANONYMOUS_UNION 49 | #define _ANONYMOUS_STRUCT 50 | #define DECLSPEC_NORETURN 51 | #define WIN32_LEAN_AND_MEAN 52 | #define DECLARE_STDCALL_P(type) __stdcall type 53 | 54 | #endif /* __MINGW_H */ 55 | -------------------------------------------------------------------------------- /win32/include/sys/locking.h: -------------------------------------------------------------------------------- 1 | /* 2 | * locking.h 3 | * 4 | * Constants for the mode parameter of the locking function. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef __STRICT_ANSI__ 28 | 29 | #ifndef _LOCKING_H_ 30 | #define _LOCKING_H_ 31 | 32 | /* All the headers include this file. */ 33 | #include <_mingw.h> 34 | 35 | #define _LK_UNLCK 0 /* Unlock */ 36 | #define _LK_LOCK 1 /* Lock */ 37 | #define _LK_NBLCK 2 /* Non-blocking lock */ 38 | #define _LK_RLCK 3 /* Lock for read only */ 39 | #define _LK_NBRLCK 4 /* Non-blocking lock for read only */ 40 | 41 | #ifndef NO_OLDNAMES 42 | #define LK_UNLCK _LK_UNLCK 43 | #define LK_LOCK _LK_LOCK 44 | #define LK_NBLCK _LK_NBLCK 45 | #define LK_RLCK _LK_RLCK 46 | #define LK_NBRLCK _LK_NBRLCK 47 | #endif /* Not NO_OLDNAMES */ 48 | 49 | #endif /* Not _LOCKING_H_ */ 50 | 51 | #endif /* Not __STRICT_ANSI__ */ 52 | 53 | -------------------------------------------------------------------------------- /include/float.h: -------------------------------------------------------------------------------- 1 | #ifndef _FLOAT_H_ 2 | #define _FLOAT_H_ 3 | 4 | #define FLT_RADIX 2 5 | 6 | /* IEEE float */ 7 | #define FLT_MANT_DIG 24 8 | #define FLT_DIG 6 9 | #define FLT_ROUNDS 1 10 | #define FLT_EPSILON 1.19209290e-07F 11 | #define FLT_MIN_EXP (-125) 12 | #define FLT_MIN 1.17549435e-38F 13 | #define FLT_MIN_10_EXP (-37) 14 | #define FLT_MAX_EXP 128 15 | #define FLT_MAX 3.40282347e+38F 16 | #define FLT_MAX_10_EXP 38 17 | 18 | /* IEEE double */ 19 | #define DBL_MANT_DIG 53 20 | #define DBL_DIG 15 21 | #define DBL_EPSILON 2.2204460492503131e-16 22 | #define DBL_MIN_EXP (-1021) 23 | #define DBL_MIN 2.2250738585072014e-308 24 | #define DBL_MIN_10_EXP (-307) 25 | #define DBL_MAX_EXP 1024 26 | #define DBL_MAX 1.7976931348623157e+308 27 | #define DBL_MAX_10_EXP 308 28 | 29 | /* horrible intel long double */ 30 | #ifdef __i386__ 31 | 32 | #define LDBL_MANT_DIG 64 33 | #define LDBL_DIG 18 34 | #define LDBL_EPSILON 1.08420217248550443401e-19L 35 | #define LDBL_MIN_EXP (-16381) 36 | #define LDBL_MIN 3.36210314311209350626e-4932L 37 | #define LDBL_MIN_10_EXP (-4931) 38 | #define LDBL_MAX_EXP 16384 39 | #define LDBL_MAX 1.18973149535723176502e+4932L 40 | #define LDBL_MAX_10_EXP 4932 41 | 42 | #else 43 | 44 | /* same as IEEE double */ 45 | #define LDBL_MANT_DIG 53 46 | #define LDBL_DIG 15 47 | #define LDBL_EPSILON 2.2204460492503131e-16 48 | #define LDBL_MIN_EXP (-1021) 49 | #define LDBL_MIN 2.2250738585072014e-308 50 | #define LDBL_MIN_10_EXP (-307) 51 | #define LDBL_MAX_EXP 1024 52 | #define LDBL_MAX 1.7976931348623157e+308 53 | #define LDBL_MAX_10_EXP 308 54 | 55 | #endif 56 | 57 | #endif /* _FLOAT_H_ */ 58 | -------------------------------------------------------------------------------- /win32/include/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * assert.h 3 | * 4 | * Define the assert macro for debug output. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef _ASSERT_H_ 28 | #define _ASSERT_H_ 29 | 30 | /* All the headers include this file. */ 31 | #include <_mingw.h> 32 | 33 | #ifndef RC_INVOKED 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #ifdef NDEBUG 40 | 41 | /* 42 | * If not debugging, assert does nothing. 43 | */ 44 | #define assert(x) ((void)0) 45 | 46 | #else /* debugging enabled */ 47 | 48 | /* 49 | * CRTDLL nicely supplies a function which does the actual output and 50 | * call to abort. 51 | */ 52 | void _assert (const char*, const char*, int) 53 | #ifdef __GNUC__ 54 | __attribute__ ((noreturn)) 55 | #endif 56 | ; 57 | 58 | /* 59 | * Definition of the assert macro. 60 | */ 61 | #define assert(e) ((e) ? (void)0 : _assert(#e, __FILE__, __LINE__)) 62 | #endif /* NDEBUG */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* Not RC_INVOKED */ 69 | 70 | #endif /* Not _ASSERT_H_ */ 71 | 72 | -------------------------------------------------------------------------------- /win32/include/sys/timeb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * timeb.h 3 | * 4 | * Support for the UNIX System V ftime system call. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef __STRICT_ANSI__ 28 | 29 | #ifndef _TIMEB_H_ 30 | #define _TIMEB_H_ 31 | 32 | /* All the headers include this file. */ 33 | #include <_mingw.h> 34 | 35 | #ifndef RC_INVOKED 36 | 37 | /* 38 | * TODO: Structure not tested. 39 | */ 40 | struct _timeb 41 | { 42 | long time; 43 | short millitm; 44 | short timezone; 45 | short dstflag; 46 | }; 47 | 48 | #ifndef _NO_OLDNAMES 49 | /* 50 | * TODO: Structure not tested. 51 | */ 52 | struct timeb 53 | { 54 | long time; 55 | short millitm; 56 | short timezone; 57 | short dstflag; 58 | }; 59 | #endif 60 | 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /* TODO: Not tested. */ 67 | void _ftime (struct _timeb*); 68 | 69 | #ifndef _NO_OLDNAMES 70 | void ftime (struct timeb*); 71 | #endif /* Not _NO_OLDNAMES */ 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* Not RC_INVOKED */ 78 | 79 | #endif /* Not _TIMEB_H_ */ 80 | 81 | #endif /* Not __STRICT_ANSI__ */ 82 | 83 | -------------------------------------------------------------------------------- /win32/include/setjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * setjmp.h 3 | * 4 | * Declarations supporting setjmp and longjump, a method for avoiding 5 | * the normal function call return sequence. (Bleah!) 6 | * 7 | * This file is part of the Mingw32 package. 8 | * 9 | * Contributors: 10 | * Created by Colin Peters 11 | * 12 | * THIS SOFTWARE IS NOT COPYRIGHTED 13 | * 14 | * This source code is offered for use in the public domain. You may 15 | * use, modify or distribute it freely. 16 | * 17 | * This code is distributed in the hope that it will be useful but 18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 19 | * DISCLAIMED. This includes but is not limited to warranties of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | * 22 | * $Revision: 1.2 $ 23 | * $Author: bellard $ 24 | * $Date: 2005/04/17 13:14:29 $ 25 | * 26 | */ 27 | 28 | #ifndef _SETJMP_H_ 29 | #define _SETJMP_H_ 30 | 31 | /* All the headers include this file. */ 32 | #include <_mingw.h> 33 | 34 | #ifndef RC_INVOKED 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* 41 | * The buffer used by setjmp to store the information used by longjmp 42 | * to perform it's evil goto-like work. The size of this buffer was 43 | * determined through experimentation; it's contents are a mystery. 44 | * NOTE: This was determined on an i386 (actually a Pentium). The 45 | * contents could be different on an Alpha or something else. 46 | */ 47 | #define _JBLEN 16 48 | #define _JBTYPE int 49 | typedef _JBTYPE jmp_buf[_JBLEN]; 50 | 51 | /* 52 | * The function provided by CRTDLL which appears to do the actual work 53 | * of setjmp. 54 | */ 55 | int _setjmp (jmp_buf); 56 | 57 | #define setjmp(x) _setjmp(x) 58 | 59 | /* 60 | * Return to the last setjmp call and act as if setjmp had returned 61 | * nVal (which had better be non-zero!). 62 | */ 63 | void longjmp (jmp_buf, int); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* Not RC_INVOKED */ 70 | 71 | #endif /* Not _SETJMP_H_ */ 72 | 73 | -------------------------------------------------------------------------------- /tests/libtcc_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple Test program for libtcc 3 | * 4 | * libtcc can be useful to use tcc as a "backend" for a code generator. 5 | */ 6 | #include 7 | #include 8 | #include 9 | 10 | #include "libtcc.h" 11 | 12 | /* this function is called by the generated code */ 13 | int add(int a, int b) 14 | { 15 | return a + b; 16 | } 17 | 18 | char my_program[] = 19 | "int fib(int n)\n" 20 | "{\n" 21 | " if (n <= 2)\n" 22 | " return 1;\n" 23 | " else\n" 24 | " return fib(n-1) + fib(n-2);\n" 25 | "}\n" 26 | "\n" 27 | "int foo(int n)\n" 28 | "{\n" 29 | " printf(\"Hello World!\\n\");\n" 30 | " printf(\"fib(%d) = %d\\n\", n, fib(n));\n" 31 | " printf(\"add(%d, %d) = %d\\n\", n, 2 * n, add(n, 2 * n));\n" 32 | " return 0;\n" 33 | "}\n"; 34 | 35 | int main(int argc, char **argv) 36 | { 37 | TCCState *s; 38 | int (*func)(int); 39 | void *mem; 40 | int size; 41 | 42 | s = tcc_new(); 43 | if (!s) { 44 | fprintf(stderr, "Could not create tcc state\n"); 45 | exit(1); 46 | } 47 | 48 | /* if tcclib.h and libtcc1.a are not installed, where can we find them */ 49 | if (argc == 2 && !memcmp(argv[1], "lib_path=",9)) 50 | tcc_set_lib_path(s, argv[1]+9); 51 | 52 | /* MUST BE CALLED before any compilation */ 53 | tcc_set_output_type(s, TCC_OUTPUT_MEMORY); 54 | 55 | if (tcc_compile_string(s, my_program) == -1) 56 | return 1; 57 | 58 | /* as a test, we add a symbol that the compiled program can use. 59 | You may also open a dll with tcc_add_dll() and use symbols from that */ 60 | tcc_add_symbol(s, "add", add); 61 | 62 | /* get needed size of the code */ 63 | size = tcc_relocate(s, NULL); 64 | if (size == -1) 65 | return 1; 66 | 67 | /* allocate memory and copy the code into it */ 68 | mem = malloc(size); 69 | tcc_relocate(s, mem); 70 | 71 | /* get entry symbol */ 72 | func = tcc_get_symbol(s, "foo"); 73 | if (!func) 74 | return 1; 75 | 76 | /* delete the state */ 77 | tcc_delete(s); 78 | 79 | /* run the code */ 80 | func(32); 81 | 82 | free(mem); 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /win32/include/sys/utime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utime.h 3 | * 4 | * Support for the utime function. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef __STRICT_ANSI__ 28 | 29 | #ifndef _UTIME_H_ 30 | #define _UTIME_H_ 31 | 32 | /* All the headers include this file. */ 33 | #include <_mingw.h> 34 | 35 | #define __need_wchar_t 36 | #define __need_size_t 37 | #ifndef RC_INVOKED 38 | #include 39 | #endif /* Not RC_INVOKED */ 40 | #include 41 | 42 | #ifndef RC_INVOKED 43 | 44 | /* 45 | * Structure used by _utime function. 46 | */ 47 | struct _utimbuf 48 | { 49 | time_t actime; /* Access time */ 50 | time_t modtime; /* Modification time */ 51 | }; 52 | 53 | 54 | #ifndef _NO_OLDNAMES 55 | /* NOTE: Must be the same as _utimbuf above. */ 56 | struct utimbuf 57 | { 58 | time_t actime; 59 | time_t modtime; 60 | }; 61 | #endif /* Not _NO_OLDNAMES */ 62 | 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | int _utime (const char*, struct _utimbuf*); 69 | int _futime (int, struct _utimbuf*); 70 | 71 | /* The wide character version, only available for MSVCRT versions of the 72 | * C runtime library. */ 73 | #ifdef __MSVCRT__ 74 | int _wutime (const wchar_t*, struct _utimbuf*); 75 | #endif /* MSVCRT runtime */ 76 | #ifndef _NO_OLDNAMES 77 | int utime (const char*, struct utimbuf*); 78 | #endif /* Not _NO_OLDNAMES */ 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* Not RC_INVOKED */ 85 | 86 | #endif /* Not _UTIME_H_ */ 87 | 88 | #endif /* Not __STRICT_ANSI__ */ 89 | 90 | -------------------------------------------------------------------------------- /win32/include/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * malloc.h 3 | * 4 | * Support for programs which want to use malloc.h to get memory management 5 | * functions. Unless you absolutely need some of these functions and they are 6 | * not in the ANSI headers you should use the ANSI standard header files 7 | * instead. 8 | * 9 | * This file is part of the Mingw32 package. 10 | * 11 | * Contributors: 12 | * Created by Colin Peters 13 | * 14 | * THIS SOFTWARE IS NOT COPYRIGHTED 15 | * 16 | * This source code is offered for use in the public domain. You may 17 | * use, modify or distribute it freely. 18 | * 19 | * This code is distributed in the hope that it will be useful but 20 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 21 | * DISCLAIMED. This includes but is not limited to warranties of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 | * 24 | * $Revision: 1.2 $ 25 | * $Author: bellard $ 26 | * $Date: 2005/04/17 13:14:29 $ 27 | * 28 | */ 29 | 30 | #ifndef __STRICT_ANSI__ 31 | 32 | #ifndef _MALLOC_H_ 33 | #define _MALLOC_H_ 34 | 35 | /* All the headers include this file. */ 36 | #include <_mingw.h> 37 | 38 | #include 39 | 40 | #ifndef RC_INVOKED 41 | 42 | /* 43 | * The structure used to walk through the heap with _heapwalk. 44 | */ 45 | typedef struct _heapinfo 46 | { 47 | int* _pentry; 48 | size_t _size; 49 | int _useflag; 50 | } _HEAPINFO; 51 | 52 | /* Values for _heapinfo.useflag */ 53 | #define _USEDENTRY 0 54 | #define _FREEENTRY 1 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | /* 60 | The _heap* memory allocation functions are supported on NT 61 | but not W9x. On latter, they always set errno to ENOSYS. 62 | */ 63 | int _heapwalk (_HEAPINFO*); 64 | 65 | #ifndef _NO_OLDNAMES 66 | int heapwalk (_HEAPINFO*); 67 | #endif /* Not _NO_OLDNAMES */ 68 | 69 | int _heapchk (void); /* Verify heap integrety. */ 70 | int _heapmin (void); /* Return unused heap to the OS. */ 71 | int _heapset (unsigned int); 72 | 73 | size_t _msize (void*); 74 | size_t _get_sbh_threshold (void); 75 | int _set_sbh_threshold (size_t); 76 | void * _expand (void*, size_t); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* RC_INVOKED */ 83 | 84 | #endif /* Not _MALLOC_H_ */ 85 | 86 | #endif /* Not __STRICT_ANSI__ */ 87 | 88 | -------------------------------------------------------------------------------- /win32/include/fenv.h: -------------------------------------------------------------------------------- 1 | #ifndef _FENV_H 2 | #define _FENV_H 3 | 4 | /* 5 | For now, support only for the basic abstraction of flags that are 6 | either set or clear. fexcept_t could be structure that holds more info 7 | about the fp environment. 8 | */ 9 | typedef unsigned short fexcept_t; 10 | 11 | /* This 28-byte struct represents the entire floating point 12 | environment as stored by fnstenv or fstenv */ 13 | typedef struct 14 | { 15 | unsigned short __control_word; 16 | unsigned short __unused0; 17 | unsigned short __status_word; 18 | unsigned short __unused1; 19 | unsigned short __tag_word; 20 | unsigned short __unused2; 21 | unsigned int __ip_offset; /* instruction pointer offset */ 22 | unsigned short __ip_selector; 23 | unsigned short __opcode; 24 | unsigned int __data_offset; 25 | unsigned short __data_selector; 26 | unsigned short __unused3; 27 | } fenv_t; 28 | 29 | 30 | /* FPU status word exception flags */ 31 | #define FE_INVALID 0x01 32 | #define FE_DENORMAL 0x02 33 | #define FE_DIVBYZERO 0x04 34 | #define FE_OVERFLOW 0x08 35 | #define FE_UNDERFLOW 0x10 36 | #define FE_INEXACT 0x20 37 | #define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \ 38 | | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) 39 | 40 | /* FPU control word rounding flags */ 41 | #define FE_TONEAREST 0x0000 42 | #define FE_DOWNWARD 0x0400 43 | #define FE_UPWARD 0x0800 44 | #define FE_TOWARDZERO 0x0c00 45 | 46 | 47 | /* The default floating point environment */ 48 | #define FE_DFL_ENV ((const fenv_t *)-1) 49 | 50 | 51 | #ifndef RC_INVOKED 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | 57 | /*TODO: Some of these could be inlined */ 58 | /* 7.6.2 Exception */ 59 | 60 | extern int feclearexcept (int); 61 | extern int fegetexceptflag (fexcept_t * flagp, int excepts); 62 | extern int feraiseexcept (int excepts ); 63 | extern int fesetexceptflag (const fexcept_t *, int); 64 | extern int fetestexcept (int excepts); 65 | 66 | 67 | /* 7.6.3 Rounding */ 68 | 69 | extern int fegetround (void); 70 | extern int fesetround (int mode); 71 | 72 | 73 | /* 7.6.4 Environment */ 74 | 75 | extern int fegetenv (fenv_t * envp); 76 | extern int fesetenv (const fenv_t * ); 77 | extern int feupdateenv (const fenv_t *); 78 | extern int feholdexcept (fenv_t *); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #endif /* Not RC_INVOKED */ 84 | 85 | #endif /* ndef _FENV_H */ 86 | -------------------------------------------------------------------------------- /win32/include/direct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * direct.h 3 | * 4 | * Functions for manipulating paths and directories (included from io.h) 5 | * plus functions for setting the current drive. 6 | * 7 | * This file is part of the Mingw32 package. 8 | * 9 | * Contributors: 10 | * Created by Colin Peters 11 | * 12 | * THIS SOFTWARE IS NOT COPYRIGHTED 13 | * 14 | * This source code is offered for use in the public domain. You may 15 | * use, modify or distribute it freely. 16 | * 17 | * This code is distributed in the hope that it will be useful but 18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 19 | * DISCLAIMED. This includes but is not limited to warranties of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | * 22 | * $Revision: 1.2 $ 23 | * $Author: bellard $ 24 | * $Date: 2005/04/17 13:14:29 $ 25 | * 26 | */ 27 | 28 | #ifndef __STRICT_ANSI__ 29 | 30 | #ifndef _DIRECT_H_ 31 | #define _DIRECT_H_ 32 | 33 | /* All the headers include this file. */ 34 | #include <_mingw.h> 35 | 36 | #define __need_wchar_t 37 | #ifndef RC_INVOKED 38 | #include 39 | #endif /* Not RC_INVOKED */ 40 | 41 | #include 42 | 43 | #ifndef RC_INVOKED 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #ifndef _DISKFREE_T_DEFINED 50 | /* needed by _getdiskfree (also in dos.h) */ 51 | struct _diskfree_t { 52 | unsigned total_clusters; 53 | unsigned avail_clusters; 54 | unsigned sectors_per_cluster; 55 | unsigned bytes_per_sector; 56 | }; 57 | #define _DISKFREE_T_DEFINED 58 | #endif 59 | 60 | /* 61 | * You really shouldn't be using these. Use the Win32 API functions instead. 62 | * However, it does make it easier to port older code. 63 | */ 64 | int _getdrive (void); 65 | unsigned long _getdrives(void); 66 | int _chdrive (int); 67 | char* _getdcwd (int, char*, int); 68 | unsigned _getdiskfree (unsigned, struct _diskfree_t *); 69 | 70 | #ifndef _NO_OLDNAMES 71 | # define diskfree_t _diskfree_t 72 | #endif 73 | 74 | #ifndef _WDIRECT_DEFINED 75 | /* wide character versions. Also in wchar.h */ 76 | #ifdef __MSVCRT__ 77 | int _wchdir(const wchar_t*); 78 | wchar_t* _wgetcwd(wchar_t*, int); 79 | wchar_t* _wgetdcwd(int, wchar_t*, int); 80 | int _wmkdir(const wchar_t*); 81 | int _wrmdir(const wchar_t*); 82 | #endif /* __MSVCRT__ */ 83 | #define _WDIRECT_DEFINED 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* Not RC_INVOKED */ 91 | 92 | #endif /* Not _DIRECT_H_ */ 93 | 94 | #endif /* Not __STRICT_ANSI__ */ 95 | 96 | -------------------------------------------------------------------------------- /examples/ex2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define N 20 5 | 6 | int nb_num; 7 | int tab[N]; 8 | int stack_ptr; 9 | int stack_op[N]; 10 | int stack_res[60]; 11 | int result; 12 | 13 | int find(int n, int i1, int a, int b, int op) 14 | { 15 | int i, j; 16 | int c; 17 | 18 | if (stack_ptr >= 0) { 19 | stack_res[3*stack_ptr] = a; 20 | stack_op[stack_ptr] = op; 21 | stack_res[3*stack_ptr+1] = b; 22 | stack_res[3*stack_ptr+2] = n; 23 | if (n == result) 24 | return 1; 25 | tab[i1] = n; 26 | } 27 | 28 | for(i=0;i 12 | * 13 | * This code is distributed in the hope that is will be useful but 14 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 15 | * DISCLAIMED. This includeds but is not limited to warranties of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * $Revision: 1.2 $ 19 | * $Author: bellard $ 20 | * $Date: 2005/04/17 13:14:29 $ 21 | * 22 | */ 23 | 24 | #ifndef __STRICT_ANSI__ 25 | 26 | #ifndef _DIRENT_H_ 27 | #define _DIRENT_H_ 28 | 29 | /* All the headers include this file. */ 30 | #include <_mingw.h> 31 | 32 | #include 33 | 34 | #ifndef RC_INVOKED 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | struct dirent 41 | { 42 | long d_ino; /* Always zero. */ 43 | unsigned short d_reclen; /* Always zero. */ 44 | unsigned short d_namlen; /* Length of name in d_name. */ 45 | char* d_name; /* File name. */ 46 | /* NOTE: The name in the dirent structure points to the name in the 47 | * finddata_t structure in the DIR. */ 48 | }; 49 | 50 | /* 51 | * This is an internal data structure. Good programmers will not use it 52 | * except as an argument to one of the functions below. 53 | */ 54 | typedef struct 55 | { 56 | /* disk transfer area for this dir */ 57 | struct _finddata_t dd_dta; 58 | 59 | /* dirent struct to return from dir (NOTE: this makes this thread 60 | * safe as long as only one thread uses a particular DIR struct at 61 | * a time) */ 62 | struct dirent dd_dir; 63 | 64 | /* _findnext handle */ 65 | long dd_handle; 66 | 67 | /* 68 | * Status of search: 69 | * 0 = not started yet (next entry to read is first entry) 70 | * -1 = off the end 71 | * positive = 0 based index of next entry 72 | */ 73 | short dd_stat; 74 | 75 | /* given path for dir with search pattern (struct is extended) */ 76 | char dd_name[1]; 77 | } DIR; 78 | 79 | 80 | DIR* opendir (const char*); 81 | struct dirent* readdir (DIR*); 82 | int closedir (DIR*); 83 | void rewinddir (DIR*); 84 | long telldir (DIR*); 85 | void seekdir (DIR*, long); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* Not RC_INVOKED */ 92 | 93 | #endif /* Not _DIRENT_H_ */ 94 | 95 | #endif /* Not __STRICT_ANSI__ */ 96 | 97 | -------------------------------------------------------------------------------- /win32/include/sys/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * types.h 3 | * 4 | * The definition of constants, data types and global variables. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * Lots of types supplied by Pedro A. Aranda 11 | * 12 | * THIS SOFTWARE IS NOT COPYRIGHTED 13 | * 14 | * This source code is offered for use in the public domain. You may 15 | * use, modify or distribute it freely. 16 | * 17 | * This code is distributed in the hope that it will be useful but 18 | * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY 19 | * DISCLAIMED. This includes but is not limited to warrenties of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | * 22 | * $Revision: 1.2 $ 23 | * $Author: bellard $ 24 | * $Date: 2005/04/17 13:14:29 $ 25 | * 26 | */ 27 | 28 | #ifndef _TYPES_H_ 29 | #define _TYPES_H_ 30 | 31 | /* All the headers include this file. */ 32 | #include <_mingw.h> 33 | 34 | #define __need_wchar_t 35 | #define __need_size_t 36 | #define __need_ptrdiff_t 37 | #ifndef RC_INVOKED 38 | #include 39 | #endif /* Not RC_INVOKED */ 40 | 41 | #ifndef RC_INVOKED 42 | 43 | #ifndef _TIME_T_DEFINED 44 | typedef long time_t; 45 | #define _TIME_T_DEFINED 46 | #endif 47 | 48 | 49 | #ifndef __STRICT_ANSI__ 50 | 51 | #ifndef _OFF_T_ 52 | #define _OFF_T_ 53 | typedef long _off_t; 54 | 55 | #ifndef _NO_OLDNAMES 56 | typedef _off_t off_t; 57 | #endif 58 | #endif /* Not _OFF_T_ */ 59 | 60 | 61 | #ifndef _DEV_T_ 62 | #define _DEV_T_ 63 | #ifdef __MSVCRT__ 64 | typedef unsigned int _dev_t; 65 | #else 66 | typedef short _dev_t; 67 | #endif 68 | 69 | #ifndef _NO_OLDNAMES 70 | typedef _dev_t dev_t; 71 | #endif 72 | #endif /* Not _DEV_T_ */ 73 | 74 | 75 | #ifndef _INO_T_ 76 | #define _INO_T_ 77 | typedef short _ino_t; 78 | 79 | #ifndef _NO_OLDNAMES 80 | typedef _ino_t ino_t; 81 | #endif 82 | #endif /* Not _INO_T_ */ 83 | 84 | 85 | #ifndef _PID_T_ 86 | #define _PID_T_ 87 | typedef int _pid_t; 88 | 89 | #ifndef _NO_OLDNAMES 90 | typedef _pid_t pid_t; 91 | #endif 92 | #endif /* Not _PID_T_ */ 93 | 94 | 95 | #ifndef _MODE_T_ 96 | #define _MODE_T_ 97 | typedef unsigned short _mode_t; 98 | 99 | #ifndef _NO_OLDNAMES 100 | typedef _mode_t mode_t; 101 | #endif 102 | #endif /* Not _MODE_T_ */ 103 | 104 | 105 | #ifndef _SIGSET_T_ 106 | #define _SIGSET_T_ 107 | typedef int _sigset_t; 108 | 109 | #ifndef _NO_OLDNAMES 110 | typedef _sigset_t sigset_t; 111 | #endif 112 | #endif /* Not _SIGSET_T_ */ 113 | 114 | #endif /* Not __STRICT_ANSI__ */ 115 | 116 | #endif /* Not RC_INVOKED */ 117 | 118 | #endif /* Not _TYPES_H_ */ 119 | -------------------------------------------------------------------------------- /win32/include/locale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * locale.h 3 | * 4 | * Functions and types for localization (ie. changing the appearance of 5 | * output based on the standards of a certain country). 6 | * 7 | * This file is part of the Mingw32 package. 8 | * 9 | * Contributors: 10 | * Created by Colin Peters 11 | * 12 | * THIS SOFTWARE IS NOT COPYRIGHTED 13 | * 14 | * This source code is offered for use in the public domain. You may 15 | * use, modify or distribute it freely. 16 | * 17 | * This code is distributed in the hope that it will be useful but 18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 19 | * DISCLAIMED. This includes but is not limited to warranties of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | * 22 | * $Revision: 1.2 $ 23 | * $Author: bellard $ 24 | * $Date: 2005/04/17 13:14:29 $ 25 | * 26 | */ 27 | 28 | #ifndef _LOCALE_H_ 29 | #define _LOCALE_H_ 30 | 31 | /* All the headers include this file. */ 32 | #include <_mingw.h> 33 | 34 | /* 35 | * NOTE: I have tried to test this, but I am limited by my knowledge of 36 | * locale issues. The structure does not bomb if you look at the 37 | * values, and 'decimal_point' even seems to be correct. But the 38 | * rest of the values are, by default, not particularly useful 39 | * (read meaningless and not related to the international settings 40 | * of the system). 41 | */ 42 | 43 | #define LC_ALL 0 44 | #define LC_COLLATE 1 45 | #define LC_CTYPE 2 46 | #define LC_MONETARY 3 47 | #define LC_NUMERIC 4 48 | #define LC_TIME 5 49 | #define LC_MIN LC_ALL 50 | #define LC_MAX LC_TIME 51 | 52 | #ifndef RC_INVOKED 53 | 54 | /* 55 | * The structure returned by 'localeconv'. 56 | */ 57 | struct lconv 58 | { 59 | char* decimal_point; 60 | char* thousands_sep; 61 | char* grouping; 62 | char* int_curr_symbol; 63 | char* currency_symbol; 64 | char* mon_decimal_point; 65 | char* mon_thousands_sep; 66 | char* mon_grouping; 67 | char* positive_sign; 68 | char* negative_sign; 69 | char int_frac_digits; 70 | char frac_digits; 71 | char p_cs_precedes; 72 | char p_sep_by_space; 73 | char n_cs_precedes; 74 | char n_sep_by_space; 75 | char p_sign_posn; 76 | char n_sign_posn; 77 | }; 78 | 79 | #ifdef __cplusplus 80 | extern "C" { 81 | #endif 82 | 83 | char* setlocale (int, const char*); 84 | struct lconv* localeconv (void); 85 | 86 | #ifndef _WLOCALE_DEFINED /* also declared in wchar.h */ 87 | # define __need_wchar_t 88 | # include 89 | wchar_t* _wsetlocale(int, const wchar_t*); 90 | # define _WLOCALE_DEFINED 91 | #endif /* ndef _WLOCALE_DEFINED */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* Not RC_INVOKED */ 98 | 99 | #endif /* Not _LOCALE_H_ */ 100 | 101 | -------------------------------------------------------------------------------- /include/tcclib.h: -------------------------------------------------------------------------------- 1 | /* Simple libc header for TCC 2 | * 3 | * Add any function you want from the libc there. This file is here 4 | * only for your convenience so that you do not need to put the whole 5 | * glibc include files on your floppy disk 6 | */ 7 | #ifndef _TCCLIB_H 8 | #define _TCCLIB_H 9 | 10 | #include 11 | #include 12 | 13 | /* stdlib.h */ 14 | void *calloc(size_t nmemb, size_t size); 15 | void *malloc(size_t size); 16 | void free(void *ptr); 17 | void *realloc(void *ptr, size_t size); 18 | int atoi(const char *nptr); 19 | long int strtol(const char *nptr, char **endptr, int base); 20 | unsigned long int strtoul(const char *nptr, char **endptr, int base); 21 | void exit(int); 22 | 23 | /* stdio.h */ 24 | typedef struct __FILE FILE; 25 | #define EOF (-1) 26 | extern FILE *stdin; 27 | extern FILE *stdout; 28 | extern FILE *stderr; 29 | FILE *fopen(const char *path, const char *mode); 30 | FILE *fdopen(int fildes, const char *mode); 31 | FILE *freopen(const char *path, const char *mode, FILE *stream); 32 | int fclose(FILE *stream); 33 | size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); 34 | size_t fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream); 35 | int fgetc(FILE *stream); 36 | char *fgets(char *s, int size, FILE *stream); 37 | int getc(FILE *stream); 38 | int getchar(void); 39 | char *gets(char *s); 40 | int ungetc(int c, FILE *stream); 41 | int fflush(FILE *stream); 42 | 43 | int printf(const char *format, ...); 44 | int fprintf(FILE *stream, const char *format, ...); 45 | int sprintf(char *str, const char *format, ...); 46 | int snprintf(char *str, size_t size, const char *format, ...); 47 | int asprintf(char **strp, const char *format, ...); 48 | int dprintf(int fd, const char *format, ...); 49 | int vprintf(const char *format, va_list ap); 50 | int vfprintf(FILE *stream, const char *format, va_list ap); 51 | int vsprintf(char *str, const char *format, va_list ap); 52 | int vsnprintf(char *str, size_t size, const char *format, va_list ap); 53 | int vasprintf(char **strp, const char *format, va_list ap); 54 | int vdprintf(int fd, const char *format, va_list ap); 55 | 56 | void perror(const char *s); 57 | 58 | /* string.h */ 59 | char *strcat(char *dest, const char *src); 60 | char *strchr(const char *s, int c); 61 | char *strrchr(const char *s, int c); 62 | char *strcpy(char *dest, const char *src); 63 | void *memcpy(void *dest, const void *src, size_t n); 64 | void *memmove(void *dest, const void *src, size_t n); 65 | void *memset(void *s, int c, size_t n); 66 | char *strdup(const char *s); 67 | 68 | /* dlfcn.h */ 69 | #define RTLD_LAZY 0x001 70 | #define RTLD_NOW 0x002 71 | #define RTLD_GLOBAL 0x100 72 | 73 | void *dlopen(const char *filename, int flag); 74 | const char *dlerror(void); 75 | void *dlsym(void *handle, char *symbol); 76 | int dlclose(void *handle); 77 | 78 | #endif /* _TCCLIB_H */ 79 | -------------------------------------------------------------------------------- /include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDARG_H 2 | #define _STDARG_H 3 | 4 | #ifdef __x86_64__ 5 | #include 6 | 7 | /* GCC compatible definition of va_list. */ 8 | struct __va_list_struct { 9 | unsigned int gp_offset; 10 | unsigned int fp_offset; 11 | union { 12 | unsigned int overflow_offset; 13 | char *overflow_arg_area; 14 | }; 15 | char *reg_save_area; 16 | }; 17 | 18 | typedef struct __va_list_struct *va_list; 19 | 20 | /* we use __builtin_(malloc|free) to avoid #define malloc tcc_malloc */ 21 | /* XXX: this lacks the support of aggregated types. */ 22 | #define va_start(ap, last) \ 23 | (ap = (va_list)__builtin_malloc(sizeof(struct __va_list_struct)), \ 24 | *ap = *(struct __va_list_struct*)( \ 25 | (char*)__builtin_frame_address(0) - 16), \ 26 | ap->overflow_arg_area = ((char *)__builtin_frame_address(0) + \ 27 | ap->overflow_offset), \ 28 | ap->reg_save_area = (char *)__builtin_frame_address(0) - 176 - 16 \ 29 | ) 30 | #define va_arg(ap, type) \ 31 | (*(type*)(__builtin_types_compatible_p(type, long double) \ 32 | ? (ap->overflow_arg_area += 16, \ 33 | ap->overflow_arg_area - 16) \ 34 | : __builtin_types_compatible_p(type, double) \ 35 | ? (ap->fp_offset < 128 + 48 \ 36 | ? (ap->fp_offset += 16, \ 37 | ap->reg_save_area + ap->fp_offset - 16) \ 38 | : (ap->overflow_arg_area += 8, \ 39 | ap->overflow_arg_area - 8)) \ 40 | : (ap->gp_offset < 48 \ 41 | ? (ap->gp_offset += 8, \ 42 | ap->reg_save_area + ap->gp_offset - 8) \ 43 | : (ap->overflow_arg_area += 8, \ 44 | ap->overflow_arg_area - 8)) \ 45 | )) 46 | #define va_copy(dest, src) \ 47 | ((dest) = (va_list)malloc(sizeof(struct __va_list_struct)), \ 48 | *(dest) = *(src)) 49 | #define va_end(ap) __builtin_free(ap) 50 | 51 | #else 52 | 53 | typedef char *va_list; 54 | 55 | /* only correct for i386 */ 56 | #define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3) 57 | #define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3))) 58 | #define va_copy(dest, src) (dest) = (src) 59 | #define va_end(ap) 60 | 61 | #endif 62 | 63 | /* fix a buggy dependency on GCC in libio.h */ 64 | typedef va_list __gnuc_va_list; 65 | #define _VA_LIST_DEFINED 66 | 67 | #endif /* _STDARG_H */ 68 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler 2 | ----------------------------------------------------------------------- 3 | 4 | Features: 5 | -------- 6 | 7 | - SMALL! You can compile and execute C code everywhere, for example on 8 | rescue disks. 9 | 10 | - FAST! tcc generates optimized x86 code. No byte code 11 | overhead. Compile, assemble and link about 7 times faster than 'gcc 12 | -O0'. 13 | 14 | - UNLIMITED! Any C dynamic library can be used directly. TCC is 15 | heading torward full ISOC99 compliance. TCC can of course compile 16 | itself. 17 | 18 | - SAFE! tcc includes an optional memory and bound checker. Bound 19 | checked code can be mixed freely with standard code. 20 | 21 | - Compile and execute C source directly. No linking or assembly 22 | necessary. Full C preprocessor included. 23 | 24 | - C script supported : just add '#!/usr/local/bin/tcc -run' at the first 25 | line of your C source, and execute it directly from the command 26 | line. 27 | 28 | Documentation: 29 | ------------- 30 | 31 | 1) Installation on a i386 Linux host (for Windows read tcc-win32.txt) 32 | 33 | ./configure 34 | make 35 | make test 36 | make install 37 | 38 | By default, tcc is installed in /usr/local/bin. 39 | ./configure --help shows configuration options. 40 | 41 | 42 | 2) Introduction 43 | 44 | We assume here that you know ANSI C. Look at the example ex1.c to know 45 | what the programs look like. 46 | 47 | The include file can be used if you want a small basic libc 48 | include support (especially useful for floppy disks). Of course, you 49 | can also use standard headers, although they are slower to compile. 50 | 51 | You can begin your C script with '#!/usr/local/bin/tcc -run' on the first 52 | line and set its execute bits (chmod a+x your_script). Then, you can 53 | launch the C code as a shell or perl script :-) The command line 54 | arguments are put in 'argc' and 'argv' of the main functions, as in 55 | ANSI C. 56 | 57 | 3) Examples 58 | 59 | ex1.c: simplest example (hello world). Can also be launched directly 60 | as a script: './ex1.c'. 61 | 62 | ex2.c: more complicated example: find a number with the four 63 | operations given a list of numbers (benchmark). 64 | 65 | ex3.c: compute fibonacci numbers (benchmark). 66 | 67 | ex4.c: more complicated: X11 program. Very complicated test in fact 68 | because standard headers are being used ! 69 | 70 | ex5.c: 'hello world' with standard glibc headers. 71 | 72 | tcc.c: TCC can of course compile itself. Used to check the code 73 | generator. 74 | 75 | tcctest.c: auto test for TCC which tests many subtle possible bugs. Used 76 | when doing 'make test'. 77 | 78 | 4) Full Documentation 79 | 80 | Please read tcc-doc.html to have all the features of TCC. 81 | 82 | Additional information is available for the Windows port in tcc-win32.txt. 83 | 84 | License: 85 | ------- 86 | 87 | TCC is distributed under the GNU Lesser General Public License (see 88 | COPYING file). 89 | 90 | Fabrice Bellard. 91 | -------------------------------------------------------------------------------- /win32/include/dos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dos.h 3 | * 4 | * DOS-specific functions and structures. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by J.J. van der Heijden 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef __STRICT_ANSI__ 28 | 29 | #ifndef _DOS_H_ 30 | #define _DOS_H_ 31 | 32 | /* All the headers include this file. */ 33 | #include <_mingw.h> 34 | 35 | #define __need_wchar_t 36 | #ifndef RC_INVOKED 37 | #include 38 | #endif /* Not RC_INVOKED */ 39 | 40 | /* For DOS file attributes */ 41 | #include 42 | 43 | #ifndef RC_INVOKED 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #ifndef __MSVCRT__ /* these are in CRTDLL, but not MSVCRT */ 50 | #ifndef __DECLSPEC_SUPPORTED 51 | extern unsigned int *__imp__basemajor_dll; 52 | extern unsigned int *__imp__baseminor_dll; 53 | extern unsigned int *__imp__baseversion_dll; 54 | extern unsigned int *__imp__osmajor_dll; 55 | extern unsigned int *__imp__osminor_dll; 56 | extern unsigned int *__imp__osmode_dll; 57 | 58 | #define _basemajor (*__imp__basemajor_dll) 59 | #define _baseminor (*__imp__baseminor_dll) 60 | #define _baseversion (*__imp__baseversion_dll) 61 | #define _osmajor (*__imp__osmajor_dll) 62 | #define _osminor (*__imp__osminor_dll) 63 | #define _osmode (*__imp__osmode_dll) 64 | 65 | #else /* __DECLSPEC_SUPPORTED */ 66 | 67 | __MINGW_IMPORT unsigned int _basemajor_dll; 68 | __MINGW_IMPORT unsigned int _baseminor_dll; 69 | __MINGW_IMPORT unsigned int _baseversion_dll; 70 | __MINGW_IMPORT unsigned int _osmajor_dll; 71 | __MINGW_IMPORT unsigned int _osminor_dll; 72 | __MINGW_IMPORT unsigned int _osmode_dll; 73 | 74 | #define _basemajor _basemajor_dll 75 | #define _baseminor _baseminor_dll 76 | #define _baseversion _baseversion_dll 77 | #define _osmajor _osmajor_dll 78 | #define _osminor _osminor_dll 79 | #define _osmode _osmode_dll 80 | 81 | #endif /* __DECLSPEC_SUPPORTED */ 82 | #endif /* ! __MSVCRT__ */ 83 | 84 | #ifndef _DISKFREE_T_DEFINED 85 | /* needed by _getdiskfree (also in direct.h) */ 86 | struct _diskfree_t { 87 | unsigned total_clusters; 88 | unsigned avail_clusters; 89 | unsigned sectors_per_cluster; 90 | unsigned bytes_per_sector; 91 | }; 92 | #define _DISKFREE_T_DEFINED 93 | #endif 94 | 95 | unsigned _getdiskfree (unsigned, struct _diskfree_t *); 96 | 97 | #ifndef _NO_OLDNAMES 98 | # define diskfree_t _diskfree_t 99 | #endif 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* Not RC_INVOKED */ 106 | 107 | #endif /* Not _DOS_H_ */ 108 | 109 | #endif /* Not __STRICT_ANSI__ */ 110 | 111 | -------------------------------------------------------------------------------- /win32/include/limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * limits.h 3 | * 4 | * Defines constants for the sizes of integral types. 5 | * 6 | * NOTE: GCC should supply a version of this header and it should be safe to 7 | * use that version instead of this one (maybe safer). 8 | * 9 | * This file is part of the Mingw32 package. 10 | * 11 | * Contributors: 12 | * Created by Colin Peters 13 | * 14 | * THIS SOFTWARE IS NOT COPYRIGHTED 15 | * 16 | * This source code is offered for use in the public domain. You may 17 | * use, modify or distribute it freely. 18 | * 19 | * This code is distributed in the hope that it will be useful but 20 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 21 | * DISCLAIMED. This includes but is not limited to warranties of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 | * 24 | * $Revision: 1.2 $ 25 | * $Author: bellard $ 26 | * $Date: 2005/04/17 13:14:29 $ 27 | * 28 | */ 29 | 30 | #ifndef _LIMITS_H_ 31 | #define _LIMITS_H_ 32 | 33 | /* All the headers include this file. */ 34 | #include <_mingw.h> 35 | 36 | /* 37 | * File system limits 38 | * 39 | * TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the 40 | * same as FILENAME_MAX and FOPEN_MAX from stdio.h? 41 | * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is 42 | * required for the NUL. TODO: Test? 43 | */ 44 | #define PATH_MAX (259) 45 | 46 | /* 47 | * Characteristics of the char data type. 48 | * 49 | * TODO: Is MB_LEN_MAX correct? 50 | */ 51 | #define CHAR_BIT 8 52 | #define MB_LEN_MAX 2 53 | 54 | #define SCHAR_MIN (-128) 55 | #define SCHAR_MAX 127 56 | 57 | #define UCHAR_MAX 255 58 | 59 | /* TODO: Is this safe? I think it might just be testing the preprocessor, 60 | * not the compiler itself... */ 61 | #if ('\x80' < 0) 62 | #define CHAR_MIN SCHAR_MIN 63 | #define CHAR_MAX SCHAR_MAX 64 | #else 65 | #define CHAR_MIN 0 66 | #define CHAR_MAX UCHAR_MAX 67 | #endif 68 | 69 | /* 70 | * Maximum and minimum values for ints. 71 | */ 72 | #define INT_MAX 2147483647 73 | #define INT_MIN (-INT_MAX-1) 74 | 75 | #define UINT_MAX 0xffffffff 76 | 77 | /* 78 | * Maximum and minimum values for shorts. 79 | */ 80 | #define SHRT_MAX 32767 81 | #define SHRT_MIN (-SHRT_MAX-1) 82 | 83 | #define USHRT_MAX 0xffff 84 | 85 | /* 86 | * Maximum and minimum values for longs and unsigned longs. 87 | * 88 | * TODO: This is not correct for Alphas, which have 64 bit longs. 89 | */ 90 | #define LONG_MAX 2147483647L 91 | 92 | #define LONG_MIN (-LONG_MAX-1) 93 | 94 | #define ULONG_MAX 0xffffffffUL 95 | 96 | 97 | /* 98 | * The GNU C compiler also allows 'long long int' 99 | */ 100 | #if !defined(__STRICT_ANSI__) && defined(__GNUC__) 101 | 102 | #define LONG_LONG_MAX 9223372036854775807LL 103 | #define LONG_LONG_MIN (-LONG_LONG_MAX-1) 104 | 105 | #define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1) 106 | 107 | /* ISO C9x macro names */ 108 | #define LLONG_MAX LONG_LONG_MAX 109 | #define LLONG_MIN LONG_LONG_MIN 110 | #define ULLONG_MAX ULONG_LONG_MAX 111 | 112 | #endif /* Not Strict ANSI and GNU C compiler */ 113 | 114 | 115 | #endif /* not _LIMITS_H_ */ 116 | -------------------------------------------------------------------------------- /win32/include/conio.h: -------------------------------------------------------------------------------- 1 | /* A conio implementation for Mingw/Dev-C++. 2 | * 3 | * Written by: 4 | * Hongli Lai 5 | * tkorrovi on 2002/02/26. 6 | * Andrew Westcott 7 | * 8 | * Offered for use in the public domain without any warranty. 9 | */ 10 | 11 | #ifndef _CONIO_H_ 12 | #define _CONIO_H_ 13 | 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define BLINK 0 22 | 23 | typedef enum 24 | { 25 | BLACK, 26 | BLUE, 27 | GREEN, 28 | CYAN, 29 | RED, 30 | MAGENTA, 31 | BROWN, 32 | LIGHTGRAY, 33 | DARKGRAY, 34 | LIGHTBLUE, 35 | LIGHTGREEN, 36 | LIGHTCYAN, 37 | LIGHTRED, 38 | LIGHTMAGENTA, 39 | YELLOW, 40 | WHITE 41 | } COLORS; 42 | 43 | 44 | #define cgets _cgets 45 | #define cprintf _cprintf 46 | #define cputs _cputs 47 | #define cscanf _cscanf 48 | #define ScreenClear clrscr 49 | 50 | /* blinkvideo */ 51 | 52 | void clreol (void); 53 | void clrscr (void); 54 | 55 | int _conio_gettext (int left, int top, int right, int bottom, 56 | char *str); 57 | /* _conio_kbhit */ 58 | 59 | void delline (void); 60 | 61 | /* gettextinfo */ 62 | void gotoxy(int x, int y); 63 | /* 64 | highvideo 65 | insline 66 | intensevideo 67 | lowvideo 68 | movetext 69 | normvideo 70 | */ 71 | 72 | void puttext (int left, int top, int right, int bottom, char *str); 73 | 74 | // Screen Variables 75 | 76 | /* ScreenCols 77 | ScreenGetChar 78 | ScreenGetCursor 79 | ScreenMode 80 | ScreenPutChar 81 | ScreenPutString 82 | ScreenRetrieve 83 | ScreenRows 84 | ScreenSetCursor 85 | ScreenUpdate 86 | ScreenUpdateLine 87 | ScreenVisualBell 88 | _set_screen_lines */ 89 | 90 | void _setcursortype (int type); 91 | 92 | void textattr (int _attr); 93 | 94 | void textbackground (int color); 95 | 96 | void textcolor (int color); 97 | 98 | /* textmode */ 99 | 100 | int wherex (void); 101 | 102 | int wherey (void); 103 | 104 | /* window */ 105 | 106 | 107 | 108 | /* The code below was part of Mingw's conio.h */ 109 | /* 110 | * conio.h 111 | * 112 | * Low level console I/O functions. Pretty please try to use the ANSI 113 | * standard ones if you are writing new code. 114 | * 115 | * This file is part of the Mingw32 package. 116 | * 117 | * Contributors: 118 | * Created by Colin Peters 119 | * 120 | * THIS SOFTWARE IS NOT COPYRIGHTED 121 | * 122 | * This source code is offered for use in the public domain. You may 123 | * use, modify or distribute it freely. 124 | * 125 | * This code is distributed in the hope that it will be useful but 126 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 127 | * DISCLAMED. This includes but is not limited to warranties of 128 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 129 | * 130 | * $Revision: 1.2 $ 131 | * $Author: bellard $ 132 | * $Date: 2005/04/17 13:14:29 $ 133 | * 134 | */ 135 | 136 | char* _cgets (char*); 137 | int _cprintf (const char*, ...); 138 | int _cputs (const char*); 139 | int _cscanf (char*, ...); 140 | 141 | int _getch (void); 142 | int _getche (void); 143 | int _kbhit (void); 144 | int _putch (int); 145 | int _ungetch (int); 146 | 147 | 148 | int getch (void); 149 | int getche (void); 150 | int kbhit (void); 151 | int putch (int); 152 | int ungetch (int); 153 | 154 | 155 | #ifdef __cplusplus 156 | } 157 | #endif 158 | 159 | #endif /* _CONIO_H_ */ 160 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | TODO list: 2 | 3 | Bugs: 4 | 5 | - fix macro substitution with nested definitions (ShangHongzhang) 6 | - FPU st(0) is left unclean (kwisatz haderach). Incompatible with 7 | optimized gcc/msc code 8 | 9 | - constructors 10 | - cast bug (Peter Wang) 11 | - define incomplete type if defined several times (Peter Wang). 12 | - configure --cc=tcc (still one bug in libtcc1.c) 13 | - test binutils/gcc compile 14 | - tci patch + argument. 15 | - see -lxxx bug (Michael Charity). 16 | - see transparent union pb in /urs/include/sys/socket.h 17 | - precise behaviour of typeof with arrays ? (__put_user macro) 18 | but should suffice for most cases) 19 | - handle '? x, y : z' in unsized variable initialization (',' is 20 | considered incorrectly as separator in preparser) 21 | - transform functions to function pointers in function parameters 22 | (net/ipv4/ip_output.c) 23 | - fix function pointer type display 24 | - check lcc test suite -> fix bitfield binary operations 25 | - check section alignment in C 26 | - fix invalid cast in comparison 'if (v == (int8_t)v)' 27 | - finish varargs.h support (gcc 3.2 testsuite issue) 28 | - fix static functions declared inside block 29 | - fix multiple unions init 30 | - sizeof, alignof, typeof can still generate code in some cases. 31 | - Fix the remaining libtcc memory leaks. 32 | - make libtcc fully reentrant (except for the compilation stage itself). 33 | 34 | Bound checking: 35 | 36 | - '-b' bug. 37 | - fix bound exit on RedHat 7.3 38 | - setjmp is not supported properly in bound checking. 39 | - fix bound check code with '&' on local variables (currently done 40 | only for local arrays). 41 | - bound checking and float/long long/struct copy code. bound 42 | checking and symbol + offset optimization 43 | 44 | Missing features: 45 | 46 | - disable-asm and disable-bcheck options 47 | - __builtin_expect() 48 | - improve '-E' option. 49 | - add '-MD' option 50 | - atexit (Nigel Horne) 51 | - packed attribute 52 | - C99: add variable size arrays (gcc 3.2 testsuite issue) 53 | - C99: add complex types (gcc 3.2 testsuite issue) 54 | - postfix compound literals (see 20010124-1.c) 55 | 56 | Optimizations: 57 | 58 | - suppress specific anonymous symbol handling 59 | - more parse optimizations (=even faster compilation) 60 | - memory alloc optimizations (=even faster compilation) 61 | - optimize VT_LOCAL + const 62 | - better local variables handling (needed for other targets) 63 | 64 | Not critical: 65 | 66 | - C99: fix multiple compound literals inits in blocks (ISOC99 67 | normative example - only relevant when using gotos! -> must add 68 | boolean variable to tell if compound literal was already 69 | initialized). 70 | - add PowerPC or ARM code generator and improve codegen for RISC (need 71 | to suppress VT_LOCAL and use a base register instead). 72 | - interactive mode / integrated debugger 73 | - fix preprocessor symbol redefinition 74 | - better constant opt (&&, ||, ?:) 75 | - add portable byte code generator and interpreter for other 76 | unsupported architectures. 77 | - C++: variable declaration in for, minimal 'class' support. 78 | - win32: __intxx. use resolve for bchecked malloc et al. 79 | check exception code (exception filter func). 80 | - handle void (__attribute__() *ptr)() 81 | 82 | Fixed (probably): 83 | 84 | - bug with defines: 85 | #define spin_lock(lock) do { } while (0) 86 | #define wq_spin_lock spin_lock 87 | #define TEST() wq_spin_lock(a) 88 | - typedefs can be structure fields 89 | - see bugfixes.diff + improvement.diff from Daniel Glockner 90 | - long long constant evaluation 91 | - add alloca() 92 | - gcc '-E' option. 93 | - #include_next support for /usr/include/limits ? 94 | - function pointers/lvalues in ? : (linux kernel net/core/dev.c) 95 | - win32: add __stdcall, check GetModuleHandle for dlls. 96 | -------------------------------------------------------------------------------- /win32/include/signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * signal.h 3 | * 4 | * A way to set handlers for exceptional conditions (also known as signals). 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef _SIGNAL_H_ 28 | #define _SIGNAL_H_ 29 | 30 | /* All the headers include this file. */ 31 | #include <_mingw.h> 32 | 33 | /* 34 | * The actual signal values. Using other values with signal 35 | * produces a SIG_ERR return value. 36 | * 37 | * NOTE: SIGINT is produced when the user presses Ctrl-C. 38 | * SIGILL has not been tested. 39 | * SIGFPE doesn't seem to work? 40 | * SIGSEGV does not catch writing to a NULL pointer (that shuts down 41 | * your app; can you say "segmentation violation core dump"?). 42 | * SIGTERM comes from what kind of termination request exactly? 43 | * SIGBREAK is indeed produced by pressing Ctrl-Break. 44 | * SIGABRT is produced by calling abort. 45 | * TODO: The above results may be related to not installing an appropriate 46 | * structured exception handling frame. Results may be better if I ever 47 | * manage to get the SEH stuff down. 48 | */ 49 | #define SIGINT 2 /* Interactive attention */ 50 | #define SIGILL 4 /* Illegal instruction */ 51 | #define SIGFPE 8 /* Floating point error */ 52 | #define SIGSEGV 11 /* Segmentation violation */ 53 | #define SIGTERM 15 /* Termination request */ 54 | #define SIGBREAK 21 /* Control-break */ 55 | #define SIGABRT 22 /* Abnormal termination (abort) */ 56 | 57 | #define NSIG 23 /* maximum signal number + 1 */ 58 | 59 | #ifndef RC_INVOKED 60 | 61 | #ifndef _SIG_ATOMIC_T_DEFINED 62 | typedef int sig_atomic_t; 63 | #define _SIG_ATOMIC_T_DEFINED 64 | #endif 65 | 66 | /* 67 | * The prototypes (below) are the easy part. The hard part is figuring 68 | * out what signals are available and what numbers they are assigned 69 | * along with appropriate values of SIG_DFL and SIG_IGN. 70 | */ 71 | 72 | /* 73 | * A pointer to a signal handler function. A signal handler takes a 74 | * single int, which is the signal it handles. 75 | */ 76 | typedef void (*__p_sig_fn_t)(int); 77 | 78 | /* 79 | * These are special values of signal handler pointers which are 80 | * used to send a signal to the default handler (SIG_DFL), ignore 81 | * the signal (SIG_IGN), or indicate an error return (SIG_ERR). 82 | */ 83 | #define SIG_DFL ((__p_sig_fn_t) 0) 84 | #define SIG_IGN ((__p_sig_fn_t) 1) 85 | #define SIG_ERR ((__p_sig_fn_t) -1) 86 | 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | /* 92 | * Call signal to set the signal handler for signal sig to the 93 | * function pointed to by handler. Returns a pointer to the 94 | * previous handler, or SIG_ERR if an error occurs. Initially 95 | * unhandled signals defined above will return SIG_DFL. 96 | */ 97 | __p_sig_fn_t signal(int, __p_sig_fn_t); 98 | 99 | /* 100 | * Raise the signal indicated by sig. Returns non-zero on success. 101 | */ 102 | int raise (int); 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* Not RC_INVOKED */ 109 | 110 | #endif /* Not _SIGNAL_H_ */ 111 | 112 | -------------------------------------------------------------------------------- /win32/include/fcntl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fcntl.h 3 | * 4 | * Access constants for _open. Note that the permissions constants are 5 | * in sys/stat.h (ick). 6 | * 7 | * This code is part of the Mingw32 package. 8 | * 9 | * Contributors: 10 | * Created by Colin Peters 11 | * 12 | * THIS SOFTWARE IS NOT COPYRIGHTED 13 | * 14 | * This source code is offered for use in the public domain. You may 15 | * use, modify or distribute it freely. 16 | * 17 | * This code is distributed in the hope that it will be useful but 18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 19 | * DISCLAIMED. This includes but is not limited to warranties of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | * 22 | * $Revision: 1.2 $ 23 | * $Author: bellard $ 24 | * $Date: 2005/04/17 13:14:29 $ 25 | * 26 | */ 27 | 28 | #ifndef __STRICT_ANSI__ 29 | 30 | #ifndef _FCNTL_H_ 31 | #define _FCNTL_H_ 32 | 33 | /* All the headers include this file. */ 34 | #include <_mingw.h> 35 | 36 | /* 37 | * It appears that fcntl.h should include io.h for compatibility... 38 | */ 39 | #include 40 | 41 | /* Specifiy one of these flags to define the access mode. */ 42 | #define _O_RDONLY 0 43 | #define _O_WRONLY 1 44 | #define _O_RDWR 2 45 | 46 | /* Mask for access mode bits in the _open flags. */ 47 | #define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR) 48 | 49 | #define _O_APPEND 0x0008 /* Writes will add to the end of the file. */ 50 | 51 | #define _O_RANDOM 0x0010 52 | #define _O_SEQUENTIAL 0x0020 53 | #define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing. 54 | * WARNING: Even if not created by _open! */ 55 | #define _O_NOINHERIT 0x0080 56 | 57 | #define _O_CREAT 0x0100 /* Create the file if it does not exist. */ 58 | #define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */ 59 | #define _O_EXCL 0x0400 /* Open only if the file does not exist. */ 60 | 61 | /* NOTE: Text is the default even if the given _O_TEXT bit is not on. */ 62 | #define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */ 63 | #define _O_BINARY 0x8000 /* Input and output is not translated. */ 64 | #define _O_RAW _O_BINARY 65 | 66 | #ifndef _NO_OLDNAMES 67 | 68 | /* POSIX/Non-ANSI names for increased portability */ 69 | #define O_RDONLY _O_RDONLY 70 | #define O_WRONLY _O_WRONLY 71 | #define O_RDWR _O_RDWR 72 | #define O_ACCMODE _O_ACCMODE 73 | #define O_APPEND _O_APPEND 74 | #define O_CREAT _O_CREAT 75 | #define O_TRUNC _O_TRUNC 76 | #define O_EXCL _O_EXCL 77 | #define O_TEXT _O_TEXT 78 | #define O_BINARY _O_BINARY 79 | #define O_TEMPORARY _O_TEMPORARY 80 | #define O_NOINHERIT _O_NOINHERIT 81 | #define O_SEQENTIAL _O_SEQUENTIAL 82 | #define O_RANDOM _O_RANDOM 83 | 84 | #endif /* Not _NO_OLDNAMES */ 85 | 86 | 87 | #ifndef RC_INVOKED 88 | 89 | /* 90 | * This variable determines the default file mode. 91 | * TODO: Which flags work? 92 | */ 93 | #ifndef __DECLSPEC_SUPPORTED 94 | 95 | #ifdef __MSVCRT__ 96 | extern unsigned int* __imp__fmode; 97 | #define _fmode (*__imp__fmode) 98 | #else 99 | /* CRTDLL */ 100 | extern unsigned int* __imp__fmode_dll; 101 | #define _fmode (*__imp__fmode_dll) 102 | #endif 103 | 104 | #else /* __DECLSPEC_SUPPORTED */ 105 | 106 | #ifdef __MSVCRT__ 107 | __MINGW_IMPORT unsigned int _fmode; 108 | #else /* ! __MSVCRT__ */ 109 | __MINGW_IMPORT unsigned int _fmode_dll; 110 | #define _fmode _fmode_dll 111 | #endif /* ! __MSVCRT__ */ 112 | 113 | #endif /* __DECLSPEC_SUPPORTED */ 114 | 115 | 116 | #ifdef __cplusplus 117 | extern "C" { 118 | #endif 119 | 120 | int _setmode (int, int); 121 | 122 | #ifndef _NO_OLDNAMES 123 | int setmode (int, int); 124 | #endif /* Not _NO_OLDNAMES */ 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* Not RC_INVOKED */ 131 | 132 | #endif /* Not _FCNTL_H_ */ 133 | 134 | #endif /* Not __STRICT_ANSI__ */ 135 | 136 | -------------------------------------------------------------------------------- /libtcc.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBTCC_H 2 | #define LIBTCC_H 3 | 4 | #ifdef LIBTCC_AS_DLL 5 | #define LIBTCCAPI __declspec(dllexport) 6 | #else 7 | #define LIBTCCAPI 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | struct TCCState; 15 | 16 | typedef struct TCCState TCCState; 17 | 18 | /* create a new TCC compilation context */ 19 | LIBTCCAPI TCCState *tcc_new(void); 20 | 21 | /* free a TCC compilation context */ 22 | LIBTCCAPI void tcc_delete(TCCState *s); 23 | 24 | /* add debug information in the generated code */ 25 | LIBTCCAPI void tcc_enable_debug(TCCState *s); 26 | 27 | /* set error/warning display callback */ 28 | LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque, 29 | void (*error_func)(void *opaque, const char *msg)); 30 | 31 | /* set/reset a warning */ 32 | LIBTCCAPI int tcc_set_warning(TCCState *s, const char *warning_name, int value); 33 | 34 | /*****************************/ 35 | /* preprocessor */ 36 | 37 | /* add include path */ 38 | LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname); 39 | 40 | /* add in system include path */ 41 | LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname); 42 | 43 | /* define preprocessor symbol 'sym'. Can put optional value */ 44 | LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value); 45 | 46 | /* undefine preprocess symbol 'sym' */ 47 | LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym); 48 | 49 | /*****************************/ 50 | /* compiling */ 51 | 52 | /* add a file (either a C file, dll, an object, a library or an ld 53 | script). Return -1 if error. */ 54 | LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename); 55 | 56 | /* compile a string containing a C source. Return non zero if 57 | error. */ 58 | LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf); 59 | 60 | /*****************************/ 61 | /* linking commands */ 62 | 63 | /* set output type. MUST BE CALLED before any compilation */ 64 | #define TCC_OUTPUT_MEMORY 0 /* output will be ran in memory (no 65 | output file) (default) */ 66 | #define TCC_OUTPUT_EXE 1 /* executable file */ 67 | #define TCC_OUTPUT_DLL 2 /* dynamic library */ 68 | #define TCC_OUTPUT_OBJ 3 /* object file */ 69 | #define TCC_OUTPUT_PREPROCESS 4 /* preprocessed file (used internally) */ 70 | LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type); 71 | 72 | #define TCC_OUTPUT_FORMAT_ELF 0 /* default output format: ELF */ 73 | #define TCC_OUTPUT_FORMAT_BINARY 1 /* binary image output */ 74 | #define TCC_OUTPUT_FORMAT_COFF 2 /* COFF */ 75 | 76 | /* equivalent to -Lpath option */ 77 | LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname); 78 | 79 | /* the library name is the same as the argument of the '-l' option */ 80 | LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname); 81 | 82 | /* add a symbol to the compiled program */ 83 | LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, void *val); 84 | 85 | /* output an executable, library or object file. DO NOT call 86 | tcc_relocate() before. */ 87 | LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename); 88 | 89 | /* link and run main() function and return its value. DO NOT call 90 | tcc_relocate() before. */ 91 | LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv); 92 | 93 | /* copy code into memory passed in by the caller and do all relocations 94 | (needed before using tcc_get_symbol()). 95 | returns -1 on error and required size if ptr is NULL */ 96 | LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr); 97 | 98 | /* return symbol value or NULL if not found */ 99 | LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name); 100 | 101 | /* set CONFIG_TCCDIR at runtime */ 102 | LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path); 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /tests/boundtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define NB_ITS 1000000 5 | //#define NB_ITS 1 6 | #define TAB_SIZE 100 7 | 8 | int tab[TAB_SIZE]; 9 | int ret_sum; 10 | char tab3[256]; 11 | 12 | int test1(void) 13 | { 14 | int i, sum = 0; 15 | for(i=0;i= 2) 203 | index = atoi(argv[1]); 204 | /* well, we also use bounds on this ! */ 205 | ftest = table_test[index]; 206 | ftest(); 207 | 208 | return 0; 209 | } 210 | 211 | /* 212 | * without bound 0.77 s 213 | * with bounds 4.73 214 | */ 215 | -------------------------------------------------------------------------------- /win32/include/wctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wctype.h 3 | * 4 | * Functions for testing wide character types and converting characters. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Mumit Khan 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | */ 22 | 23 | #ifndef _WCTYPE_H_ 24 | #define _WCTYPE_H_ 25 | 26 | /* All the headers include this file. */ 27 | #include <_mingw.h> 28 | 29 | #define __need_wchar_t 30 | #define __need_wint_t 31 | #ifndef RC_INVOKED 32 | #include 33 | #endif /* Not RC_INVOKED */ 34 | 35 | /* 36 | * The following flags are used to tell iswctype and _isctype what character 37 | * types you are looking for. 38 | */ 39 | #define _UPPER 0x0001 40 | #define _LOWER 0x0002 41 | #define _DIGIT 0x0004 42 | #define _SPACE 0x0008 43 | #define _PUNCT 0x0010 44 | #define _CONTROL 0x0020 45 | #define _BLANK 0x0040 46 | #define _HEX 0x0080 47 | #define _LEADBYTE 0x8000 48 | 49 | #define _ALPHA 0x0103 50 | 51 | #ifndef RC_INVOKED 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | #ifndef WEOF 58 | #define WEOF (wchar_t)(0xFFFF) 59 | #endif 60 | 61 | #ifndef _WCTYPE_T_DEFINED 62 | typedef wchar_t wctype_t; 63 | #define _WCTYPE_T_DEFINED 64 | #endif 65 | 66 | /* Wide character equivalents - also in ctype.h */ 67 | int iswalnum(wint_t); 68 | int iswalpha(wint_t); 69 | int iswascii(wint_t); 70 | int iswcntrl(wint_t); 71 | int iswctype(wint_t, wctype_t); 72 | int is_wctype(wint_t, wctype_t); /* Obsolete! */ 73 | int iswdigit(wint_t); 74 | int iswgraph(wint_t); 75 | int iswlower(wint_t); 76 | int iswprint(wint_t); 77 | int iswpunct(wint_t); 78 | int iswspace(wint_t); 79 | int iswupper(wint_t); 80 | int iswxdigit(wint_t); 81 | 82 | wchar_t towlower(wchar_t); 83 | wchar_t towupper(wchar_t); 84 | 85 | int isleadbyte (int); 86 | 87 | /* Also in ctype.h */ 88 | 89 | __MINGW_IMPORT unsigned short _ctype[]; 90 | #ifdef __MSVCRT__ 91 | __MINGW_IMPORT unsigned short* _pctype; 92 | #else 93 | __MINGW_IMPORT unsigned short* _pctype_dll; 94 | #define _pctype _pctype_dll 95 | #endif 96 | 97 | #if !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) 98 | #define __WCTYPE_INLINES_DEFINED 99 | extern inline int iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));} 100 | extern inline int iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));} 101 | extern inline int iswascii(wint_t wc) {return (((unsigned)wc & 0x7F) ==0);} 102 | extern inline int iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));} 103 | extern inline int iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));} 104 | extern inline int iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));} 105 | extern inline int iswlower(wint_t wc) {return (iswctype(wc,_LOWER));} 106 | extern inline int iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));} 107 | extern inline int iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));} 108 | extern inline int iswspace(wint_t wc) {return (iswctype(wc,_SPACE));} 109 | extern inline int iswupper(wint_t wc) {return (iswctype(wc,_UPPER));} 110 | extern inline int iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));} 111 | extern inline int isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);} 112 | #endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */ 113 | 114 | 115 | typedef wchar_t wctrans_t; 116 | wint_t towctrans(wint_t, wctrans_t); 117 | wctrans_t wctrans(const char*); 118 | wctype_t wctype(const char*); 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif /* Not RC_INVOKED */ 125 | 126 | #endif /* Not _WCTYPE_H_ */ 127 | 128 | -------------------------------------------------------------------------------- /win32/include/errno.h: -------------------------------------------------------------------------------- 1 | /* 2 | * errno.h 3 | * 4 | * Error numbers and access to error reporting. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef _ERRNO_H_ 28 | #define _ERRNO_H_ 29 | 30 | /* All the headers include this file. */ 31 | #include <_mingw.h> 32 | 33 | /* 34 | * Error numbers. 35 | * TODO: Can't be sure of some of these assignments, I guessed from the 36 | * names given by strerror and the defines in the Cygnus errno.h. A lot 37 | * of the names from the Cygnus errno.h are not represented, and a few 38 | * of the descriptions returned by strerror do not obviously match 39 | * their error naming. 40 | */ 41 | #define EPERM 1 /* Operation not permitted */ 42 | #define ENOFILE 2 /* No such file or directory */ 43 | #define ENOENT 2 44 | #define ESRCH 3 /* No such process */ 45 | #define EINTR 4 /* Interrupted function call */ 46 | #define EIO 5 /* Input/output error */ 47 | #define ENXIO 6 /* No such device or address */ 48 | #define E2BIG 7 /* Arg list too long */ 49 | #define ENOEXEC 8 /* Exec format error */ 50 | #define EBADF 9 /* Bad file descriptor */ 51 | #define ECHILD 10 /* No child processes */ 52 | #define EAGAIN 11 /* Resource temporarily unavailable */ 53 | #define ENOMEM 12 /* Not enough space */ 54 | #define EACCES 13 /* Permission denied */ 55 | #define EFAULT 14 /* Bad address */ 56 | /* 15 - Unknown Error */ 57 | #define EBUSY 16 /* strerror reports "Resource device" */ 58 | #define EEXIST 17 /* File exists */ 59 | #define EXDEV 18 /* Improper link (cross-device link?) */ 60 | #define ENODEV 19 /* No such device */ 61 | #define ENOTDIR 20 /* Not a directory */ 62 | #define EISDIR 21 /* Is a directory */ 63 | #define EINVAL 22 /* Invalid argument */ 64 | #define ENFILE 23 /* Too many open files in system */ 65 | #define EMFILE 24 /* Too many open files */ 66 | #define ENOTTY 25 /* Inappropriate I/O control operation */ 67 | /* 26 - Unknown Error */ 68 | #define EFBIG 27 /* File too large */ 69 | #define ENOSPC 28 /* No space left on device */ 70 | #define ESPIPE 29 /* Invalid seek (seek on a pipe?) */ 71 | #define EROFS 30 /* Read-only file system */ 72 | #define EMLINK 31 /* Too many links */ 73 | #define EPIPE 32 /* Broken pipe */ 74 | #define EDOM 33 /* Domain error (math functions) */ 75 | #define ERANGE 34 /* Result too large (possibly too small) */ 76 | /* 35 - Unknown Error */ 77 | #define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */ 78 | #define EDEADLK 36 79 | /* 37 - Unknown Error */ 80 | #define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */ 81 | #define ENOLCK 39 /* No locks available (46 in Cyg?) */ 82 | #define ENOSYS 40 /* Function not implemented (88 in Cyg?) */ 83 | #define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */ 84 | #define EILSEQ 42 /* Illegal byte sequence */ 85 | 86 | /* 87 | * NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the 88 | * sockets.h header provided with windows32api-0.1.2. 89 | * You should go and put an #if 0 ... #endif around the whole block 90 | * of errors (look at the comment above them). 91 | */ 92 | 93 | #ifndef RC_INVOKED 94 | 95 | #ifdef __cplusplus 96 | extern "C" { 97 | #endif 98 | 99 | /* 100 | * Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see 101 | * stdlib.h. 102 | */ 103 | #ifdef _UWIN 104 | #undef errno 105 | extern int errno; 106 | #else 107 | int* _errno(void); 108 | #define errno (*_errno()) 109 | #endif 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* Not RC_INVOKED */ 116 | 117 | #endif /* Not _ERRNO_H_ */ 118 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Tiny C Compiler Makefile - tests 3 | # 4 | 5 | # what tests to run 6 | TESTS = libtest test3 7 | 8 | # these should work too 9 | # TESTS += test1 test2 speed 10 | 11 | # these don't work as they should 12 | # TESTS += test4 btest asmtest 13 | 14 | 15 | TOP = .. 16 | include $(TOP)/Makefile 17 | 18 | # run local version of tcc with local libraries and includes 19 | TCC = ../tcc -B.. 20 | RUN_TCC = $(NATIVE_TARGET) -run ../tcc.c -B.. 21 | DISAS=objdump -d 22 | 23 | all test : $(TESTS) 24 | 25 | # make sure that tcc exists 26 | $(TESTS) : ../tcc 27 | ../tcc ../libtcc.a : 28 | $(MAKE) -C .. 29 | 30 | # libtcc test 31 | libtest: libtcc_test$(EXESUF) 32 | @echo ------------ $@ ------------ 33 | ./libtcc_test lib_path=.. 34 | 35 | libtcc_test$(EXESUF): libtcc_test.c ../libtcc.a 36 | $(CC) -o $@ $^ -I.. $(CFLAGS) $(LIBS) 37 | 38 | # test.ref - generate using gcc 39 | test.ref: tcctest.c 40 | cp -u ../include/tcclib.h . 41 | $(CC) -o tcctest.gcc $< -I. -w $(CFLAGS) 42 | ./tcctest.gcc > $@ 43 | 44 | # auto test 45 | test1: test.ref 46 | @echo ------------ $@ ------------ 47 | $(TCC) -run tcctest.c > test.out1 48 | @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi 49 | 50 | # iterated test2 (compile tcc then compile tcctest.c !) 51 | test2: test.ref 52 | @echo ------------ $@ ------------ 53 | $(TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out2 54 | @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi 55 | 56 | # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) 57 | test3: test.ref 58 | @echo ------------ $@ ------------ 59 | $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out3 60 | @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi 61 | 62 | # binary output test 63 | test4: test.ref 64 | @echo ------------ $@ ------------ 65 | # dynamic output 66 | $(TCC) -o tcctest1 tcctest.c 67 | ./tcctest1 > test1.out 68 | @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi 69 | # object + link output 70 | $(TCC) -c -o tcctest3.o tcctest.c 71 | $(TCC) -o tcctest3 tcctest3.o 72 | ./tcctest3 > test3.out 73 | @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi 74 | # static output 75 | $(TCC) -static -o tcctest2 tcctest.c 76 | ./tcctest2 > test2.out 77 | @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi 78 | # dynamic output + bound check 79 | $(TCC) -b -o tcctest4 tcctest.c 80 | ./tcctest4 > test4.out 81 | @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi 82 | 83 | # memory and bound check auto test 84 | BOUNDS_OK = 1 4 8 10 85 | BOUNDS_FAIL= 2 5 7 9 11 12 13 86 | 87 | btest: boundtest.c 88 | @echo ------------ $@ ------------ 89 | @for i in $(BOUNDS_OK); do \ 90 | if $(TCC) -b -run boundtest.c $$i ; then \ 91 | /bin/true ; \ 92 | else\ 93 | echo Failed positive test $$i ; exit 1 ; \ 94 | fi ;\ 95 | done ;\ 96 | for i in $(BOUNDS_FAIL); do \ 97 | if $(TCC) -b -run boundtest.c $$i ; then \ 98 | echo Failed negative test $$i ; exit 1 ;\ 99 | else\ 100 | /bin/true ; \ 101 | fi ;\ 102 | done ;\ 103 | echo Bound test OK 104 | 105 | # speed test 106 | speed: ex2 ex3 107 | @echo ------------ $@ ------------ 108 | time ./ex2 1238 2 3 4 10 13 4 109 | time $(TCC) -run ../examples/ex2.c 1238 2 3 4 10 13 4 110 | time ./ex3 35 111 | time $(TCC) -run ../examples/ex3.c 35 112 | 113 | ex%: ../examples/ex%.c 114 | $(CC) -o $@ $< $(CFLAGS) 115 | 116 | # tiny assembler testing 117 | asmtest.ref: asmtest.S 118 | $(CC) -o asmtest.ref.o -c asmtest.S 119 | objdump -D asmtest.ref.o > $@ 120 | 121 | asmtest: asmtest.ref 122 | @echo ------------ $@ ------------ 123 | $(TCC) -c asmtest.S 124 | objdump -D asmtest.o > $@ 125 | @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi 126 | 127 | # targets for development 128 | %.bin: %.c tcc 129 | $(TCC) -g -o $@ $< 130 | $(DISAS) $@ 131 | 132 | instr: instr.o 133 | objdump -d instr.o 134 | 135 | instr.o: instr.S 136 | $(CC) -o $@ -c $< -O2 -Wall -g 137 | 138 | cache: tcc_g 139 | cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c 140 | vg_annotate tcc.c > /tmp/linpack.cache.log 141 | 142 | # clean 143 | clean: 144 | rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.gcc \ 145 | tcctest[1234] ex? libtcc_test$(EXESUF) tcc_g tcclib.h 146 | -------------------------------------------------------------------------------- /win32/include/winapi/basetsd.h: -------------------------------------------------------------------------------- 1 | #ifndef _BASETSD_H 2 | #define _BASETSD_H 3 | #if __GNUC__ >=3 4 | #pragma GCC system_header 5 | #endif 6 | 7 | #ifdef __GNUC__ 8 | #ifndef __int64 9 | #define __int64 long long 10 | #endif 11 | #endif 12 | 13 | #if defined(_WIN64) 14 | #define __int3264 __int64 15 | #define ADDRESS_TAG_BIT 0x40000000000UI64 16 | #else /* !_WIN64 */ 17 | #define __int3264 __int32 18 | #define ADDRESS_TAG_BIT 0x80000000UL 19 | #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) ) 20 | #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) ) 21 | #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h)) 22 | #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) 23 | #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) ) 24 | #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) 25 | #define PtrToInt( p ) ((INT)(INT_PTR) (p) ) 26 | #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) 27 | #define PtrToShort( p ) ((short)(LONG_PTR)(p) ) 28 | #define IntToPtr( i ) ((VOID*)(INT_PTR)((int)i)) 29 | #define UIntToPtr( ui ) ((VOID*)(UINT_PTR)((unsigned int)ui)) 30 | #define LongToPtr( l ) ((VOID*)(LONG_PTR)((long)l)) 31 | #define ULongToPtr( ul ) ((VOID*)(ULONG_PTR)((unsigned long)ul)) 32 | #endif /* !_WIN64 */ 33 | 34 | #define UlongToPtr(ul) ULongToPtr(ul) 35 | #define UintToPtr(ui) UIntToPtr(ui) 36 | #define MAXUINT_PTR (~((UINT_PTR)0)) 37 | #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1)) 38 | #define MININT_PTR (~MAXINT_PTR) 39 | #define MAXULONG_PTR (~((ULONG_PTR)0)) 40 | #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1)) 41 | #define MINLONG_PTR (~MAXLONG_PTR) 42 | #define MAXUHALF_PTR ((UHALF_PTR)~0) 43 | #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1)) 44 | #define MINHALF_PTR (~MAXHALF_PTR) 45 | 46 | #ifndef RC_INVOKED 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | typedef int LONG32, *PLONG32; 51 | #ifndef XFree86Server 52 | typedef int INT32, *PINT32; 53 | #endif /* ndef XFree86Server */ 54 | typedef unsigned int ULONG32, *PULONG32; 55 | typedef unsigned int DWORD32, *PDWORD32; 56 | typedef unsigned int UINT32, *PUINT32; 57 | 58 | #if defined(_WIN64) 59 | typedef __int64 INT_PTR, *PINT_PTR; 60 | typedef unsigned __int64 UINT_PTR, *PUINT_PTR; 61 | typedef __int64 LONG_PTR, *PLONG_PTR; 62 | typedef unsigned __int64 ULONG_PTR, *PULONG_PTR; 63 | typedef unsigned __int64 HANDLE_PTR; 64 | typedef unsigned int UHALF_PTR, *PUHALF_PTR; 65 | typedef int HALF_PTR, *PHALF_PTR; 66 | 67 | #if 0 /* TODO when WIN64 is here */ 68 | inline unsigned long HandleToUlong(const void* h ) 69 | { return((unsigned long) h ); } 70 | inline long HandleToLong( const void* h ) 71 | { return((long) h ); } 72 | inline void* LongToHandle( const long h ) 73 | { return((void*) (INT_PTR) h ); } 74 | inline unsigned long PtrToUlong( const void* p) 75 | { return((unsigned long) p ); } 76 | inline unsigned int PtrToUint( const void* p ) 77 | { return((unsigned int) p ); } 78 | inline unsigned short PtrToUshort( const void* p ) 79 | { return((unsigned short) p ); } 80 | inline long PtrToLong( const void* p ) 81 | { return((long) p ); } 82 | inline int PtrToInt( const void* p ) 83 | { return((int) p ); } 84 | inline short PtrToShort( const void* p ) 85 | { return((short) p ); } 86 | inline void* IntToPtr( const int i ) 87 | { return( (void*)(INT_PTR)i ); } 88 | inline void* UIntToPtr(const unsigned int ui) 89 | { return( (void*)(UINT_PTR)ui ); } 90 | inline void* LongToPtr( const long l ) 91 | { return( (void*)(LONG_PTR)l ); } 92 | inline void* ULongToPtr( const unsigned long ul ) 93 | { return( (void*)(ULONG_PTR)ul ); } 94 | #endif /* 0_ */ 95 | 96 | #else /* !_WIN64 */ 97 | typedef int INT_PTR, *PINT_PTR; 98 | typedef unsigned int UINT_PTR, *PUINT_PTR; 99 | typedef long LONG_PTR, *PLONG_PTR; 100 | typedef unsigned long ULONG_PTR, *PULONG_PTR; 101 | typedef unsigned short UHALF_PTR, *PUHALF_PTR; 102 | typedef short HALF_PTR, *PHALF_PTR; 103 | typedef unsigned long HANDLE_PTR; 104 | #endif /* !_WIN64 */ 105 | 106 | typedef ULONG_PTR SIZE_T, *PSIZE_T; 107 | typedef LONG_PTR SSIZE_T, *PSSIZE_T; 108 | typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; 109 | typedef __int64 LONG64, *PLONG64; 110 | typedef __int64 INT64, *PINT64; 111 | typedef unsigned __int64 ULONG64, *PULONG64; 112 | typedef unsigned __int64 DWORD64, *PDWORD64; 113 | typedef unsigned __int64 UINT64, *PUINT64; 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | #endif /* !RC_INVOKED */ 118 | 119 | #endif /* _BASETSD_H */ 120 | -------------------------------------------------------------------------------- /win32/include/winapi/winver.h: -------------------------------------------------------------------------------- 1 | #ifndef _WINVER_H 2 | #define _WINVER_H 3 | #if __GNUC__ >=3 4 | #pragma GCC system_header 5 | #endif 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #define VS_FILE_INFO RT_VERSION 11 | #define VS_VERSION_INFO 1 12 | #define VS_USER_DEFINED 100 13 | #define VS_FFI_SIGNATURE 0xFEEF04BD 14 | #define VS_FFI_STRUCVERSION 0x10000 15 | #define VS_FFI_FILEFLAGSMASK 0x3F 16 | #define VS_FF_DEBUG 1 17 | #define VS_FF_PRERELEASE 2 18 | #define VS_FF_PATCHED 4 19 | #define VS_FF_PRIVATEBUILD 8 20 | #define VS_FF_INFOINFERRED 16 21 | #define VS_FF_SPECIALBUILD 32 22 | #define VOS_UNKNOWN 0 23 | #define VOS_DOS 0x10000 24 | #define VOS_OS216 0x20000 25 | #define VOS_OS232 0x30000 26 | #define VOS_NT 0x40000 27 | #define VOS__BASE 0 28 | #define VOS__WINDOWS16 1 29 | #define VOS__PM16 2 30 | #define VOS__PM32 3 31 | #define VOS__WINDOWS32 4 32 | #define VOS_DOS_WINDOWS16 0x10001 33 | #define VOS_DOS_WINDOWS32 0x10004 34 | #define VOS_OS216_PM16 0x20002 35 | #define VOS_OS232_PM32 0x30003 36 | #define VOS_NT_WINDOWS32 0x40004 37 | #define VFT_UNKNOWN 0 38 | #define VFT_APP 1 39 | #define VFT_DLL 2 40 | #define VFT_DRV 3 41 | #define VFT_FONT 4 42 | #define VFT_VXD 5 43 | #define VFT_STATIC_LIB 7 44 | #define VFT2_UNKNOWN 0 45 | #define VFT2_DRV_PRINTER 1 46 | #define VFT2_DRV_KEYBOARD 2 47 | #define VFT2_DRV_LANGUAGE 3 48 | #define VFT2_DRV_DISPLAY 4 49 | #define VFT2_DRV_MOUSE 5 50 | #define VFT2_DRV_NETWORK 6 51 | #define VFT2_DRV_SYSTEM 7 52 | #define VFT2_DRV_INSTALLABLE 8 53 | #define VFT2_DRV_SOUND 9 54 | #define VFT2_DRV_COMM 10 55 | #define VFT2_DRV_INPUTMETHOD 11 56 | #define VFT2_FONT_RASTER 1 57 | #define VFT2_FONT_VECTOR 2 58 | #define VFT2_FONT_TRUETYPE 3 59 | #define VFFF_ISSHAREDFILE 1 60 | #define VFF_CURNEDEST 1 61 | #define VFF_FILEINUSE 2 62 | #define VFF_BUFFTOOSMALL 4 63 | #define VIFF_FORCEINSTALL 1 64 | #define VIFF_DONTDELETEOLD 2 65 | #define VIF_TEMPFILE 1 66 | #define VIF_MISMATCH 2 67 | #define VIF_SRCOLD 4 68 | #define VIF_DIFFLANG 8 69 | #define VIF_DIFFCODEPG 16 70 | #define VIF_DIFFTYPE 32 71 | #define VIF_WRITEPROT 64 72 | #define VIF_FILEINUSE 128 73 | #define VIF_OUTOFSPACE 256 74 | #define VIF_ACCESSVIOLATION 512 75 | #define VIF_SHARINGVIOLATION 1024 76 | #define VIF_CANNOTCREATE 2048 77 | #define VIF_CANNOTDELETE 4096 78 | #define VIF_CANNOTRENAME 8192 79 | #define VIF_CANNOTDELETECUR 16384 80 | #define VIF_OUTOFMEMORY 32768 81 | #define VIF_CANNOTREADSRC 65536 82 | #define VIF_CANNOTREADDST 0x20000 83 | #define VIF_BUFFTOOSMALL 0x40000 84 | #ifndef RC_INVOKED 85 | typedef struct tagVS_FIXEDFILEINFO { 86 | DWORD dwSignature; 87 | DWORD dwStrucVersion; 88 | DWORD dwFileVersionMS; 89 | DWORD dwFileVersionLS; 90 | DWORD dwProductVersionMS; 91 | DWORD dwProductVersionLS; 92 | DWORD dwFileFlagsMask; 93 | DWORD dwFileFlags; 94 | DWORD dwFileOS; 95 | DWORD dwFileType; 96 | DWORD dwFileSubtype; 97 | DWORD dwFileDateMS; 98 | DWORD dwFileDateLS; 99 | } VS_FIXEDFILEINFO; 100 | DWORD WINAPI VerFindFileA(DWORD,LPSTR,LPSTR,LPSTR,LPSTR,PUINT,LPSTR,PUINT); 101 | DWORD WINAPI VerFindFileW(DWORD,LPWSTR,LPWSTR,LPWSTR,LPWSTR,PUINT,LPWSTR,PUINT); 102 | DWORD WINAPI VerInstallFileA(DWORD,LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,PUINT); 103 | DWORD WINAPI VerInstallFileW(DWORD,LPWSTR,LPWSTR,LPWSTR,LPWSTR,LPWSTR,LPWSTR,PUINT); 104 | DWORD WINAPI GetFileVersionInfoSizeA(LPSTR,PDWORD); 105 | DWORD WINAPI GetFileVersionInfoSizeW(LPWSTR,PDWORD); 106 | BOOL WINAPI GetFileVersionInfoA(LPSTR,DWORD,DWORD,PVOID); 107 | BOOL WINAPI GetFileVersionInfoW(LPWSTR,DWORD,DWORD,PVOID); 108 | DWORD WINAPI VerLanguageNameA(DWORD,LPSTR,DWORD); 109 | DWORD WINAPI VerLanguageNameW(DWORD,LPWSTR,DWORD); 110 | BOOL WINAPI VerQueryValueA(PCVOID,LPSTR,PVOID*,PUINT); 111 | BOOL WINAPI VerQueryValueW(PCVOID,LPWSTR,PVOID*,PUINT); 112 | #ifdef UNICODE 113 | #define VerFindFile VerFindFileW 114 | #define VerQueryValue VerQueryValueW 115 | #define VerInstallFile VerInstallFileW 116 | #define GetFileVersionInfoSize GetFileVersionInfoSizeW 117 | #define GetFileVersionInfo GetFileVersionInfoW 118 | #define VerLanguageName VerLanguageNameW 119 | #define VerQueryValue VerQueryValueW 120 | #else 121 | #define VerQueryValue VerQueryValueA 122 | #define VerFindFile VerFindFileA 123 | #define VerInstallFile VerInstallFileA 124 | #define GetFileVersionInfoSize GetFileVersionInfoSizeA 125 | #define GetFileVersionInfo GetFileVersionInfoA 126 | #define VerLanguageName VerLanguageNameA 127 | #define VerQueryValue VerQueryValueA 128 | #endif 129 | #endif 130 | #ifdef __cplusplus 131 | } 132 | #endif 133 | #endif 134 | -------------------------------------------------------------------------------- /win32/examples/hello_win.c: -------------------------------------------------------------------------------- 1 | //+--------------------------------------------------------------------------- 2 | // 3 | // HELLO_WIN.C - Windows GUI 'Hello World!' Example 4 | // 5 | //+--------------------------------------------------------------------------- 6 | 7 | #include 8 | 9 | #define APPNAME "HELLO_WIN" 10 | 11 | char szAppName[] = APPNAME; // The name of this application 12 | char szTitle[] = APPNAME; // The title bar text 13 | char *pWindowText; 14 | 15 | HINSTANCE g_hInst; // current instance 16 | 17 | void CenterWindow(HWND hWnd); 18 | 19 | //+--------------------------------------------------------------------------- 20 | // 21 | // Function: WndProc 22 | // 23 | // Synopsis: very unusual type of function - gets called by system to 24 | // process windows messages. 25 | // 26 | // Arguments: same as always. 27 | //---------------------------------------------------------------------------- 28 | 29 | LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 30 | { 31 | switch (message) 32 | { 33 | // ----------------------- first and last 34 | case WM_CREATE: 35 | CenterWindow(hwnd); 36 | break; 37 | 38 | case WM_DESTROY: 39 | PostQuitMessage(0); 40 | break; 41 | 42 | 43 | // ----------------------- get out of it... 44 | case WM_RBUTTONUP: 45 | DestroyWindow(hwnd); 46 | break; 47 | 48 | case WM_KEYDOWN: 49 | if (VK_ESCAPE == wParam) 50 | DestroyWindow(hwnd); 51 | break; 52 | 53 | 54 | // ----------------------- display our minimal info 55 | case WM_PAINT: 56 | { 57 | PAINTSTRUCT ps; 58 | HDC hdc; 59 | RECT rc; 60 | hdc = BeginPaint(hwnd, &ps); 61 | 62 | GetClientRect(hwnd, &rc); 63 | SetTextColor(hdc, RGB(240,240,96)); 64 | SetBkMode(hdc, TRANSPARENT); 65 | DrawText(hdc, pWindowText, -1, &rc, DT_CENTER|DT_SINGLELINE|DT_VCENTER); 66 | 67 | EndPaint(hwnd, &ps); 68 | break; 69 | } 70 | 71 | // ----------------------- let windows do all other stuff 72 | default: 73 | return DefWindowProc(hwnd, message, wParam, lParam); 74 | } 75 | return 0; 76 | } 77 | 78 | //+--------------------------------------------------------------------------- 79 | // 80 | // Function: WinMain 81 | // 82 | // Synopsis: standard entrypoint for GUI Win32 apps 83 | // 84 | //---------------------------------------------------------------------------- 85 | int APIENTRY WinMain( 86 | HINSTANCE hInstance, 87 | HINSTANCE hPrevInstance, 88 | LPSTR lpCmdLine, 89 | int nCmdShow) 90 | { 91 | MSG msg; 92 | 93 | WNDCLASS wc; 94 | 95 | HWND hwnd; 96 | 97 | // Fill in window class structure with parameters that describe 98 | // the main window. 99 | 100 | ZeroMemory(&wc, sizeof wc); 101 | wc.hInstance = hInstance; 102 | wc.lpszClassName = szAppName; 103 | wc.lpfnWndProc = (WNDPROC)WndProc; 104 | wc.style = CS_DBLCLKS|CS_VREDRAW|CS_HREDRAW; 105 | wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); 106 | wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 107 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 108 | 109 | if (FALSE == RegisterClass(&wc)) return 0; 110 | 111 | // create the browser 112 | hwnd = CreateWindow( 113 | szAppName, 114 | szTitle, 115 | WS_OVERLAPPEDWINDOW|WS_VISIBLE, 116 | CW_USEDEFAULT, 117 | CW_USEDEFAULT, 118 | 360,//CW_USEDEFAULT, 119 | 240,//CW_USEDEFAULT, 120 | 0, 121 | 0, 122 | g_hInst, 123 | 0); 124 | 125 | if (NULL == hwnd) return 0; 126 | 127 | pWindowText = lpCmdLine[0] ? lpCmdLine : "Hello Windows!"; 128 | 129 | // Main message loop: 130 | while (GetMessage(&msg, NULL, 0, 0) > 0) 131 | { 132 | TranslateMessage(&msg); 133 | DispatchMessage(&msg); 134 | } 135 | 136 | return msg.wParam; 137 | } 138 | 139 | //+--------------------------------------------------------------------------- 140 | 141 | //+--------------------------------------------------------------------------- 142 | 143 | void CenterWindow(HWND hwnd_self) 144 | { 145 | RECT rw_self, rc_parent, rw_parent; HWND hwnd_parent; 146 | hwnd_parent = GetParent(hwnd_self); 147 | if (NULL==hwnd_parent) hwnd_parent = GetDesktopWindow(); 148 | GetWindowRect(hwnd_parent, &rw_parent); 149 | GetClientRect(hwnd_parent, &rc_parent); 150 | GetWindowRect(hwnd_self, &rw_self); 151 | SetWindowPos(hwnd_self, NULL, 152 | rw_parent.left + (rc_parent.right + rw_self.left - rw_self.right) / 2, 153 | rw_parent.top + (rc_parent.bottom + rw_self.top - rw_self.bottom) / 2, 154 | 0, 0, 155 | SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE 156 | ); 157 | } 158 | 159 | //+--------------------------------------------------------------------------- 160 | -------------------------------------------------------------------------------- /win32/tcc-win32.txt: -------------------------------------------------------------------------------- 1 | 2 | TinyCC 3 | ====== 4 | 5 | This file contains specific information for usage of TinyCC 6 | under MS-Windows. See tcc-doc.html to have all the features. 7 | 8 | 9 | 10 | Compilation from source: 11 | ------------------------ 12 | * You can use the MinGW and MSYS tools available at 13 | 14 | http://www.mingw.org 15 | 16 | Untar the TCC archive and type in the MSYS shell: 17 | 18 | ./configure 19 | make 20 | make install 21 | 22 | The default install location is c:\Program Files\tcc 23 | 24 | 25 | * Alternatively you can compile TCC with just GCC from MinGW using 26 | 27 | win32\build-tcc.bat 28 | 29 | To install, copy the entire contents of the win32 directory to 30 | where you want. 31 | 32 | 33 | 34 | Installation from the binary ZIP package: 35 | ----------------------------------------- 36 | Unzip the package to a directory of your choice. 37 | 38 | (Note that the binary package does not include libtcc. If you 39 | want TCC as dynamic code generator, please use the source code 40 | distribution.) 41 | 42 | 43 | 44 | Set the system PATH: 45 | -------------------- 46 | To be able to invoke the compiler from everywhere on your computer by 47 | just typing "tcc", please add the directory containing tcc.exe to your 48 | system PATH. 49 | 50 | 51 | 52 | Examples: 53 | --------- 54 | Open a console window (DOS box) and 'cd' to the examples directory. 55 | 56 | For the 'Fibonacci' example type: 57 | 58 | tcc fib.c 59 | 60 | For the 'Hello Windows' GUI example type: 61 | 62 | tcc hello_win.c 63 | 64 | for the 'Hello DLL' example type 65 | 66 | tcc -shared dll.c 67 | tiny_impdef dll.dll (optional) 68 | tcc hello_dll.c dll.def 69 | 70 | 71 | 72 | Import Definition Files: 73 | ------------------------ 74 | To link with Windows system DLLs, TCC uses import definition 75 | files (.def) instead of libraries. 76 | 77 | The included 'tiny_impdef' program may be used to make additional 78 | .def files for any DLL. For example: 79 | 80 | tiny_impdef.exe opengl32.dll 81 | 82 | Put opengl32.def into the tcc/lib directory. Specify -lopengl32 at 83 | the TCC commandline to link a program that uses opengl32.dll. 84 | 85 | 86 | 87 | Header Files: 88 | ------------- 89 | The system header files (except _mingw.h) are from the MinGW 90 | distribution: 91 | 92 | http://www.mingw.org/ 93 | 94 | From the windows headers, only a minimal set is included. If you need 95 | more, get MinGW's "w32api" package. 96 | 97 | 98 | 99 | Resource Files: 100 | --------------- 101 | TCC can link windows resources in coff format as generated by MinGW's 102 | windres.exe. For example: 103 | 104 | windres -O coff app.rc -o appres.o 105 | tcc app.c appres.o -o app.exe 106 | 107 | 108 | 109 | Tiny Libmaker: 110 | -------------- 111 | The included tiny_libmaker tool by Timovj Lahde can be used as 112 | 'ar' replacement to make a library from several object files: 113 | 114 | tiny_libmaker [rcs] library objectfiles ... 115 | 116 | 117 | 118 | Limitations: 119 | ------------ 120 | - On the object file level, currently TCC supports only the ELF format, 121 | not COFF as used by MinGW and MSVC. It is not possible to exchange 122 | object files or libraries between TCC and these compilers. However 123 | libraries for TCC from objects by TCC can be made using tiny_libmaker 124 | or MinGW's ar. 125 | 126 | - No leading underscore is generated in the ELF symbols. 127 | 128 | - With DLLs, only functions (not data) can be im-/exported. 129 | 130 | - Bounds checking (option -b) is not supported currently. 131 | 132 | - 64-bit systems are not (yet) supported. 133 | 134 | 135 | 136 | Documentation and License: 137 | -------------------------- 138 | TCC is distributed under the GNU Lesser General Public License. (See 139 | COPYING file or http://www.gnu.org/licenses/lgpl-2.1.html) 140 | 141 | TinyCC homepage is at: 142 | 143 | http://fabrice.bellard.free.fr/tcc/ 144 | 145 | 146 | 147 | WinAPI Help and 3rd-party tools: 148 | -------------------------------- 149 | The Windows API documentation (Win95) in a single .hlp file is 150 | available on the lcc-win32 site as "win32hlp.exe" or from other 151 | locations as "win32hlp_big.zip". 152 | 153 | A nice RAD tool to create windows resources (dialog boxes etc.) is 154 | "ResEd", available at the RadASM website. 155 | 156 | 157 | 158 | --- grischka 159 | -------------------------------------------------------------------------------- /win32/include/winapi/windows.h: -------------------------------------------------------------------------------- 1 | /* 2 | windows.h - main header file for the Win32 API 3 | 4 | Written by Anders Norlander 5 | 6 | This file is part of a free library for the Win32 API. 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | */ 13 | #ifndef _WINDOWS_H 14 | #define _WINDOWS_H 15 | #if __GNUC__ >=3 16 | #pragma GCC system_header 17 | #endif 18 | 19 | /* translate GCC target defines to MS equivalents. Keep this synchronized 20 | with winnt.h. */ 21 | #if defined(__i686__) && !defined(_M_IX86) 22 | #define _M_IX86 600 23 | #elif defined(__i586__) && !defined(_M_IX86) 24 | #define _M_IX86 500 25 | #elif defined(__i486__) && !defined(_M_IX86) 26 | #define _M_IX86 400 27 | #elif defined(__i386__) && !defined(_M_IX86) 28 | #define _M_IX86 300 29 | #endif 30 | #if defined(_M_IX86) && !defined(_X86_) 31 | #define _X86_ 32 | #elif defined(_M_ALPHA) && !defined(_ALPHA_) 33 | #define _ALPHA_ 34 | #elif defined(_M_PPC) && !defined(_PPC_) 35 | #define _PPC_ 36 | #elif defined(_M_MRX000) && !defined(_MIPS_) 37 | #define _MIPS_ 38 | #elif defined(_M_M68K) && !defined(_68K_) 39 | #define _68K_ 40 | #endif 41 | 42 | #ifdef RC_INVOKED 43 | /* winresrc.h includes the necessary headers */ 44 | #include 45 | #else 46 | 47 | #ifdef __GNUC__ 48 | #ifndef NONAMELESSUNION 49 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 50 | #define _ANONYMOUS_UNION __extension__ 51 | #define _ANONYMOUS_STRUCT __extension__ 52 | #else 53 | #if defined(__cplusplus) 54 | #define _ANONYMOUS_UNION __extension__ 55 | #endif /* __cplusplus */ 56 | #endif /* __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) */ 57 | #endif /* NONAMELESSUNION */ 58 | #elif defined(__WATCOMC__) 59 | #define _ANONYMOUS_UNION 60 | #define _ANONYMOUS_STRUCT 61 | #endif /* __GNUC__/__WATCOMC__ */ 62 | 63 | #ifndef _ANONYMOUS_UNION 64 | #define _ANONYMOUS_UNION 65 | #define _UNION_NAME(x) x 66 | #define DUMMYUNIONNAME u 67 | #define DUMMYUNIONNAME2 u2 68 | #define DUMMYUNIONNAME3 u3 69 | #define DUMMYUNIONNAME4 u4 70 | #define DUMMYUNIONNAME5 u5 71 | #define DUMMYUNIONNAME6 u6 72 | #define DUMMYUNIONNAME7 u7 73 | #define DUMMYUNIONNAME8 u8 74 | #else 75 | #define _UNION_NAME(x) 76 | #define DUMMYUNIONNAME 77 | #define DUMMYUNIONNAME2 78 | #define DUMMYUNIONNAME3 79 | #define DUMMYUNIONNAME4 80 | #define DUMMYUNIONNAME5 81 | #define DUMMYUNIONNAME6 82 | #define DUMMYUNIONNAME7 83 | #define DUMMYUNIONNAME8 84 | #endif 85 | #ifndef _ANONYMOUS_STRUCT 86 | #define _ANONYMOUS_STRUCT 87 | #define _STRUCT_NAME(x) x 88 | #define DUMMYSTRUCTNAME s 89 | #define DUMMYSTRUCTNAME2 s2 90 | #define DUMMYSTRUCTNAME3 s3 91 | #else 92 | #define _STRUCT_NAME(x) 93 | #define DUMMYSTRUCTNAME 94 | #define DUMMYSTRUCTNAME2 95 | #define DUMMYSTRUCTNAME3 96 | #endif 97 | 98 | #ifndef NO_STRICT 99 | #ifndef STRICT 100 | #define STRICT 1 101 | #endif 102 | #endif 103 | 104 | #include 105 | #include 106 | #include 107 | #include 108 | #include 109 | #include 110 | #ifndef _WINGDI_H 111 | #include 112 | #endif 113 | #ifndef _WINUSER_H 114 | #include 115 | #endif 116 | #ifndef _WINNLS_H 117 | #include 118 | #endif 119 | #ifndef _WINVER_H 120 | #include 121 | #endif 122 | #ifndef _WINNETWK_H 123 | #include 124 | #endif 125 | #ifndef _WINREG_H 126 | #include 127 | #endif 128 | #ifndef _WINSVC_H 129 | #include 130 | #endif 131 | 132 | #ifndef WIN32_LEAN_AND_MEAN 133 | #include 134 | #include 135 | #include 136 | #include 137 | #include 138 | #include 139 | #include 140 | #include 141 | #include 142 | #include 143 | #include 144 | #include 145 | #if defined(Win32_Winsock) 146 | #warning "The Win32_Winsock macro name is deprecated.\ 147 | Please use __USE_W32_SOCKETS instead" 148 | #ifndef __USE_W32_SOCKETS 149 | #define __USE_W32_SOCKETS 150 | #endif 151 | #endif 152 | #if defined(__USE_W32_SOCKETS) || !(defined(__CYGWIN__) || defined(__MSYS__) || defined(_UWIN)) 153 | #if (_WIN32_WINNT >= 0x0400) 154 | #include 155 | /* 156 | * MS likes to include mswsock.h here as well, 157 | * but that can cause undefined symbols if 158 | * winsock2.h is included before windows.h 159 | */ 160 | #else 161 | #include 162 | #endif /* (_WIN32_WINNT >= 0x0400) */ 163 | #endif 164 | #endif /* WIN32_LEAN_AND_MEAN */ 165 | 166 | #endif /* RC_INVOKED */ 167 | 168 | #ifdef __OBJC__ 169 | /* FIXME: Not undefining BOOL here causes all BOOLs to be WINBOOL (int), 170 | but undefining it causes trouble as well if a file is included after 171 | windows.h 172 | */ 173 | #undef BOOL 174 | #endif 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /win32/include/winapi/basetyps.h: -------------------------------------------------------------------------------- 1 | #ifndef _BASETYPS_H 2 | #define _BASETYPS_H 3 | #if __GNUC__ >=3 4 | #pragma GCC system_header 5 | #endif 6 | 7 | #ifndef __OBJC__ 8 | #ifdef __cplusplus 9 | #define EXTERN_C extern "C" 10 | #else 11 | #define EXTERN_C extern 12 | #endif /* __cplusplus */ 13 | #define STDMETHODCALLTYPE __stdcall 14 | #define STDMETHODVCALLTYPE __cdecl 15 | #define STDAPICALLTYPE __stdcall 16 | #define STDAPIVCALLTYPE __cdecl 17 | #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE 18 | #define STDAPI_(t) EXTERN_C t STDAPICALLTYPE 19 | #define STDMETHODIMP HRESULT STDMETHODCALLTYPE 20 | #define STDMETHODIMP_(t) t STDMETHODCALLTYPE 21 | #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE 22 | #define STDAPIV_(t) EXTERN_C t STDAPIVCALLTYPE 23 | #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE 24 | #define STDMETHODIMPV_(t) t STDMETHODVCALLTYPE 25 | #define interface struct 26 | #if defined(__cplusplus) && !defined(CINTERFACE) 27 | #define STDMETHOD(m) virtual HRESULT STDMETHODCALLTYPE m 28 | #define STDMETHOD_(t,m) virtual t STDMETHODCALLTYPE m 29 | #define PURE =0 30 | #define THIS_ 31 | #define THIS void 32 | /* 33 | __attribute__((com_interface)) is obsolete in __GNUC__ >= 3 34 | g++ vtables are now COM-compatible by default 35 | */ 36 | #if defined(__GNUC__) && __GNUC__ < 3 && !defined(NOCOMATTRIBUTE) 37 | #define DECLARE_INTERFACE(i) interface __attribute__((com_interface)) i 38 | #define DECLARE_INTERFACE_(i,b) interface __attribute__((com_interface)) i : public b 39 | #else 40 | #define DECLARE_INTERFACE(i) interface i 41 | #define DECLARE_INTERFACE_(i,b) interface i : public b 42 | #endif 43 | #else 44 | #define STDMETHOD(m) HRESULT(STDMETHODCALLTYPE *m) 45 | #define STDMETHOD_(t,m) t(STDMETHODCALLTYPE *m) 46 | #define PURE 47 | #define THIS_ INTERFACE *, 48 | #define THIS INTERFACE * 49 | #ifndef CONST_VTABLE 50 | #define CONST_VTABLE 51 | #endif 52 | #define DECLARE_INTERFACE(i) \ 53 | typedef interface i { CONST_VTABLE struct i##Vtbl *lpVtbl; } i; \ 54 | typedef CONST_VTABLE struct i##Vtbl i##Vtbl; \ 55 | CONST_VTABLE struct i##Vtbl 56 | #define DECLARE_INTERFACE_(i,b) DECLARE_INTERFACE(i) 57 | #endif 58 | #define BEGIN_INTERFACE 59 | #define END_INTERFACE 60 | 61 | #define FWD_DECL(i) typedef interface i i 62 | #if defined(__cplusplus) && !defined(CINTERFACE) 63 | #define IENUM_THIS(T) 64 | #define IENUM_THIS_(T) 65 | #else 66 | #define IENUM_THIS(T) T* 67 | #define IENUM_THIS_(T) T*, 68 | #endif 69 | #define DECLARE_ENUMERATOR_(I,T) \ 70 | DECLARE_INTERFACE_(I,IUnknown) \ 71 | { \ 72 | STDMETHOD(QueryInterface)(IENUM_THIS_(I) REFIID,PVOID*) PURE; \ 73 | STDMETHOD_(ULONG,AddRef)(IENUM_THIS(I)) PURE; \ 74 | STDMETHOD_(ULONG,Release)(IENUM_THIS(I)) PURE; \ 75 | STDMETHOD(Next)(IENUM_THIS_(I) ULONG,T*,ULONG*) PURE; \ 76 | STDMETHOD(Skip)(IENUM_THIS_(I) ULONG) PURE; \ 77 | STDMETHOD(Reset)(IENUM_THIS(I)) PURE; \ 78 | STDMETHOD(Clone)(IENUM_THIS_(I) I**) PURE; \ 79 | } 80 | #define DECLARE_ENUMERATOR(T) DECLARE_ENUMERATOR_(IEnum##T,T) 81 | 82 | #endif /* __OBJC__ */ 83 | 84 | #ifndef _GUID_DEFINED /* also defined in winnt.h */ 85 | #define _GUID_DEFINED 86 | typedef struct _GUID 87 | { 88 | unsigned long Data1; 89 | unsigned short Data2; 90 | unsigned short Data3; 91 | unsigned char Data4[8]; 92 | } GUID,*REFGUID,*LPGUID; 93 | #endif /* _GUID_DEFINED */ 94 | #ifndef UUID_DEFINED 95 | #define UUID_DEFINED 96 | typedef GUID UUID; 97 | #endif /* UUID_DEFINED */ 98 | typedef GUID IID; 99 | typedef GUID CLSID; 100 | typedef CLSID *LPCLSID; 101 | typedef IID *LPIID; 102 | typedef IID *REFIID; 103 | typedef CLSID *REFCLSID; 104 | typedef GUID FMTID; 105 | typedef FMTID *REFFMTID; 106 | typedef unsigned long error_status_t; 107 | #define uuid_t UUID 108 | typedef unsigned long PROPID; 109 | 110 | #ifndef _REFGUID_DEFINED 111 | #if defined (__cplusplus) && !defined (CINTERFACE) 112 | #define REFGUID const GUID& 113 | #define REFIID const IID& 114 | #define REFCLSID const CLSID& 115 | #else 116 | #define REFGUID const GUID* const 117 | #define REFIID const IID* const 118 | #define REFCLSID const CLSID* const 119 | #endif 120 | #define _REFGUID_DEFINED 121 | #define _REFGIID_DEFINED 122 | #define _REFCLSID_DEFINED 123 | #endif 124 | #ifndef GUID_SECTION 125 | #define GUID_SECTION ".text" 126 | #endif 127 | #ifdef __GNUC__ 128 | #define GUID_SECT __attribute__ ((section (GUID_SECTION))) 129 | #else 130 | #define GUID_SECT 131 | #endif 132 | #if !defined(INITGUID) || (defined(INITGUID) && defined(__cplusplus)) 133 | #define GUID_EXT EXTERN_C 134 | #else 135 | #define GUID_EXT 136 | #endif 137 | #ifdef INITGUID 138 | #define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) GUID_EXT const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} 139 | #define DEFINE_OLEGUID(n,l,w1,w2) DEFINE_GUID(n,l,w1,w2,0xC0,0,0,0,0,0,0,0x46) 140 | #else 141 | #define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) GUID_EXT const GUID n 142 | #define DEFINE_OLEGUID(n,l,w1,w2) DEFINE_GUID(n,l,w1,w2,0xC0,0,0,0,0,0,0,0x46) 143 | #endif 144 | #endif 145 | -------------------------------------------------------------------------------- /win32/include/process.h: -------------------------------------------------------------------------------- 1 | /* 2 | * process.h 3 | * 4 | * Function calls for spawning child processes. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef __STRICT_ANSI__ 28 | 29 | #ifndef _PROCESS_H_ 30 | #define _PROCESS_H_ 31 | 32 | /* All the headers include this file. */ 33 | #include <_mingw.h> 34 | 35 | /* Includes a definition of _pid_t and pid_t */ 36 | #include 37 | 38 | /* 39 | * Constants for cwait actions. 40 | * Obsolete for Win32. 41 | */ 42 | #define _WAIT_CHILD 0 43 | #define _WAIT_GRANDCHILD 1 44 | 45 | #ifndef _NO_OLDNAMES 46 | #define WAIT_CHILD _WAIT_CHILD 47 | #define WAIT_GRANDCHILD _WAIT_GRANDCHILD 48 | #endif /* Not _NO_OLDNAMES */ 49 | 50 | /* 51 | * Mode constants for spawn functions. 52 | */ 53 | #define _P_WAIT 0 54 | #define _P_NOWAIT 1 55 | #define _P_OVERLAY 2 56 | #define _OLD_P_OVERLAY _P_OVERLAY 57 | #define _P_NOWAITO 3 58 | #define _P_DETACH 4 59 | 60 | #ifndef _NO_OLDNAMES 61 | #define P_WAIT _P_WAIT 62 | #define P_NOWAIT _P_NOWAIT 63 | #define P_OVERLAY _P_OVERLAY 64 | #define OLD_P_OVERLAY _OLD_P_OVERLAY 65 | #define P_NOWAITO _P_NOWAITO 66 | #define P_DETACH _P_DETACH 67 | #endif /* Not _NO_OLDNAMES */ 68 | 69 | 70 | #ifndef RC_INVOKED 71 | 72 | #ifdef __cplusplus 73 | extern "C" { 74 | #endif 75 | 76 | void _cexit(void); 77 | void _c_exit(void); 78 | 79 | int _cwait (int*, _pid_t, int); 80 | 81 | _pid_t _getpid(void); 82 | 83 | int _execl (const char*, const char*, ...); 84 | int _execle (const char*, const char*, ...); 85 | int _execlp (const char*, const char*, ...); 86 | int _execlpe (const char*, const char*, ...); 87 | int _execv (const char*, char* const*); 88 | int _execve (const char*, char* const*, char* const*); 89 | int _execvp (const char*, char* const*); 90 | int _execvpe (const char*, char* const*, char* const*); 91 | 92 | int _spawnl (int, const char*, const char*, ...); 93 | int _spawnle (int, const char*, const char*, ...); 94 | int _spawnlp (int, const char*, const char*, ...); 95 | int _spawnlpe (int, const char*, const char*, ...); 96 | int _spawnv (int, const char*, char* const*); 97 | int _spawnve (int, const char*, char* const*, char* const*); 98 | int _spawnvp (int, const char*, char* const*); 99 | int _spawnvpe (int, const char*, char* const*, char* const*); 100 | 101 | /* 102 | * The functions _beginthreadex and _endthreadex are not provided by CRTDLL. 103 | * They are provided by MSVCRT. 104 | * 105 | * NOTE: Apparently _endthread calls CloseHandle on the handle of the thread, 106 | * making for race conditions if you are not careful. Basically you have to 107 | * make sure that no-one is going to do *anything* with the thread handle 108 | * after the thread calls _endthread or returns from the thread function. 109 | * 110 | * NOTE: No old names for these functions. Use the underscore. 111 | */ 112 | unsigned long 113 | _beginthread (void (*)(void *), unsigned, void*); 114 | void _endthread (void); 115 | 116 | #ifdef __MSVCRT__ 117 | unsigned long 118 | _beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *), 119 | void*, unsigned, unsigned*); 120 | void _endthreadex (unsigned); 121 | #endif 122 | 123 | 124 | #ifndef _NO_OLDNAMES 125 | /* 126 | * Functions without the leading underscore, for portability. These functions 127 | * live in liboldnames.a. 128 | */ 129 | int cwait (int*, pid_t, int); 130 | pid_t getpid (void); 131 | int execl (const char*, const char*, ...); 132 | int execle (const char*, const char*, ...); 133 | int execlp (const char*, const char*, ...); 134 | int execlpe (const char*, const char*, ...); 135 | int execv (const char*, char* const*); 136 | int execve (const char*, char* const*, char* const*); 137 | int execvp (const char*, char* const*); 138 | int execvpe (const char*, char* const*, char* const*); 139 | int spawnl (int, const char*, const char*, ...); 140 | int spawnle (int, const char*, const char*, ...); 141 | int spawnlp (int, const char*, const char*, ...); 142 | int spawnlpe (int, const char*, const char*, ...); 143 | int spawnv (int, const char*, char* const*); 144 | int spawnve (int, const char*, char* const*, char* const*); 145 | int spawnvp (int, const char*, char* const*); 146 | int spawnvpe (int, const char*, char* const*, char* const*); 147 | #endif /* Not _NO_OLDNAMES */ 148 | 149 | #ifdef __cplusplus 150 | } 151 | #endif 152 | 153 | #endif /* Not RC_INVOKED */ 154 | 155 | #endif /* _PROCESS_H_ not defined */ 156 | 157 | #endif /* Not __STRICT_ANSI__ */ 158 | 159 | -------------------------------------------------------------------------------- /win32/include/sys/stat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stat.h 3 | * 4 | * Symbolic constants for opening and creating files, also stat, fstat and 5 | * chmod functions. 6 | * 7 | * This file is part of the Mingw32 package. 8 | * 9 | * Contributors: 10 | * Created by Colin Peters 11 | * 12 | * THIS SOFTWARE IS NOT COPYRIGHTED 13 | * 14 | * This source code is offered for use in the public domain. You may 15 | * use, modify or distribute it freely. 16 | * 17 | * This code is distributed in the hope that it will be useful but 18 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 19 | * DISCLAIMED. This includes but is not limited to warranties of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | * 22 | * $Revision: 1.2 $ 23 | * $Author: bellard $ 24 | * $Date: 2005/04/17 13:14:29 $ 25 | * 26 | */ 27 | 28 | #ifndef __STRICT_ANSI__ 29 | 30 | #ifndef _STAT_H_ 31 | #define _STAT_H_ 32 | 33 | /* All the headers include this file. */ 34 | #include <_mingw.h> 35 | 36 | #define __need_size_t 37 | #define __need_wchar_t 38 | #ifndef RC_INVOKED 39 | #include 40 | #endif /* Not RC_INVOKED */ 41 | 42 | #include 43 | 44 | /* 45 | * Constants for the stat st_mode member. 46 | */ 47 | #define _S_IFIFO 0x1000 /* FIFO */ 48 | #define _S_IFCHR 0x2000 /* Character */ 49 | #define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */ 50 | #define _S_IFDIR 0x4000 /* Directory */ 51 | #define _S_IFREG 0x8000 /* Regular */ 52 | 53 | #define _S_IFMT 0xF000 /* File type mask */ 54 | 55 | #define _S_IEXEC 0x0040 56 | #define _S_IWRITE 0x0080 57 | #define _S_IREAD 0x0100 58 | 59 | #define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC) 60 | #define _S_IXUSR _S_IEXEC 61 | #define _S_IWUSR _S_IWRITE 62 | #define _S_IRUSR _S_IREAD 63 | 64 | #define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) 65 | #define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) 66 | #define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR) 67 | #define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK) 68 | #define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) 69 | 70 | #ifndef _NO_OLDNAMES 71 | 72 | #define S_IFIFO _S_IFIFO 73 | #define S_IFCHR _S_IFCHR 74 | #define S_IFBLK _S_IFBLK 75 | #define S_IFDIR _S_IFDIR 76 | #define S_IFREG _S_IFREG 77 | #define S_IFMT _S_IFMT 78 | #define S_IEXEC _S_IEXEC 79 | #define S_IWRITE _S_IWRITE 80 | #define S_IREAD _S_IREAD 81 | #define S_IRWXU _S_IRWXU 82 | #define S_IXUSR _S_IXUSR 83 | #define S_IWUSR _S_IWUSR 84 | #define S_IRUSR _S_IRUSR 85 | 86 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 87 | #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 88 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 89 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 90 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 91 | 92 | #endif /* Not _NO_OLDNAMES */ 93 | 94 | #ifndef RC_INVOKED 95 | 96 | #ifndef _STAT_DEFINED 97 | /* 98 | * The structure manipulated and returned by stat and fstat. 99 | * 100 | * NOTE: If called on a directory the values in the time fields are not only 101 | * invalid, they will cause localtime et. al. to return NULL. And calling 102 | * asctime with a NULL pointer causes an Invalid Page Fault. So watch it! 103 | */ 104 | struct _stat 105 | { 106 | _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ 107 | _ino_t st_ino; /* Always zero ? */ 108 | _mode_t st_mode; /* See above constants */ 109 | short st_nlink; /* Number of links. */ 110 | short st_uid; /* User: Maybe significant on NT ? */ 111 | short st_gid; /* Group: Ditto */ 112 | _dev_t st_rdev; /* Seems useless (not even filled in) */ 113 | _off_t st_size; /* File size in bytes */ 114 | time_t st_atime; /* Accessed date (always 00:00 hrs local 115 | * on FAT) */ 116 | time_t st_mtime; /* Modified time */ 117 | time_t st_ctime; /* Creation time */ 118 | }; 119 | 120 | struct stat 121 | { 122 | _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ 123 | _ino_t st_ino; /* Always zero ? */ 124 | _mode_t st_mode; /* See above constants */ 125 | short st_nlink; /* Number of links. */ 126 | short st_uid; /* User: Maybe significant on NT ? */ 127 | short st_gid; /* Group: Ditto */ 128 | _dev_t st_rdev; /* Seems useless (not even filled in) */ 129 | _off_t st_size; /* File size in bytes */ 130 | time_t st_atime; /* Accessed date (always 00:00 hrs local 131 | * on FAT) */ 132 | time_t st_mtime; /* Modified time */ 133 | time_t st_ctime; /* Creation time */ 134 | }; 135 | #if defined (__MSVCRT__) 136 | struct _stati64 { 137 | _dev_t st_dev; 138 | _ino_t st_ino; 139 | unsigned short st_mode; 140 | short st_nlink; 141 | short st_uid; 142 | short st_gid; 143 | _dev_t st_rdev; 144 | __int64 st_size; 145 | time_t st_atime; 146 | time_t st_mtime; 147 | time_t st_ctime; 148 | }; 149 | #endif /* __MSVCRT__ */ 150 | #define _STAT_DEFINED 151 | #endif /* _STAT_DEFINED */ 152 | 153 | #ifdef __cplusplus 154 | extern "C" { 155 | #endif 156 | 157 | int _fstat (int, struct _stat*); 158 | int _chmod (const char*, int); 159 | int _stat (const char*, struct _stat*); 160 | 161 | #if defined (__MSVCRT__) 162 | int _fstati64(int, struct _stati64 *); 163 | int _stati64(const char *, struct _stati64 *); 164 | #if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */ 165 | int _wstat(const wchar_t*, struct _stat*); 166 | int _wstati64 (const wchar_t*, struct _stati64*); 167 | #define _WSTAT_DEFINED 168 | #endif /* _WSTAT_DEFIND */ 169 | #endif /* __MSVCRT__ */ 170 | 171 | #ifndef _NO_OLDNAMES 172 | 173 | /* These functions live in liboldnames.a. */ 174 | int fstat (int, struct stat*); 175 | int chmod (const char*, int); 176 | int stat (const char*, struct stat*); 177 | 178 | #endif /* Not _NO_OLDNAMES */ 179 | 180 | 181 | #ifdef __cplusplus 182 | } 183 | #endif 184 | 185 | #endif /* Not RC_INVOKED */ 186 | 187 | #endif /* Not _STAT_H_ */ 188 | 189 | #endif /* Not __STRICT_ANSI__ */ 190 | 191 | -------------------------------------------------------------------------------- /win32/include/winapi/windef.h: -------------------------------------------------------------------------------- 1 | #ifndef _WINDEF_H 2 | #define _WINDEF_H 3 | #if __GNUC__ >=3 4 | #pragma GCC system_header 5 | #endif 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #ifndef WINVER 12 | #define WINVER 0x0400 13 | #endif 14 | #ifndef _WIN32_WINNT 15 | #define _WIN32_WINNT WINVER 16 | #endif 17 | #ifndef WIN32 18 | #define WIN32 19 | #endif 20 | #ifndef _WIN32 21 | #define _WIN32 22 | #endif 23 | #define FAR 24 | #define far 25 | #define NEAR 26 | #define near 27 | #ifndef CONST 28 | #define CONST const 29 | #endif 30 | #undef MAX_PATH 31 | #define MAX_PATH 260 32 | 33 | #ifndef NULL 34 | #ifdef __cplusplus 35 | #define NULL 0 36 | #else 37 | #define NULL ((void*)0) 38 | #endif 39 | #endif 40 | #ifndef FALSE 41 | #define FALSE 0 42 | #endif 43 | #ifndef TRUE 44 | #define TRUE 1 45 | #endif 46 | #define IN 47 | #define OUT 48 | #ifndef OPTIONAL 49 | #define OPTIONAL 50 | #endif 51 | 52 | #ifdef __GNUC__ 53 | #define PACKED __attribute__((packed)) 54 | #ifndef _stdcall 55 | #define _stdcall __attribute__((stdcall)) 56 | #endif 57 | #ifndef __stdcall 58 | #define __stdcall __attribute__((stdcall)) 59 | #endif 60 | #ifndef _cdecl 61 | #define _cdecl __attribute__((cdecl)) 62 | #endif 63 | #ifndef __cdecl 64 | #define __cdecl __attribute__((cdecl)) 65 | #endif 66 | #ifndef __declspec 67 | #define __declspec(e) __attribute__((e)) 68 | #endif 69 | #ifndef _declspec 70 | #define _declspec(e) __attribute__((e)) 71 | #endif 72 | #else 73 | #define PACKED 74 | #define _cdecl 75 | #define __cdecl 76 | #endif 77 | 78 | #undef pascal 79 | #undef _pascal 80 | #undef __pascal 81 | #define pascal __stdcall 82 | #define _pascal __stdcall 83 | #define __pascal __stdcall 84 | #define PASCAL _pascal 85 | #define CDECL _cdecl 86 | #define STDCALL __stdcall 87 | #define WINAPI __stdcall 88 | #define WINAPIV __cdecl 89 | #define APIENTRY __stdcall 90 | #define CALLBACK __stdcall 91 | #define APIPRIVATE __stdcall 92 | 93 | #define DECLSPEC_IMPORT __declspec(dllimport) 94 | #define DECLSPEC_EXPORT __declspec(dllexport) 95 | #ifdef __GNUC__ 96 | #define DECLSPEC_NORETURN __declspec(noreturn) 97 | #define DECLARE_STDCALL_P( type ) __stdcall type 98 | #elif defined(__WATCOMC__) 99 | #define DECLSPEC_NORETURN 100 | #define DECLARE_STDCALL_P( type ) type __stdcall 101 | #endif /* __GNUC__/__WATCOMC__ */ 102 | #define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8))) 103 | #define MAKELONG(a,b) ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16))) 104 | #define LOWORD(l) ((WORD)((DWORD)(l))) 105 | #define HIWORD(l) ((WORD)(((DWORD)(l)>>16)&0xFFFF)) 106 | #define LOBYTE(w) ((BYTE)(w)) 107 | #define HIBYTE(w) ((BYTE)(((WORD)(w)>>8)&0xFF)) 108 | 109 | #ifndef _export 110 | #define _export 111 | #endif 112 | #ifndef __export 113 | #define __export 114 | #endif 115 | 116 | #ifndef NOMINMAX 117 | #ifndef max 118 | #define max(a,b) ((a)>(b)?(a):(b)) 119 | #endif 120 | #ifndef min 121 | #define min(a,b) ((a)<(b)?(a):(b)) 122 | #endif 123 | #endif 124 | 125 | #define UNREFERENCED_PARAMETER(P) {(P)=(P);} 126 | #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} 127 | #define DBG_UNREFERENCED_PARAMETER(P) 128 | #define DBG_UNREFERENCED_LOCAL_VARIABLE(L) 129 | 130 | typedef unsigned long DWORD; 131 | typedef int WINBOOL,*PWINBOOL,*LPWINBOOL; 132 | /* FIXME: Is there a good solution to this? */ 133 | #ifndef XFree86Server 134 | #ifndef __OBJC__ 135 | typedef WINBOOL BOOL; 136 | #else 137 | #define BOOL WINBOOL 138 | #endif 139 | typedef unsigned char BYTE; 140 | #endif /* ndef XFree86Server */ 141 | typedef BOOL *PBOOL,*LPBOOL; 142 | typedef unsigned short WORD; 143 | typedef float FLOAT; 144 | typedef FLOAT *PFLOAT; 145 | typedef BYTE *PBYTE,*LPBYTE; 146 | typedef int *PINT,*LPINT; 147 | typedef WORD *PWORD,*LPWORD; 148 | typedef long *LPLONG; 149 | typedef DWORD *PDWORD,*LPDWORD; 150 | typedef void *PVOID,*LPVOID; 151 | typedef CONST void *PCVOID,*LPCVOID; 152 | typedef int INT; 153 | typedef unsigned int UINT,*PUINT,*LPUINT; 154 | 155 | #include 156 | 157 | typedef UINT WPARAM; 158 | typedef LONG LPARAM; 159 | typedef LONG LRESULT; 160 | #ifndef _HRESULT_DEFINED 161 | typedef LONG HRESULT; 162 | #define _HRESULT_DEFINED 163 | #endif 164 | #ifndef XFree86Server 165 | typedef WORD ATOM; 166 | #endif /* XFree86Server */ 167 | typedef HANDLE HGLOBAL; 168 | typedef HANDLE HLOCAL; 169 | typedef HANDLE GLOBALHANDLE; 170 | typedef HANDLE LOCALHANDLE; 171 | typedef void *HGDIOBJ; 172 | DECLARE_HANDLE(HACCEL); 173 | DECLARE_HANDLE(HBITMAP); 174 | DECLARE_HANDLE(HBRUSH); 175 | DECLARE_HANDLE(HCOLORSPACE); 176 | DECLARE_HANDLE(HDC); 177 | DECLARE_HANDLE(HGLRC); 178 | DECLARE_HANDLE(HDESK); 179 | DECLARE_HANDLE(HENHMETAFILE); 180 | DECLARE_HANDLE(HFONT); 181 | DECLARE_HANDLE(HICON); 182 | DECLARE_HANDLE(HKEY); 183 | /* FIXME: How to handle these. SM_CMONITORS etc in winuser.h also. */ 184 | /* #if (WINVER >= 0x0500) */ 185 | DECLARE_HANDLE(HMONITOR); 186 | #define HMONITOR_DECLARED 1 187 | DECLARE_HANDLE(HTERMINAL); 188 | DECLARE_HANDLE(HWINEVENTHOOK); 189 | /* #endif */ 190 | typedef HKEY *PHKEY; 191 | DECLARE_HANDLE(HMENU); 192 | DECLARE_HANDLE(HMETAFILE); 193 | DECLARE_HANDLE(HINSTANCE); 194 | typedef HINSTANCE HMODULE; 195 | DECLARE_HANDLE(HPALETTE); 196 | DECLARE_HANDLE(HPEN); 197 | DECLARE_HANDLE(HRGN); 198 | DECLARE_HANDLE(HRSRC); 199 | DECLARE_HANDLE(HSTR); 200 | DECLARE_HANDLE(HTASK); 201 | DECLARE_HANDLE(HWND); 202 | DECLARE_HANDLE(HWINSTA); 203 | DECLARE_HANDLE(HKL); 204 | typedef int HFILE; 205 | typedef HICON HCURSOR; 206 | typedef DWORD COLORREF; 207 | typedef int (WINAPI *FARPROC)(); 208 | typedef int (WINAPI *NEARPROC)(); 209 | typedef int (WINAPI *PROC)(); 210 | typedef struct tagRECT { 211 | LONG left; 212 | LONG top; 213 | LONG right; 214 | LONG bottom; 215 | } RECT,*PRECT,*LPRECT; 216 | typedef const RECT *LPCRECT; 217 | typedef struct tagRECTL { 218 | LONG left; 219 | LONG top; 220 | LONG right; 221 | LONG bottom; 222 | } RECTL,*PRECTL,*LPRECTL; 223 | typedef const RECTL *LPCRECTL; 224 | typedef struct tagPOINT { 225 | LONG x; 226 | LONG y; 227 | } POINT,POINTL,*PPOINT,*LPPOINT,*PPOINTL,*LPPOINTL; 228 | typedef struct tagSIZE { 229 | LONG cx; 230 | LONG cy; 231 | } SIZE,SIZEL,*PSIZE,*LPSIZE,*PSIZEL,*LPSIZEL; 232 | typedef struct tagPOINTS { 233 | SHORT x; 234 | SHORT y; 235 | } POINTS,*PPOINTS,*LPPOINTS; 236 | 237 | #ifdef __cplusplus 238 | } 239 | #endif 240 | #endif 241 | -------------------------------------------------------------------------------- /win32/include/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * time.h 3 | * 4 | * Date and time functions and types. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef _TIME_H_ 28 | #define _TIME_H_ 29 | 30 | /* All the headers include this file. */ 31 | #include <_mingw.h> 32 | 33 | #define __need_wchar_t 34 | #define __need_size_t 35 | #ifndef RC_INVOKED 36 | #include 37 | #endif /* Not RC_INVOKED */ 38 | 39 | /* 40 | * Need a definition of time_t. 41 | */ 42 | #include 43 | 44 | /* 45 | * Number of clock ticks per second. A clock tick is the unit by which 46 | * processor time is measured and is returned by 'clock'. 47 | */ 48 | #define CLOCKS_PER_SEC ((clock_t)1000) 49 | #define CLK_TCK CLOCKS_PER_SEC 50 | 51 | 52 | #ifndef RC_INVOKED 53 | 54 | /* 55 | * A type for storing the current time and date. This is the number of 56 | * seconds since midnight Jan 1, 1970. 57 | * NOTE: Normally this is defined by the above include of sys/types.h 58 | */ 59 | #ifndef _TIME_T_DEFINED 60 | typedef long time_t; 61 | #define _TIME_T_DEFINED 62 | #endif 63 | 64 | /* 65 | * A type for measuring processor time (in clock ticks). 66 | */ 67 | #ifndef _CLOCK_T_DEFINED 68 | typedef long clock_t; 69 | #define _CLOCK_T_DEFINED 70 | #endif 71 | 72 | 73 | /* 74 | * A structure for storing all kinds of useful information about the 75 | * current (or another) time. 76 | */ 77 | struct tm 78 | { 79 | int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */ 80 | int tm_min; /* Minutes: 0-59 */ 81 | int tm_hour; /* Hours since midnight: 0-23 */ 82 | int tm_mday; /* Day of the month: 1-31 */ 83 | int tm_mon; /* Months *since* january: 0-11 */ 84 | int tm_year; /* Years since 1900 */ 85 | int tm_wday; /* Days since Sunday (0-6) */ 86 | int tm_yday; /* Days since Jan. 1: 0-365 */ 87 | int tm_isdst; /* +1 Daylight Savings Time, 0 No DST, 88 | * -1 don't know */ 89 | }; 90 | 91 | #ifdef __cplusplus 92 | extern "C" { 93 | #endif 94 | 95 | clock_t clock (void); 96 | time_t time (time_t*); 97 | double difftime (time_t, time_t); 98 | time_t mktime (struct tm*); 99 | 100 | /* 101 | * These functions write to and return pointers to static buffers that may 102 | * be overwritten by other function calls. Yikes! 103 | * 104 | * NOTE: localtime, and perhaps the others of the four functions grouped 105 | * below may return NULL if their argument is not 'acceptable'. Also note 106 | * that calling asctime with a NULL pointer will produce an Invalid Page 107 | * Fault and crap out your program. Guess how I know. Hint: stat called on 108 | * a directory gives 'invalid' times in st_atime etc... 109 | */ 110 | char* asctime (const struct tm*); 111 | char* ctime (const time_t*); 112 | struct tm* gmtime (const time_t*); 113 | struct tm* localtime (const time_t*); 114 | 115 | 116 | size_t strftime (char*, size_t, const char*, const struct tm*); 117 | 118 | size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*); 119 | 120 | #ifndef __STRICT_ANSI__ 121 | extern void _tzset (void); 122 | 123 | #ifndef _NO_OLDNAMES 124 | extern void tzset (void); 125 | #endif 126 | 127 | size_t strftime(char*, size_t, const char*, const struct tm*); 128 | char* _strdate(char*); 129 | char* _strtime(char*); 130 | 131 | #endif /* Not __STRICT_ANSI__ */ 132 | 133 | /* 134 | * _daylight: non zero if daylight savings time is used. 135 | * _timezone: difference in seconds between GMT and local time. 136 | * _tzname: standard/daylight savings time zone names (an array with two 137 | * elements). 138 | */ 139 | #ifdef __MSVCRT__ 140 | 141 | /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */ 142 | extern int* __p__daylight (void); 143 | extern long* __p__timezone (void); 144 | extern char** __p__tzname (void); 145 | 146 | __MINGW_IMPORT int _daylight; 147 | __MINGW_IMPORT long _timezone; 148 | __MINGW_IMPORT char *_tzname[2]; 149 | 150 | #else /* not __MSVCRT (ie. crtdll) */ 151 | 152 | #ifndef __DECLSPEC_SUPPORTED 153 | 154 | extern int* __imp__daylight_dll; 155 | extern long* __imp__timezone_dll; 156 | extern char** __imp__tzname; 157 | 158 | #define _daylight (*__imp__daylight_dll) 159 | #define _timezone (*__imp__timezone_dll) 160 | #define _tzname (__imp__tzname) 161 | 162 | #else /* __DECLSPEC_SUPPORTED */ 163 | 164 | __MINGW_IMPORT int _daylight_dll; 165 | __MINGW_IMPORT long _timezone_dll; 166 | __MINGW_IMPORT char* _tzname[2]; 167 | 168 | #define _daylight _daylight_dll 169 | #define _timezone _timezone_dll 170 | 171 | #endif /* __DECLSPEC_SUPPORTED */ 172 | 173 | #endif /* not __MSVCRT__ */ 174 | 175 | #ifndef _NO_OLDNAMES 176 | 177 | #ifdef __MSVCRT__ 178 | 179 | /* These go in the oldnames import library for MSVCRT. */ 180 | __MINGW_IMPORT int daylight; 181 | __MINGW_IMPORT long timezone; 182 | __MINGW_IMPORT char *tzname[2]; 183 | 184 | #ifndef _WTIME_DEFINED 185 | 186 | /* wide function prototypes, also declared in wchar.h */ 187 | 188 | wchar_t * _wasctime(const struct tm*); 189 | wchar_t * _wctime(const time_t*); 190 | wchar_t* _wstrdate(wchar_t*); 191 | wchar_t* _wstrtime(wchar_t*); 192 | 193 | #define _WTIME_DEFINED 194 | #endif /* _WTIME_DEFINED */ 195 | 196 | 197 | #else /* not __MSVCRT__ */ 198 | 199 | /* CRTDLL is royally messed up when it comes to these macros. 200 | TODO: import and alias these via oldnames import library instead 201 | of macros. */ 202 | 203 | #define daylight _daylight 204 | /* NOTE: timezone not defined because it would conflict with sys/timeb.h. 205 | Also, tzname used to a be macro, but now it's in moldname. */ 206 | __MINGW_IMPORT char *tzname[2]; 207 | 208 | #endif /* not __MSVCRT__ */ 209 | 210 | #endif /* Not _NO_OLDNAMES */ 211 | 212 | #ifdef __cplusplus 213 | } 214 | #endif 215 | 216 | #endif /* Not RC_INVOKED */ 217 | 218 | #endif /* Not _TIME_H_ */ 219 | 220 | -------------------------------------------------------------------------------- /win32/include/stdint.h: -------------------------------------------------------------------------------- 1 | /* ISO C9x 7.18 Integer types 2 | * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794) 3 | * 4 | * THIS SOFTWARE IS NOT COPYRIGHTED 5 | * 6 | * Contributor: Danny Smith 7 | * 8 | * This source code is offered for use in the public domain. You may 9 | * use, modify or distribute it freely. 10 | * 11 | * This code is distributed in the hope that it will be useful but 12 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 13 | * DISCLAIMED. This includes but is not limited to warranties of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | * 16 | * Date: 2000-12-02 17 | */ 18 | 19 | 20 | #ifndef _STDINT_H 21 | #define _STDINT_H 22 | 23 | /* 7.18.1.1 Exact-width integer types */ 24 | typedef signed char int8_t; 25 | typedef unsigned char uint8_t; 26 | typedef short int16_t; 27 | typedef unsigned short uint16_t; 28 | typedef int int32_t; 29 | typedef unsigned uint32_t; 30 | typedef long long int64_t; 31 | typedef unsigned long long uint64_t; 32 | 33 | /* 7.18.1.2 Minimum-width integer types */ 34 | typedef signed char int_least8_t; 35 | typedef unsigned char uint_least8_t; 36 | typedef short int_least16_t; 37 | typedef unsigned short uint_least16_t; 38 | typedef int int_least32_t; 39 | typedef unsigned uint_least32_t; 40 | typedef long long int_least64_t; 41 | typedef unsigned long long uint_least64_t; 42 | 43 | /* 7.18.1.3 Fastest minimum-width integer types 44 | * Not actually guaranteed to be fastest for all purposes 45 | * Here we use the exact-width types for 8 and 16-bit ints. 46 | */ 47 | typedef char int_fast8_t; 48 | typedef unsigned char uint_fast8_t; 49 | typedef short int_fast16_t; 50 | typedef unsigned short uint_fast16_t; 51 | typedef int int_fast32_t; 52 | typedef unsigned int uint_fast32_t; 53 | typedef long long int_fast64_t; 54 | typedef unsigned long long uint_fast64_t; 55 | 56 | /* 7.18.1.4 Integer types capable of holding object pointers */ 57 | typedef int intptr_t; 58 | typedef unsigned uintptr_t; 59 | 60 | /* 7.18.1.5 Greatest-width integer types */ 61 | typedef long long intmax_t; 62 | typedef unsigned long long uintmax_t; 63 | 64 | /* 7.18.2 Limits of specified-width integer types */ 65 | #if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS) 66 | 67 | /* 7.18.2.1 Limits of exact-width integer types */ 68 | #define INT8_MIN (-128) 69 | #define INT16_MIN (-32768) 70 | #define INT32_MIN (-2147483647 - 1) 71 | #define INT64_MIN (-9223372036854775807LL - 1) 72 | 73 | #define INT8_MAX 127 74 | #define INT16_MAX 32767 75 | #define INT32_MAX 2147483647 76 | #define INT64_MAX 9223372036854775807LL 77 | 78 | #define UINT8_MAX 0xff /* 255U */ 79 | #define UINT16_MAX 0xffff /* 65535U */ 80 | #define UINT32_MAX 0xffffffff /* 4294967295U */ 81 | #define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ 82 | 83 | /* 7.18.2.2 Limits of minimum-width integer types */ 84 | #define INT_LEAST8_MIN INT8_MIN 85 | #define INT_LEAST16_MIN INT16_MIN 86 | #define INT_LEAST32_MIN INT32_MIN 87 | #define INT_LEAST64_MIN INT64_MIN 88 | 89 | #define INT_LEAST8_MAX INT8_MAX 90 | #define INT_LEAST16_MAX INT16_MAX 91 | #define INT_LEAST32_MAX INT32_MAX 92 | #define INT_LEAST64_MAX INT64_MAX 93 | 94 | #define UINT_LEAST8_MAX UINT8_MAX 95 | #define UINT_LEAST16_MAX UINT16_MAX 96 | #define UINT_LEAST32_MAX UINT32_MAX 97 | #define UINT_LEAST64_MAX UINT64_MAX 98 | 99 | /* 7.18.2.3 Limits of fastest minimum-width integer types */ 100 | #define INT_FAST8_MIN INT8_MIN 101 | #define INT_FAST16_MIN INT16_MIN 102 | #define INT_FAST32_MIN INT32_MIN 103 | #define INT_FAST64_MIN INT64_MIN 104 | 105 | #define INT_FAST8_MAX INT8_MAX 106 | #define INT_FAST16_MAX INT16_MAX 107 | #define INT_FAST32_MAX INT32_MAX 108 | #define INT_FAST64_MAX INT64_MAX 109 | 110 | #define UINT_FAST8_MAX UINT8_MAX 111 | #define UINT_FAST16_MAX UINT16_MAX 112 | #define UINT_FAST32_MAX UINT32_MAX 113 | #define UINT_FAST64_MAX UINT64_MAX 114 | 115 | /* 7.18.2.4 Limits of integer types capable of holding 116 | object pointers */ 117 | #define INTPTR_MIN INT32_MIN 118 | #define INTPTR_MAX INT32_MAX 119 | #define UINTPTR_MAX UINT32_MAX 120 | 121 | /* 7.18.2.5 Limits of greatest-width integer types */ 122 | #define INTMAX_MIN INT64_MIN 123 | #define INTMAX_MAX INT64_MAX 124 | #define UINTMAX_MAX UINT64_MAX 125 | 126 | /* 7.18.3 Limits of other integer types */ 127 | #define PTRDIFF_MIN INT32_MIN 128 | #define PTRDIFF_MAX INT32_MAX 129 | 130 | #define SIG_ATOMIC_MIN INT32_MIN 131 | #define SIG_ATOMIC_MAX INT32_MAX 132 | 133 | #define SIZE_MAX UINT32_MAX 134 | 135 | #ifndef WCHAR_MIN /* also in wchar.h */ 136 | #define WCHAR_MIN 0 137 | #define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */ 138 | #endif 139 | 140 | /* 141 | * wint_t is unsigned int in __MINGW32__, 142 | * but unsigned short in MS runtime 143 | */ 144 | #define WINT_MIN 0 145 | #define WINT_MAX UINT32_MAX 146 | 147 | #endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */ 148 | 149 | 150 | /* 7.18.4 Macros for integer constants */ 151 | #if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS) 152 | 153 | /* 7.18.4.1 Macros for minimum-width integer constants 154 | 155 | Accoding to Douglas Gwyn : 156 | "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC 157 | 9899:1999 as initially published, the expansion was required 158 | to be an integer constant of precisely matching type, which 159 | is impossible to accomplish for the shorter types on most 160 | platforms, because C99 provides no standard way to designate 161 | an integer constant with width less than that of type int. 162 | TC1 changed this to require just an integer constant 163 | *expression* with *promoted* type." 164 | 165 | The trick used here is from Clive D W Feather. 166 | */ 167 | 168 | #define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) 169 | #define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) 170 | #define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) 171 | #define INT64_C(val) (INT_LEAST64_MAX-INT_LEAST64_MAX+(val)) 172 | 173 | #define UINT8_C(val) (UINT_LEAST8_MAX-UINT_LEAST8_MAX+(val)) 174 | #define UINT16_C(val) (UINT_LEAST16_MAX-UINT_LEAST16_MAX+(val)) 175 | #define UINT32_C(val) (UINT_LEAST32_MAX-UINT_LEAST32_MAX+(val)) 176 | #define UINT64_C(val) (UINT_LEAST64_MAX-UINT_LEAST64_MAX+(val)) 177 | 178 | /* 7.18.4.2 Macros for greatest-width integer constants */ 179 | #define INTMAX_C(val) (INTMAX_MAX-INTMAX_MAX+(val)) 180 | #define UINTMAX_C(val) (UINTMAX_MAX-UINTMAX_MAX+(val)) 181 | 182 | #endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /win32/include/inttypes.h: -------------------------------------------------------------------------------- 1 | /* 7.8 Format conversion of integer types */ 2 | 3 | #ifndef _INTTYPES_H 4 | #define _INTTYPES_H 5 | 6 | #include 7 | #define __need_wchar_t 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | typedef struct { 15 | intmax_t quot; 16 | intmax_t rem; 17 | } imaxdiv_t; 18 | 19 | #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) 20 | 21 | /* 7.8.1 Macros for format specifiers 22 | * 23 | * MS runtime does not yet understand C9x standard "ll" 24 | * length specifier. It appears to treat "ll" as "l". 25 | * The non-standard I64 length specifier causes warning in GCC, 26 | * but understood by MS runtime functions. 27 | */ 28 | 29 | /* fprintf macros for signed types */ 30 | #define PRId8 "d" 31 | #define PRId16 "d" 32 | #define PRId32 "d" 33 | #define PRId64 "I64d" 34 | 35 | #define PRIdLEAST8 "d" 36 | #define PRIdLEAST16 "d" 37 | #define PRIdLEAST32 "d" 38 | #define PRIdLEAST64 "I64d" 39 | 40 | #define PRIdFAST8 "d" 41 | #define PRIdFAST16 "d" 42 | #define PRIdFAST32 "d" 43 | #define PRIdFAST64 "I64d" 44 | 45 | #define PRIdMAX "I64d" 46 | #define PRIdPTR "d" 47 | 48 | #define PRIi8 "i" 49 | #define PRIi16 "i" 50 | #define PRIi32 "i" 51 | #define PRIi64 "I64i" 52 | 53 | #define PRIiLEAST8 "i" 54 | #define PRIiLEAST16 "i" 55 | #define PRIiLEAST32 "i" 56 | #define PRIiLEAST64 "I64i" 57 | 58 | #define PRIiFAST8 "i" 59 | #define PRIiFAST16 "i" 60 | #define PRIiFAST32 "i" 61 | #define PRIiFAST64 "I64i" 62 | 63 | #define PRIiMAX "I64i" 64 | #define PRIiPTR "i" 65 | 66 | #define PRIo8 "o" 67 | #define PRIo16 "o" 68 | #define PRIo32 "o" 69 | #define PRIo64 "I64o" 70 | 71 | #define PRIoLEAST8 "o" 72 | #define PRIoLEAST16 "o" 73 | #define PRIoLEAST32 "o" 74 | #define PRIoLEAST64 "I64o" 75 | 76 | #define PRIoFAST8 "o" 77 | #define PRIoFAST16 "o" 78 | #define PRIoFAST32 "o" 79 | #define PRIoFAST64 "I64o" 80 | 81 | #define PRIoMAX "I64o" 82 | 83 | #define PRIoPTR "o" 84 | 85 | /* fprintf macros for unsigned types */ 86 | #define PRIu8 "u" 87 | #define PRIu16 "u" 88 | #define PRIu32 "u" 89 | #define PRIu64 "I64u" 90 | 91 | 92 | #define PRIuLEAST8 "u" 93 | #define PRIuLEAST16 "u" 94 | #define PRIuLEAST32 "u" 95 | #define PRIuLEAST64 "I64u" 96 | 97 | #define PRIuFAST8 "u" 98 | #define PRIuFAST16 "u" 99 | #define PRIuFAST32 "u" 100 | #define PRIuFAST64 "I64u" 101 | 102 | #define PRIuMAX "I64u" 103 | #define PRIuPTR "u" 104 | 105 | #define PRIx8 "x" 106 | #define PRIx16 "x" 107 | #define PRIx32 "x" 108 | #define PRIx64 "I64x" 109 | 110 | #define PRIxLEAST8 "x" 111 | #define PRIxLEAST16 "x" 112 | #define PRIxLEAST32 "x" 113 | #define PRIxLEAST64 "I64x" 114 | 115 | #define PRIxFAST8 "x" 116 | #define PRIxFAST16 "x" 117 | #define PRIxFAST32 "x" 118 | #define PRIxFAST64 "I64x" 119 | 120 | #define PRIxMAX "I64x" 121 | #define PRIxPTR "x" 122 | 123 | #define PRIX8 "X" 124 | #define PRIX16 "X" 125 | #define PRIX32 "X" 126 | #define PRIX64 "I64X" 127 | 128 | #define PRIXLEAST8 "X" 129 | #define PRIXLEAST16 "X" 130 | #define PRIXLEAST32 "X" 131 | #define PRIXLEAST64 "I64X" 132 | 133 | #define PRIXFAST8 "X" 134 | #define PRIXFAST16 "X" 135 | #define PRIXFAST32 "X" 136 | #define PRIXFAST64 "I64X" 137 | 138 | #define PRIXMAX "I64X" 139 | #define PRIXPTR "X" 140 | 141 | /* 142 | * fscanf macros for signed int types 143 | * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t 144 | * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have 145 | * no length identifiers 146 | */ 147 | 148 | #define SCNd16 "hd" 149 | #define SCNd32 "d" 150 | #define SCNd64 "I64d" 151 | 152 | #define SCNdLEAST16 "hd" 153 | #define SCNdLEAST32 "d" 154 | #define SCNdLEAST64 "I64d" 155 | 156 | #define SCNdFAST16 "hd" 157 | #define SCNdFAST32 "d" 158 | #define SCNdFAST64 "I64d" 159 | 160 | #define SCNdMAX "I64d" 161 | #define SCNdPTR "d" 162 | 163 | #define SCNi16 "hi" 164 | #define SCNi32 "i" 165 | #define SCNi64 "I64i" 166 | 167 | #define SCNiLEAST16 "hi" 168 | #define SCNiLEAST32 "i" 169 | #define SCNiLEAST64 "I64i" 170 | 171 | #define SCNiFAST16 "hi" 172 | #define SCNiFAST32 "i" 173 | #define SCNiFAST64 "I64i" 174 | 175 | #define SCNiMAX "I64i" 176 | #define SCNiPTR "i" 177 | 178 | #define SCNo16 "ho" 179 | #define SCNo32 "o" 180 | #define SCNo64 "I64o" 181 | 182 | #define SCNoLEAST16 "ho" 183 | #define SCNoLEAST32 "o" 184 | #define SCNoLEAST64 "I64o" 185 | 186 | #define SCNoFAST16 "ho" 187 | #define SCNoFAST32 "o" 188 | #define SCNoFAST64 "I64o" 189 | 190 | #define SCNoMAX "I64o" 191 | #define SCNoPTR "o" 192 | 193 | #define SCNx16 "hx" 194 | #define SCNx32 "x" 195 | #define SCNx64 "I64x" 196 | 197 | #define SCNxLEAST16 "hx" 198 | #define SCNxLEAST32 "x" 199 | #define SCNxLEAST64 "I64x" 200 | 201 | #define SCNxFAST16 "hx" 202 | #define SCNxFAST32 "x" 203 | #define SCNxFAST64 "I64x" 204 | 205 | #define SCNxMAX "I64x" 206 | #define SCNxPTR "x" 207 | 208 | 209 | /* fscanf macros for unsigned int types */ 210 | 211 | #define SCNu16 "hu" 212 | #define SCNu32 "u" 213 | #define SCNu64 "I64u" 214 | 215 | #define SCNuLEAST16 "hu" 216 | #define SCNuLEAST32 "u" 217 | #define SCNuLEAST64 "I64u" 218 | 219 | #define SCNuFAST16 "hu" 220 | #define SCNuFAST32 "u" 221 | #define SCNuFAST64 "I64u" 222 | 223 | #define SCNuMAX "I64u" 224 | #define SCNuPTR "u" 225 | 226 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 227 | /* 228 | * no length modifier for char types prior to C9x 229 | * MS runtime scanf appears to treat "hh" as "h" 230 | */ 231 | 232 | /* signed char */ 233 | #define SCNd8 "hhd" 234 | #define SCNdLEAST8 "hhd" 235 | #define SCNdFAST8 "hhd" 236 | 237 | #define SCNi8 "hhi" 238 | #define SCNiLEAST8 "hhi" 239 | #define SCNiFAST8 "hhi" 240 | 241 | #define SCNo8 "hho" 242 | #define SCNoLEAST8 "hho" 243 | #define SCNoFAST8 "hho" 244 | 245 | #define SCNx8 "hhx" 246 | #define SCNxLEAST8 "hhx" 247 | #define SCNxFAST8 "hhx" 248 | 249 | /* unsigned char */ 250 | #define SCNu8 "hhu" 251 | #define SCNuLEAST8 "hhu" 252 | #define SCNuFAST8 "hhu" 253 | #endif /* __STDC_VERSION__ >= 199901 */ 254 | 255 | #endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */ 256 | 257 | extern inline intmax_t imaxabs (intmax_t j) 258 | {return (j >= 0 ? j : -j);} 259 | imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom); 260 | 261 | /* 7.8.2 Conversion functions for greatest-width integer types */ 262 | 263 | intmax_t strtoimax (const char* __restrict__ nptr, char** __restrict__ endptr, int base); 264 | uintmax_t strtoumax (const char* __restrict__ nptr, char** __restrict__ endptr, int base); 265 | 266 | intmax_t wcstoimax (const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr, 267 | int base); 268 | uintmax_t wcstoumax (const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr, 269 | int base); 270 | 271 | #ifdef __cplusplus 272 | } 273 | #endif 274 | 275 | #endif /* ndef _INTTYPES_H */ 276 | -------------------------------------------------------------------------------- /win32/lib/gdi32.def: -------------------------------------------------------------------------------- 1 | LIBRARY gdi32.dll 2 | 3 | EXPORTS 4 | AbortDoc 5 | AbortPath 6 | AddFontResourceA 7 | AddFontResourceW 8 | AngleArc 9 | AnimatePalette 10 | Arc 11 | ArcTo 12 | BeginPath 13 | BitBlt 14 | ByeByeGDI 15 | CancelDC 16 | CheckColorsInGamut 17 | ChoosePixelFormat 18 | Chord 19 | CloseEnhMetaFile 20 | CloseFigure 21 | CloseMetaFile 22 | ColorCorrectPalette 23 | ColorMatchToTarget 24 | CombineRgn 25 | CombineTransform 26 | CopyEnhMetaFileA 27 | CopyEnhMetaFileW 28 | CopyMetaFileA 29 | CopyMetaFileW 30 | CreateBitmap 31 | CreateBitmapIndirect 32 | CreateBrushIndirect 33 | CreateColorSpaceA 34 | CreateColorSpaceW 35 | CreateCompatibleBitmap 36 | CreateCompatibleDC 37 | CreateDCA 38 | CreateDCW 39 | CreateDIBPatternBrush 40 | CreateDIBPatternBrushPt 41 | CreateDIBSection 42 | CreateDIBitmap 43 | CreateDiscardableBitmap 44 | CreateEllipticRgn 45 | CreateEllipticRgnIndirect 46 | CreateEnhMetaFileA 47 | CreateEnhMetaFileW 48 | CreateFontA 49 | CreateFontIndirectA 50 | CreateFontIndirectW 51 | CreateFontW 52 | CreateHalftonePalette 53 | CreateHatchBrush 54 | CreateICA 55 | CreateICW 56 | CreateMetaFileA 57 | CreateMetaFileW 58 | CreatePalette 59 | CreatePatternBrush 60 | CreatePen 61 | CreatePenIndirect 62 | CreatePolyPolygonRgn 63 | CreatePolygonRgn 64 | CreateRectRgn 65 | CreateRectRgnIndirect 66 | CreateRoundRectRgn 67 | CreateScalableFontResourceA 68 | CreateScalableFontResourceW 69 | CreateSolidBrush 70 | DPtoLP 71 | DeleteColorSpace 72 | DeleteDC 73 | DeleteEnhMetaFile 74 | DeleteMetaFile 75 | DeleteObject 76 | DescribePixelFormat 77 | DeviceCapabilitiesEx 78 | DeviceCapabilitiesExA 79 | DeviceCapabilitiesExW 80 | DrawEscape 81 | Ellipse 82 | EnableEUDC 83 | EndDoc 84 | EndPage 85 | EndPath 86 | EnumEnhMetaFile 87 | EnumFontFamiliesA 88 | EnumFontFamiliesExA 89 | EnumFontFamiliesExW 90 | EnumFontFamiliesW 91 | EnumFontsA 92 | EnumFontsW 93 | EnumICMProfilesA 94 | EnumICMProfilesW 95 | EnumMetaFile 96 | EnumObjects 97 | EqualRgn 98 | Escape 99 | ExcludeClipRect 100 | ExtCreatePen 101 | ExtCreateRegion 102 | ExtEscape 103 | ExtFloodFill 104 | ExtSelectClipRgn 105 | ExtTextOutA 106 | ExtTextOutW 107 | FillPath 108 | FillRgn 109 | FixBrushOrgEx 110 | FlattenPath 111 | FloodFill 112 | FrameRgn 113 | GdiComment 114 | GdiFlush 115 | GdiGetBatchLimit 116 | GdiPlayDCScript 117 | GdiPlayJournal 118 | GdiPlayScript 119 | GdiSetBatchLimit 120 | GetArcDirection 121 | GetAspectRatioFilterEx 122 | GetBitmapBits 123 | GetBitmapDimensionEx 124 | GetBkColor 125 | GetBkMode 126 | GetBoundsRect 127 | GetBrushOrgEx 128 | GetCharABCWidthsA 129 | GetCharABCWidthsFloatA 130 | GetCharABCWidthsFloatW 131 | GetCharABCWidthsW 132 | GetCharWidth32A 133 | GetCharWidth32W 134 | GetCharWidthA 135 | GetCharWidthFloatA 136 | GetCharWidthFloatW 137 | GetCharWidthW 138 | GetCharacterPlacementA 139 | GetCharacterPlacementW 140 | GetClipBox 141 | GetClipRgn 142 | GetColorAdjustment 143 | GetColorSpace 144 | GetCurrentObject 145 | GetCurrentPositionEx 146 | GetDCOrgEx 147 | GetDIBColorTable 148 | GetDIBits 149 | GetDeviceCaps 150 | GetDeviceGammaRamp 151 | GetEnhMetaFileA 152 | GetEnhMetaFileBits 153 | GetEnhMetaFileDescriptionA 154 | GetEnhMetaFileDescriptionW 155 | GetEnhMetaFileHeader 156 | GetEnhMetaFilePaletteEntries 157 | GetEnhMetaFileW 158 | GetFontData 159 | GetFontLanguageInfo 160 | GetFontResourceInfo 161 | GetGlyphOutline 162 | GetGlyphOutlineA 163 | GetGlyphOutlineW 164 | GetGraphicsMode 165 | GetICMProfileA 166 | GetICMProfileW 167 | GetKerningPairs 168 | GetKerningPairsA 169 | GetKerningPairsW 170 | GetLayout 171 | GetLogColorSpaceA 172 | GetLogColorSpaceW 173 | GetMapMode 174 | GetMetaFileA 175 | GetMetaFileBitsEx 176 | GetMetaFileW 177 | GetMetaRgn 178 | GetMiterLimit 179 | GetNearestColor 180 | GetNearestPaletteIndex 181 | GetObjectA 182 | GetObjectType 183 | GetObjectW 184 | GetOutlineTextMetricsA 185 | GetOutlineTextMetricsW 186 | GetPaletteEntries 187 | GetPath 188 | GetPixel 189 | GetPixelFormat 190 | GetPolyFillMode 191 | GetROP2 192 | GetRandomRgn 193 | GetRasterizerCaps 194 | GetRegionData 195 | GetRgnBox 196 | GetStockObject 197 | GetStretchBltMode 198 | GetSystemPaletteEntries 199 | GetSystemPaletteUse 200 | GetTextAlign 201 | GetTextCharacterExtra 202 | GetTextCharset 203 | GetTextCharsetInfo 204 | GetTextColor 205 | GetTextExtentExPointA 206 | GetTextExtentExPointW 207 | GetTextExtentPoint32A 208 | GetTextExtentPoint32W 209 | GetTextExtentPointA 210 | GetTextExtentPointW 211 | GetTextFaceA 212 | GetTextFaceW 213 | GetTextMetricsA 214 | GetTextMetricsW 215 | GetViewportExtEx 216 | GetViewportOrgEx 217 | GetWinMetaFileBits 218 | GetWindowExtEx 219 | GetWindowOrgEx 220 | GetWorldTransform 221 | IntersectClipRect 222 | InvertRgn 223 | LPtoDP 224 | LineDDA 225 | LineTo 226 | MaskBlt 227 | ModifyWorldTransform 228 | MoveToEx 229 | OffsetClipRgn 230 | OffsetRgn 231 | OffsetViewportOrgEx 232 | OffsetWindowOrgEx 233 | PaintRgn 234 | PatBlt 235 | PathToRegion 236 | Pie 237 | PlayEnhMetaFile 238 | PlayEnhMetaFileRecord 239 | PlayMetaFile 240 | PlayMetaFileRecord 241 | PlgBlt 242 | PolyBezier 243 | PolyBezierTo 244 | PolyDraw 245 | PolyPolygon 246 | PolyPolyline 247 | PolyTextOutA 248 | PolyTextOutW 249 | Polygon 250 | Polyline 251 | PolylineTo 252 | PtInRegion 253 | PtVisible 254 | RealizePalette 255 | RectInRegion 256 | RectVisible 257 | Rectangle 258 | RemoveFontResourceA 259 | RemoveFontResourceW 260 | ResetDCA 261 | ResetDCW 262 | ResizePalette 263 | RestoreDC 264 | RoundRect 265 | SaveDC 266 | ScaleViewportExtEx 267 | ScaleWindowExtEx 268 | SelectClipPath 269 | SelectClipRgn 270 | SelectObject 271 | SelectPalette 272 | SetAbortProc 273 | SetArcDirection 274 | SetBitmapBits 275 | SetBitmapDimensionEx 276 | SetBkColor 277 | SetBkMode 278 | SetBoundsRect 279 | SetBrushOrgEx 280 | SetColorAdjustment 281 | SetColorSpace 282 | SetDIBColorTable 283 | SetDIBits 284 | SetDIBitsToDevice 285 | SetDeviceGammaRamp 286 | SetEnhMetaFileBits 287 | SetFontEnumeration 288 | SetGraphicsMode 289 | SetICMMode 290 | SetICMProfileA 291 | SetICMProfileW 292 | SetLayout 293 | SetMagicColors 294 | SetMapMode 295 | SetMapperFlags 296 | SetMetaFileBitsEx 297 | SetMetaRgn 298 | SetMiterLimit 299 | SetObjectOwner 300 | SetPaletteEntries 301 | SetPixel 302 | SetPixelFormat 303 | SetPixelV 304 | SetPolyFillMode 305 | SetROP2 306 | SetRectRgn 307 | SetStretchBltMode 308 | SetSystemPaletteUse 309 | SetTextAlign 310 | SetTextCharacterExtra 311 | SetTextColor 312 | SetTextJustification 313 | SetViewportExtEx 314 | SetViewportOrgEx 315 | SetWinMetaFileBits 316 | SetWindowExtEx 317 | SetWindowOrgEx 318 | SetWorldTransform 319 | StartDocA 320 | StartDocW 321 | StartPage 322 | StretchBlt 323 | StretchDIBits 324 | StrokeAndFillPath 325 | StrokePath 326 | SwapBuffers 327 | TextOutA 328 | TextOutW 329 | TranslateCharsetInfo 330 | UnrealizeObject 331 | UpdateColors 332 | UpdateICMRegKeyA 333 | UpdateICMRegKeyW 334 | WidenPath 335 | gdiPlaySpoolStream 336 | pfnRealizePalette 337 | pfnSelectPalette 338 | -------------------------------------------------------------------------------- /win32/include/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * string.h 3 | * 4 | * Definitions for memory and string functions. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef _STRING_H_ 28 | #define _STRING_H_ 29 | 30 | /* All the headers include this file. */ 31 | #include <_mingw.h> 32 | 33 | /* 34 | * Define size_t, wchar_t and NULL 35 | */ 36 | #define __need_size_t 37 | #define __need_wchar_t 38 | #define __need_NULL 39 | #ifndef RC_INVOKED 40 | #include 41 | #endif /* Not RC_INVOKED */ 42 | 43 | #ifndef RC_INVOKED 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* 50 | * Prototypes of the ANSI Standard C library string functions. 51 | */ 52 | void* memchr (const void*, int, size_t); 53 | int memcmp (const void*, const void*, size_t); 54 | void* memcpy (void*, const void*, size_t); 55 | void* memmove (void*, const void*, size_t); 56 | void* memset (void*, int, size_t); 57 | char* strcat (char*, const char*); 58 | char* strchr (const char*, int); 59 | int strcmp (const char*, const char*); 60 | int strcoll (const char*, const char*); /* Compare using locale */ 61 | char* strcpy (char*, const char*); 62 | size_t strcspn (const char*, const char*); 63 | char* strerror (int); /* NOTE: NOT an old name wrapper. */ 64 | char* _strerror (const char *); 65 | size_t strlen (const char*); 66 | char* strncat (char*, const char*, size_t); 67 | int strncmp (const char*, const char*, size_t); 68 | char* strncpy (char*, const char*, size_t); 69 | char* strpbrk (const char*, const char*); 70 | char* strrchr (const char*, int); 71 | size_t strspn (const char*, const char*); 72 | char* strstr (const char*, const char*); 73 | char* strtok (char*, const char*); 74 | size_t strxfrm (char*, const char*, size_t); 75 | 76 | #ifndef __STRICT_ANSI__ 77 | /* 78 | * Extra non-ANSI functions provided by the CRTDLL library 79 | */ 80 | void* _memccpy (void*, const void*, int, size_t); 81 | int _memicmp (const void*, const void*, size_t); 82 | char* _strdup (const char*); 83 | int _strcmpi (const char*, const char*); 84 | int _stricmp (const char*, const char*); 85 | int _stricoll (const char*, const char*); 86 | char* _strlwr (char*); 87 | int _strnicmp (const char*, const char*, size_t); 88 | char* _strnset (char*, int, size_t); 89 | char* _strrev (char*); 90 | char* _strset (char*, int); 91 | char* _strupr (char*); 92 | void _swab (const char*, char*, size_t); 93 | 94 | /* 95 | * Multi-byte character functions 96 | */ 97 | unsigned char* _mbschr (unsigned char*, unsigned char*); 98 | unsigned char* _mbsncat (unsigned char*, const unsigned char*, size_t); 99 | unsigned char* _mbstok (unsigned char*, unsigned char*); 100 | 101 | #ifdef __MSVCRT__ 102 | int _strncoll(const char*, const char*, size_t); 103 | int _strnicoll(const char*, const char*, size_t); 104 | #endif 105 | 106 | #endif /* Not __STRICT_ANSI__ */ 107 | 108 | /* 109 | * Unicode versions of the standard calls. 110 | */ 111 | wchar_t* wcscat (wchar_t*, const wchar_t*); 112 | wchar_t* wcschr (const wchar_t*, wchar_t); 113 | int wcscmp (const wchar_t*, const wchar_t*); 114 | int wcscoll (const wchar_t*, const wchar_t*); 115 | wchar_t* wcscpy (wchar_t*, const wchar_t*); 116 | size_t wcscspn (const wchar_t*, const wchar_t*); 117 | /* Note: No wcserror in CRTDLL. */ 118 | size_t wcslen (const wchar_t*); 119 | wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t); 120 | int wcsncmp(const wchar_t*, const wchar_t*, size_t); 121 | wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t); 122 | wchar_t* wcspbrk(const wchar_t*, const wchar_t*); 123 | wchar_t* wcsrchr(const wchar_t*, wchar_t); 124 | size_t wcsspn(const wchar_t*, const wchar_t*); 125 | wchar_t* wcsstr(const wchar_t*, const wchar_t*); 126 | wchar_t* wcstok(wchar_t*, const wchar_t*); 127 | size_t wcsxfrm(wchar_t*, const wchar_t*, size_t); 128 | 129 | #ifndef __STRICT_ANSI__ 130 | /* 131 | * Unicode versions of non-ANSI functions provided by CRTDLL. 132 | */ 133 | 134 | /* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */ 135 | #define _wcscmpi _wcsicmp 136 | 137 | wchar_t* _wcsdup (wchar_t*); 138 | int _wcsicmp (const wchar_t*, const wchar_t*); 139 | int _wcsicoll (const wchar_t*, const wchar_t*); 140 | wchar_t* _wcslwr (wchar_t*); 141 | int _wcsnicmp (const wchar_t*, const wchar_t*, size_t); 142 | wchar_t* _wcsnset (wchar_t*, wchar_t, size_t); 143 | wchar_t* _wcsrev (wchar_t*); 144 | wchar_t* _wcsset (wchar_t*, wchar_t); 145 | wchar_t* _wcsupr (wchar_t*); 146 | 147 | #ifdef __MSVCRT__ 148 | int _wcsncoll(const wchar_t*, const wchar_t*, size_t); 149 | int _wcsnicoll(const wchar_t*, const wchar_t*, size_t); 150 | #endif 151 | 152 | 153 | #endif /* Not __STRICT_ANSI__ */ 154 | 155 | 156 | #ifndef __STRICT_ANSI__ 157 | #ifndef _NO_OLDNAMES 158 | 159 | /* 160 | * Non-underscored versions of non-ANSI functions. They live in liboldnames.a 161 | * and provide a little extra portability. Also a few extra UNIX-isms like 162 | * strcasecmp. 163 | */ 164 | 165 | void* memccpy (void*, const void*, int, size_t); 166 | int memicmp (const void*, const void*, size_t); 167 | char* strdup (const char*); 168 | int strcmpi (const char*, const char*); 169 | int stricmp (const char*, const char*); 170 | int strcasecmp (const char*, const char*); 171 | int stricoll (const char*, const char*); 172 | char* strlwr (char*); 173 | int strnicmp (const char*, const char*, size_t); 174 | int strncasecmp (const char*, const char*, size_t); 175 | char* strnset (char*, int, size_t); 176 | char* strrev (char*); 177 | char* strset (char*, int); 178 | char* strupr (char*); 179 | #ifndef _UWIN 180 | void swab (const char*, char*, size_t); 181 | #endif /* _UWIN */ 182 | 183 | /* NOTE: There is no _wcscmpi, but this is for compatibility. */ 184 | int wcscmpi (const wchar_t*, const wchar_t*); 185 | wchar_t* wcsdup (wchar_t*); 186 | int wcsicmp (const wchar_t*, const wchar_t*); 187 | int wcsicoll (const wchar_t*, const wchar_t*); 188 | wchar_t* wcslwr (wchar_t*); 189 | int wcsnicmp (const wchar_t*, const wchar_t*, size_t); 190 | wchar_t* wcsnset (wchar_t*, wchar_t, size_t); 191 | wchar_t* wcsrev (wchar_t*); 192 | wchar_t* wcsset (wchar_t*, wchar_t); 193 | wchar_t* wcsupr (wchar_t*); 194 | 195 | #endif /* Not _NO_OLDNAMES */ 196 | #endif /* Not strict ANSI */ 197 | 198 | 199 | #ifdef __cplusplus 200 | } 201 | #endif 202 | 203 | #endif /* Not RC_INVOKED */ 204 | 205 | #endif /* Not _STRING_H_ */ 206 | 207 | -------------------------------------------------------------------------------- /win32/include/winapi/winreg.h: -------------------------------------------------------------------------------- 1 | #ifndef _WINREG_H 2 | #define _WINREG_H 3 | #if __GNUC__ >=3 4 | #pragma GCC system_header 5 | #endif 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #define HKEY_CLASSES_ROOT ((HKEY)0x80000000) 11 | #define HKEY_CURRENT_USER ((HKEY)0x80000001) 12 | #define HKEY_LOCAL_MACHINE ((HKEY)0x80000002) 13 | #define HKEY_USERS ((HKEY)0x80000003) 14 | #define HKEY_PERFORMANCE_DATA ((HKEY)0x80000004) 15 | #define HKEY_CURRENT_CONFIG ((HKEY)0x80000005) 16 | #define HKEY_DYN_DATA ((HKEY)0x80000006) 17 | #define REG_OPTION_VOLATILE 1 18 | #define REG_OPTION_NON_VOLATILE 0 19 | #define REG_CREATED_NEW_KEY 1 20 | #define REG_OPENED_EXISTING_KEY 2 21 | #define REG_NONE 0 22 | #define REG_SZ 1 23 | #define REG_EXPAND_SZ 2 24 | #define REG_BINARY 3 25 | #define REG_DWORD 4 26 | #define REG_DWORD_BIG_ENDIAN 5 27 | #define REG_DWORD_LITTLE_ENDIAN 4 28 | #define REG_LINK 6 29 | #define REG_MULTI_SZ 7 30 | #define REG_RESOURCE_LIST 8 31 | #define REG_FULL_RESOURCE_DESCRIPTOR 9 32 | #define REG_RESOURCE_REQUIREMENTS_LIST 10 33 | #define REG_NOTIFY_CHANGE_NAME 1 34 | #define REG_NOTIFY_CHANGE_ATTRIBUTES 2 35 | #define REG_NOTIFY_CHANGE_LAST_SET 4 36 | #define REG_NOTIFY_CHANGE_SECURITY 8 37 | 38 | #ifndef RC_INVOKED 39 | typedef ACCESS_MASK REGSAM; 40 | typedef struct value_entA { 41 | LPSTR ve_valuename; 42 | DWORD ve_valuelen; 43 | DWORD ve_valueptr; 44 | DWORD ve_type; 45 | } VALENTA,*PVALENTA; 46 | typedef struct value_entW { 47 | LPWSTR ve_valuename; 48 | DWORD ve_valuelen; 49 | DWORD ve_valueptr; 50 | DWORD ve_type; 51 | } VALENTW,*PVALENTW; 52 | BOOL WINAPI AbortSystemShutdownA(LPCSTR); 53 | BOOL WINAPI AbortSystemShutdownW(LPCWSTR); 54 | BOOL WINAPI InitiateSystemShutdownA(LPSTR,LPSTR,DWORD,BOOL,BOOL); 55 | BOOL WINAPI InitiateSystemShutdownW(LPWSTR,LPWSTR,DWORD,BOOL,BOOL); 56 | LONG WINAPI RegCloseKey(HKEY); 57 | LONG WINAPI RegConnectRegistryA(LPSTR,HKEY,PHKEY); 58 | LONG WINAPI RegConnectRegistryW(LPWSTR,HKEY,PHKEY); 59 | LONG WINAPI RegCreateKeyA(HKEY,LPCSTR,PHKEY); 60 | LONG WINAPI RegCreateKeyExA(HKEY,LPCSTR,DWORD,LPSTR,DWORD,REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,PDWORD); 61 | LONG WINAPI RegCreateKeyExW(HKEY,LPCWSTR,DWORD,LPWSTR,DWORD,REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,PDWORD); 62 | LONG WINAPI RegCreateKeyW(HKEY,LPCWSTR,PHKEY); 63 | LONG WINAPI RegDeleteKeyA(HKEY,LPCSTR); 64 | LONG WINAPI RegDeleteKeyW(HKEY,LPCWSTR); 65 | LONG WINAPI RegDeleteValueA (HKEY,LPCSTR); 66 | LONG WINAPI RegDeleteValueW(HKEY,LPCWSTR); 67 | LONG WINAPI RegEnumKeyA (HKEY,DWORD,LPSTR,DWORD); 68 | LONG WINAPI RegEnumKeyW(HKEY,DWORD,LPWSTR,DWORD); 69 | LONG WINAPI RegEnumKeyExA(HKEY,DWORD,LPSTR,PDWORD,PDWORD,LPSTR,PDWORD,PFILETIME); 70 | LONG WINAPI RegEnumKeyExW(HKEY,DWORD,LPWSTR,PDWORD,PDWORD,LPWSTR,PDWORD,PFILETIME); 71 | LONG WINAPI RegEnumValueA(HKEY,DWORD,LPSTR,PDWORD,PDWORD,PDWORD,LPBYTE,PDWORD); 72 | LONG WINAPI RegEnumValueW(HKEY,DWORD,LPWSTR,PDWORD,PDWORD,PDWORD,LPBYTE,PDWORD); 73 | LONG WINAPI RegFlushKey(HKEY); 74 | LONG WINAPI RegGetKeySecurity(HKEY,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,PDWORD); 75 | LONG WINAPI RegLoadKeyA(HKEY,LPCSTR,LPCSTR); 76 | LONG WINAPI RegLoadKeyW(HKEY,LPCWSTR,LPCWSTR); 77 | LONG WINAPI RegNotifyChangeKeyValue(HKEY,BOOL,DWORD,HANDLE,BOOL); 78 | LONG WINAPI RegOpenKeyA(HKEY,LPCSTR,PHKEY); 79 | LONG WINAPI RegOpenKeyExA(HKEY,LPCSTR,DWORD,REGSAM,PHKEY); 80 | LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY); 81 | LONG WINAPI RegOpenKeyW(HKEY,LPCWSTR,PHKEY); 82 | LONG WINAPI RegQueryInfoKeyA(HKEY,LPSTR,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PFILETIME); 83 | LONG WINAPI RegQueryInfoKeyW(HKEY,LPWSTR,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PDWORD,PFILETIME); 84 | LONG WINAPI RegQueryMultipleValuesA(HKEY,PVALENTA,DWORD,LPSTR,PDWORD); 85 | LONG WINAPI RegQueryMultipleValuesW(HKEY,PVALENTW,DWORD,LPWSTR,PDWORD); 86 | LONG WINAPI RegQueryValueA(HKEY,LPCSTR,LPSTR,PLONG); 87 | LONG WINAPI RegQueryValueExA (HKEY,LPCSTR,PDWORD,PDWORD,LPBYTE,PDWORD); 88 | LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,PDWORD,PDWORD,LPBYTE,PDWORD); 89 | LONG WINAPI RegQueryValueW(HKEY,LPCWSTR,LPWSTR,PLONG); 90 | LONG WINAPI RegReplaceKeyA(HKEY,LPCSTR,LPCSTR,LPCSTR); 91 | LONG WINAPI RegReplaceKeyW(HKEY,LPCWSTR,LPCWSTR,LPCWSTR); 92 | LONG WINAPI RegRestoreKeyA (HKEY,LPCSTR,DWORD); 93 | LONG WINAPI RegRestoreKeyW(HKEY,LPCWSTR,DWORD); 94 | LONG WINAPI RegSaveKeyA(HKEY,LPCSTR,LPSECURITY_ATTRIBUTES); 95 | LONG WINAPI RegSaveKeyW(HKEY,LPCWSTR,LPSECURITY_ATTRIBUTES); 96 | LONG WINAPI RegSetKeySecurity(HKEY,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR); 97 | LONG WINAPI RegSetValueA(HKEY,LPCSTR,DWORD,LPCSTR,DWORD); 98 | LONG WINAPI RegSetValueExA(HKEY,LPCSTR,DWORD,DWORD,const BYTE*,DWORD); 99 | LONG WINAPI RegSetValueExW(HKEY,LPCWSTR,DWORD,DWORD,const BYTE*,DWORD); 100 | LONG WINAPI RegSetValueW(HKEY,LPCWSTR,DWORD,LPCWSTR,DWORD); 101 | LONG WINAPI RegUnLoadKeyA(HKEY,LPCSTR); 102 | LONG WINAPI RegUnLoadKeyW(HKEY,LPCWSTR); 103 | 104 | #ifdef UNICODE 105 | typedef VALENTW VALENT,*PVALENT; 106 | #define AbortSystemShutdown AbortSystemShutdownW 107 | #define InitiateSystemShutdown InitiateSystemShutdownW 108 | #define RegConnectRegistry RegConnectRegistryW 109 | #define RegCreateKey RegCreateKeyW 110 | #define RegCreateKeyEx RegCreateKeyExW 111 | #define RegDeleteKey RegDeleteKeyW 112 | #define RegDeleteValue RegDeleteValueW 113 | #define RegEnumKey RegEnumKeyW 114 | #define RegEnumKeyEx RegEnumKeyExW 115 | #define RegEnumValue RegEnumValueW 116 | #define RegLoadKey RegLoadKeyW 117 | #define RegOpenKey RegOpenKeyW 118 | #define RegOpenKeyEx RegOpenKeyExW 119 | #define RegQueryInfoKey RegQueryInfoKeyW 120 | #define RegQueryMultipleValues RegQueryMultipleValuesW 121 | #define RegQueryValue RegQueryValueW 122 | #define RegQueryValueEx RegQueryValueExW 123 | #define RegReplaceKey RegReplaceKeyW 124 | #define RegRestoreKey RegRestoreKeyW 125 | #define RegSaveKey RegSaveKeyW 126 | #define RegSetValue RegSetValueW 127 | #define RegSetValueEx RegSetValueExW 128 | #define RegUnLoadKey RegUnLoadKeyW 129 | #else 130 | typedef VALENTA VALENT,*PVALENT; 131 | #define AbortSystemShutdown AbortSystemShutdownA 132 | #define InitiateSystemShutdown InitiateSystemShutdownA 133 | #define RegConnectRegistry RegConnectRegistryA 134 | #define RegCreateKey RegCreateKeyA 135 | #define RegCreateKeyEx RegCreateKeyExA 136 | #define RegDeleteKey RegDeleteKeyA 137 | #define RegDeleteValue RegDeleteValueA 138 | #define RegEnumKey RegEnumKeyA 139 | #define RegEnumKeyEx RegEnumKeyExA 140 | #define RegEnumValue RegEnumValueA 141 | #define RegLoadKey RegLoadKeyA 142 | #define RegOpenKey RegOpenKeyA 143 | #define RegOpenKeyEx RegOpenKeyExA 144 | #define RegQueryInfoKey RegQueryInfoKeyA 145 | #define RegQueryMultipleValues RegQueryMultipleValuesA 146 | #define RegQueryValue RegQueryValueA 147 | #define RegQueryValueEx RegQueryValueExA 148 | #define RegReplaceKey RegReplaceKeyA 149 | #define RegRestoreKey RegRestoreKeyA 150 | #define RegSaveKey RegSaveKeyA 151 | #define RegSetValue RegSetValueA 152 | #define RegSetValueEx RegSetValueExA 153 | #define RegUnLoadKey RegUnLoadKeyA 154 | #endif 155 | #endif 156 | #ifdef __cplusplus 157 | } 158 | #endif 159 | #endif 160 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007-2012 LuaDist. 2 | # Submited by David Manura 3 | # Redistribution and use of this file is allowed according to the terms of the MIT license. 4 | # For details see the COPYRIGHT file distributed with LuaDist. 5 | # Please note that the package source code is licensed under its own license. 6 | 7 | #~WARNING: The was derived from the Makefile and some parts 8 | # remain unimplemented: 9 | # gcc-2, x86-64, CFLAGS_P, bcheck.o, arm, TCC_UCLIBC, 10 | # CONFIG_CROSS 11 | # NOTE: tcc itself is broken on Cygwin. 12 | 13 | project ( tcc C ) 14 | cmake_minimum_required ( VERSION 2.8 ) 15 | include ( cmake/dist.cmake ) 16 | 17 | #~TODO: autodetect? 18 | set ( ARCH i386 ) 19 | 20 | # Build config.h 21 | configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h ) 22 | 23 | set ( CORE_FILES tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tcc.h config.h 24 | libtcc.h tcctok.h ) 25 | set ( I386_FILES ${CORE_FILES} i386-gen.c i386-asm.c i386-asm.h ) 26 | set ( WIN32_FILES ${CORE_FILES} i386-gen.c i386-asm.c i386-asm.h tccpe.c ) 27 | set ( X86_64_FILES ${CORE_FILES} x86_64-gen.c ) 28 | set ( ARM_FILES ${CORE_FILES} arm-gen.c ) 29 | set ( C67_FILES ${CORE_FILES} c67-gen.c tcccoff.c ) 30 | 31 | # Set C compiler flags. 32 | include ( CheckCCompilerFlag ) 33 | check_c_compiler_flag ( -fno-strict-aliasing, HAVE_NOSTRICTALIASING ) 34 | if ( HAVE_NOSTRICTALIASING ) 35 | add_definitions ( -fno-strict-aliasing ) 36 | endif ( HAVE_NOSTRICTALIASING ) 37 | 38 | # Set target and sources 39 | if ( WIN32 AND NOT CYGWIN ) 40 | set ( NATIVE_TARGET -DTCC_TARGET_PE ) 41 | set ( NATIVE_FILES ${WIN32_FILES} ) 42 | else ( ) 43 | if ( ${ARCH} STREQUAL i386 ) 44 | set ( NATIVE_TARGET -DTCC_TARGET_I386 ) 45 | set ( NATIVE_FILES ${I386_FILES} ) 46 | elseif ( ${ARCH} STREQUALS arm ) 47 | set ( NATIVE_TARGET -DTCC_TARGET_ARM ) 48 | #NOT-IMPL: 49 | # NATIVE_TARGET+=$(if $(wildcard /lib/ld-linux.so.3),-DTCC_ARM_EABI) 50 | # NATIVE_TARGET+=$(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " 51 | # /proc/cpuinfo),-DTCC_ARM_VFP) 52 | message ( FATAL_ERROR "TODO - not implemented" ) 53 | elseif ( ${ARCH} STREQUALS x86-64 ) 54 | set ( NATIVE_TARGET -DTCC_X86_64 ) 55 | endif ( ${ARCH} STREQUAL i386 ) 56 | # (CMAKE_SIZEOF_VOID_P MATCHES "8") 57 | endif ( WIN32 AND NOT CYGWIN ) 58 | 59 | # Set C flags. 60 | add_definitions ( ${NATIVE_TARGET} ) 61 | 62 | # Set libraries. 63 | if ( NOT WIN32 ) 64 | link_libraries ( -ldl ) 65 | endif ( NOT WIN32 ) 66 | 67 | # Set libtcc1 sources and tcc arguments 68 | set ( LIBTCC1_SRC lib/libtcc1.c ) 69 | set ( TCC ${CMAKE_CURRENT_BINARY_DIR}/tcc ) 70 | set ( TCC_ARGS ) 71 | if ( WIN32 AND NOT CYGWIN ) 72 | set ( LIBTCC1_SRC ${LIBTCC1_SRC} win32/lib/crt1.c win32/lib/wincrt1.c win32/lib/dllcrt1.c 73 | win32/lib/dllmain.c win32/lib/chkstk.S ) 74 | set ( LIBTCC1_OBJS ${LIBTCC1_OBJS} crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o ) 75 | set ( TCC_ARGS -Bwin32 -DTCC_TARGET_PE ) 76 | endif ( WIN32 AND NOT CYGWIN ) 77 | if ( ARCH STREQUAL i386 ) 78 | set ( LIBTCC1_SRC ${LIBTCC1_SRC} lib/alloca86.S lib/alloca86-bt.S ) 79 | set ( LIBTCC1_OBJS ${LIBTCC1_OBJS} alloca86.o alloca86-bt.o ) 80 | endif ( ARCH STREQUAL i386 ) 81 | 82 | # make 'include "config.h"' and 'include "../config.h"' work 83 | file ( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/child-dir ) 84 | include_directories ( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/child-dir ) 85 | 86 | # TCC executable. 87 | add_executable ( tcc tcc.c ) 88 | 89 | # libtcc 90 | add_library ( libtcc STATIC libtcc.c ) 91 | 92 | # Extra utility executables. 93 | if ( WIN32 AND NOT CYGWIN ) 94 | add_executable ( tiny_impdef win32/tools/tiny_impdef.c ) 95 | endif ( WIN32 AND NOT CYGWIN ) 96 | add_executable ( tiny_libmaker win32/tools/tiny_libmaker.c ) 97 | 98 | set ( TCC_INCLUDE -I${CMAKE_CURRENT_BINARY_DIR}/child-dir ) 99 | # make include "../config.h" work 100 | if ( WIN32 AND NOT CYGWIN ) 101 | set ( TCC_INCLUDE ${TCC_INCLUDE} -I${CMAKE_CURRENT_SOURCE_DIR}/win32/include -I${CMAKE_CURRENT_SOURCE_DIR}/win32/include/winapi ) 102 | endif ( WIN32 AND NOT CYGWIN ) 103 | 104 | # libtcc1 sources built with tcc. 105 | foreach ( src ${LIBTCC1_SRC} ) 106 | get_filename_component ( srcname ${src} NAME_WE ) 107 | get_filename_component ( srcext ${src} EXT ) 108 | if ( ${srcext} STREQUAL .c ) 109 | set ( TCC_EXTRA_FLAGS -O2 -Wall ) 110 | else ( ) 111 | # .S 112 | set ( TCC_EXTRA_FLAGS ) 113 | endif ( ${srcext} STREQUAL .c ) 114 | add_custom_command ( OUTPUT ${srcname}.o DEPENDS tcc ${src} COMMAND ${TCC} ${TCC_EXTRA_FLAGS} 115 | ${TCC_INCLUDE} -c ${CMAKE_CURRENT_SOURCE_DIR}/${src} ) 116 | endforeach ( src ) 117 | 118 | # Link libtcc1 119 | add_custom_command ( OUTPUT libtcc1.a DEPENDS tiny_libmaker ${LIBTCC1_OBJS} COMMAND 120 | ${CMAKE_CURRENT_BINARY_DIR}/tiny_libmaker rcs libtcc1.a ${LIBTCC1_OBJS} ) 121 | add_custom_target ( libtcc1 ALL DEPENDS libtcc1.a ) 122 | 123 | # Install files. 124 | install_executable ( tcc ) 125 | install_library ( libtcc ) 126 | 127 | install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/libtcc1.a DESTINATION ${INSTALL_LIB}/tcc COMPONENT Library ) 128 | 129 | install_header ( libtcc.h ) 130 | install_doc ( tcc-doc.html ) 131 | install_header ( include/stdarg.h include/stddef.h include/stdbool.h include/float.h 132 | include/varargs.h include/tcclib.h INTO tcc/include ) 133 | install_data ( README COPYING ) 134 | if ( WIN32 ) 135 | install_header ( win32/include/assert.h win32/include/conio.h win32/include/ctype.h 136 | win32/include/dir.h win32/include/direct.h win32/include/dirent.h win32/include/dos.h 137 | win32/include/errno.h win32/include/excpt.h win32/include/fcntl.h win32/include/fenv.h 138 | win32/include/float.h win32/include/inttypes.h win32/include/io.h win32/include/limits.h 139 | win32/include/locale.h win32/include/malloc.h win32/include/math.h win32/include/mem.h 140 | win32/include/memory.h win32/include/process.h win32/include/setjmp.h win32/include/share.h 141 | win32/include/signal.h win32/include/stdarg.h win32/include/stdbool.h win32/include/stddef.h 142 | win32/include/stdint.h win32/include/stdio.h win32/include/stdlib.h win32/include/string.h 143 | win32/include/tchar.h win32/include/time.h win32/include/unistd.h win32/include/values.h 144 | win32/include/varargs.h win32/include/wchar.h win32/include/wctype.h win32/include/_mingw.h 145 | INTO tcc/include ) 146 | install_header ( win32/include/sys/fcntl.h win32/include/sys/file.h win32/include/sys/locking.h 147 | win32/include/sys/stat.h win32/include/sys/time.h win32/include/sys/timeb.h win32/include/sys/types.h 148 | win32/include/sys/unistd.h win32/include/sys/utime.h INTO tcc/include/sys ) 149 | install_header ( win32/include/winapi/basetsd.h win32/include/winapi/basetyps.h 150 | win32/include/winapi/winbase.h win32/include/winapi/wincon.h win32/include/winapi/windef.h 151 | win32/include/winapi/windows.h win32/include/winapi/winerror.h win32/include/winapi/wingdi.h 152 | win32/include/winapi/winnetwk.h win32/include/winapi/winnls.h win32/include/winapi/winnt.h 153 | win32/include/winapi/winreg.h win32/include/winapi/winsvc.h win32/include/winapi/winuser.h 154 | win32/include/winapi/winver.h INTO tcc/include/winapi ) 155 | endif ( ) 156 | -------------------------------------------------------------------------------- /win32/include/float.h: -------------------------------------------------------------------------------- 1 | /* 2 | * float.h 3 | * 4 | * Constants related to floating point arithmetic. 5 | * 6 | * Also included here are some non-ANSI bits for accessing the floating 7 | * point controller. 8 | * 9 | * NOTE: GCC provides float.h, and it is probably more accurate than this, 10 | * but it doesn't include the non-standard stuff for accessing the 11 | * fp controller. (TODO: Move those bits elsewhere?) Thus it is 12 | * probably not a good idea to use the GCC supplied version instead 13 | * of this header. 14 | * 15 | * This file is part of the Mingw32 package. 16 | * 17 | * Contributors: 18 | * Created by Colin Peters 19 | * 20 | * THIS SOFTWARE IS NOT COPYRIGHTED 21 | * 22 | * This source code is offered for use in the public domain. You may 23 | * use, modify or distribute it freely. 24 | * 25 | * This code is distributed in the hope that it will be useful but 26 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 27 | * DISCLAIMED. This includes but is not limited to warranties of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 29 | * 30 | * $Revision: 1.2 $ 31 | * $Author: bellard $ 32 | * $Date: 2005/04/17 13:14:29 $ 33 | * 34 | */ 35 | 36 | #ifndef _FLOAT_H_ 37 | #define _FLOAT_H_ 38 | 39 | /* All the headers include this file. */ 40 | #include <_mingw.h> 41 | 42 | #define FLT_ROUNDS 1 43 | #define FLT_GUARD 1 44 | #define FLT_NORMALIZE 1 45 | 46 | /* 47 | * The characteristics of float. 48 | */ 49 | 50 | /* The radix for floating point representation. */ 51 | #define FLT_RADIX 2 52 | 53 | /* Decimal digits of precision. */ 54 | #define FLT_DIG 6 55 | 56 | /* Smallest number such that 1+x != 1 */ 57 | #define FLT_EPSILON 1.19209290e-07F 58 | 59 | /* The number of base FLT_RADIX digits in the mantissa. */ 60 | #define FLT_MANT_DIG 24 61 | 62 | /* The maximum floating point number. */ 63 | #define FLT_MAX 3.40282347e+38F 64 | 65 | /* Maximum n such that FLT_RADIX^n - 1 is representable. */ 66 | #define FLT_MAX_EXP 128 67 | 68 | /* Maximum n such that 10^n is representable. */ 69 | #define FLT_MAX_10_EXP 38 70 | 71 | /* Minimum normalized floating-point number. */ 72 | #define FLT_MIN 1.17549435e-38F 73 | 74 | /* Minimum n such that FLT_RADIX^n is a normalized number. */ 75 | #define FLT_MIN_EXP (-125) 76 | 77 | /* Minimum n such that 10^n is a normalized number. */ 78 | #define FLT_MIN_10_EXP (-37) 79 | 80 | 81 | /* 82 | * The characteristics of double. 83 | */ 84 | #define DBL_DIG 15 85 | #define DBL_EPSILON 1.1102230246251568e-16 86 | #define DBL_MANT_DIG 53 87 | #define DBL_MAX 1.7976931348623157e+308 88 | #define DBL_MAX_EXP 1024 89 | #define DBL_MAX_10_EXP 308 90 | #define DBL_MIN 2.2250738585072014e-308 91 | #define DBL_MIN_EXP (-1021) 92 | #define DBL_MIN_10_EXP (-307) 93 | 94 | 95 | /* 96 | * The characteristics of long double. 97 | * NOTE: long double is the same as double. 98 | */ 99 | #define LDBL_DIG 15 100 | #define LDBL_EPSILON 1.1102230246251568e-16L 101 | #define LDBL_MANT_DIG 53 102 | #define LDBL_MAX 1.7976931348623157e+308L 103 | #define LDBL_MAX_EXP 1024 104 | #define LDBL_MAX_10_EXP 308 105 | #define LDBL_MIN 2.2250738585072014e-308L 106 | #define LDBL_MIN_EXP (-1021) 107 | #define LDBL_MIN_10_EXP (-307) 108 | 109 | 110 | /* 111 | * Functions and definitions for controlling the FPU. 112 | */ 113 | #ifndef __STRICT_ANSI__ 114 | 115 | /* TODO: These constants are only valid for x86 machines */ 116 | 117 | /* Control word masks for unMask */ 118 | #define _MCW_EM 0x0008001F /* Error masks */ 119 | #define _MCW_IC 0x00040000 /* Infinity */ 120 | #define _MCW_RC 0x00000300 /* Rounding */ 121 | #define _MCW_PC 0x00030000 /* Precision */ 122 | 123 | /* Control word values for unNew (use with related unMask above) */ 124 | #define _EM_INVALID 0x00000010 125 | #define _EM_DENORMAL 0x00080000 126 | #define _EM_ZERODIVIDE 0x00000008 127 | #define _EM_OVERFLOW 0x00000004 128 | #define _EM_UNDERFLOW 0x00000002 129 | #define _EM_INEXACT 0x00000001 130 | #define _IC_AFFINE 0x00040000 131 | #define _IC_PROJECTIVE 0x00000000 132 | #define _RC_CHOP 0x00000300 133 | #define _RC_UP 0x00000200 134 | #define _RC_DOWN 0x00000100 135 | #define _RC_NEAR 0x00000000 136 | #define _PC_24 0x00020000 137 | #define _PC_53 0x00010000 138 | #define _PC_64 0x00000000 139 | 140 | /* These are also defined in Mingw math.h, needed to work around 141 | GCC build issues. */ 142 | /* Return values for fpclass. */ 143 | #ifndef __MINGW_FPCLASS_DEFINED 144 | #define __MINGW_FPCLASS_DEFINED 1 145 | #define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */ 146 | #define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */ 147 | #define _FPCLASS_NINF 0x0004 /* Negative Infinity */ 148 | #define _FPCLASS_NN 0x0008 /* Negative Normal */ 149 | #define _FPCLASS_ND 0x0010 /* Negative Denormal */ 150 | #define _FPCLASS_NZ 0x0020 /* Negative Zero */ 151 | #define _FPCLASS_PZ 0x0040 /* Positive Zero */ 152 | #define _FPCLASS_PD 0x0080 /* Positive Denormal */ 153 | #define _FPCLASS_PN 0x0100 /* Positive Normal */ 154 | #define _FPCLASS_PINF 0x0200 /* Positive Infinity */ 155 | #endif /* __MINGW_FPCLASS_DEFINED */ 156 | 157 | /* invalid subconditions (_SW_INVALID also set) */ 158 | #define _SW_UNEMULATED 0x0040 /* unemulated instruction */ 159 | #define _SW_SQRTNEG 0x0080 /* square root of a neg number */ 160 | #define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */ 161 | #define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */ 162 | 163 | /* Floating point error signals and return codes */ 164 | #define _FPE_INVALID 0x81 165 | #define _FPE_DENORMAL 0x82 166 | #define _FPE_ZERODIVIDE 0x83 167 | #define _FPE_OVERFLOW 0x84 168 | #define _FPE_UNDERFLOW 0x85 169 | #define _FPE_INEXACT 0x86 170 | #define _FPE_UNEMULATED 0x87 171 | #define _FPE_SQRTNEG 0x88 172 | #define _FPE_STACKOVERFLOW 0x8a 173 | #define _FPE_STACKUNDERFLOW 0x8b 174 | #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ 175 | 176 | #ifndef RC_INVOKED 177 | 178 | #ifdef __cplusplus 179 | extern "C" { 180 | #endif 181 | 182 | /* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask), 183 | * i.e. change the bits in unMask to have the values they have in unNew, 184 | * leaving other bits unchanged. */ 185 | unsigned int _controlfp (unsigned int unNew, unsigned int unMask); 186 | unsigned int _control87 (unsigned int unNew, unsigned int unMask); 187 | 188 | 189 | unsigned int _clearfp (void); /* Clear the FPU status word */ 190 | unsigned int _statusfp (void); /* Report the FPU status word */ 191 | #define _clear87 _clearfp 192 | #define _status87 _statusfp 193 | 194 | void _fpreset (void); /* Reset the FPU */ 195 | void fpreset (void); 196 | 197 | /* Global 'variable' for the current floating point error code. */ 198 | int * __fpecode(void); 199 | #define _fpecode (*(__fpecode())) 200 | 201 | /* 202 | * IEEE recommended functions 203 | */ 204 | 205 | double _chgsign (double); 206 | double _copysign (double, double); 207 | double _logb (double); 208 | double _nextafter (double, double); 209 | double _scalb (double, long); 210 | 211 | int _finite (double); 212 | int _fpclass (double); 213 | int _isnan (double); 214 | 215 | #ifdef __cplusplus 216 | } 217 | #endif 218 | 219 | #endif /* Not RC_INVOKED */ 220 | 221 | #endif /* Not __STRICT_ANSI__ */ 222 | 223 | #endif /* _FLOAT_H_ */ 224 | 225 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Tiny C Compiler Makefile 3 | # 4 | 5 | TOP ?= . 6 | include $(TOP)/config.mak 7 | 8 | CFLAGS+=-g -Wall 9 | CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC 10 | LIBS_P= 11 | 12 | ifneq ($(GCC_MAJOR),2) 13 | CFLAGS+=-fno-strict-aliasing 14 | endif 15 | 16 | ifeq ($(ARCH),i386) 17 | CFLAGS+=-mpreferred-stack-boundary=2 18 | ifeq ($(GCC_MAJOR),2) 19 | CFLAGS+=-m386 -malign-functions=0 20 | else 21 | CFLAGS+=-march=i386 -falign-functions=0 22 | ifneq ($(GCC_MAJOR),3) 23 | CFLAGS+=-Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0 24 | endif 25 | endif 26 | endif 27 | 28 | ifeq ($(ARCH),x86-64) 29 | CFLAGS+=-Wno-pointer-sign 30 | endif 31 | 32 | ifndef CONFIG_WIN32 33 | LIBS=-lm 34 | ifndef CONFIG_NOLDL 35 | LIBS+=-ldl 36 | endif 37 | endif 38 | 39 | ifdef CONFIG_WIN32 40 | NATIVE_TARGET=-DTCC_TARGET_PE 41 | LIBTCC1=libtcc1.a 42 | else 43 | ifeq ($(ARCH),i386) 44 | NATIVE_TARGET=-DTCC_TARGET_I386 45 | LIBTCC1=libtcc1.a 46 | BCHECK_O=bcheck.o 47 | else 48 | ifeq ($(ARCH),arm) 49 | NATIVE_TARGET=-DTCC_TARGET_ARM 50 | NATIVE_TARGET+=$(if $(wildcard /lib/ld-linux.so.3),-DTCC_ARM_EABI) 51 | NATIVE_TARGET+=$(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo),-DTCC_ARM_VFP) 52 | else 53 | ifeq ($(ARCH),x86-64) 54 | NATIVE_TARGET=-DTCC_TARGET_X86_64 55 | LIBTCC1=libtcc1.a 56 | endif 57 | endif 58 | endif 59 | endif 60 | 61 | ifneq ($(wildcard /lib/ld-uClibc.so.0),) 62 | NATIVE_TARGET+=-DTCC_UCLIBC 63 | BCHECK_O= 64 | endif 65 | 66 | ifdef CONFIG_USE_LIBGCC 67 | LIBTCC1= 68 | endif 69 | 70 | ifeq ($(TOP),.) 71 | 72 | PROGS=tcc$(EXESUF) 73 | 74 | I386_CROSS = i386-tcc$(EXESUF) 75 | WIN32_CROSS = i386-win32-tcc$(EXESUF) 76 | X64_CROSS = x86_64-tcc$(EXESUF) 77 | ARM_CROSS = arm-tcc-fpa$(EXESUF) arm-tcc-fpa-ld$(EXESUF) \ 78 | arm-tcc-vfp$(EXESUF) arm-tcc-vfp-eabi$(EXESUF) 79 | C67_CROSS = c67-tcc$(EXESUF) 80 | 81 | CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c \ 82 | tcc.h config.h libtcc.h tcctok.h 83 | I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h 84 | WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h tccpe.c 85 | X86_64_FILES = $(CORE_FILES) x86_64-gen.c 86 | ARM_FILES = $(CORE_FILES) arm-gen.c 87 | C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c 88 | 89 | ifdef CONFIG_WIN32 90 | PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF) 91 | NATIVE_FILES=$(WIN32_FILES) 92 | PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(C67_CROSS) 93 | else 94 | ifeq ($(ARCH),i386) 95 | NATIVE_FILES=$(I386_FILES) 96 | PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(ARM_CROSS) $(C67_CROSS) 97 | else 98 | ifeq ($(ARCH),x86-64) 99 | NATIVE_FILES=$(X86_64_FILES) 100 | PROGS_CROSS=$(I386_CROSS) $(WIN32_CROSS) $(ARM_CROSS) $(C67_CROSS) 101 | else 102 | ifeq ($(ARCH),arm) 103 | NATIVE_FILES=$(ARM_FILES) 104 | PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(C67_CROSS) 105 | endif 106 | endif 107 | endif 108 | endif 109 | 110 | ifdef CONFIG_CROSS 111 | PROGS+=$(PROGS_CROSS) 112 | endif 113 | 114 | all: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc-doc.html tcc.1 libtcc_test$(EXESUF) 115 | 116 | # Host Tiny C Compiler 117 | tcc$(EXESUF): $(NATIVE_FILES) 118 | $(CC) -o $@ $< $(NATIVE_TARGET) $(CFLAGS) $(LIBS) 119 | 120 | # Cross Tiny C Compilers 121 | i386-tcc$(EXESUF): $(I386_FILES) 122 | $(CC) -o $@ $< -DTCC_TARGET_I386 $(CFLAGS) $(LIBS) 123 | 124 | i386-win32-tcc$(EXESUF): $(WIN32_FILES) 125 | $(CC) -o $@ $< -DTCC_TARGET_PE $(CFLAGS) $(LIBS) 126 | 127 | x86_64-tcc$(EXESUF): $(X86_64_FILES) 128 | $(CC) -o $@ $< -DTCC_TARGET_X86_64 $(CFLAGS) $(LIBS) 129 | 130 | c67-tcc$(EXESUF): $(C67_FILES) 131 | $(CC) -o $@ $< -DTCC_TARGET_C67 $(CFLAGS) $(LIBS) 132 | 133 | arm-tcc-fpa$(EXESUF): $(ARM_FILES) 134 | $(CC) -o $@ $< -DTCC_TARGET_ARM $(CFLAGS) $(LIBS) 135 | 136 | arm-tcc-fpa-ld$(EXESUF): $(ARM_FILES) 137 | $(CC) -o $@ $< -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12 $(CFLAGS) $(LIBS) 138 | 139 | arm-tcc-vfp$(EXESUF): $(ARM_FILES) 140 | $(CC) -o $@ $< -DTCC_TARGET_ARM -DTCC_ARM_VFP $(CFLAGS) $(LIBS) 141 | 142 | arm-tcc-vfp-eabi$(EXESUF): $(ARM_FILES) 143 | $(CC) -o $@ $< -DTCC_TARGET_ARM -DTCC_ARM_EABI $(CFLAGS) $(LIBS) 144 | 145 | # libtcc generation and test 146 | libtcc.o: $(NATIVE_FILES) 147 | $(CC) -o $@ -c libtcc.c $(NATIVE_TARGET) $(CFLAGS) 148 | 149 | libtcc.a: libtcc.o 150 | $(AR) rcs $@ $^ 151 | 152 | libtcc_test$(EXESUF): tests/libtcc_test.c libtcc.a 153 | $(CC) -o $@ $^ -I. $(CFLAGS) $(LIBS) 154 | 155 | libtest: libtcc_test$(EXESUF) $(LIBTCC1) 156 | ./libtcc_test$(EXESUF) lib_path=. 157 | 158 | # profiling version 159 | tcc_p$(EXESUF): $(NATIVE_FILES) 160 | $(CC) -o $@ $< $(NATIVE_TARGET) $(CFLAGS_P) $(LIBS_P) 161 | 162 | # windows utilities 163 | tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c 164 | $(CC) -o $@ $< $(CFLAGS) 165 | tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c 166 | $(CC) -o $@ $< $(CFLAGS) 167 | 168 | # TinyCC runtime libraries 169 | LIBTCC1_OBJS=libtcc1.o 170 | LIBTCC1_CC=$(CC) 171 | VPATH+=lib 172 | ifdef CONFIG_WIN32 173 | # for windows, we must use TCC because we generate ELF objects 174 | LIBTCC1_OBJS+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o 175 | LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE 176 | VPATH+=win32/lib 177 | endif 178 | ifeq ($(ARCH),i386) 179 | LIBTCC1_OBJS+=alloca86.o alloca86-bt.o 180 | endif 181 | 182 | %.o: %.c 183 | $(LIBTCC1_CC) -o $@ -c $< -O2 -Wall 184 | 185 | %.o: %.S 186 | $(LIBTCC1_CC) -o $@ -c $< 187 | 188 | libtcc1.a: $(LIBTCC1_OBJS) 189 | $(AR) rcs $@ $^ 190 | 191 | bcheck.o: bcheck.c 192 | $(CC) -o $@ -c $< -O2 -Wall 193 | 194 | # install 195 | TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h 196 | INSTALL=install 197 | 198 | ifndef CONFIG_WIN32 199 | install: $(PROGS) $(LIBTCC1) $(BCHECK_O) libtcc.a tcc.1 tcc-doc.html 200 | mkdir -p "$(bindir)" 201 | $(INSTALL) -s -m755 $(PROGS) "$(bindir)" 202 | mkdir -p "$(mandir)/man1" 203 | $(INSTALL) tcc.1 "$(mandir)/man1" 204 | mkdir -p "$(tccdir)" 205 | mkdir -p "$(tccdir)/include" 206 | ifneq ($(LIBTCC1),) 207 | $(INSTALL) -m644 $(LIBTCC1) "$(tccdir)" 208 | endif 209 | ifneq ($(BCHECK_O),) 210 | $(INSTALL) -m644 $(BCHECK_O) "$(tccdir)" 211 | endif 212 | $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include" 213 | mkdir -p "$(docdir)" 214 | $(INSTALL) -m644 tcc-doc.html "$(docdir)" 215 | mkdir -p "$(libdir)" 216 | $(INSTALL) -m644 libtcc.a "$(libdir)" 217 | mkdir -p "$(includedir)" 218 | $(INSTALL) -m644 libtcc.h "$(includedir)" 219 | 220 | uninstall: 221 | rm -fv $(foreach P,$(PROGS),"$(bindir)/$P") 222 | rm -fv $(foreach P,$(LIBTCC1) $(BCHECK_O),"$(tccdir)/$P") 223 | rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P") 224 | rm -fv "$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1" 225 | rm -fv "$(libdir)/libtcc.a" "$(includedir)/libtcc.h" 226 | 227 | else 228 | install: $(PROGS) $(LIBTCC1) libtcc.a tcc-doc.html 229 | mkdir -p "$(tccdir)" 230 | mkdir -p "$(tccdir)/lib" 231 | mkdir -p "$(tccdir)/include" 232 | mkdir -p "$(tccdir)/examples" 233 | mkdir -p "$(tccdir)/doc" 234 | mkdir -p "$(tccdir)/libtcc" 235 | $(INSTALL) -s -m755 $(PROGS) "$(tccdir)" 236 | $(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(tccdir)/lib" 237 | cp -r win32/include/. "$(tccdir)/include" 238 | cp -r win32/examples/. "$(tccdir)/examples" 239 | # $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include" 240 | $(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc" 241 | $(INSTALL) -m644 libtcc.a libtcc.h "$(tccdir)/libtcc" 242 | endif 243 | 244 | # documentation and man page 245 | tcc-doc.html: tcc-doc.texi 246 | -texi2html -monolithic -number $< 247 | 248 | tcc.1: tcc-doc.texi 249 | -./texi2pod.pl $< tcc.pod 250 | -pod2man --section=1 --center=" " --release=" " tcc.pod > $@ 251 | 252 | # tar release (use 'make -k tar' on a checkouted tree) 253 | TCC-VERSION=tcc-$(shell cat VERSION) 254 | tar: 255 | rm -rf /tmp/$(TCC-VERSION) 256 | cp -r . /tmp/$(TCC-VERSION) 257 | ( cd /tmp ; tar zcvf ~/$(TCC-VERSION).tar.gz $(TCC-VERSION) --exclude CVS ) 258 | rm -rf /tmp/$(TCC-VERSION) 259 | 260 | # in tests subdir 261 | test clean : 262 | $(MAKE) -C tests $@ 263 | 264 | # clean 265 | clean: local_clean 266 | local_clean: 267 | rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.out libtcc_test$(EXESUF) 268 | 269 | distclean: clean 270 | rm -vf config.h config.mak config.texi tcc.1 tcc-doc.html 271 | 272 | endif # ifeq ($(TOP),.) 273 | -------------------------------------------------------------------------------- /win32/include/ctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ctype.h 3 | * 4 | * Functions for testing character types and converting characters. 5 | * 6 | * This file is part of the Mingw32 package. 7 | * 8 | * Contributors: 9 | * Created by Colin Peters 10 | * 11 | * THIS SOFTWARE IS NOT COPYRIGHTED 12 | * 13 | * This source code is offered for use in the public domain. You may 14 | * use, modify or distribute it freely. 15 | * 16 | * This code is distributed in the hope that it will be useful but 17 | * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 | * DISCLAIMED. This includes but is not limited to warranties of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * $Revision: 1.2 $ 22 | * $Author: bellard $ 23 | * $Date: 2005/04/17 13:14:29 $ 24 | * 25 | */ 26 | 27 | #ifndef _CTYPE_H_ 28 | #define _CTYPE_H_ 29 | 30 | /* All the headers include this file. */ 31 | #include <_mingw.h> 32 | 33 | #define __need_wchar_t 34 | #define __need_wint_t 35 | #ifndef RC_INVOKED 36 | #include 37 | #endif /* Not RC_INVOKED */ 38 | 39 | 40 | /* 41 | * The following flags are used to tell iswctype and _isctype what character 42 | * types you are looking for. 43 | */ 44 | #define _UPPER 0x0001 45 | #define _LOWER 0x0002 46 | #define _DIGIT 0x0004 47 | #define _SPACE 0x0008 /* HT LF VT FF CR SP */ 48 | #define _PUNCT 0x0010 49 | #define _CONTROL 0x0020 50 | #define _BLANK 0x0040 /* this is SP only, not SP and HT as in C99 */ 51 | #define _HEX 0x0080 52 | #define _LEADBYTE 0x8000 53 | 54 | #define _ALPHA 0x0103 55 | 56 | #ifndef RC_INVOKED 57 | 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | int isalnum(int); 63 | int isalpha(int); 64 | int iscntrl(int); 65 | int isdigit(int); 66 | int isgraph(int); 67 | int islower(int); 68 | int isprint(int); 69 | int ispunct(int); 70 | int isspace(int); 71 | int isupper(int); 72 | int isxdigit(int); 73 | 74 | #ifndef __STRICT_ANSI__ 75 | int _isctype (int, int); 76 | #endif 77 | 78 | /* These are the ANSI versions, with correct checking of argument */ 79 | int tolower(int); 80 | int toupper(int); 81 | 82 | /* 83 | * NOTE: The above are not old name type wrappers, but functions exported 84 | * explicitly by MSVCRT/CRTDLL. However, underscored versions are also 85 | * exported. 86 | */ 87 | #ifndef __STRICT_ANSI__ 88 | /* 89 | * These are the cheap non-std versions: The return values are undefined 90 | * if the argument is not ASCII char or is not of appropriate case 91 | */ 92 | int _tolower(int); 93 | int _toupper(int); 94 | #endif 95 | 96 | /* Also defined in stdlib.h */ 97 | #ifndef MB_CUR_MAX 98 | # ifdef __MSVCRT__ 99 | # define MB_CUR_MAX __mb_cur_max 100 | __MINGW_IMPORT int __mb_cur_max; 101 | # else /* not __MSVCRT */ 102 | # define MB_CUR_MAX __mb_cur_max_dll 103 | __MINGW_IMPORT int __mb_cur_max_dll; 104 | # endif /* not __MSVCRT */ 105 | #endif /* MB_CUR_MAX */ 106 | 107 | __MINGW_IMPORT unsigned short _ctype[]; 108 | #ifdef __MSVCRT__ 109 | __MINGW_IMPORT unsigned short* _pctype; 110 | #else /* CRTDLL */ 111 | __MINGW_IMPORT unsigned short* _pctype_dll; 112 | #define _pctype _pctype_dll 113 | #endif 114 | 115 | /* 116 | * Use inlines here rather than macros, because macros will upset 117 | * C++ usage (eg, ::isalnum), and so usually get undefined 118 | * 119 | * According to standard for SB chars, these function are defined only 120 | * for input values representable by unsigned char or EOF. 121 | * Thus, there is no range test. 122 | * This reproduces behaviour of MSVCRT.dll lib implemention for SB chars. 123 | * 124 | * If no MB char support is needed, these can be simplified even 125 | * more by command line define -DMB_CUR_MAX=1. The compiler will then 126 | * optimise away the constant condition. 127 | */ 128 | 129 | 130 | #if ! (defined (__NO_CTYPE_INLINES) || defined (__STRICT_ANSI__ )) 131 | /* use simple lookup if SB locale, else _isctype() */ 132 | #define __ISCTYPE(c, mask) (MB_CUR_MAX == 1 ? (_pctype[c] & mask) : _isctype(c, mask)) 133 | extern __inline__ int isalnum(int c) {return __ISCTYPE(c, (_ALPHA|_DIGIT));} 134 | extern __inline__ int isalpha(int c) {return __ISCTYPE(c, _ALPHA);} 135 | extern __inline__ int iscntrl(int c) {return __ISCTYPE(c, _CONTROL);} 136 | extern __inline__ int isdigit(int c) {return __ISCTYPE(c, _DIGIT);} 137 | extern __inline__ int isgraph(int c) {return __ISCTYPE(c, (_PUNCT|_ALPHA|_DIGIT));} 138 | extern __inline__ int islower(int c) {return __ISCTYPE(c, _LOWER);} 139 | extern __inline__ int isprint(int c) {return __ISCTYPE(c, (_BLANK|_PUNCT|_ALPHA|_DIGIT));} 140 | extern __inline__ int ispunct(int c) {return __ISCTYPE(c, _PUNCT);} 141 | extern __inline__ int isspace(int c) {return __ISCTYPE(c, _SPACE);} 142 | extern __inline__ int isupper(int c) {return __ISCTYPE(c, _UPPER);} 143 | extern __inline__ int isxdigit(int c) {return __ISCTYPE(c, _HEX);} 144 | 145 | /* these reproduce behaviour of lib underscored versions */ 146 | extern __inline__ int _tolower(int c) {return ( c -'A'+'a');} 147 | extern __inline__ int _toupper(int c) {return ( c -'a'+'A');} 148 | 149 | /* TODO? Is it worth inlining ANSI tolower, toupper? Probably only 150 | if we only want C-locale. */ 151 | 152 | #endif /* _NO_CTYPE_INLINES */ 153 | 154 | /* Wide character equivalents */ 155 | 156 | #ifndef WEOF 157 | #define WEOF (wchar_t)(0xFFFF) 158 | #endif 159 | 160 | #ifndef _WCTYPE_T_DEFINED 161 | typedef wchar_t wctype_t; 162 | #define _WCTYPE_T_DEFINED 163 | #endif 164 | 165 | int iswalnum(wint_t); 166 | int iswalpha(wint_t); 167 | int iswascii(wint_t); 168 | int iswcntrl(wint_t); 169 | int iswctype(wint_t, wctype_t); 170 | int is_wctype(wint_t, wctype_t); /* Obsolete! */ 171 | int iswdigit(wint_t); 172 | int iswgraph(wint_t); 173 | int iswlower(wint_t); 174 | int iswprint(wint_t); 175 | int iswpunct(wint_t); 176 | int iswspace(wint_t); 177 | int iswupper(wint_t); 178 | int iswxdigit(wint_t); 179 | 180 | wchar_t towlower(wchar_t); 181 | wchar_t towupper(wchar_t); 182 | 183 | int isleadbyte (int); 184 | 185 | /* Also in wctype.h */ 186 | #if ! (defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) 187 | #define __WCTYPE_INLINES_DEFINED 188 | extern __inline__ int iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));} 189 | extern __inline__ int iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));} 190 | extern __inline__ int iswascii(wint_t wc) {return (((unsigned)wc & 0x7F) ==0);} 191 | extern __inline__ int iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));} 192 | extern __inline__ int iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));} 193 | extern __inline__ int iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));} 194 | extern __inline__ int iswlower(wint_t wc) {return (iswctype(wc,_LOWER));} 195 | extern __inline__ int iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));} 196 | extern __inline__ int iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));} 197 | extern __inline__ int iswspace(wint_t wc) {return (iswctype(wc,_SPACE));} 198 | extern __inline__ int iswupper(wint_t wc) {return (iswctype(wc,_UPPER));} 199 | extern __inline__ int iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));} 200 | extern __inline__ int isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);} 201 | #endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */ 202 | 203 | #ifndef __STRICT_ANSI__ 204 | int __isascii (int); 205 | int __toascii (int); 206 | int __iscsymf (int); /* Valid first character in C symbol */ 207 | int __iscsym (int); /* Valid character in C symbol (after first) */ 208 | 209 | #ifndef __NO_CTYPE_INLINES 210 | extern __inline__ int __isascii(int c) {return (((unsigned)c & ~0x7F) == 0);} 211 | extern __inline__ int __toascii(int c) {return (c & 0x7F);} 212 | extern __inline__ int __iscsymf(int c) {return (isalpha(c) || (c == '_'));} 213 | extern __inline__ int __iscsym(int c) {return (isalnum(c) || (c == '_'));} 214 | #endif /* __NO_CTYPE_INLINES */ 215 | 216 | #ifndef _NO_OLDNAMES 217 | int isascii (int); 218 | int toascii (int); 219 | int iscsymf (int); 220 | int iscsym (int); 221 | #endif /* Not _NO_OLDNAMES */ 222 | 223 | #endif /* Not __STRICT_ANSI__ */ 224 | 225 | #ifdef __cplusplus 226 | } 227 | #endif 228 | 229 | #endif /* Not RC_INVOKED */ 230 | 231 | #endif /* Not _CTYPE_H_ */ 232 | 233 | --------------------------------------------------------------------------------