mirror of https://github.com/x64dbg/zydis
Some FreeBSD fixes for examples and including Zydis in shared/static libraries
This commit is contained in:
parent
51686517c4
commit
9f0eae62c1
|
@ -73,6 +73,9 @@ function (_set_common_flags target)
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
target_compile_options("${target}" PRIVATE "-std=c99")
|
target_compile_options("${target}" PRIVATE "-std=c99")
|
||||||
endif ()
|
endif ()
|
||||||
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||||
|
target_compile_options("${target}" PRIVATE "-fPIC")
|
||||||
|
endif ()
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
add_library("Zydis")
|
add_library("Zydis")
|
||||||
|
@ -210,6 +213,10 @@ if (ZYDIS_BUILD_EXAMPLES)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries("ZydisPerfTest" Threads::Threads)
|
target_link_libraries("ZydisPerfTest" Threads::Threads)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
target_link_libraries("ZydisPerfTest" Threads::Threads)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,10 @@
|
||||||
#elif defined(ZYDIS_LINUX)
|
#elif defined(ZYDIS_LINUX)
|
||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
|
#elif defined(ZYDIS_FREEBSD)
|
||||||
|
# include <sys/time.h>
|
||||||
|
# include <pthread.h>
|
||||||
|
# include <pthread_np.h>
|
||||||
#else
|
#else
|
||||||
# error "Unsupported platform detected"
|
# error "Unsupported platform detected"
|
||||||
#endif
|
#endif
|
||||||
|
@ -95,7 +99,7 @@ double GetCounter()
|
||||||
|
|
||||||
return (double)elapsed * timebaseInfo.numer / timebaseInfo.denom / 1000000;
|
return (double)elapsed * timebaseInfo.numer / timebaseInfo.denom / 1000000;
|
||||||
}
|
}
|
||||||
#elif defined(ZYDIS_LINUX)
|
#elif defined(ZYDIS_LINUX) || defined(ZYDIS_FREEBSD)
|
||||||
struct timeval t1;
|
struct timeval t1;
|
||||||
|
|
||||||
void StartCounter()
|
void StartCounter()
|
||||||
|
@ -138,12 +142,18 @@ void adjustProcessAndThreadPriority()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef ZYDIS_LINUX
|
#if defined(ZYDIS_LINUX)
|
||||||
pthread_t thread = pthread_self();
|
pthread_t thread = pthread_self();
|
||||||
cpu_set_t cpus;
|
cpu_set_t cpus;
|
||||||
CPU_ZERO(&cpus);
|
CPU_ZERO(&cpus);
|
||||||
CPU_SET(0, &cpus);
|
CPU_SET(0, &cpus);
|
||||||
pthread_setaffinity_np(thread, sizeof(cpus), &cpus);
|
pthread_setaffinity_np(thread, sizeof(cpus), &cpus);
|
||||||
|
#elif defined(ZYDIS_FREEBSD)
|
||||||
|
pthread_t thread = pthread_self();
|
||||||
|
cpuset_t cpus;
|
||||||
|
CPU_ZERO(&cpus);
|
||||||
|
CPU_SET(0, &cpus);
|
||||||
|
pthread_setaffinity_np(thread, sizeof(cpus), &cpus);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,9 @@
|
||||||
#elif defined(__linux)
|
#elif defined(__linux)
|
||||||
# define ZYDIS_LINUX
|
# define ZYDIS_LINUX
|
||||||
# define ZYDIS_POSIX
|
# define ZYDIS_POSIX
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
# define ZYDIS_FREEBSD
|
||||||
|
# define ZYDIS_POSIX
|
||||||
#elif defined(__unix)
|
#elif defined(__unix)
|
||||||
# define ZYDIS_UNIX
|
# define ZYDIS_UNIX
|
||||||
# define ZYDIS_POSIX
|
# define ZYDIS_POSIX
|
||||||
|
|
Loading…
Reference in New Issue