mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-30 21:57:47 +00:00
Fix Windows portability issues that break MSVC build.
This commit is contained in:
parent
f284ec9382
commit
0cedcef6a1
3 changed files with 7 additions and 20 deletions
12
kernel/io.cc
12
kernel/io.cc
|
|
@ -155,19 +155,13 @@ std::string get_base_tmpdir()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# ifdef __MINGW32__
|
|
||||||
char longpath[MAX_PATH + 1];
|
char longpath[MAX_PATH + 1];
|
||||||
char shortpath[MAX_PATH + 1];
|
char shortpath[MAX_PATH + 1];
|
||||||
# else
|
if (!GetTempPathA(MAX_PATH+1, longpath))
|
||||||
WCHAR longpath[MAX_PATH + 1];
|
|
||||||
TCHAR shortpath[MAX_PATH + 1];
|
|
||||||
# endif
|
|
||||||
if (!GetTempPath(MAX_PATH+1, longpath))
|
|
||||||
log_error("GetTempPath() failed.\n");
|
log_error("GetTempPath() failed.\n");
|
||||||
if (!GetShortPathName(longpath, shortpath, MAX_PATH + 1))
|
if (!GetShortPathNameA(longpath, shortpath, MAX_PATH + 1))
|
||||||
log_error("GetShortPathName() failed.\n");
|
log_error("GetShortPathName() failed.\n");
|
||||||
for (int i = 0; shortpath[i]; i++)
|
tmpdir += shortpath;
|
||||||
tmpdir += char(shortpath[i]);
|
|
||||||
#else
|
#else
|
||||||
char * var = std::getenv("TMPDIR");
|
char * var = std::getenv("TMPDIR");
|
||||||
if (var && strlen(var)!=0) {
|
if (var && strlen(var)!=0) {
|
||||||
|
|
|
||||||
|
|
@ -537,25 +537,17 @@ std::string proc_self_dirname()
|
||||||
std::string proc_self_dirname()
|
std::string proc_self_dirname()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
# ifdef __MINGW32__
|
|
||||||
char longpath[MAX_PATH + 1];
|
char longpath[MAX_PATH + 1];
|
||||||
char shortpath[MAX_PATH + 1];
|
char shortpath[MAX_PATH + 1];
|
||||||
# else
|
if (!GetModuleFileNameA(0, longpath, MAX_PATH+1))
|
||||||
WCHAR longpath[MAX_PATH + 1];
|
|
||||||
TCHAR shortpath[MAX_PATH + 1];
|
|
||||||
# endif
|
|
||||||
if (!GetModuleFileName(0, longpath, MAX_PATH+1))
|
|
||||||
log_error("GetModuleFileName() failed.\n");
|
log_error("GetModuleFileName() failed.\n");
|
||||||
if (!GetShortPathName(longpath, shortpath, MAX_PATH+1))
|
if (!GetShortPathNameA(longpath, shortpath, MAX_PATH+1))
|
||||||
log_error("GetShortPathName() failed.\n");
|
log_error("GetShortPathName() failed.\n");
|
||||||
while (shortpath[i] != 0)
|
while (shortpath[i] != 0)
|
||||||
i++;
|
i++;
|
||||||
while (i > 0 && shortpath[i-1] != '/' && shortpath[i-1] != '\\')
|
while (i > 0 && shortpath[i-1] != '/' && shortpath[i-1] != '\\')
|
||||||
shortpath[--i] = 0;
|
shortpath[--i] = 0;
|
||||||
std::string path;
|
return shortpath;
|
||||||
for (i = 0; shortpath[i]; i++)
|
|
||||||
path += char(shortpath[i]);
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
#elif defined(EMSCRIPTEN) || defined(__wasm)
|
#elif defined(EMSCRIPTEN) || defined(__wasm)
|
||||||
std::string proc_self_dirname()
|
std::string proc_self_dirname()
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ typedef ULONG ULONG_PTR;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/* https://docs.microsoft.com/en-us/cpp/intrinsics/returnaddress */
|
/* https://docs.microsoft.com/en-us/cpp/intrinsics/returnaddress */
|
||||||
|
extern "C" void * _ReturnAddress(void);
|
||||||
#pragma intrinsic( _ReturnAddress )
|
#pragma intrinsic( _ReturnAddress )
|
||||||
#else
|
#else
|
||||||
/* https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html */
|
/* https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue