diff --git a/HISTORY b/HISTORY index 5079504..3fc1b51 100644 --- a/HISTORY +++ b/HISTORY @@ -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 + * adapt to FreeBSD 13 Version 1.73 2024-03-05 * add macro FC_SET_STRING_EMPTY diff --git a/make.sh b/make.sh index b0b7f62..a4318c7 100755 --- a/make.sh +++ b/make.sh @@ -99,6 +99,7 @@ else CFLAGS="$CFLAGS -g -O3" fi +INCS='' LIBS='-lm -ldl' if [ -f /usr/include/curl/curl.h ] || [ -f /usr/local/include/curl/curl.h ]; then CFLAGS="$CFLAGS -DUSE_LIBCURL" @@ -121,6 +122,9 @@ elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then if [ "$uname" = "Darwin" ]; then CFLAGS="$CFLAGS -DDARWIN" TARGET_PREFIX=$TARGET_PREFIX/local + else + INCS="$INCS -I/usr/local/include" + LIBS="$LIBS -L/usr/local/lib" fi if [ -f /usr/include/sys/vmmeter.h ]; then @@ -247,6 +251,7 @@ sed_replace() cd src cp Makefile.in 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#\\\$(TARGET_PREFIX)#$TARGET_PREFIX#g" Makefile sed_replace "s#\\\$(LIB_VERSION)#$LIB_VERSION#g" Makefile diff --git a/src/Makefile.in b/src/Makefile.in index ada7954..2f84906 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ .SUFFIXES: .c .o .lo COMPILE = $(CC) $(CFLAGS) -INC_PATH = +INC_PATH = $(INCS) LIB_PATH = $(LIBS) TARGET_LIB = $(TARGET_PREFIX)/$(LIB_VERSION) diff --git a/src/common_define.h b/src/common_define.h index aa416c0..3ecc508 100644 --- a/src/common_define.h +++ b/src/common_define.h @@ -203,10 +203,12 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind); #define st_ctimensec st_ctim.tv_nsec #endif #elif defined(OS_FREEBSD) +#ifndef st_atimensec #define st_atimensec st_atimespec.tv_nsec #define st_mtimensec st_mtimespec.tv_nsec #define st_ctimensec st_ctimespec.tv_nsec #endif +#endif #ifdef __cplusplus extern "C" { diff --git a/src/ioevent_loop.c b/src/ioevent_loop.c index 6feb4f2..f1ba16e 100644 --- a/src/ioevent_loop.c +++ b/src/ioevent_loop.c @@ -102,7 +102,9 @@ int ioevent_loop(struct nio_thread_data *thread_data, time_t last_check_time; int save_extra_events; int count; +#ifdef OS_LINUX uint32_t sched_counter; +#endif bool sched_pull; 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 +#ifdef OS_LINUX sched_counter = 0; +#endif + thread_data->deleted_list = NULL; last_check_time = g_current_time; while (*continue_flag) diff --git a/src/shared_func.c b/src/shared_func.c index 2fbe0d1..9d47a65 100644 --- a/src/shared_func.c +++ b/src/shared_func.c @@ -2911,8 +2911,16 @@ int parseAddress(char *src, char *parts[2]) 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; - if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) != 0) + if (clock_gettime(MY_NS_CLK_ID, &ts) != 0) { logError("file: "__FILE__", line: %d, " "call clock_gettime fail, " diff --git a/src/sockopt.c b/src/sockopt.c index 82330ef..4cb59f0 100644 --- a/src/sockopt.c +++ b/src/sockopt.c @@ -2849,9 +2849,13 @@ bool tcp_socket_connected(int sock) struct tcp_info info; #else #include -#define TCP_INFO TCP_CONNECTION_INFO #define TCP_ESTABLISHED TCPS_ESTABLISHED +#ifndef TCP_INFO + #define TCP_INFO TCP_CONNECTION_INFO struct tcp_connection_info info; +#else + struct tcp_info info; +#endif #endif len = sizeof(info); diff --git a/src/system_info.c b/src/system_info.c index 75ca792..5618b89 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -72,7 +72,8 @@ int get_sys_total_mem_size(int64_t *mem_size) size_t len; mib[0] = CTL_HW; - mib[1] = HW_MEMSIZE; + //mib[1] = HW_MEMSIZE; + mib[1] = HW_PHYSMEM; len = sizeof(*mem_size); if (sysctl(mib, 2, mem_size, &len, NULL, 0) != 0) {