Skip to content

Commit

Permalink
Fix compile in gcc492, ignore some designed warning with diagnostic p…
Browse files Browse the repository at this point in the history
…ragma

Signed-off-by: Coldwings <[email protected]>
  • Loading branch information
Coldwings committed Feb 29, 2024
1 parent 9caa491 commit 1996912
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_BUILD_PARALLEL_LEVEL ${NumCPU})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-packed-bitfield-compat")

if (${ARCH} STREQUAL x86_64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
elseif (${ARCH} STREQUAL aarch64)
Expand Down
13 changes: 7 additions & 6 deletions common/alog.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ struct Prologue
int len_func, len_file;
int line, level;

template <size_t N, typename FILEN>
constexpr Prologue(const char (&addr_func_)[N], FILEN addr_file_, int line_,
int level_)
template <size_t N, size_t M>
constexpr Prologue(const char (&addr_func_)[N], const char (&addr_file_)[M],
int line_, int level_)
: addr_func(addr_func_),
addr_file(addr_file_.chars),
addr_file(addr_file_),
len_func(N - 1),
len_file(addr_file_.len),
len_file(M - 1),
line(line_),
level(level_) {}
};
Expand Down Expand Up @@ -456,7 +456,8 @@ struct LogBuilder {
auto _partial_file = \
ConstString::TSpliter<'/', ' ', \
decltype(_prologue_file_r)>::Current::reverse(); \
constexpr static Prologue prolog(__func__, _partial_file, __LINE__, level);
constexpr static Prologue prolog(__func__, _partial_file.chars, __LINE__, \
level);

#define _IS_LITERAL_STRING(x) \
(sizeof(#x) > 2 && (#x[0] == '"') && (#x[sizeof(#x) - 2] == '"'))
Expand Down
1 change: 0 additions & 1 deletion examples/perf/net-perf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ DEFINE_uint64(port, 9527, "port");
DEFINE_uint64(buf_size, 512, "buffer size");
DEFINE_uint64(vcpu_num, 1, "server vcpu num. Increase this value to enable multi-vcpu scheduling");

static int event_engine = 0;
static bool stop_test = false;
static uint64_t qps = 0;
static uint64_t time_cost = 0;
Expand Down
4 changes: 2 additions & 2 deletions net/http/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class ClientImpl : public Client {
CommonHeaders<> m_common_headers;
ICookieJar *m_cookie_jar;
ClientImpl(ICookieJar *cookie_jar, TLSContext *tls_ctx) :
m_cookie_jar(cookie_jar),
m_dialer(tls_ctx) {
m_dialer(tls_ctx),
m_cookie_jar(cookie_jar) {
}

using SocketStream_ptr = std::unique_ptr<ISocketStream>;
Expand Down
3 changes: 3 additions & 0 deletions net/http/headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ HeadersBase::KV* HeadersBase::kv_add_sort(KV kv) {
if ((char*)(begin - 1) <= m_buf + m_buf_size)
LOG_ERROR_RETURN(ENOBUFS, nullptr, "no buffer");
auto it = std::lower_bound(begin, kv_end(), kv, HA(this));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
memmove(begin - 1, begin, sizeof(KV) * (it - begin));
#pragma GCC diagnostic pop
m_kv_size++;
*(it - 1) = kv;
return it - 1;
Expand Down
3 changes: 3 additions & 0 deletions net/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ inline __attribute__((always_inline)) void base64_translate_3to4(const char *in,
static const unsigned char tbl[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
auto v = htonl(*(uint32_t *)in);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
auto x = *(xlator *)(&v);
#pragma GCC diagnostic pop
*(uint32_t *)out = ((tbl[x.a] << 24) + (tbl[x.b] << 16) +
(tbl[x.c] << 8) + (tbl[x.d] << 0));
}
Expand Down
3 changes: 3 additions & 0 deletions thread/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,10 @@ R"(
stack_size = align_up(randomizer + stack_size + sizeof(thread), PAGE_SIZE);
char* ptr = (char*)photon_thread_alloc(stack_size);
auto p = ptr + stack_size - sizeof(thread) - randomizer;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
(uint64_t&)p &= ~63;
#pragma GCC diagnostic pop
auto th = new (p) thread;
th->buf = ptr;
th->stackful_alloc_top = ptr;
Expand Down

0 comments on commit 1996912

Please sign in to comment.