Skip to content

Commit dc251a7

Browse files
author
grischka
committed
win64: use new headers from mingw
1 parent 06aed3d commit dc251a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+32103
-17293
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ VPATH+=lib
177177
ifdef CONFIG_WIN32
178178
# for windows, we must use TCC because we generate ELF objects
179179
LIBTCC1_OBJS+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
180-
LIBTCC1_CC=./tcc.exe -Bwin32 -DTCC_TARGET_PE
180+
LIBTCC1_CC=./tcc.exe -Bwin32 -Iinclude $(NATIVE_TARGET)
181181
VPATH+=win32/lib
182182
endif
183183
ifeq ($(ARCH),i386)
@@ -245,7 +245,7 @@ install: $(PROGS) $(LIBTCC1) libtcc.a tcc-doc.html
245245
$(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(tccdir)/lib"
246246
cp -r win32/include/. "$(tccdir)/include"
247247
cp -r win32/examples/. "$(tccdir)/examples"
248-
# $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
248+
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
249249
$(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc"
250250
$(INSTALL) -m644 libtcc.a libtcc.h "$(tccdir)/libtcc"
251251
endif

include/stdarg.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _STDARG_H
33

44
#ifdef __x86_64__
5+
#ifndef _WIN64
56
#include <stdlib.h>
67

78
/* GCC compatible definition of va_list. */
@@ -48,16 +49,21 @@ typedef struct __va_list_struct *va_list;
4849
*(dest) = *(src))
4950
#define va_end(ap) __builtin_free(ap)
5051

51-
#else
52-
52+
#else /* _WIN64 */
5353
typedef char *va_list;
54+
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+7)&~7)
55+
#define va_arg(ap,type) (ap += (sizeof(type)+7)&~7, *(type *)(ap - ((sizeof(type)+7)&~7)))
56+
#define va_copy(dest, src) (dest) = (src)
57+
#define va_end(ap)
58+
#endif
5459

60+
#else /* __i386__ */
61+
typedef char *va_list;
5562
/* only correct for i386 */
5663
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
5764
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
5865
#define va_copy(dest, src) (dest) = (src)
5966
#define va_end(ap)
60-
6167
#endif
6268

6369
/* fix a buggy dependency on GCC in libio.h */

include/varargs.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
/**
2+
* This file has no copyright assigned and is placed in the Public Domain.
3+
* This file is part of the w64 mingw-runtime package.
4+
* No warranty is given; refer to the file DISCLAIMER within this package.
5+
*/
16
#ifndef _VARARGS_H
27
#define _VARARGS_H
38

4-
#include <stdarg.h>
5-
6-
#define va_dcl
7-
#define va_alist __va_alist
8-
#undef va_start
9-
#define va_start(ap) ap = __builtin_varargs_start
9+
#error "TinyCC no longer implements <varargs.h>."
10+
#error "Revise your code to use <stdarg.h>."
1011

1112
#endif

win32/include/_mingw.h

+73-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* _mingw.h
33
*
4-
* This file is for TCC-PE and not part of the Mingw32 package.
4+
* This file is for TinyCC and not part of the Mingw32 package.
55
*
66
* THIS SOFTWARE IS NOT COPYRIGHTED
77
*
@@ -24,31 +24,93 @@
2424
#define __int32 long
2525
#define __int16 short
2626
#define __int8 char
27+
2728
#define __cdecl __attribute__((__cdecl__))
28-
#define __stdcall __attribute__((__stdcall__))
2929
#define __declspec(x) __attribute__((x))
30+
#define __fastcall
31+
32+
// #define __MINGW_IMPORT extern __declspec(dllimport)
3033

31-
#define __MINGW32_VERSION 2.0
32-
#define __MINGW32_MAJOR_VERSION 2
33-
#define __MINGW32_MINOR_VERSION 0
34+
#undef _MSVCRT_
35+
#undef __MINGW_IMPORT
3436

35-
#define __MSVCRT__ 1
36-
#define __MINGW_IMPORT extern
37-
#define _CRTIMP
37+
#define _CRTIMP extern
3838
#define __CRT_INLINE extern __inline__
39+
#define __MINGW_NOTHROW
40+
#define __MINGW_ATTRIB_NORETURN
41+
#define __MINGW_ATTRIB_DEPRECATED
42+
#define __GNUC_VA_LIST
43+
44+
#define _CONST_RETURN
45+
#define _CRT_ALIGN(x) __attribute__((aligned(x)))
46+
#define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
47+
48+
#define __CRT_STRINGIZE(_Value) #_Value
49+
#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
3950

51+
#define __CRT_WIDE(_String) L ## _String
52+
#define _CRT_WIDE(_String) __CRT_WIDE(_String)
53+
54+
#ifdef _WIN64
55+
typedef __int64 intptr_t;
56+
typedef unsigned __int64 uintptr_t;
57+
#define __stdcall
58+
#define _AMD64_ 1
59+
#define __x86_64 1
60+
#else
61+
typedef __int32 intptr_t;
62+
typedef unsigned __int32 uintptr_t;
63+
#define __stdcall __attribute__((__stdcall__))
64+
#define _X86_ 1
4065
#define WIN32 1
66+
#endif
4167

