diff --git a/common/test/test_alog.cpp b/common/test/test_alog.cpp index 32001f7e..bf0f6fbb 100644 --- a/common/test/test_alog.cpp +++ b/common/test/test_alog.cpp @@ -39,7 +39,7 @@ class LogOutputTest : public ILogOutput { } const char* log_start() const { auto ls = _log_buf; - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) ls = strchr(ls, '|') + 1; ls = strchr(ls, ':') + 1; return ls; @@ -493,7 +493,7 @@ void testnull_func() { } void segfault() { - char *pc = nullptr; + volatile char *pc = nullptr; *pc = 'w'; //this must trigger sigfault } @@ -522,21 +522,21 @@ TEST(ALog, LOG_LIMIT) { auto x = 0; for (int i=0; i< 1000000;i++) { // every 60 secs print only once - LOG_EVERY_T(60, LOG_INFO("LOG once every 60 second ...", x++)); + LOG_EVERY_T(60, LOG_INFO("LOG once every 60 second ...", x++)); } // suppose to print and evaluate 1 times EXPECT_EQ(1, x); x = 0; for (int i=0; i< 1000000;i++) { // every 100`000 times logs only only once - LOG_EVERY_N(100000, LOG_INFO("LOG once every 100000 logs ...", x++)); + LOG_EVERY_N(100000, LOG_INFO("LOG once every 100000 logs ...", x++)); } // suppose to print and evaluate 1`000`000 / 100`000 = 10 times EXPECT_EQ(10, x); x = 0; for (int i=0; i< 1000000;i++) { // logs only 10 records. - LOG_FIRST_N(10, LOG_INFO("LOG first 10 logs ...", x++)); + LOG_FIRST_N(10, LOG_INFO("LOG first 10 logs ...", x++)); } // suppose to print and evaluate 10 times EXPECT_EQ(10, x); diff --git a/include/arpa/inet.h b/third_party/include/arpa/inet.h similarity index 100% rename from include/arpa/inet.h rename to third_party/include/arpa/inet.h diff --git a/include/netinet/in.h b/third_party/include/netinet/in.h similarity index 100% rename from include/netinet/in.h rename to third_party/include/netinet/in.h diff --git a/include/netinet/ip.h b/third_party/include/netinet/ip.h similarity index 100% rename from include/netinet/ip.h rename to third_party/include/netinet/ip.h diff --git a/include/sys/socket.h b/third_party/include/sys/socket.h similarity index 100% rename from include/sys/socket.h rename to third_party/include/sys/socket.h diff --git a/include/sys/uio.h b/third_party/include/sys/uio.h similarity index 100% rename from include/sys/uio.h rename to third_party/include/sys/uio.h diff --git a/thread/test/build-test.sh b/thread/test/build-test.sh new file mode 100644 index 00000000..b3789935 --- /dev/null +++ b/thread/test/build-test.sh @@ -0,0 +1,4 @@ +g++ -std=c++17 -I ../../include/ -I../../third_party/include -DThreadUT test.cpp x.cpp \ + ../thread-pool.cpp ../workerpool.cpp ../thread-key.cpp \ + ../../common/identity-pool.cpp ../../common/alog.cpp -lgtest -lgflags -O2 + diff --git a/thread/thread11.h b/thread/thread11.h index bb9d7b27..bf2a1e99 100644 --- a/thread/thread11.h +++ b/thread/thread11.h @@ -45,10 +45,9 @@ namespace photon { return th; } - template + template struct FunctorWrapper { typename std::decay::type _obj; - template __attribute__((always_inline)) void operator()(ARGUMENTS&&...args) { _obj(std::forward(args)...); @@ -103,7 +102,7 @@ namespace photon { template inline _ENABLE_IF((is_functor::value)) thread_create11(uint64_t stack_size, FUNCTOR&& f, ARGUMENTS&&...args) { - using Wrapper = FunctorWrapper; + using Wrapper = FunctorWrapper; using SavedArgs = std::tuple::type ...>; return __thread_create11( stack_size, Wrapper{std::forward(f)},