Use SDL_DISABLE_ALLOCA instead of HAVE_ALLOCA in SDL_stdinc.h

main
Anonymous Maarten 2023-10-02 11:00:06 +02:00 committed by Anonymous Maarten
parent 552bee47cb
commit 6127ac0871
20 changed files with 185 additions and 44 deletions

View File

@ -486,6 +486,18 @@ sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/video/*.c" "${SDL3_SOURCE_DIR}/src/video/*.c"
"${SDL3_SOURCE_DIR}/src/video/yuv2rgb/*.c" "${SDL3_SOURCE_DIR}/src/video/yuv2rgb/*.c"
) )
if(MSVC AND TARGET SDL3-shared)
if(SDL_CPU_X64)
enable_language(ASM_MASM)
set(asm_src "${SDL3_SOURCE_DIR}/src/stdlib/SDL_mslibc_x64.asm")
target_compile_options(SDL3-shared PRIVATE "$<$<COMPILE_LANGUAGE:ASM_MASM>:/nologo>")
set_property(SOURCE "${asm_src}" PROPERTY LANGUAGE "ASM_MASM")
target_sources(SDL3-shared PRIVATE "${asm_src}")
elseif(SDL_CPU_ARM32 OR DL_CPU_ARM64)
# FIXME: ARM assembler (armasm.exe/armasm64.exe) is NOT ASM_MASM, and does currently not work with CMake
# (https://gitlab.kitware.com/cmake/cmake/-/issues/18912)
endif()
endif()
if(USE_INTELCC) if(USE_INTELCC)
# warning #39: division by zero # warning #39: division by zero
@ -985,12 +997,21 @@ if(NOT HAVE_ARMNEON)
set(SDL_DISABLE_NEON 1) set(SDL_DISABLE_NEON 1)
endif() endif()
set(SDL_DISABLE_ALLOCA 0)
check_include_file("alloca.h" "HAVE_ALLOCA_H")
if(MSVC)
check_include_file("malloc.h" "HAVE_MALLOC")
check_symbol_exists("_alloca" "malloc.h" _ALLOCA_IN_MALLOC_H)
if(NOT HAVE_ALLOCA_H AND NOT _ALLOCA_IN_MALLOC_H)
set(SDL_DISABLE_ALLOCA 1)
endif()
endif()
# TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define anything. # TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define anything.
if(SDL_LIBC) if(SDL_LIBC)
set(available_headers) set(available_headers)
set(HAVE_LIBC TRUE) set(HAVE_LIBC TRUE)
set(headers_to_check set(headers_to_check
alloca.h
ctype.h ctype.h
float.h float.h
iconv.h iconv.h
@ -1022,7 +1043,7 @@ if(SDL_LIBC)
endforeach() endforeach()
set(symbols_to_check set(symbols_to_check
abs acos acosf alloca asin asinf atan atan2 atan2f atanf atof atoi abs acos acosf asin asinf atan atan2 atan2f atanf atof atoi
bcopy bsearch bcopy bsearch
calloc ceil ceilf copysign copysignf cos cosf calloc ceil ceilf copysign copysignf cos cosf
_Exit exp expf _Exit exp expf
@ -1717,7 +1738,7 @@ elseif(WINDOWS)
if(TARGET SDL3-shared AND MSVC AND NOT SDL_LIBC) if(TARGET SDL3-shared AND MSVC AND NOT SDL_LIBC)
# Prevent codegen that would use the VC runtime libraries. # Prevent codegen that would use the VC runtime libraries.
target_compile_options(SDL3-shared PRIVATE "/GS-" "/Gs1048576") target_compile_options(SDL3-shared PRIVATE $<$<COMPILE_LANGUAGE:C,CXX>:/GS-> $<$<COMPILE_LANGUAGE:C,CXX>:/Gs1048576>)
if(SDL_CPU_X86) if(SDL_CPU_X86)
target_compile_options(SDL3-shared PRIVATE "/arch:SSE") target_compile_options(SDL3-shared PRIVATE "/arch:SSE")
endif() endif()

View File

@ -59,6 +59,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Desktop.x64'" Label="PropertySheets"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Desktop.x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
@ -729,6 +730,9 @@
<ClCompile Include="..\..\src\stdlib\SDL_iconv.c" /> <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c" /> <ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
<ClCompile Include="..\..\src\stdlib\SDL_mslibc.c" /> <ClCompile Include="..\..\src\stdlib\SDL_mslibc.c" />
<MASM Condition="'$(Platform)'=='x64'" Include="..\..\src\stdlib\SDL_mslibc_x64.asm" >
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</MASM>
<ClCompile Include="..\..\src\stdlib\SDL_qsort.c" /> <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
<ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" /> <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
<ClCompile Include="..\..\src\stdlib\SDL_string.c" /> <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
@ -793,5 +797,6 @@
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -1388,6 +1388,9 @@
<ClCompile Include="..\..\src\stdlib\SDL_mslibc.c"> <ClCompile Include="..\..\src\stdlib\SDL_mslibc.c">
<Filter>stdlib</Filter> <Filter>stdlib</Filter>
</ClCompile> </ClCompile>
<MASM Include="..\..\src\stdlib\SDL_mslibc_x64.asm">
<Filter>stdlib</Filter>
</MASM>
<ClCompile Include="..\..\src\core\gdk\SDL_gdk.cpp"> <ClCompile Include="..\..\src\core\gdk\SDL_gdk.cpp">
<Filter>core\gdk</Filter> <Filter>core\gdk</Filter>
</ClCompile> </ClCompile>

View File

@ -413,6 +413,9 @@
<ClCompile Include="..\src\stdlib\SDL_iconv.c" /> <ClCompile Include="..\src\stdlib\SDL_iconv.c" />
<ClCompile Include="..\src\stdlib\SDL_malloc.c" /> <ClCompile Include="..\src\stdlib\SDL_malloc.c" />
<ClCompile Include="..\src\stdlib\SDL_mslibc.c" /> <ClCompile Include="..\src\stdlib\SDL_mslibc.c" />
<MASM Condition="'$(Platform)'=='x64'" Include="..\src\stdlib\SDL_mslibc_x64.asm" >
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</MASM>
<ClCompile Include="..\src\stdlib\SDL_qsort.c" /> <ClCompile Include="..\src\stdlib\SDL_qsort.c" />
<ClCompile Include="..\src\stdlib\SDL_stdlib.c" /> <ClCompile Include="..\src\stdlib\SDL_stdlib.c" />
<ClCompile Include="..\src\stdlib\SDL_string.c" /> <ClCompile Include="..\src\stdlib\SDL_string.c" />
@ -668,6 +671,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
</ImportGroup> </ImportGroup>
@ -867,5 +871,6 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -875,6 +875,9 @@
<ClCompile Include="..\src\stdlib\SDL_mslibc.c"> <ClCompile Include="..\src\stdlib\SDL_mslibc.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<MASM Include="..\src\stdlib\SDL_mslibc_x64.asm">
<Filter>stdlib</Filter>
</MASM>
<ClCompile Include="..\src\core\windows\pch.c"> <ClCompile Include="..\src\core\windows\pch.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View File

@ -43,6 +43,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
@ -609,6 +610,9 @@
<ClCompile Include="..\..\src\stdlib\SDL_iconv.c" /> <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c" /> <ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
<ClCompile Include="..\..\src\stdlib\SDL_mslibc.c" /> <ClCompile Include="..\..\src\stdlib\SDL_mslibc.c" />
<MASM Condition="'$(Platform)'=='x64'" Include="..\..\src\stdlib\SDL_mslibc_x64.asm" >
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</MASM>
<ClCompile Include="..\..\src\stdlib\SDL_qsort.c" /> <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
<ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" /> <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
<ClCompile Include="..\..\src\stdlib\SDL_string.c" /> <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
@ -669,5 +673,6 @@
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -1375,6 +1375,9 @@
<ClCompile Include="..\..\src\stdlib\SDL_mslibc.c"> <ClCompile Include="..\..\src\stdlib\SDL_mslibc.c">
<Filter>stdlib</Filter> <Filter>stdlib</Filter>
</ClCompile> </ClCompile>
<MASM Include="..\..\src\stdlib\SDL_mslibc_x64.asm">
<Filter>stdlib</Filter>
</MASM>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\src\core\windows\version.rc" /> <ResourceCompile Include="..\..\src\core\windows\version.rc" />

View File

@ -49,12 +49,12 @@ function(SDL_AddCommonCompilerFlags TARGET)
check_c_compiler_flag(-Wundef HAVE_GCC_WUNDEF) check_c_compiler_flag(-Wundef HAVE_GCC_WUNDEF)
if(HAVE_GCC_WUNDEF) if(HAVE_GCC_WUNDEF)
target_compile_options(${TARGET} PRIVATE "-Wundef") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wundef>")
endif() endif()
check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING) check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING)
if(HAVE_GCC_NO_STRICT_ALIASING) if(HAVE_GCC_NO_STRICT_ALIASING)
target_compile_options(${TARGET} PRIVATE "-fno-strict-aliasing") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fno-strict-aliasing>")
endif() endif()
check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION) check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION)
@ -62,10 +62,10 @@ function(SDL_AddCommonCompilerFlags TARGET)
if(SDL_WERROR) if(SDL_WERROR)
check_c_compiler_flag(-Werror=documentation HAVE_GCC_WERROR_DOCUMENTATION) check_c_compiler_flag(-Werror=documentation HAVE_GCC_WERROR_DOCUMENTATION)
if(HAVE_GCC_WERROR_DOCUMENTATION) if(HAVE_GCC_WERROR_DOCUMENTATION)
target_compile_options(${TARGET} PRIVATE "-Werror=documentation") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=documentation>")
endif() endif()
endif() endif()
target_compile_options(${TARGET} PRIVATE "-Wdocumentation") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wdocumentation>")
endif() endif()
check_c_compiler_flag(-Wdocumentation-unknown-command HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND) check_c_compiler_flag(-Wdocumentation-unknown-command HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND)
@ -73,30 +73,30 @@ function(SDL_AddCommonCompilerFlags TARGET)
if(SDL_WERROR) if(SDL_WERROR)
check_c_compiler_flag(-Werror=documentation-unknown-command HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND) check_c_compiler_flag(-Werror=documentation-unknown-command HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND) if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND)
target_compile_options(${TARGET} PRIVATE "-Werror=documentation-unknown-command") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=documentation-unknown-command>")
endif() endif()
endif() endif()
target_compile_options(${TARGET} PRIVATE "-Wdocumentation-unknown-command") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wdocumentation-unknown-command>")
endif() endif()
check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS) check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS)
if(HAVE_GCC_COMMENT_BLOCK_COMMANDS) if(HAVE_GCC_COMMENT_BLOCK_COMMANDS)
target_compile_options(${TARGET} PRIVATE "-fcomment-block-commands=threadsafety") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fcomment-block-commands=threadsafety>")
else() else()
check_c_compiler_flag(/clang:-fcomment-block-commands=threadsafety HAVE_CLANG_COMMENT_BLOCK_COMMANDS) check_c_compiler_flag(/clang:-fcomment-block-commands=threadsafety HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS) if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS)
target_compile_options(${TARGET} PRIVATE "/clang:-fcomment-block-commands=threadsafety") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:/clang:-fcomment-block-commands=threadsafety>")
endif() endif()
endif() endif()
check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW) check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
if(HAVE_GCC_WSHADOW) if(HAVE_GCC_WSHADOW)
target_compile_options(${TARGET} PRIVATE "-Wshadow") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wshadow>")
endif() endif()
check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS) check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS) if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
target_compile_options(${TARGET} PRIVATE "-Wno-unused-local-typedefs") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-local-typedefs>")
endif() endif()
endif() endif()
@ -109,7 +109,7 @@ function(SDL_AddCommonCompilerFlags TARGET)
elseif(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QNX) elseif(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QNX)
check_c_compiler_flag(-Werror HAVE_WERROR) check_c_compiler_flag(-Werror HAVE_WERROR)
if(HAVE_WERROR) if(HAVE_WERROR)
target_compile_options(${TARGET} PRIVATE "-Werror") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-Werror>")
endif() endif()
endif() endif()
endif() endif()
@ -117,12 +117,12 @@ function(SDL_AddCommonCompilerFlags TARGET)
if(USE_CLANG) if(USE_CLANG)
check_c_compiler_flag("-fcolor-diagnostics" COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS) check_c_compiler_flag("-fcolor-diagnostics" COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS)
if(COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS) if(COMPILER_SUPPORTS_FCOLOR_DIAGNOSTICS)
target_compile_options(${TARGET} PRIVATE "-fcolor-diagnostics") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fcolor-diagnostics>")
endif() endif()
else() else()
check_c_compiler_flag("-fdiagnostics-color=always" COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS) check_c_compiler_flag("-fdiagnostics-color=always" COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS)
if(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS) if(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS)
target_compile_options(${TARGET} PRIVATE "-fdiagnostics-color=always") target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-fdiagnostics-color=always>")
endif() endif()
endif() endif()
endfunction() endfunction()

View File

@ -37,26 +37,28 @@
#include <stdint.h> #include <stdint.h>
#include <wchar.h> #include <wchar.h>
#ifndef alloca #ifndef SDL_DISABLE_ALLOCA
# ifdef HAVE_ALLOCA_H # ifndef alloca
# include <alloca.h> # ifdef HAVE_ALLOCA_H
# elif defined(__GNUC__) # include <alloca.h>
# define alloca __builtin_alloca # elif defined(__GNUC__)
# elif defined(_MSC_VER) # define alloca __builtin_alloca
# include <malloc.h> # elif defined(_MSC_VER)
# define alloca _alloca # include <malloc.h>
# elif defined(__WATCOMC__) # define alloca _alloca
# include <malloc.h> # elif defined(__WATCOMC__)
# elif defined(__BORLANDC__) # include <malloc.h>
# include <malloc.h> # elif defined(__BORLANDC__)
# elif defined(__DMC__) # include <malloc.h>
# include <stdlib.h> # elif defined(__DMC__)
# elif defined(__AIX__) # include <stdlib.h>
#pragma alloca # elif defined(__AIX__)
# elif defined(__MRC__) # pragma alloca
# elif defined(__MRC__)
void *alloca(unsigned); void *alloca(unsigned);
# else # else
char *alloca(); char *alloca();
# endif
# endif # endif
#endif #endif
@ -379,7 +381,7 @@ SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
extern "C" { extern "C" {
#endif #endif
#ifdef HAVE_ALLOCA #ifndef SDL_DISABLE_ALLOCA
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
#define SDL_stack_free(data) #define SDL_stack_free(data)
#else #else

View File

@ -42,6 +42,8 @@
#cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@ #cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@
#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@ #cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@
#cmakedefine SDL_DISABLE_ALLOCA
/* Comment this if you want to build without any C library requirements */ /* Comment this if you want to build without any C library requirements */
#cmakedefine HAVE_LIBC 1 #cmakedefine HAVE_LIBC 1
#ifdef HAVE_LIBC #ifdef HAVE_LIBC
@ -74,7 +76,6 @@
#cmakedefine HAVE_CALLOC 1 #cmakedefine HAVE_CALLOC 1
#cmakedefine HAVE_REALLOC 1 #cmakedefine HAVE_REALLOC 1
#cmakedefine HAVE_FREE 1 #cmakedefine HAVE_FREE 1
#cmakedefine HAVE_ALLOCA 1
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ #ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
#cmakedefine HAVE_GETENV 1 #cmakedefine HAVE_GETENV 1
#cmakedefine HAVE_SETENV 1 #cmakedefine HAVE_SETENV 1

