mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
runtime: use _strdup on Windows
Windows prefers the `_strdup` extension over `strdup`. This avoids unnecessary warnings when building the standard library.
This commit is contained in:
@@ -84,7 +84,11 @@ private:
|
|||||||
static char *getCString(char *str) { return str; }
|
static char *getCString(char *str) { return str; }
|
||||||
|
|
||||||
static char *getCString(const std::string &str) {
|
static char *getCString(const std::string &str) {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return _strdup(str.c_str());
|
||||||
|
#else
|
||||||
return strdup(str.c_str());
|
return strdup(str.c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -330,7 +330,11 @@ reportOnCrash(uint32_t flags, const char *message)
|
|||||||
if (previous)
|
if (previous)
|
||||||
swift_asprintf(¤t, "%s%s", current, message);
|
swift_asprintf(¤t, "%s%s", current, message);
|
||||||
else
|
else
|
||||||
|
#if defined(_WIN32)
|
||||||
|
current = ::_strdup(message);
|
||||||
|
#else
|
||||||
current = ::strdup(message);
|
current = ::strdup(message);
|
||||||
|
#endif
|
||||||
} while (!std::atomic_compare_exchange_strong_explicit(&kFatalErrorMessage,
|
} while (!std::atomic_compare_exchange_strong_explicit(&kFatalErrorMessage,
|
||||||
&previous,
|
&previous,
|
||||||
static_cast<const char *>(current),
|
static_cast<const char *>(current),
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ static Win32ModuleInfo moduleInfoFromAddress(const void *address) {
|
|||||||
if (pwszFileName != wszBuffer)
|
if (pwszFileName != wszBuffer)
|
||||||
::free(pwszFileName);
|
::free(pwszFileName);
|
||||||
|
|
||||||
return { ::strdup("<unknown>"), mi.lpBaseOfDll };
|
return { ::_strdup("<unknown>"), mi.lpBaseOfDll };
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *result = _swift_win32_copyUTF8FromWide(pwszFileName);
|
const char *result = _swift_win32_copyUTF8FromWide(pwszFileName);
|
||||||
@@ -125,7 +125,7 @@ static Win32ModuleInfo moduleInfoFromAddress(const void *address) {
|
|||||||
|
|
||||||
return { result, mi.lpBaseOfDll };
|
return { result, mi.lpBaseOfDll };
|
||||||
} else {
|
} else {
|
||||||
return { ::strdup("<unknown>"), nullptr };
|
return { ::_strdup("<unknown>"), nullptr };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -156,7 +156,7 @@ std::optional<SymbolInfo> SymbolInfo::lookup(const void *address) {
|
|||||||
|
|
||||||
if (bRet) {
|
if (bRet) {
|
||||||
return SymbolInfo((const void *)package.si.Address,
|
return SymbolInfo((const void *)package.si.Address,
|
||||||
::strdup(package.si.Name),
|
::_strdup(package.si.Name),
|
||||||
moduleInfo.name,
|
moduleInfo.name,
|
||||||
moduleInfo.base);
|
moduleInfo.base);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ private:
|
|||||||
|
|
||||||
void initializeFrom(const SymbolInfo &other) {
|
void initializeFrom(const SymbolInfo &other) {
|
||||||
_symbolAddress = other._symbolAddress;
|
_symbolAddress = other._symbolAddress;
|
||||||
_symbolName = ::strdup(other._symbolName);
|
_symbolName = ::_strdup(other._symbolName);
|
||||||
_moduleFileName = ::strdup(other._moduleFileName);
|
_moduleFileName = ::_strdup(other._moduleFileName);
|
||||||
_moduleBaseAddress = other._moduleBaseAddress;
|
_moduleBaseAddress = other._moduleBaseAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user