mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 06:03:23 +00:00
Add "#ifdef __FreeBSD__"
This commit is contained in:
parent
145c685de0
commit
e3575a86c5
5 changed files with 52 additions and 9 deletions
|
@ -46,10 +46,15 @@
|
|||
# include <unistd.h>
|
||||
# include <dirent.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
# include <sys/stat.h>
|
||||
# include <glob.h>
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -72,7 +77,7 @@ std::vector<void*> memhasher_store;
|
|||
|
||||
void memhasher_on()
|
||||
{
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
memhasher_rng += time(NULL) << 16 ^ getpid();
|
||||
#endif
|
||||
memhasher_store.resize(0x10000);
|
||||
|
@ -667,6 +672,26 @@ std::string proc_self_dirname()
|
|||
buflen--;
|
||||
return std::string(path, buflen);
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
std::string proc_self_dirname()
|
||||
{
|
||||
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
||||
size_t buflen;
|
||||
char *buffer;
|
||||
std::string path;
|
||||
if (sysctl(mib, 4, NULL, &buflen, NULL, 0) != 0)
|
||||
log_error("sysctl failed: %s\n", strerror(errno));
|
||||
buffer = (char*)malloc(buflen);
|
||||
if (buffer == NULL)
|
||||
log_error("malloc failed: %s\n", strerror(errno));
|
||||
if (sysctl(mib, 4, buffer, &buflen, NULL, 0) != 0)
|
||||
log_error("sysctl failed: %s\n", strerror(errno));
|
||||
while (buflen > 0 && buffer[buflen-1] != '/')
|
||||
buflen--;
|
||||
path.assign(buffer, buflen);
|
||||
free(buffer);
|
||||
return path;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
std::string proc_self_dirname()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue