aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Swiecki <robert@swiecki.net>2023-09-21 08:29:36 +0200
committerRobert Swiecki <robert@swiecki.net>2023-09-21 08:29:36 +0200
commit557633c1de6e58c0791f349d4f0968899f97bdac (patch)
tree0ef3d47f3eb85dc3915cc0ed99e0f3d4a59c8824
parent439606be70e2f9d8732636c88ba4cff690ec5e0f (diff)
downloadnsjail-557633c1de6e58c0791f349d4f0968899f97bdac.tar.gz
Makefile: move to c++17 to use [[maybe_unused]] and remove DEFER (actually not used) from macros.h
-rw-r--r--Makefile2
-rw-r--r--macros.h26
-rw-r--r--subproc.cc2
3 files changed, 2 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index a9db531..e4b2305 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ COMMON_FLAGS += -O2 -c \
-Ikafel/include
CXXFLAGS += $(USER_DEFINES) $(COMMON_FLAGS) $(shell pkg-config --cflags protobuf) \
- -std=c++14 -fno-exceptions -Wno-unused -Wno-unused-parameter
+ -std=c++17 -fno-exceptions -Wno-unused -Wno-unused-parameter
LDFLAGS += -pie -Wl,-z,noexecstack -lpthread $(shell pkg-config --libs protobuf)
BIN = nsjail
diff --git a/macros.h b/macros.h
index c9a7ca1..d25ff33 100644
--- a/macros.h
+++ b/macros.h
@@ -37,32 +37,6 @@
#if !defined(ARR_SZ)
#define ARR_SZ(array) (sizeof(array) / sizeof(*array))
#endif /* !defined(ARR_SZ) */
-#define UNUSED __attribute__((unused))
-
-#if 0 /* Works, but needs -fblocks and libBlocksRuntime with clang */
-/* Go-style defer implementation */
-#define __STRMERGE(a, b) a##b
-#define _STRMERGE(a, b) __STRMERGE(a, b)
-
-#ifdef __clang__
-static void __attribute__ ((unused)) __clang_cleanup_func(void (^*dfunc) (void))
-{
- (*dfunc) ();
-}
-
-#define defer \
- void (^_STRMERGE(__defer_f_, __COUNTER__))(void) \
- __attribute__((cleanup(__clang_cleanup_func))) __attribute__((unused)) = ^
-#else
-#define __block
-#define _DEFER(a, count) \
- auto void _STRMERGE(__defer_f_, count)(void* _defer_arg __attribute__((unused))); \
- int _STRMERGE(__defer_var_, count) __attribute__((cleanup(_STRMERGE(__defer_f_, count)))) \
- __attribute__((unused)); \
- void _STRMERGE(__defer_f_, count)(void* _defer_arg __attribute__((unused)))
-#define defer _DEFER(a, __COUNTER__)
-#endif
-#endif
#define NS_VALSTR_STRUCT(x) \
{ (uint64_t) x, #x }
diff --git a/subproc.cc b/subproc.cc
index e0f4a88..1337491 100644
--- a/subproc.cc
+++ b/subproc.cc
@@ -520,7 +520,7 @@ static uint8_t cloneStack[128 * 1024] __attribute__((aligned(__BIGGEST_ALIGNMENT
/* Cannot be on the stack, as the child's stack pointer will change after clone() */
static __thread jmp_buf env;
-[[noreturn]] static int cloneFunc(void* arg __attribute__((unused))) {
+[[noreturn]] static int cloneFunc([[maybe_unused]] void* arg ) {
longjmp(env, 1);
LOG_F("Execution past longjmp");
}