mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 01:20:51 +03:00
Solaris: fix assert for betterC build. (#2566)
* Solaris: fix assert for betterC build. * Added parens to avoid relying on operator precedence rules.
This commit is contained in:
parent
66a19de8ed
commit
907dae171a
2 changed files with 13 additions and 1 deletions
|
@ -311,6 +311,14 @@ void DtoCAssert(Module *M, Loc &loc, LLValue *msg) {
|
||||||
args.push_back(file);
|
args.push_back(file);
|
||||||
args.push_back(line);
|
args.push_back(line);
|
||||||
args.push_back(msg);
|
args.push_back(msg);
|
||||||
|
} else if (global.params.targetTriple->isOSSolaris()) {
|
||||||
|
const auto irFunc = gIR->func();
|
||||||
|
const auto funcName =
|
||||||
|
(irFunc && irFunc->decl) ? irFunc->decl->toPrettyChars() : "";
|
||||||
|
args.push_back(msg);
|
||||||
|
args.push_back(file);
|
||||||
|
args.push_back(line);
|
||||||
|
args.push_back(DtoConstCString(funcName));
|
||||||
} else if (global.params.targetTriple->getEnvironment() ==
|
} else if (global.params.targetTriple->getEnvironment() ==
|
||||||
llvm::Triple::Android) {
|
llvm::Triple::Android) {
|
||||||
args.push_back(file);
|
args.push_back(file);
|
||||||
|
|
|
@ -165,6 +165,8 @@ llvm::Function *getRuntimeFunction(const Loc &loc, llvm::Module &target,
|
||||||
// const char *msg)
|
// const char *msg)
|
||||||
// Android: void __assert(const char *file, int line, const char *msg)
|
// Android: void __assert(const char *file, int line, const char *msg)
|
||||||
// MSVC: void _assert(const char *msg, const char *file, unsigned line)
|
// MSVC: void _assert(const char *msg, const char *file, unsigned line)
|
||||||
|
// Solaris: void __assert_c99(const char *assertion, const char *filename, int line_num,
|
||||||
|
// const char *funcname);
|
||||||
// else: void __assert(const char *msg, const char *file, unsigned line)
|
// else: void __assert(const char *msg, const char *file, unsigned line)
|
||||||
|
|
||||||
static const char *getCAssertFunctionName() {
|
static const char *getCAssertFunctionName() {
|
||||||
|
@ -172,6 +174,8 @@ static const char *getCAssertFunctionName() {
|
||||||
return "__assert_rtn";
|
return "__assert_rtn";
|
||||||
} else if (global.params.targetTriple->isWindowsMSVCEnvironment()) {
|
} else if (global.params.targetTriple->isWindowsMSVCEnvironment()) {
|
||||||
return "_assert";
|
return "_assert";
|
||||||
|
} else if (global.params.targetTriple->isOSSolaris()) {
|
||||||
|
return "__assert_c99";
|
||||||
}
|
}
|
||||||
return "__assert";
|
return "__assert";
|
||||||
}
|
}
|
||||||
|
@ -180,7 +184,7 @@ static std::vector<Type *> getCAssertFunctionParamTypes() {
|
||||||
const auto voidPtr = Type::tvoidptr;
|
const auto voidPtr = Type::tvoidptr;
|
||||||
const auto uint = Type::tuns32;
|
const auto uint = Type::tuns32;
|
||||||
|
|
||||||
if (global.params.targetTriple->isOSDarwin()) {
|
if (global.params.targetTriple->isOSDarwin() || global.params.targetTriple->isOSSolaris()) {
|
||||||
return {voidPtr, voidPtr, uint, voidPtr};
|
return {voidPtr, voidPtr, uint, voidPtr};
|
||||||
}
|
}
|
||||||
if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) {
|
if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue