Skip to content

Commit

Permalink
First attempt at fixing nlohmann doctest compilation error (#4499)
Browse files Browse the repository at this point in the history
* First attempt at fixing nlohmann doctest compilation error

* fixed compilation issue

* Fixed ApiView generation for azure core
  • Loading branch information
LarryOsterman authored and antkmsft committed Apr 5, 2023
1 parent f7fef25 commit 8be6490
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
19 changes: 19 additions & 0 deletions sdk/core/azure-core-tracing-opentelemetry/inc/ApiViewSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"sourceFilesToProcess": null,
"sourceFilesToSkip": [
],
"additionalIncludeDirectories": [
"../../azure-core/inc"
],
"additionalCompilerSwitches": [
"-D_azure_APIVIEW",
"-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
],
"allowInternal": true,
"includeDetail": false,
"includePrivate": false,
"filterNamespace": "Azure::",
"reviewName": "Azure Core Tracing Open-Telemetry API Review",
"serviceName": null,
"packageName": "azure-core-tracing-opentelemetry-cpp"
}
3 changes: 2 additions & 1 deletion sdk/core/azure-core/inc/ApiViewSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"additionalCompilerSwitches": [
"-DBUILD_CURL_HTTP_TRANSPORT_ADAPTER",
"-DBUILD_TRANSPORT_WINHTTP_ADAPTER",
"-DCURL_STATICLIB"
"-DCURL_STATICLIB",
"-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
],
"allowInternal": true,
"includeDetail": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3930,6 +3930,8 @@ namespace {
struct FatalConditionHandler
{
void reset() {}
static void allocateAltStackMem() {}
static void freeAltStackMem() {}
};
#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH

Expand Down Expand Up @@ -3966,6 +3968,9 @@ namespace {
return EXCEPTION_CONTINUE_SEARCH;
}

static void allocateAltStackMem() {}
static void freeAltStackMem() {}

FatalConditionHandler() {
isSet = true;
// 32k seems enough for doctest to handle stack overflow,
Expand Down Expand Up @@ -4018,7 +4023,8 @@ namespace {
static bool isSet;
static struct sigaction oldSigActions[DOCTEST_COUNTOF(signalDefs)];
static stack_t oldSigStack;
static char altStackMem[4 * SIGSTKSZ];
static size_t altStackSize;
static char * altStackMem;

static void handleSignal(int sig) {
const char* name = "<unknown signal>";
Expand All @@ -4034,11 +4040,18 @@ namespace {
raise(sig);
}

static void allocateAltStackMem() {
altStackMem = new char[altStackSize];
}
static void freeAltStackMem() {
delete[] altStackMem;
}

FatalConditionHandler() {
isSet = true;
stack_t sigStack;
sigStack.ss_sp = altStackMem;
sigStack.ss_size = sizeof(altStackMem);
sigStack.ss_size = altStackSize;
sigStack.ss_flags = 0;
sigaltstack(&sigStack, &oldSigStack);
struct sigaction sa = {};
Expand All @@ -4063,10 +4076,12 @@ namespace {
}
};

bool FatalConditionHandler::isSet = false;
bool FatalConditionHandler::isSet = false;
struct sigaction FatalConditionHandler::oldSigActions[DOCTEST_COUNTOF(signalDefs)] = {};
stack_t FatalConditionHandler::oldSigStack = {};
char FatalConditionHandler::altStackMem[] = {};
stack_t FatalConditionHandler::oldSigStack = {};
size_t FatalConditionHandler::altStackSize = 4 * SIGSTKSZ;
char * FatalConditionHandler::altStackMem = nullptr;


#endif // DOCTEST_PLATFORM_WINDOWS
#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
Expand Down Expand Up @@ -5687,7 +5702,10 @@ int Context::run() {
p->cout = &fstr;
}

FatalConditionHandler::allocateAltStackMem();

auto cleanup_and_return = [&]() {
FatalConditionHandler::freeAltStackMem();
if(fstr.is_open())
fstr.close();

Expand Down

0 comments on commit 8be6490

Please sign in to comment.