Skip to content

Commit

Permalink
improve to check ifaddrs for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 24, 2024
1 parent cf97d35 commit cb91a14
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tbox/platform/ifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ static tb_ifaddrs_interface_ref_t tb_ifaddrs_interface_find(tb_iterator_ref_t it
#ifdef TB_CONFIG_OS_WINDOWS
# include "windows/ifaddrs.c"
#elif defined(TB_CONFIG_POSIX_HAVE_GETIFADDRS) && !defined(TB_CONFIG_OS_WEB)
# if defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_ANDROID)
# if defined(TB_CONFIG_LINUX_HAVE_IFADDRS) || defined(TB_CONFIG_OS_ANDROID)
# include "linux/ifaddrs.c"
# else
# include "posix/ifaddrs.c"
# endif
#elif defined(TB_CONFIG_OS_LINUX) || defined(TB_CONFIG_OS_ANDROID)
#elif defined(TB_CONFIG_LINUX_HAVE_IFADDRS) || defined(TB_CONFIG_OS_ANDROID)
# include "linux/ifaddrs2.c"
#else
tb_ifaddrs_ref_t tb_ifaddrs_init()
Expand Down
1 change: 1 addition & 0 deletions src/tbox/tbox.config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ ${define TB_CONFIG_SYSTEMV_HAVE_SEMTIMEDOP}

// linux functions
${define TB_CONFIG_LINUX_HAVE_INOTIFY_INIT}
${define TB_CONFIG_LINUX_HAVE_IFADDRS}

// valgrind functions
${define TB_CONFIG_VALGRIND_HAVE_VALGRIND_STACK_REGISTER}
Expand Down
3 changes: 3 additions & 0 deletions src/xmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ check_interfaces() {

# add the interfaces for linux
check_module_cfuncs "linux" "sys/inotify.h" "inotify_init"
check_module_csnippets "linux_ifaddrs" "TB_CONFIG_LINUX_HAVE_IFADDRS" \
"#include <linux/if.h>\n
#include <linux/netlink.h>"

# add the interfaces for sigsetjmp
check_module_csnippets "libc_sigsetjmp" "TB_CONFIG_LIBC_HAVE_SIGSETJMP" \
Expand Down
1 change: 1 addition & 0 deletions xmake/check_interfaces.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ function _check_interfaces(target)
-- add the interfaces for linux
if target:is_plat("linux", "android") then
_check_module_cfuncs(target, "linux", {"sys/inotify.h"}, "inotify_init")
_check_keyword_csnippet(target, "linux_ifaddrs", "TB_CONFIG_LINUX_HAVE_IFADDRS", "#include <linux/if.h>\n#include <linux/netlink.h>")
end

-- add the interfaces for valgrind
Expand Down

0 comments on commit cb91a14

Please sign in to comment.