History

win64: defined size_t and ptrdiff_t to unsigned long long

grischka committed 16 years ago

Commit e20bf691 parent b0abcfd3 files · +43 −31Browse files

Unified · Split

3 files
  1. include/stddef.h +14 −6
  2. libtcc.c +12 −7
  3. win32/include/_mingw.h +17 −18
include/stddef.h+14−6
@@ -1,20 +1,28 @@
11 #ifndef _STDDEF_H
22 #define _STDDEF_H
33
4−#define NULL ((void *)0)
54 typedef __SIZE_TYPE__ size_t;
5+typedef __PTRDIFF_TYPE__ ssize_t;
66 typedef __WCHAR_TYPE__ wchar_t;
77 typedef __PTRDIFF_TYPE__ ptrdiff_t;
8−#define offsetof(type, field) ((size_t) &((type *)0)->field)
8+typedef __PTRDIFF_TYPE__ intptr_t;
9+typedef __SIZE_TYPE__ uintptr_t;
910
1011 #ifndef __int8_t_defined
1112 #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;
13+typedef signed char int8_t;
14+typedef signed short int int16_t;
15+typedef signed int int32_t;
16+typedef signed long long int int64_t;
17+typedef unsigned char uint8_t;
18+typedef unsigned short int uint16_t;
19+typedef unsigned int uint32_t;
20+typedef unsigned long long int uint64_t;
1621 #endif
1722
23+#define NULL ((void *)0)
24+#define offsetof(type, field) ((size_t)&((type *)0)->field)
25+
1826 void *alloca(size_t size);
1927
2028 #endif
libtcc.c+12−7
@@ -886,9 +886,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 885 unmodified lines
886886 tcc_define_symbol(s, "__STDC__", NULL);
887887 tcc_define_symbol(s, "__STDC_VERSION__", "199901L");
888888 #if defined(TCC_TARGET_I386)
889− tcc_define_symbol(s, "__i386__", "1");
890− tcc_define_symbol(s, "__i386", "1");
891− tcc_define_symbol(s, "i386", "1");
889+ tcc_define_symbol(s, "__i386__", NULL);
890+ tcc_define_symbol(s, "__i386", NULL);
891+ tcc_define_symbol(s, "i386", NULL);
892892 #endif
893893 #if defined(TCC_TARGET_X86_64)
894894 tcc_define_symbol(s, "__x86_64__", NULL);
@@ -909,13 +909,12 @@ LIBTCCAPI TCCState *tcc_new(void) · 14 unmodified lines
909909 tcc_define_symbol(s, "_WIN64", NULL);
910910 #endif
911911 #else
912− tcc_define_symbol(s, "__unix__", "1");
913− tcc_define_symbol(s, "__unix", "1");
914− tcc_define_symbol(s, "unix", "1");
912+ tcc_define_symbol(s, "__unix__", NULL);
913+ tcc_define_symbol(s, "__unix", NULL);
914+ tcc_define_symbol(s, "unix", NULL);
915915 #if defined(__FreeBSD__)
916916 #define str(s) #s
917917 tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
918− tcc_define_symbol(s, "__INTEL_COMPILER", "1");
919918 #undef str
920919 #endif
921920 #if defined(__linux)
@@ -929,8 +928,14 @@ LIBTCCAPI TCCState *tcc_new(void) · 7 unmodified lines
929928 tcc_define_symbol(s, "__TINYC__", buffer);
930929
931930 /* tiny C & gcc defines */
931+#if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64
932+ tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long long");
933+ tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long long");
934+#else
932935 tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long");
933936 tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long");
937+#endif
938+
934939 #ifdef TCC_TARGET_PE
935940 tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
936941 #else
win32/include/_mingw.h+17−18
@@ -58,28 +58,27 @@ · 57 unmodified lines
5858 #define _CRT_WIDE(_String) __CRT_WIDE(_String)
5959
6060 #ifdef _WIN64
61−# define _INTEGRAL_MAX_BITS 64
62−typedef __int64 intptr_t;
63−typedef __int64 ptrdiff_t;
64−typedef unsigned __int64 uintptr_t;
65−# define __stdcall
66−# define _AMD64_ 1
67−# define __x86_64 1
68−# define USE_MINGW_SETJMP_TWO_ARGS
69−# define mingw_getsp tinyc_getbp
61+#define __stdcall
62+#define _AMD64_ 1
63+#define __x86_64 1
64+#define USE_MINGW_SETJMP_TWO_ARGS
65+#define mingw_getsp tinyc_getbp
7066 #else
71−# define _INTEGRAL_MAX_BITS 32
72−typedef __int32 intptr_t;
73−typedef __int32 ptrdiff_t;
74−typedef unsigned __int32 uintptr_t;
75−# define __stdcall __attribute__((__stdcall__))
76−# define _X86_ 1
77−# define WIN32 1
78−# define _USE_32BIT_TIME_T
67+#define __stdcall __attribute__((__stdcall__))
68+#define _X86_ 1
69+#define WIN32 1
70+#define _USE_32BIT_TIME_T
7971 #endif
72+
73+/* in stddef.h */
74+#define _SIZE_T_DEFINED
75+#define _SSIZE_T_DEFINED
76+#define _PTRDIFF_T_DEFINED
77+#define _WCHAR_T_DEFINED
8078 #define _UINTPTR_T_DEFINED
8179 #define _INTPTR_T_DEFINED
82−#define _PTRDIFF_T_DEFINED
80+
81+#define _INTEGRAL_MAX_BITS 64
8382
8483 typedef long __time32_t;
8584 #define _TIME32_T_DEFINED

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t