From a19fd1f871d1f348e505069f38e98be030653fcf Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 6 Feb 2024 15:48:32 +0500 Subject: [PATCH] restore compatibility with older clang --- fdpp/clang.mak | 3 ++- fdpp/farptr.hpp | 10 ++++++++++ fdpp/meson.build | 3 ++- hdr/process.h | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fdpp/clang.mak b/fdpp/clang.mak index 8e61aeae..de71b332 100644 --- a/fdpp/clang.mak +++ b/fdpp/clang.mak @@ -24,7 +24,8 @@ endif NASM ?= nasm-segelf PKG_CONFIG ?= pkg-config -TARGETOPT = -std=c++20 -c -fno-threadsafe-statics -fpic +TARGETOPT = -std=c++20 -c -fno-threadsafe-statics -fpic \ + -DCLANG_VER=$(CLANG_VER) # _XTRA should go at the end of cmd line TARGETOPT_XTRA = -Wno-format-invalid-specifier -Wno-c99-designator diff --git a/fdpp/farptr.hpp b/fdpp/farptr.hpp index 5192689c..9d5332c3 100644 --- a/fdpp/farptr.hpp +++ b/fdpp/farptr.hpp @@ -754,14 +754,24 @@ class SymMembT : public MembBase { #define __ASMCALL(f) AsmCSym f #define __ASYM(x) x.get_sym() #define ASMREF(t) AsmRef +#if CLANG_VER < 14 +#define DUMMY_MARK(p, n) \ + static constexpr int off_##n(void) { return offsetof(p, n); } +#define OFF_M(p, n) p::off_##n +#else +#define DUMMY_MARK(p, n) #define OFF_M(p, n) []() constexpr { return offsetof(T, n); } +#endif #define AR_MEMB(p, t, n, l) \ + DUMMY_MARK(p, n); \ ArMemb n #define SYM_MEMB(p, t, n) \ + DUMMY_MARK(p, n); \ SymMemb n #define SYM_MEMB2(p, m, o, t, n) \ SymMemb n #define SYM_MEMB_T(p, t, n) \ + DUMMY_MARK(p, n); \ SymMembT n #define FP_SEG(fp) ((fp).seg()) #define FP_OFF(fp) ((fp).off()) diff --git a/fdpp/meson.build b/fdpp/meson.build index f425c70d..f943cf40 100644 --- a/fdpp/meson.build +++ b/fdpp/meson.build @@ -138,11 +138,12 @@ FDPP_CCFILES = ['thunks.cc', 'thunks_c.cc', 'thunks_a.cc', 'thunks_p.cc', CPPFILES = ['objhlp.cpp', 'ctors.cpp', 'farhlp.cpp', 'objtrace.cpp'] hdr = ['src', 'hdr', '.', rel_inc] incdir2 = include_directories(hdr) +CLANG_VER = meson.get_compiler('cpp').version().split('.')[0] LIBFDPP = shared_library('fdpp', [ccfiles, ppccf, FDPP_CCFILES, CPPFILES], include_directories: incdir2, version: FVER, sources: [gad, pac, pap, tc, ta], - cpp_args: ['-DFDPP', '-DDEBUG', '-DWITHFAT32', + cpp_args: ['-DFDPP', '-DDEBUG', '-DWITHFAT32', '-DCLANG_VER=' + CLANG_VER, '-fno-threadsafe-statics', '-Werror=packed-non-pod', '-Wno-unknown-warning-option', '-Wno-format-invalid-specifier', '-Wno-c99-designator' diff --git a/hdr/process.h b/hdr/process.h index a18aeb31..227d87a8 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -90,7 +90,7 @@ typedef struct _psp { UBYTE ps_fill2c[7]; /* 49 unused, 7 bytes */ UBYTE ps_unix[3]; /* 50 unix style call - 0xcd 0x21 0xcb */ BYTE ps_fill3[9]; /* 53 */ -// DUMMY_MARK(_psp, _u); + DUMMY_MARK(_psp, _u); union { struct { SYM_MEMB2(_psp, _u, 0, fcb, _ps_fcb1); /* 5c first command line argument */