mirror of
https://github.com/upa/mscp.git
synced 2026-02-04 03:24:58 +08:00
make it buildable at FreeBSD
This commit is contained in:
@@ -177,7 +177,7 @@ set(CPACK_PACKAGE_DESCRIPTION
|
||||
execute_process(COMMAND uname -m
|
||||
OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(UNIX AND NOT APPLE) # on linux
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
|
||||
execute_process(COMMAND
|
||||
bash "-c" "cat /etc/os-release|grep '^ID='|cut -d '=' -f 2|tr -d '\"'"
|
||||
OUTPUT_VARIABLE DIST_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
@@ -329,7 +329,7 @@ int mscp_glob(const char *pattern, int flags, glob_t *pglob, sftp_session sftp)
|
||||
#else
|
||||
flags |= GLOB_ALTDIRFUNC;
|
||||
set_tls_sftp_session(sftp);
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
pglob->gl_opendir = (void *(*)(const char *))mscp_opendir_wrapped;
|
||||
pglob->gl_readdir = (struct dirent *(*)(void *))mscp_readdir;
|
||||
pglob->gl_closedir = (void (*)(void *))mscp_closedir;
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <sched.h>
|
||||
#include <stdlib.h>
|
||||
#elif __FreeBSD__
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread_np.h>
|
||||
#else
|
||||
#error unsupported platform
|
||||
#endif
|
||||
@@ -78,6 +82,17 @@ int nr_cpus()
|
||||
return CPU_COUNT(&cpu_set);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
int nr_cpus()
|
||||
{
|
||||
long nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
return nr_cpus;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(linux) || defined(__FreeBSD__)
|
||||
|
||||
int set_thread_affinity(pthread_t tid, int core)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user