adapt to FreeBSD 13

use_iouring
YuQing 2024-05-19 11:11:24 +08:00
parent 7f699688c0
commit fef0a4a7f3
8 changed files with 31 additions and 5 deletions

View File

@ -1,6 +1,7 @@
Version 1.74 2024-04-08 Version 1.74 2024-05-18
* add functions: get_log_level and get_log_level_caption * add functions: get_log_level and get_log_level_caption
* adapt to FreeBSD 13
Version 1.73 2024-03-05 Version 1.73 2024-03-05
* add macro FC_SET_STRING_EMPTY * add macro FC_SET_STRING_EMPTY

View File

@ -99,6 +99,7 @@ else
CFLAGS="$CFLAGS -g -O3" CFLAGS="$CFLAGS -g -O3"
fi fi
INCS=''
LIBS='-lm -ldl' LIBS='-lm -ldl'
if [ -f /usr/include/curl/curl.h ] || [ -f /usr/local/include/curl/curl.h ]; then if [ -f /usr/include/curl/curl.h ] || [ -f /usr/local/include/curl/curl.h ]; then
CFLAGS="$CFLAGS -DUSE_LIBCURL" CFLAGS="$CFLAGS -DUSE_LIBCURL"
@ -121,6 +122,9 @@ elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
if [ "$uname" = "Darwin" ]; then if [ "$uname" = "Darwin" ]; then
CFLAGS="$CFLAGS -DDARWIN" CFLAGS="$CFLAGS -DDARWIN"
TARGET_PREFIX=$TARGET_PREFIX/local TARGET_PREFIX=$TARGET_PREFIX/local
else
INCS="$INCS -I/usr/local/include"
LIBS="$LIBS -L/usr/local/lib"
fi fi
if [ -f /usr/include/sys/vmmeter.h ]; then if [ -f /usr/include/sys/vmmeter.h ]; then
@ -247,6 +251,7 @@ sed_replace()
cd src cd src
cp Makefile.in Makefile cp Makefile.in Makefile
sed_replace "s#\\\$(CFLAGS)#$CFLAGS#g" Makefile sed_replace "s#\\\$(CFLAGS)#$CFLAGS#g" Makefile
sed_replace "s#\\\$(INCS)#$INCS#g" Makefile
sed_replace "s#\\\$(LIBS)#$LIBS#g" Makefile sed_replace "s#\\\$(LIBS)#$LIBS#g" Makefile
sed_replace "s#\\\$(TARGET_PREFIX)#$TARGET_PREFIX#g" Makefile sed_replace "s#\\\$(TARGET_PREFIX)#$TARGET_PREFIX#g" Makefile
sed_replace "s#\\\$(LIB_VERSION)#$LIB_VERSION#g" Makefile sed_replace "s#\\\$(LIB_VERSION)#$LIB_VERSION#g" Makefile

View File

@ -1,7 +1,7 @@
.SUFFIXES: .c .o .lo .SUFFIXES: .c .o .lo
COMPILE = $(CC) $(CFLAGS) COMPILE = $(CC) $(CFLAGS)
INC_PATH = INC_PATH = $(INCS)
LIB_PATH = $(LIBS) LIB_PATH = $(LIBS)
TARGET_LIB = $(TARGET_PREFIX)/$(LIB_VERSION) TARGET_LIB = $(TARGET_PREFIX)/$(LIB_VERSION)

View File

@ -203,10 +203,12 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
#define st_ctimensec st_ctim.tv_nsec #define st_ctimensec st_ctim.tv_nsec
#endif #endif
#elif defined(OS_FREEBSD) #elif defined(OS_FREEBSD)
#ifndef st_atimensec
#define st_atimensec st_atimespec.tv_nsec #define st_atimensec st_atimespec.tv_nsec
#define st_mtimensec st_mtimespec.tv_nsec #define st_mtimensec st_mtimespec.tv_nsec
#define st_ctimensec st_ctimespec.tv_nsec #define st_ctimensec st_ctimespec.tv_nsec
#endif #endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -102,7 +102,9 @@ int ioevent_loop(struct nio_thread_data *thread_data,
time_t last_check_time; time_t last_check_time;
int save_extra_events; int save_extra_events;
int count; int count;
#ifdef OS_LINUX
uint32_t sched_counter; uint32_t sched_counter;
#endif
bool sched_pull; bool sched_pull;
memset(&ev_notify, 0, sizeof(ev_notify)); memset(&ev_notify, 0, sizeof(ev_notify));
@ -123,7 +125,10 @@ int ioevent_loop(struct nio_thread_data *thread_data,
} }
thread_data->ev_puller.extra_events = save_extra_events; //restore thread_data->ev_puller.extra_events = save_extra_events; //restore
#ifdef OS_LINUX
sched_counter = 0; sched_counter = 0;
#endif
thread_data->deleted_list = NULL; thread_data->deleted_list = NULL;
last_check_time = g_current_time; last_check_time = g_current_time;
while (*continue_flag) while (*continue_flag)

View File

@ -2911,8 +2911,16 @@ int parseAddress(char *src, char *parts[2])
int64_t get_current_time_ns() int64_t get_current_time_ns()
{ {
#ifdef CLOCK_MONOTONIC_RAW
#define MY_NS_CLK_ID CLOCK_MONOTONIC_RAW
#elif defined(CLOCK_MONOTONIC_PRECISE)
#define MY_NS_CLK_ID CLOCK_MONOTONIC_PRECISE
#else
#define MY_NS_CLK_ID CLOCK_MONOTONIC
#endif
struct timespec ts; struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) != 0) if (clock_gettime(MY_NS_CLK_ID, &ts) != 0)
{ {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "
"call clock_gettime fail, " "call clock_gettime fail, "

View File

@ -2849,9 +2849,13 @@ bool tcp_socket_connected(int sock)
struct tcp_info info; struct tcp_info info;
#else #else
#include <netinet/tcp_fsm.h> #include <netinet/tcp_fsm.h>
#define TCP_INFO TCP_CONNECTION_INFO
#define TCP_ESTABLISHED TCPS_ESTABLISHED #define TCP_ESTABLISHED TCPS_ESTABLISHED
#ifndef TCP_INFO
#define TCP_INFO TCP_CONNECTION_INFO
struct tcp_connection_info info; struct tcp_connection_info info;
#else
struct tcp_info info;
#endif
#endif #endif
len = sizeof(info); len = sizeof(info);

View File

@ -72,7 +72,8 @@ int get_sys_total_mem_size(int64_t *mem_size)
size_t len; size_t len;
mib[0] = CTL_HW; mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE; //mib[1] = HW_MEMSIZE;
mib[1] = HW_PHYSMEM;
len = sizeof(*mem_size); len = sizeof(*mem_size);
if (sysctl(mib, 2, mem_size, &len, NULL, 0) != 0) if (sysctl(mib, 2, mem_size, &len, NULL, 0) != 0)
{ {