diff --git a/HISTORY b/HISTORY index 9f01486..86e59d5 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,7 @@ +Version 1.56 2022-01-29 + * add function fc_gettid + Version 1.55 2022-01-12 * fastcommon php extension adapt to php 8 * function fast_mblock_batch_alloc changed diff --git a/src/shared_func.h b/src/shared_func.h index a5818c7..272ade3 100644 --- a/src/shared_func.h +++ b/src/shared_func.h @@ -19,11 +19,15 @@ #include #include #include +#include #include #include #include #include #include "common_define.h" +#ifdef OS_LINUX +#include +#endif #include "fc_memory.h" #include "ini_file_reader.h" @@ -1212,6 +1216,21 @@ static inline int fc_check_realloc_iovec_array( return 0; } +static inline pid_t fc_gettid() +{ +#ifdef OS_LINUX + +#ifdef SYS_gettid + return (pid_t)syscall(SYS_gettid); +#else + return getpid(); +#endif + +#else + return getpid(); +#endif +} + #ifdef __cplusplus } #endif