diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 4b0d53805..7c215564e 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -319,7 +319,7 @@ ifeq ($(PLATFORM),DARWIN) endif ifeq ($(PLATFORM),WINDOWS) - LIBS += -lFLAC -lvorbisfile -lvorbis -logg -lcompat-from-mingw-w64 + LIBS += -lFLAC -lvorbisfile -lvorbis -logg LIBDIRS += -L$(AUDIOLIB_ROOT)/third-party/Windows/lib$(WINLIB) DUKE3D_OBJS+= gameres winbits startwin.game DUKE3D_EDITOR_OBJS+= buildres diff --git a/polymer/eduke32/Makefile.msvc b/polymer/eduke32/Makefile.msvc index 6eeaa53a5..0771121b4 100644 --- a/polymer/eduke32/Makefile.msvc +++ b/polymer/eduke32/Makefile.msvc @@ -98,7 +98,7 @@ ENET_CFLAGS=/I$(ENET_INC) /I$(ENET_SRC) AUDIOLIB_CFLAGS=/I$(AUDIOLIB_INC) /I$(AUDIOLIB_SRC) LIBS=user32.lib gdi32.lib shell32.lib winmm.lib ws2_32.lib comctl32.lib shlwapi.lib oleaut32.lib ole32.lib imm32.lib version.lib \ - libogg.a libvorbis.a libvorbisfile.a libvpx.a libpng_mini.a libz_mini.a libcompat-from-mingw-w64.a \ + libogg.a libvorbis.a libvorbisfile.a libvpx.a libpng_mini.a libz_mini.a \ dxguid.lib dsound.lib advapi32.lib libcompat-to-msvc.a !if ("$(RENDERTYPE)"=="SDL") diff --git a/polymer/eduke32/platform/Windows/lib/32/libcompat-from-mingw-w64.a b/polymer/eduke32/platform/Windows/lib/32/libcompat-from-mingw-w64.a deleted file mode 100644 index 3a82a4586..000000000 Binary files a/polymer/eduke32/platform/Windows/lib/32/libcompat-from-mingw-w64.a and /dev/null differ diff --git a/polymer/eduke32/platform/Windows/lib/32/libcompat-to-msvc.a b/polymer/eduke32/platform/Windows/lib/32/libcompat-to-msvc.a index b585978fb..e3c6507fb 100644 Binary files a/polymer/eduke32/platform/Windows/lib/32/libcompat-to-msvc.a and b/polymer/eduke32/platform/Windows/lib/32/libcompat-to-msvc.a differ diff --git a/polymer/eduke32/platform/Windows/lib/64/libcompat-from-mingw-w64.a b/polymer/eduke32/platform/Windows/lib/64/libcompat-from-mingw-w64.a deleted file mode 100644 index d4ab1e1a3..000000000 Binary files a/polymer/eduke32/platform/Windows/lib/64/libcompat-from-mingw-w64.a and /dev/null differ diff --git a/polymer/eduke32/platform/Windows/lib/64/libcompat-to-msvc.a b/polymer/eduke32/platform/Windows/lib/64/libcompat-to-msvc.a index 477b7ddd0..5428547cc 100644 Binary files a/polymer/eduke32/platform/Windows/lib/64/libcompat-to-msvc.a and b/polymer/eduke32/platform/Windows/lib/64/libcompat-to-msvc.a differ diff --git a/polymer/eduke32/platform/Windows/src/compat-from-mingw-w64/Makefile b/polymer/eduke32/platform/Windows/src/compat-from-mingw-w64/Makefile deleted file mode 100644 index d477f1b2d..000000000 --- a/polymer/eduke32/platform/Windows/src/compat-from-mingw-w64/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -o=o - -NAME:=libcompat-from-mingw-w64 - - -%.$o: %.c - gcc -Wall -Wextra -O3 -c $< -o $@ - -$(NAME).a: vsnprintf.$o - ar rc $@ $^ - ranlib $@ - -all : $(NAME).a - @ls -l $^ - -clean: - -rm -f *.a *.o diff --git a/polymer/eduke32/platform/Windows/src/compat-from-mingw-w64/vsnprintf.c b/polymer/eduke32/platform/Windows/src/compat-from-mingw-w64/vsnprintf.c deleted file mode 100644 index e4701483c..000000000 --- a/polymer/eduke32/platform/Windows/src/compat-from-mingw-w64/vsnprintf.c +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#define __CRT__NO_INLINE -#include -#include - -int __cdecl __ms_vsnprintf (char *s,size_t n,const char *format,va_list arg) -{ - return _vsnprintf(s, n, format, arg); -} diff --git a/polymer/eduke32/platform/Windows/src/compat-to-msvc/Makefile b/polymer/eduke32/platform/Windows/src/compat-to-msvc/Makefile index b5023fdd5..6928f9825 100644 --- a/polymer/eduke32/platform/Windows/src/compat-to-msvc/Makefile +++ b/polymer/eduke32/platform/Windows/src/compat-to-msvc/Makefile @@ -7,12 +7,16 @@ NAME:=libcompat-to-msvc %.$o: %.c gcc -Wall -Wextra -O3 -c $< -o $@ -$(NAME).a: dll_math.$o io_math.$o +%.$o: %.S + gcc -c $< -o $@ + +OBJS=dll_math.$o io_math.$o dll_dependency.$o vsnprintf.$o + +.INTERMEDIATE: $(OBJS) + +$(NAME).a: $(OBJS) ar rc $@ $^ ranlib $@ -all : $(NAME).a - @ls -l $^ - clean: -rm -f *.a *.o diff --git a/polymer/eduke32/platform/Windows/src/compat-to-msvc/dll_dependency.S b/polymer/eduke32/platform/Windows/src/compat-to-msvc/dll_dependency.S new file mode 100644 index 000000000..e69f86be6 --- /dev/null +++ b/polymer/eduke32/platform/Windows/src/compat-to-msvc/dll_dependency.S @@ -0,0 +1,88 @@ +/* Implementation for gcc's internal stack-allocation routines. */ +.global ___chkstk +.global __alloca + +.global ___chkstk_ms +___chkstk_ms: +#ifdef _WIN64 + pushq %rax + pushq %rcx + cmpq $0x1000, %rax + leaq 24(%rsp), %rcx + jb .Lchkstk_ms_end +.Lchkstk_ms_loop: + subq $0x1000, %rcx + subq $0x1000, %rax + orq $0x0, (%rcx) + cmpq $0x1000, %rax + ja .Lchkstk_ms_loop +.Lchkstk_ms_end: + subq %rax, %rcx + orq $0x0, (%rcx) + popq %rcx + popq %rax + ret +#else + pushl %eax + pushl %ecx + cmpl $0x1000, %eax + leal 12(%esp), %ecx + jb chkstk_ms_end +chkstk_ms_loop: + subl $0x1000, %ecx + subl $0x1000, %eax + orl $0x0, (%ecx) + cmpl $0x1000, %eax + ja chkstk_ms_loop +chkstk_ms_end: + subl %eax, %ecx + orl $0x0, (%ecx) + popl %ecx + popl %eax + ret +#endif + +#ifdef _WIN64 +__alloca: + movq %rcx, %rax +.align 4 +___chkstk: + popq %r11 + movq %rsp, %r10 + cmpq $0x1000, %rax + jb .Lchkstk_end +.Lchkstk_loop: + subq $0x1000, %r10 + subq $0x1000, %rax + orl $0x0, (%r10) + cmpq $0x1000, %rax + ja .Lchkstk_loop +.Lchkstk_end: + subq %rax, %r10 + movq %rsp, %rax + orl $0x0, (%r10) + movq %r10, %rsp + pushq %r11 + ret +#else +___chkstk: +__alloca: + pushl %ecx + leal 8(%esp), %ecx + cmpl $0x1000, %eax /* > 4k ?*/ + jb chkstk_end +chkstk_loop: + subl $0x1000, %ecx + subl $0x1000, %eax + orl $0x0, (%ecx) + cmpl $0x1000, %eax + ja chkstk_loop +chkstk_end: + subl %eax, %ecx + orl $0x0, (%ecx) + movl %esp, %eax + movl %ecx, %esp + movl (%eax), %ecx + pushl 4(%eax) + ret +#endif diff --git a/polymer/eduke32/platform/Windows/src/compat-to-msvc/vsnprintf.c b/polymer/eduke32/platform/Windows/src/compat-to-msvc/vsnprintf.c new file mode 100644 index 000000000..7992984fc --- /dev/null +++ b/polymer/eduke32/platform/Windows/src/compat-to-msvc/vsnprintf.c @@ -0,0 +1,19 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ +#define __CRT__NO_INLINE +#include +#include + +extern int __cdecl _vsnprintf(char * __restrict__, size_t, const char * __restrict__, va_list); + +int __cdecl __ms_vsnprintf (char * __restrict__ s, size_t n, const char * __restrict__ format, va_list arg) +{ + return _vsnprintf(s, n, format, arg); +} +int __cdecl __mingw_vsnprintf (char * __restrict__ s, size_t n, const char * __restrict__ format, va_list arg) +{ + return _vsnprintf(s, n, format, arg); +}