From cbdddcca4d9720fb13deea4e88060a15736feb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?shuxin=20=E3=80=80=E3=80=80zheng?= Date: Thu, 16 Sep 2021 15:17:40 +0800 Subject: [PATCH] optimize fiber for windows platform --- lib_fiber/c/src/common/msg.h | 15 ++++++++------- lib_fiber/c/src/dns/resolver.c | 2 ++ lib_fiber/c/src/dns/rfc1035.c | 2 ++ lib_fiber/c/src/hook/getaddrinfo.c | 4 ++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib_fiber/c/src/common/msg.h b/lib_fiber/c/src/common/msg.h index c1743dba8..a51eb2aae 100644 --- a/lib_fiber/c/src/common/msg.h +++ b/lib_fiber/c/src/common/msg.h @@ -7,6 +7,7 @@ extern "C" { #include #include +#include "fiber/fiber_define.h" #include "define.h" #undef USE_PRINTF_MACRO @@ -22,28 +23,28 @@ extern "C" { * @param fmt {const char*} 参数格式 * @param ... 变参序列 */ -void PRINTF(1, 2) msg_info(const char *fmt,...); +FIBER_API void PRINTF(1, 2) msg_info(const char *fmt,...); /** * 警告级别日志信息记录函数 * @param fmt {const char*} 参数格式 * @param ... 变参序列 */ -void PRINTF(1, 2) msg_warn(const char *fmt,...); +FIBER_API void PRINTF(1, 2) msg_warn(const char *fmt,...); /** * 错误级别日志信息记录函数 * @param fmt {const char*} 参数格式 * @param ... 变参序列 */ -void PRINTF(1, 2) msg_error(const char *fmt,...); +FIBER_API void PRINTF(1, 2) msg_error(const char *fmt,...); /** * 致命级别日志信息记录函数 * @param fmt {const char*} 参数格式 * @param ... 变参序列 */ -void PRINTF(1, 2) msg_fatal(const char *fmt,...); +FIBER_API void PRINTF(1, 2) msg_fatal(const char *fmt,...); #else @@ -71,21 +72,21 @@ void PRINTF(1, 2) msg_fatal(const char *fmt,...); * @param size {size_t} buffer 的空间大小 * @return {const char*} 返回的地址应与 buffer 相同 */ -const char *last_strerror(char *buffer, size_t size); +FIBER_API const char *last_strerror(char *buffer, size_t size); /** * 获得上次系统调用出错时的错误描述信息,该函数内部采用了线程局部变量,所以是 * 线程安全的,但使用起来更简单些 * @return {const char *} 返回错误提示信息 */ -const char *last_serror(void); +FIBER_API const char *last_serror(void); /** * 输出信息至标准输出 * @param fmt {const char*} 格式参数 * @param ... 变参序列 */ -void PRINTF(1, 2) msg_printf(const char *fmt,...); +FIBER_API void PRINTF(1, 2) msg_printf(const char *fmt,...); #ifdef __cplusplus } diff --git a/lib_fiber/c/src/dns/resolver.c b/lib_fiber/c/src/dns/resolver.c index 08871c2ed..8c8e6288f 100644 --- a/lib_fiber/c/src/dns/resolver.c +++ b/lib_fiber/c/src/dns/resolver.c @@ -5,6 +5,8 @@ #ifndef SYS_UNIX #include "common/pthread_patch.h" +#elif defined(SYS_WIN) +#pragma comment(lib, "Iphlpapi.lib") #endif #include "common/msg.h" diff --git a/lib_fiber/c/src/dns/rfc1035.c b/lib_fiber/c/src/dns/rfc1035.c index 045a1dfaa..1dcbdfb14 100644 --- a/lib_fiber/c/src/dns/rfc1035.c +++ b/lib_fiber/c/src/dns/rfc1035.c @@ -4,6 +4,8 @@ #include #include #include +#elif defined(SYS_WIN) +#pragma comment(lib, "Iphlpapi.lib") #endif #include diff --git a/lib_fiber/c/src/hook/getaddrinfo.c b/lib_fiber/c/src/hook/getaddrinfo.c index 4125f8ef0..f4aad5a97 100644 --- a/lib_fiber/c/src/hook/getaddrinfo.c +++ b/lib_fiber/c/src/hook/getaddrinfo.c @@ -5,6 +5,10 @@ #include "fiber.h" #include "hook.h" +#if defined(SYS_WIN) +#pragma comment(lib, "Iphlpapi.lib") +#endif + static struct addrinfo *create_addrinfo(const char *ip, short port, int iptype, int socktype, int flags) {