diff --git a/src/tbox/platform/windows/dns.c b/src/tbox/platform/windows/dns.c index 80c141f0e..9590c77d0 100644 --- a/src/tbox/platform/windows/dns.c +++ b/src/tbox/platform/windows/dns.c @@ -33,10 +33,8 @@ */ tb_bool_t tb_dns_init_env() { - // done - FIXED_INFO* info = tb_null; - ULONG size = 0; - tb_size_t count = 0; + FIXED_INFO* info = tb_null; + ULONG size = 0; do { // init func @@ -66,7 +64,6 @@ tb_bool_t tb_dns_init_env() // add the first dns address tb_dns_server_add(info->DnsServerList.IpAddress.String); - count++; // walk dns address IP_ADDR_STRING* addr = info->DnsServerList.Next; @@ -77,7 +74,6 @@ tb_bool_t tb_dns_init_env() // add the dns address tb_dns_server_add(addr->IpAddress.String); - count++; } } while (0); diff --git a/src/tbox/prefix/compiler.h b/src/tbox/prefix/compiler.h index 1fbc200d5..c427e512a 100644 --- a/src/tbox/prefix/compiler.h +++ b/src/tbox/prefix/compiler.h @@ -126,9 +126,9 @@ # error Unknown borland c++ Compiler Version # endif -// gnu c/c++ -#elif defined(__GNUC__) -# define TB_COMPILER_IS_GCC +// gcc or clang +#elif defined(__GNUC__) || defined(__clang__) + # if defined(__MINGW32__) || defined(__MINGW64__) # define TB_COMPILER_IS_MINGW # endif @@ -142,43 +142,23 @@ defined(TB_COMPILER_ON_MSYS) || defined(TB_COMPILER_ON_CYGWIN) # define TB_COMPILER_LIKE_UNIX # endif -# define TB_COMPILER_VERSION_BT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) > ((major) * 100 + (minor))) -# define TB_COMPILER_VERSION_BE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) >= ((major) * 100 + (minor))) -# define TB_COMPILER_VERSION_EQ(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) == ((major) * 100 + (minor))) -# define TB_COMPILER_VERSION_LT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) < ((major) * 100 + (minor))) -# define TB_COMPILER_VERSION_LE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) <= ((major) * 100 + (minor))) -# define TB_COMPILER_STRING "gnu c/c++" -# if __GNUC__ == 2 -# if __GNUC_MINOR__ < 95 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ <2.95" -# elif __GNUC_MINOR__ == 95 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.95" -# elif __GNUC_MINOR__ == 96 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.96" -# else -# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 2.96 && < 3.0" -# endif -# elif __GNUC__ == 3 -# if __GNUC_MINOR__ == 2 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.2" -# elif __GNUC_MINOR__ == 3 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.3" -# elif __GNUC_MINOR__ == 4 -# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.4" -# else -# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 3.4 && < 4.0" -# endif -# elif __GNUC__ >= 4 && defined(__GNUC_MINOR__) -# define TB_COMPILER_VERSION_STRING __tb_mstrcat4__("gnu c/c++ ", __tb_mstring_ex__(__GNUC__), ".", __tb_mstring_ex__(__GNUC_MINOR__)) -# else -# error Unknown gnu c/c++ Compiler Version + +# if defined(__clang__) +# define TB_COMPILER_IS_CLANG # endif + // we always need to be compatible with gcc style code if the current compiler is clang +# define TB_COMPILER_IS_GCC + // clang # if defined(__clang__) -# define TB_COMPILER_IS_CLANG # undef TB_COMPILER_STRING # define TB_COMPILER_STRING "clang c/c++" +# define TB_COMPILER_VERSION_BT(major, minor) ((__clang_major__ * 100 + __clang_minor__) > ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_BE(major, minor) ((__clang_major__ * 100 + __clang_minor__) >= ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_EQ(major, minor) ((__clang_major__ * 100 + __clang_minor__) == ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_LT(major, minor) ((__clang_major__ * 100 + __clang_minor__) < ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_LE(major, minor) ((__clang_major__ * 100 + __clang_minor__) <= ((major) * 100 + (minor))) # if defined(__VERSION__) # undef TB_COMPILER_VERSION_STRING # define TB_COMPILER_VERSION_STRING __VERSION__ @@ -204,6 +184,40 @@ * pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) */ # pragma clang diagnostic ignored "-Wnullability-completeness" + + // gcc +# elif defined(__GNUC__) +# define TB_COMPILER_VERSION_BT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) > ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_BE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) >= ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_EQ(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) == ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_LT(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) < ((major) * 100 + (minor))) +# define TB_COMPILER_VERSION_LE(major, minor) ((__GNUC__ * 100 + __GNUC_MINOR__) <= ((major) * 100 + (minor))) +# define TB_COMPILER_STRING "gnu c/c++" +# if __GNUC__ == 2 +# if __GNUC_MINOR__ < 95 +# define TB_COMPILER_VERSION_STRING "gnu c/c++ <2.95" +# elif __GNUC_MINOR__ == 95 +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.95" +# elif __GNUC_MINOR__ == 96 +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 2.96" +# else +# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 2.96 && < 3.0" +# endif +# elif __GNUC__ == 3 +# if __GNUC_MINOR__ == 2 +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.2" +# elif __GNUC_MINOR__ == 3 +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.3" +# elif __GNUC_MINOR__ == 4 +# define TB_COMPILER_VERSION_STRING "gnu c/c++ 3.4" +# else +# define TB_COMPILER_VERSION_STRING "gnu c/c++ > 3.4 && < 4.0" +# endif +# elif __GNUC__ >= 4 && defined(__GNUC_MINOR__) +# define TB_COMPILER_VERSION_STRING __tb_mstrcat4__("gnu c/c++ ", __tb_mstring_ex__(__GNUC__), ".", __tb_mstring_ex__(__GNUC_MINOR__)) +# else +# error Unknown gnu c/c++ Compiler Version +# endif # endif // watcom c/c++ diff --git a/src/xmake.sh b/src/xmake.sh index 6d72c1270..4234925d9 100755 --- a/src/xmake.sh +++ b/src/xmake.sh @@ -248,7 +248,7 @@ check_interfaces() { check_module_cfuncs "posix" "dlfcn.h" "dlopen" check_module_cfuncs "posix" "sys/stat.h fcntl.h" "open" "stat64" "lstat64" check_module_cfuncs "posix" "unistd.h" "gethostname" - check_module_cfuncs "posix" "ifaddrs.h" "getifaddrs" + check_module_cfuncs "posix" "ifaddrs.h net/if_dl.h" "getifaddrs" check_module_cfuncs "posix" "semaphore.h" "sem_init" check_module_cfuncs "posix" "unistd.h" "getpagesize" "sysconf" check_module_cfuncs "posix" "sched.h" "sched_yield" "sched_setaffinity" # need _GNU_SOURCE diff --git a/xmake/check_interfaces.lua b/xmake/check_interfaces.lua index c906e234d..ee4c4c51d 100644 --- a/xmake/check_interfaces.lua +++ b/xmake/check_interfaces.lua @@ -183,7 +183,7 @@ function _check_interfaces(target) _check_module_cfuncs(target, "posix", "dlfcn.h", "dlopen") _check_module_cfuncs(target, "posix", {"sys/stat.h", "fcntl.h"}, "open", "stat64", "lstat64") _check_module_cfuncs(target, "posix", "unistd.h", "gethostname") - _check_module_cfuncs(target, "posix", "ifaddrs.h", "getifaddrs") + _check_module_cfuncs(target, "posix", {"ifaddrs.h", "net/if_dl.h"}, "getifaddrs") _check_module_cfuncs(target, "posix", "unistd.h", "getpagesize", "sysconf") _check_module_cfuncs(target, "posix", "sched.h", "sched_yield", "sched_setaffinity") -- need _GNU_SOURCE _check_module_cfuncs(target, "posix", "regex.h", "regcomp", "regexec")