View File

@ -57,7 +57,6 @@
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1

View File

@ -60,7 +60,6 @@
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1

View File

@ -49,7 +49,6 @@
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1

View File

@ -54,7 +54,6 @@
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1

View File

@ -131,7 +131,6 @@ typedef unsigned int uintptr_t;
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1 #define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1

View File

@ -77,7 +77,6 @@
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1 #define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1

View File

@ -75,7 +75,6 @@
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1 #define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1

View File

@ -77,7 +77,6 @@
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1 #define HAVE_QSORT 1
#define HAVE_BSEARCH 1 #define HAVE_BSEARCH 1
#define HAVE_ABS 1 #define HAVE_ABS 1

View File

@ -696,8 +696,80 @@ RETZERO:
/* *INDENT-ON* */ /* *INDENT-ON* */
} }
void __declspec(naked) _chkstk(void)
{
__asm {
push ecx
mov ecx,esp ; lea ecx,dword ptr [esp]+4
add ecx,4
sub ecx,eax
sbb eax,eax
not eax
and ecx,eax
mov eax,esp
and eax,0xfffff000
L1:
cmp ecx,eax
jb short L2
mov eax,ecx
pop ecx
xchg esp,eax
mov eax,dword ptr [eax]
mov dword ptr [esp],eax
ret
L2:
sub eax,0x1000
test dword ptr [eax],eax
jmp short L1
}
}
void __declspec(naked) _alloca_probe_8(void)
{
/* *INDENT-OFF* */
__asm {
push ecx
mov ecx,esp ; lea ecx,dword ptr [esp]+8
add ecx,8
sub ecx,eax
and ecx,0x7
add eax,ecx
sbb ecx,ecx
or eax,ecx
pop ecx
jmp _chkstk
}
/* *INDENT-ON* */
}
void __declspec(naked) _alloca_probe_16(void)
{
/* *INDENT-OFF* */
__asm {
push ecx
mov ecx,esp ; lea ecx,dword ptr [esp]+8
add ecx,8
sub ecx,eax
and ecx,0xf
add eax,ecx
sbb ecx,ecx
or eax,ecx
pop ecx
jmp _chkstk
}
/* *INDENT-ON* */
}
#endif /* _M_IX86 */ #endif /* _M_IX86 */
#ifdef _M_ARM64
void __chkstk(void);
void __chkstk() {
}
#endif
#endif /* MSC_VER */ #endif /* MSC_VER */
#ifdef __ICL #ifdef __ICL

View File

@ -0,0 +1,29 @@
include ksamd64.inc
text SEGMENT EXECUTE
public __chkstk
__chkstk:
sub rsp,010h
mov QWORD PTR [rsp],r10
mov QWORD PTR [rsp+08h],r11
xor r11,r11
lea r10,[rsp+018h]
sub r10,rax
cmovb r10,r11
mov r11,QWORD PTR gs:[TeStackLimit]
cmp r10,r11
jae chkstk_finish
and r10w,0f000h
chkstk_loop:
lea r11,[r11-PAGE_SIZE]
mov BYTE PTR [r11],0h
cmp r10,r11
jne chkstk_loop
chkstk_finish:
mov r10,QWORD PTR [rsp]
mov r11,QWORD PTR [rsp+08h]
add rsp,010h
ret
end