From 4ae9c8f55fcc5df886516ad9c7164191371f82db Mon Sep 17 00:00:00 2001 From: yuqing Date: Tue, 31 Jul 2018 14:27:13 +0800 Subject: [PATCH] add function fc_compare_string --- src/Makefile.in | 2 +- src/common_define.h | 15 +++++++++++++++ src/fast_task_queue.c | 2 -- src/fast_task_queue.h | 2 ++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Makefile.in b/src/Makefile.in index c8b4e61..8a471ec 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -37,7 +37,7 @@ HEADER_FILES = common_define.h hash.h chain.h logger.h base64.h \ skiplist_common.h system_info.h fast_blocked_queue.h \ php7_ext_wrapper.h id_generator.h char_converter.h \ char_convert_loader.h common_blocked_queue.h \ - multi_socket_client.h skiplist_set.h + multi_socket_client.h skiplist_set.h fc_list.h ALL_OBJS = $(FAST_STATIC_OBJS) $(FAST_SHARED_OBJS) diff --git a/src/common_define.h b/src/common_define.h index afecb7e..b7a849b 100644 --- a/src/common_define.h +++ b/src/common_define.h @@ -12,6 +12,7 @@ #define _COMMON_DEFINE_H_ #include +#include #include #ifdef WIN32 @@ -206,6 +207,20 @@ typedef void* (*MallocFunc)(size_t size); #define __gcc_attribute__(x) #endif +static inline int fc_compare_string(const string_t *s1, const string_t *s2) +{ + int result; + if (s1->len == s2->len) { + return memcmp(s1->str, s2->str, s1->len); + } else if (s1->len < s2->len) { + result = memcmp(s1->str, s2->str, s1->len); + return result == 0 ? -1 : result; + } else { + result = memcmp(s1->str, s2->str, s2->len); + return result == 0 ? 1 : result; + } +} + #ifdef __cplusplus } #endif diff --git a/src/fast_task_queue.c b/src/fast_task_queue.c index 6942ad2..63940ee 100644 --- a/src/fast_task_queue.c +++ b/src/fast_task_queue.c @@ -24,8 +24,6 @@ struct mpool_chain { static struct mpool_chain g_mpool = {NULL, NULL}; -#define ALIGNED_TASK_INFO_SIZE MEM_ALIGN(sizeof(struct fast_task_info)) - int task_queue_init(struct fast_task_queue *pQueue) { int result; diff --git a/src/fast_task_queue.h b/src/fast_task_queue.h index c5ca8e6..dac9b9d 100644 --- a/src/fast_task_queue.h +++ b/src/fast_task_queue.h @@ -19,6 +19,8 @@ #include "ioevent.h" #include "fast_timer.h" +#define ALIGNED_TASK_INFO_SIZE MEM_ALIGN(sizeof(struct fast_task_info)) + struct nio_thread_data; struct fast_task_info;