diff --git a/core/mount.c b/core/mount.c index cafe4a7c..aad58e25 100644 --- a/core/mount.c +++ b/core/mount.c @@ -103,7 +103,7 @@ uint64_t uwsgi_mount_flag(char *mflag) { } int uwsgi_mount(char *fs, char *what, char *where, char *flags) { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) struct iovec iov[6]; #endif unsigned long mountflags = 0; @@ -122,7 +122,7 @@ int uwsgi_mount(char *fs, char *what, char *where, char *flags) { parsed: #ifdef __linux__ return mount(what, where, fs, mountflags, NULL); -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) iov[0].iov_base = "fstype"; iov[0].iov_len = 7; iov[1].iov_base = fs; @@ -190,7 +190,7 @@ unmountable: free(slashed); } return umount2(where, mountflags); -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) return unmount(where, mountflags); #endif return -1; diff --git a/core/offload.c b/core/offload.c index e3a663e6..7e52c6f2 100644 --- a/core/offload.c +++ b/core/offload.c @@ -323,7 +323,7 @@ static int u_offload_sendfile_do(struct uwsgi_thread *ut, struct uwsgi_offload_r if (event_queue_add_fd_write(ut->queue, uor->fd2)) return -1; return 0; } -#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD_kernel__) +#if defined(__linux__) || defined(__sun__) || defined(__GNU_kFreeBSD__) ssize_t len = sendfile(uor->fd2, uor->fd, &uor->pos, 128 * 1024); if (len > 0) { uor->written += len; diff --git a/core/sendfile.c b/core/sendfile.c index 2299d40d..9dd11eff 100644 --- a/core/sendfile.c +++ b/core/sendfile.c @@ -20,7 +20,7 @@ ssize_t uwsgi_sendfile_do(int sockfd, int filefd, size_t pos, size_t len) { int sf_ret = sendfile(filefd, sockfd, pos, &sf_len, NULL, 0); if (sf_ret == 0 || (sf_ret == -1 && errno == EAGAIN)) return sf_len; return -1; -#elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD_kernel__) +#elif defined(__linux__) || defined(__sun__) || defined(__GNU_kFreeBSD__) off_t off = pos; return sendfile(sockfd, filefd, &off, len); #endif diff --git a/core/utils.c b/core/utils.c index 9fa190e8..54505c83 100644 --- a/core/utils.c +++ b/core/utils.c @@ -366,7 +366,7 @@ void uwsgi_as_root() { #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) if (uwsgi.jail && !uwsgi.reloads) { struct jail ujail; @@ -2644,7 +2644,7 @@ char *uwsgi_get_binary_path(char *argvzero) { return newbuf; } } -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) char *buf = uwsgi_malloc(uwsgi.page_size); size_t len = uwsgi.page_size; int mib[4]; @@ -3055,7 +3055,7 @@ void uwsgi_set_processname(char *name) { // end with \0 memset(uwsgi.orig_argv[0] + amount + 1 + (uwsgi.max_procname - (amount)), '\0', 1); -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) +#elif defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) || defined(__NetBSD__) if (uwsgi.procname_prefix) { if (!uwsgi.procname_append) { setproctitle("-%s%s", uwsgi.procname_prefix, name); @@ -3455,12 +3455,12 @@ void uwsgi_set_cpu_affinity() { exit(1); } pos += ret; -#if defined(__linux__) || defined(__FreeBSD_kernel__) +#if defined(__linux__) || defined(__GNU_kFreeBSD__) cpu_set_t cpuset; #elif defined(__FreeBSD__) cpuset_t cpuset; #endif -#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) CPU_ZERO(&cpuset); int i; for (i = 0; i < uwsgi.cpu_affinity; i++) { @@ -3476,7 +3476,7 @@ void uwsgi_set_cpu_affinity() { base_cpu++; } #endif -#if defined(__linux__) || defined(__FreeBSD_kernel__) +#if defined(__linux__) || defined(__GNU_kFreeBSD__) if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) { uwsgi_error("sched_setaffinity()"); } diff --git a/core/uwsgi.c b/core/uwsgi.c index 607a2417..49d84eb0 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -324,7 +324,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"unshare", required_argument, 0, "unshare() part of the processes and put it in a new namespace", uwsgi_opt_set_unshare, &uwsgi.unshare, 0}, {"unshare2", required_argument, 0, "unshare() part of the processes and put it in a new namespace after rootfs change", uwsgi_opt_set_unshare, &uwsgi.unshare2, 0}, #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) {"jail", required_argument, 0, "put the instance in a FreeBSD jail", uwsgi_opt_set_str, &uwsgi.jail, 0}, {"jail-ip4", required_argument, 0, "add an ipv4 address to the FreeBSD jail", uwsgi_opt_add_string_list, &uwsgi.jail_ip4, 0}, {"jail-ip6", required_argument, 0, "add an ipv6 address to the FreeBSD jail", uwsgi_opt_add_string_list, &uwsgi.jail_ip6, 0}, diff --git a/plugins/forkptyrouter/forkptyrouter.c b/plugins/forkptyrouter/forkptyrouter.c index 69f37d42..db448ec3 100644 --- a/plugins/forkptyrouter/forkptyrouter.c +++ b/plugins/forkptyrouter/forkptyrouter.c @@ -16,7 +16,7 @@ extern struct uwsgi_server uwsgi; -#if defined(__linux__) || defined(__FreeBSD_kernel__) +#if defined(__linux__) || defined(__GNU_kFreeBSD__) #include #elif defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) #include diff --git a/plugins/pty/pty.c b/plugins/pty/pty.c index 118d3291..9cae5b21 100644 --- a/plugins/pty/pty.c +++ b/plugins/pty/pty.c @@ -1,5 +1,5 @@ #include -#if defined(__linux__) || defined(__FreeBSD_kernel__) +#if defined(__linux__) || defined(__GNU_kFreeBSD__) #include #elif defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) #include diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 0b5921b7..8c266b6c 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -314,7 +314,7 @@ realstuff: // this time we use this higher level function // as this code can be executed in a signal handler -#ifdef __FreeBSD_kernel__ +#ifdef __GNU_kFreeBSD__ return; #endif diff --git a/uwsgi.h b/uwsgi.h index 3b8c7ceb..922c8953 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -195,11 +195,11 @@ extern "C" { #endif #include -#if defined(__FreeBSD_kernel__) +#if defined(__GNU_kFreeBSD__) #include #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) #include #include #include @@ -239,7 +239,7 @@ extern "C" { #include #endif -#if defined(__linux) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__linux) || defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) #include #endif @@ -310,7 +310,7 @@ extern int pivot_root(const char *new_root, const char *put_old); #ifdef __linux__ #include #include -#elif defined(__FreeBSD_kernel__) +#elif defined(__GNU_kFreeBSD__) #include #include #elif defined(__sun__) @@ -1890,7 +1890,7 @@ struct uwsgi_server { #endif char *emperor_wrapper; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) char *jail; struct uwsgi_string_list *jail_ip4; #ifdef AF_INET6 diff --git a/uwsgiconfig.py b/uwsgiconfig.py index ca560da4..57d4219c 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -627,6 +627,7 @@ class uConf(object): if uwsgi_os in ('Linux', 'GNU', 'GNU/kFreeBSD'): self.libs.append('-ldl') if uwsgi_os == 'GNU/kFreeBSD': + self.cflags.append('-d__GNU_kFreeBSD__') self.libs.append('-lbsd') # check for inherit option