42-
#ifndef _WINT_T
43-
#define _WINT_T
44-
typedef unsigned int wint_t;
68+
#define _INTEGRAL_MAX_BITS 64
69+
#define _CRT_PACKING 8
70+
71+
typedef long __time32_t;
72+
#define _TIME32_T_DEFINED
73+
typedef __int64 __time64_t;
74+
#define _TIME64_T_DEFINED
75+
76+
#ifdef _USE_32BIT_TIME_T
77+
#ifdef _WIN64
78+
#error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64
79+
#endif
80+
typedef __time32_t time_t;
81+
#else
82+
typedef __time64_t time_t;
4583
#endif
84+
#define _TIME_T_DEFINED
85+
86+
#define _WCTYPE_T_DEFINED
87+
typedef unsigned int wint_t;
88+
typedef unsigned short wctype_t;
89+
90+
#define _ERRCODE_DEFINED
91+
typedef int errno_t;
92+
93+
typedef struct threadlocaleinfostruct *pthreadlocinfo;
94+
typedef struct threadmbcinfostruct *pthreadmbcinfo;
95+
typedef struct localeinfo_struct _locale_tstruct,*_locale_t;
4696

4797
/* for winapi */
4898
#define _ANONYMOUS_UNION
4999
#define _ANONYMOUS_STRUCT
50100
#define DECLSPEC_NORETURN
51101
#define WIN32_LEAN_AND_MEAN
52102
#define DECLARE_STDCALL_P(type) __stdcall type
103+
#define NOSERVICE 1
104+
#define NOMCX 1
105+
#define NOIME 1
106+
#ifndef WINVER
107+
#define WINVER 0x0502
108+
#endif
109+
#ifndef _WIN32_WINNT
110+
#define _WIN32_WINNT 0x502
111+
#endif
112+
113+
/* get va_list */
114+
#include <stdarg.h>
53115

54116
#endif /* __MINGW_H */

win32/include/assert.h

+37-54
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,54 @@
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 <colin@bird.fu.is.saga-u.ac.jp>
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-
*
1+
/**
2+
* This file has no copyright assigned and is placed in the Public Domain.
3+
* This file is part of the w64 mingw-runtime package.
4+
* No warranty is given; refer to the file DISCLAIMER within this package.
255
*/
6+
#ifndef __ASSERT_H_
7+
#define __ASSERT_H_
268

27-
#ifndef _ASSERT_H_
28-
#define _ASSERT_H_
29-
30-
/* All the headers include this file. */
319
#include <_mingw.h>
32-
33-
#ifndef RC_INVOKED
34-
35-
#ifdef __cplusplus
36-
extern "C" {
10+
#ifdef __cplusplus
11+
#include <stdlib.h>
3712
#endif
3813

3914
#ifdef NDEBUG
15+
#ifndef assert
16+
#define assert(_Expression) ((void)0)
17+
#endif
18+
#else
19+
20+
#ifndef _CRT_TERMINATE_DEFINED
21+
#define _CRT_TERMINATE_DEFINED
22+
void __cdecl __MINGW_NOTHROW exit(int _Code) __MINGW_ATTRIB_NORETURN;
23+
_CRTIMP void __cdecl __MINGW_NOTHROW _exit(int _Code) __MINGW_ATTRIB_NORETURN;
24+
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
25+
/* C99 function name */
26+
void __cdecl _Exit(int) __MINGW_ATTRIB_NORETURN;
27+
__CRT_INLINE __MINGW_ATTRIB_NORETURN void __cdecl _Exit(int status)
28+
{ _exit(status); }
29+
#endif
4030

41-
/*
42-
* If not debugging, assert does nothing.
43-
*/
44-
#define assert(x) ((void)0)
31+
#pragma push_macro("abort")
32+
#undef abort
33+
void __cdecl __declspec(noreturn) abort(void);
34+
#pragma pop_macro("abort")
4535

46-
#else /* debugging enabled */
36+
#endif
4737

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))
38+
#ifdef __cplusplus
39+
extern "C" {
5540
#endif
56-
;
5741

58-
/*
59-
* Definition of the assert macro.
60-
*/
61-
#define assert(e) ((e) ? (void)0 : _assert(#e, __FILE__, __LINE__))
62-
#endif /* NDEBUG */
42+
extern void __cdecl _wassert(const wchar_t *_Message,const wchar_t *_File,unsigned _Line);
6343

64-
#ifdef __cplusplus
44+
#ifdef __cplusplus
6545
}
6646
#endif
6747

68-
#endif /* Not RC_INVOKED */
48+
#ifndef assert
49+
#define assert(_Expression) (void)((!!(_Expression)) || (_wassert(_CRT_WIDE(#_Expression),_CRT_WIDE(__FILE__),__LINE__),0))
50+
#endif
6951

70-
#endif /* Not _ASSERT_H_ */
52+
#endif
7153

54+
#endif

0 commit comments

Comments
 (0)