Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- run: msbuild tools\windows\sp\sp.sln /p:Configuration=Release /p:Platform=x64 /m
- shell: bash
run: |
for t in tools/windows/sp/build/vs/Release/bin/*.exe; do
for t in tools/windows/sp/build/vs/Release/bin/*.exe tools/windows/sp/build/vs/Release/bin/spn/*.exe; do
echo "=== $t ==="
"$t" || exit 1
done
Expand Down
34 changes: 22 additions & 12 deletions sp/sp_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,27 @@ typedef struct {
#if defined(__ELF__) || defined(SP_WASM) || (defined(SP_TCC) && defined(SP_LINUX))
#define SP_TEST_AUTOREG 1

#define __sp_test_section __attribute__((used, section("sp_test")))
#if SP_HAS_ATTRIBUTE(retain)
#define __sp_test_section __attribute__((used, retain, section("sp_test")))
#else
#define __sp_test_section __attribute__((used, section("sp_test")))
#endif
#define __sp_test_ptr_const const
#define __sp_test_keep(ID)
#elif defined(SP_MACOS)
#define SP_TEST_AUTOREG 1

#define __sp_test_section __attribute__((used, section("__DATA,sp_test"), no_sanitize("address")))
#define __sp_test_ptr_const const
#define __sp_test_keep(ID)
#elif defined(SP_WIN32) && defined(SP_GNUC)
#define SP_TEST_AUTOREG 1

// The pointer must be const: lld's MinGW driver only merges and $-sorts
// same-named section chunks with identical flags, and the anchors are const
#define __sp_test_section __attribute__((used, section("sp_test$m")))
#define __sp_test_section __declspec(dllexport) __attribute__((used, section("sp_test$m")))
#define __sp_test_ptr_const const
#define __sp_test_keep(ID)
#elif defined(SP_WIN32) && defined(SP_MSVC)
#define SP_TEST_AUTOREG 1

Expand All @@ -176,6 +183,7 @@ typedef struct {
#pragma section("sp_test$z", read)
#define __sp_test_section __declspec(allocate("sp_test$m"))
#define __sp_test_ptr_const
#define __sp_test_keep(ID) __pragma(comment(linker, "/include:" sp_mstr(ID)))
#else
#define SP_TEST_AUTOREG 0
#endif
Expand All @@ -189,9 +197,10 @@ typedef struct {
__VA_ARGS__ \
} \
}; \
static __sp_test_section const sp_test_entry_t* __sp_test_ptr_const ID = &sp_mcat(ID, _v)
__sp_test_keep(ID) \
SP_EXTERN_C __sp_test_section const sp_test_entry_t* __sp_test_ptr_const ID = &sp_mcat(ID, _v)

#define sp_test_reg(SUITE, ...) __sp_test_reg(sp_mcat(sp_test_reg_, __COUNTER__), SUITE, __VA_ARGS__)
#define sp_test_reg(SUITE, NAME, ...) __sp_test_reg(sp_mcat(sp_mcat(sp_test_reg_, SUITE), sp_mcat(_, NAME)), SUITE, __VA_ARGS__)

#define __sp_test_reg_suite(ID, SUITE, ...) \
static const sp_test_entry_t sp_mcat(ID, _v) = { \
Expand All @@ -201,13 +210,14 @@ typedef struct {
__VA_ARGS__ \
} \
}; \
static __sp_test_section const sp_test_entry_t* __sp_test_ptr_const ID = &sp_mcat(ID, _v)
__sp_test_keep(ID) \
SP_EXTERN_C __sp_test_section const sp_test_entry_t* __sp_test_ptr_const ID = &sp_mcat(ID, _v)

#define sp_test_suite(SUITE, ...) __sp_test_reg_suite(sp_mcat(sp_test_suite_reg_, __COUNTER__), SUITE, __VA_ARGS__)
#define sp_test_suite(SUITE, ...) __sp_test_reg_suite(sp_mcat(sp_test_suite_reg_, SUITE), SUITE, __VA_ARGS__)

#define sp_test(SUITE, NAME, ...) \
static sp_err_t __sp_test_fn(SUITE, NAME)(sp_test_t* t); \
sp_test_reg(SUITE, \
sp_test_reg(SUITE, NAME, \
.name = #NAME, \
.kind = SP_TEST_DECL_FN, \
.fn = __sp_test_fn(SUITE, NAME), \
Expand All @@ -234,7 +244,7 @@ typedef struct {
#define sp_test_each(SUITE, NAME, TYPE, ARR, ...) \
__sp_test_each_def(SUITE, NAME, TYPE, ARR) \
__sp_test_each_name_check(ARR); \
sp_test_reg(SUITE, \
sp_test_reg(SUITE, NAME, \
.name = #NAME, \
.kind = SP_TEST_DECL_EACH, \
.each = { \
Expand All @@ -251,7 +261,7 @@ typedef struct {

#define sp_test_each_anon(SUITE, NAME, TYPE, ARR, ...) \
__sp_test_each_def(SUITE, NAME, TYPE, ARR) \
sp_test_reg(SUITE, \
sp_test_reg(SUITE, NAME, \
.name = #NAME, \
.kind = SP_TEST_DECL_EACH, \
.each = { \
Expand All @@ -268,7 +278,7 @@ typedef struct {
sp_static_assert(sizeof(TYPE) == sizeof((ARR)[0]), sp_test_each_row_type_mismatch); \
__sp_test_each_name_check(ARR); \
__sp_test_each_thunk_def(SUITE, NAME, TYPE, FN) \
sp_test_reg(SUITE, \
sp_test_reg(SUITE, NAME, \
.name = #NAME, \
.kind = SP_TEST_DECL_EACH, \
.each = { \
Expand All @@ -285,7 +295,7 @@ typedef struct {
#define sp_test_sweep(SUITE, NAME, TYPE, ...) \
static sp_err_t __sp_test_fn(SUITE, NAME)(sp_test_t* t, TYPE* it); \
__sp_test_each_thunk_def(SUITE, NAME, TYPE, __sp_test_fn(SUITE, NAME)) \
sp_test_reg(SUITE, \
sp_test_reg(SUITE, NAME, \
.name = #NAME, \
.kind = SP_TEST_DECL_SWEEP, \
.sweep = { \
Expand All @@ -299,7 +309,7 @@ typedef struct {
#define __sp_test_unsupported() \
sp_static_assert(false, no_sp_test_autoreg_for_this_object_format__pass_entries_to_sp_test_main)

#define sp_test_reg(SUITE, ...) __sp_test_unsupported()
#define sp_test_reg(SUITE, NAME, ...) __sp_test_unsupported()
#define sp_test_suite(SUITE, ...) __sp_test_unsupported()
#define sp_test(SUITE, NAME, ...) __sp_test_unsupported(); static sp_err_t __sp_test_fn(SUITE, NAME)(sp_test_t* t)
#define sp_test_each(SUITE, NAME, TYPE, ARR, ...) __sp_test_unsupported(); static sp_err_t __sp_test_fn(SUITE, NAME)(sp_test_t* t, TYPE* it)
Expand Down
4 changes: 2 additions & 2 deletions test/msvc/sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sp_test_each(msvc, sdk_new, test_t, tests) {
c8 buf [SP_MSVC_PATH_MAX] = sp_zero;
sp_expect_str_eq_c(t, sp_msvc_sdk_path_buf(buf, sizeof(buf), &sdk, SP_MSVC_SDK_PATH_LIB_UM).value, it->expect.lib_um);

c8 small [8] = sp_zero;
sp_expect_eq(t, sp_msvc_sdk_path_buf(small, sizeof(small), &sdk, SP_MSVC_SDK_PATH_LIB_UM).err, SP_ERR_IO_NO_SPACE);
c8 tiny [8] = sp_zero;
sp_expect_eq(t, sp_msvc_sdk_path_buf(tiny, sizeof(tiny), &sdk, SP_MSVC_SDK_PATH_LIB_UM).err, SP_ERR_IO_NO_SPACE);
return SP_OK;
}
24 changes: 9 additions & 15 deletions tools/windows/sp/tls.vcxproj → tools/windows/sp/qsort.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,18 @@
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{E1D4B7A9-6A0C-4F2B-8D3E-9B5C1A7F4D21}</ProjectGuid>
<RootNamespace>tls</RootNamespace>
<ProjectName>tls</ProjectName>
<ProjectGuid>{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E68}</ProjectGuid>
<RootNamespace>qsort</RootNamespace>
<ProjectName>qsort</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<SpTargetName>tls</SpTargetName>
<SpSource>..\..\..\test\tls.c</SpSource>
<SpHeaders>..\..\..\sp.h;..\..\..\sp\sp_tls.h;..\..\..\test\tools\utest.h</SpHeaders>
<SpTargetName>qsort</SpTargetName>
<SpSource>..\..\..\test\qsort.c</SpSource>
<SpHeaders>..\..\..\sp.h;..\..\..\test\tools\utest.h</SpHeaders>
<SpProjectReferences></SpProjectReferences>
<SpPreprocessorDefinitions>SP_TLS_WITH_MBEDTLS</SpPreprocessorDefinitions>
<SpAdditionalIncludeDirectories>$(MSBuildThisFileDirectory)..\..\vendor\mbedtls\include;$(MSBuildThisFileDirectory)..\..\vendor\mbedtls\library</SpAdditionalIncludeDirectories>
<SpAdditionalDependencies>ws2_32.lib;crypt32.lib;advapi32.lib;bcrypt.lib</SpAdditionalDependencies>
<SpPreprocessorDefinitions></SpPreprocessorDefinitions>
<SpAdditionalIncludeDirectories></SpAdditionalIncludeDirectories>
<SpAdditionalDependencies></SpAdditionalDependencies>
</PropertyGroup>
<ItemGroup>
<ClCompile Include="..\..\vendor\mbedtls\library\*.c">
<WarningLevel>Level1</WarningLevel>
<SDLCheck>false</SDLCheck>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
Expand Down
2 changes: 1 addition & 1 deletion tools/windows/sp/sp.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>shell32.lib;ws2_32.lib;$(SpAdditionalDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>shell32.lib;ws2_32.lib;crypt32.lib;advapi32.lib;bcrypt.lib;$(SpAdditionalDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)' == 'Release'">
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand Down
84 changes: 84 additions & 0 deletions tools/windows/sp/sp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,32 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "prompt_fancy", "examples\pr
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cli", "examples\cli.vcxproj", "{10000014-0014-4014-8014-000000000014}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qsort", "qsort.vcxproj", "{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E68}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "term", "term.vcxproj", "{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E69}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "spn", "spn", "{FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "amalgamation", "spn\amalgamation.vcxproj", "{20000001-0001-4001-8001-000000000001}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meta", "spn\meta.vcxproj", "{20000002-0002-4002-8002-000000000002}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sys", "spn\sys.vcxproj", "{20000003-0003-4003-8003-000000000003}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "atomic", "spn\atomic.vcxproj", "{20000004-0004-4004-8004-000000000004}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fs", "spn\fs.vcxproj", "{20000005-0005-4005-8005-000000000005}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msvct", "spn\msvct.vcxproj", "{20000006-0006-4006-8006-000000000006}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync", "spn\sync.vcxproj", "{20000007-0007-4007-8007-000000000007}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mem", "spn\mem.vcxproj", "{20000008-0008-4008-8008-000000000008}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "http", "spn\http.vcxproj", "{20000009-0009-4009-8009-000000000009}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tls", "spn\tls.vcxproj", "{20000010-0010-4010-8010-000000000010}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -232,6 +258,54 @@ Global
{CB96468E-6F42-4AD6-BD41-CBD668979062}.Debug|x64.Build.0 = Debug|x64
{CB96468E-6F42-4AD6-BD41-CBD668979062}.Release|x64.ActiveCfg = Release|x64
{CB96468E-6F42-4AD6-BD41-CBD668979062}.Release|x64.Build.0 = Release|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E68}.Debug|x64.ActiveCfg = Debug|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E68}.Debug|x64.Build.0 = Debug|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E68}.Release|x64.ActiveCfg = Release|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E68}.Release|x64.Build.0 = Release|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E69}.Debug|x64.ActiveCfg = Debug|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E69}.Debug|x64.Build.0 = Debug|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E69}.Release|x64.ActiveCfg = Release|x64
{21A5F3D1-2C70-4A11-9F8B-1A2B3C4D5E69}.Release|x64.Build.0 = Release|x64
{20000001-0001-4001-8001-000000000001}.Debug|x64.ActiveCfg = Debug|x64
{20000001-0001-4001-8001-000000000001}.Debug|x64.Build.0 = Debug|x64
{20000001-0001-4001-8001-000000000001}.Release|x64.ActiveCfg = Release|x64
{20000001-0001-4001-8001-000000000001}.Release|x64.Build.0 = Release|x64
{20000002-0002-4002-8002-000000000002}.Debug|x64.ActiveCfg = Debug|x64
{20000002-0002-4002-8002-000000000002}.Debug|x64.Build.0 = Debug|x64
{20000002-0002-4002-8002-000000000002}.Release|x64.ActiveCfg = Release|x64
{20000002-0002-4002-8002-000000000002}.Release|x64.Build.0 = Release|x64
{20000003-0003-4003-8003-000000000003}.Debug|x64.ActiveCfg = Debug|x64
{20000003-0003-4003-8003-000000000003}.Debug|x64.Build.0 = Debug|x64
{20000003-0003-4003-8003-000000000003}.Release|x64.ActiveCfg = Release|x64
{20000003-0003-4003-8003-000000000003}.Release|x64.Build.0 = Release|x64
{20000004-0004-4004-8004-000000000004}.Debug|x64.ActiveCfg = Debug|x64
{20000004-0004-4004-8004-000000000004}.Debug|x64.Build.0 = Debug|x64
{20000004-0004-4004-8004-000000000004}.Release|x64.ActiveCfg = Release|x64
{20000004-0004-4004-8004-000000000004}.Release|x64.Build.0 = Release|x64
{20000005-0005-4005-8005-000000000005}.Debug|x64.ActiveCfg = Debug|x64
{20000005-0005-4005-8005-000000000005}.Debug|x64.Build.0 = Debug|x64
{20000005-0005-4005-8005-000000000005}.Release|x64.ActiveCfg = Release|x64
{20000005-0005-4005-8005-000000000005}.Release|x64.Build.0 = Release|x64
{20000006-0006-4006-8006-000000000006}.Debug|x64.ActiveCfg = Debug|x64
{20000006-0006-4006-8006-000000000006}.Debug|x64.Build.0 = Debug|x64
{20000006-0006-4006-8006-000000000006}.Release|x64.ActiveCfg = Release|x64
{20000006-0006-4006-8006-000000000006}.Release|x64.Build.0 = Release|x64
{20000007-0007-4007-8007-000000000007}.Debug|x64.ActiveCfg = Debug|x64
{20000007-0007-4007-8007-000000000007}.Debug|x64.Build.0 = Debug|x64
{20000007-0007-4007-8007-000000000007}.Release|x64.ActiveCfg = Release|x64
{20000007-0007-4007-8007-000000000007}.Release|x64.Build.0 = Release|x64
{20000008-0008-4008-8008-000000000008}.Debug|x64.ActiveCfg = Debug|x64
{20000008-0008-4008-8008-000000000008}.Debug|x64.Build.0 = Debug|x64
{20000008-0008-4008-8008-000000000008}.Release|x64.ActiveCfg = Release|x64
{20000008-0008-4008-8008-000000000008}.Release|x64.Build.0 = Release|x64
{20000009-0009-4009-8009-000000000009}.Debug|x64.ActiveCfg = Debug|x64
{20000009-0009-4009-8009-000000000009}.Debug|x64.Build.0 = Debug|x64
{20000009-0009-4009-8009-000000000009}.Release|x64.ActiveCfg = Release|x64
{20000009-0009-4009-8009-000000000009}.Release|x64.Build.0 = Release|x64
{20000010-0010-4010-8010-000000000010}.Debug|x64.ActiveCfg = Debug|x64
{20000010-0010-4010-8010-000000000010}.Debug|x64.Build.0 = Debug|x64
{20000010-0010-4010-8010-000000000010}.Release|x64.ActiveCfg = Release|x64
{20000010-0010-4010-8010-000000000010}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -251,5 +325,15 @@ Global
{10000012-0012-4012-8012-000000000012} = {FFFFFFFF-EEEE-DDDD-CCCC-BBBBBBBBBBBB}
{10000013-0013-4013-8013-000000000013} = {FFFFFFFF-EEEE-DDDD-CCCC-BBBBBBBBBBBB}
{10000014-0014-4014-8014-000000000014} = {FFFFFFFF-EEEE-DDDD-CCCC-BBBBBBBBBBBB}
{20000001-0001-4001-8001-000000000001} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000002-0002-4002-8002-000000000002} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000003-0003-4003-8003-000000000003} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000004-0004-4004-8004-000000000004} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000005-0005-4005-8005-000000000005} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000006-0006-4006-8006-000000000006} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000007-0007-4007-8007-000000000007} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000008-0008-4008-8008-000000000008} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000009-0009-4009-8009-000000000009} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
{20000010-0010-4010-8010-000000000010} = {FFFFFFFF-EEEE-DDDD-CCCC-AAAAAAAAAAAA}
EndGlobalSection
EndGlobal
7 changes: 7 additions & 0 deletions tools/windows/sp/sp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
<ItemGroup Condition="'$(SpProjectReferences)' != ''">
<ProjectReference Include="$(SpProjectReferences)" />
</ItemGroup>
<Target Name="SpObjectNames" BeforeTargets="PrepareForBuild">
<ItemGroup>
<ClCompile Condition="$([System.String]::Copy('%(RelativeDir)').StartsWith('..\'))">
<ObjectFileName>$(IntDir)$([System.String]::Copy('%(RelativeDir)').Replace('..\', '').Replace('\', '_'))%(Filename).obj</ObjectFileName>
</ClCompile>
</ItemGroup>
</Target>
<Target Name="Run" DependsOnTargets="Build">
<Exec Command="&quot;$(TargetPath)&quot;" />
</Target>
Expand Down
Loading
Loading