Skip to content

Commit

Permalink
restore compatibility with older clang
Browse files Browse the repository at this point in the history
  • Loading branch information
stsp committed Feb 6, 2024
1 parent 23cebf3 commit a19fd1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion fdpp/clang.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions fdpp/farptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,24 @@ class SymMembT : public MembBase<T, P, M, O> {
#define __ASMCALL(f) AsmCSym f
#define __ASYM(x) x.get_sym()
#define ASMREF(t) AsmRef<t>
#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) []<typename T = p>() constexpr { return offsetof(T, n); }
#endif
#define AR_MEMB(p, t, n, l) \
DUMMY_MARK(p, n); \
ArMemb<t, l, p, OFF_M(p, n)> n
#define SYM_MEMB(p, t, n) \
DUMMY_MARK(p, n); \
SymMemb<t, p, OFF_M(p, n)> n
#define SYM_MEMB2(p, m, o, t, n) \
SymMemb<t, p, OFF_M(p, m), o> n
#define SYM_MEMB_T(p, t, n) \
DUMMY_MARK(p, n); \
SymMembT<t, p, OFF_M(p, n)> n
#define FP_SEG(fp) ((fp).seg())
#define FP_OFF(fp) ((fp).off())
Expand Down
3 changes: 2 additions & 1 deletion fdpp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion hdr/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit a19fd1f

Please sign in to comment.