Replace typedef with using.
Test: m berberis_all
Change-Id: Ia72a5aa8f8dcfba6b50469e4c79f924110f02081
diff --git a/assembler/assembler_test.cc b/assembler/assembler_test.cc
index 1949c42..1f86404 100644
--- a/assembler/assembler_test.cc
+++ b/assembler/assembler_test.cc
@@ -29,9 +29,9 @@
#include "berberis/test_utils/scoped_exec_region.h"
#if defined(__i386__)
-typedef berberis::x86_32::Assembler CodeEmitter;
+using CodeEmitter = berberis::x86_32::Assembler;
#elif defined(__amd64__)
-typedef berberis::x86_64::Assembler CodeEmitter;
+using CodeEmitter = berberis::x86_64::Assembler;
#else
#error "Unsupported platform"
#endif
@@ -166,7 +166,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc(int, int);
+ using TestFunc = uint32_t(int, int);
auto target_func = exec.get<TestFunc>();
uint32_t result = target_func(1, 2);
if (result != 0xcccccc00) {
@@ -196,7 +196,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc(int, int);
+ using TestFunc = uint32_t(int, int);
auto target_func = exec.get<TestFunc>();
uint32_t result = target_func(0x11, 1);
if (result != 0x1) {
@@ -243,7 +243,7 @@
ScopedExecRegion exec(&code);
- typedef int TestFunc(int, int);
+ using TestFunc = int(int, int);
auto target_func = exec.get<TestFunc>();
int result = target_func(1, 1);
if (result != 0) {
@@ -276,7 +276,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc(uint32_t);
+ using TestFunc = uint32_t(uint32_t);
uint32_t result = exec.get<TestFunc>()(22);
return result == (22 << 4);
}
@@ -294,7 +294,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc(uint32_t);
+ using TestFunc = uint32_t(uint32_t);
uint32_t result = exec.get<TestFunc>()(239);
return result == ((239 ^ 1) & 0xf);
}
@@ -312,7 +312,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc(uint32_t arg);
+ using TestFunc = uint32_t(uint32_t arg);
auto func = exec.get<TestFunc>();
return func(0) == 239 && func(1 << 15) == 15;
}
@@ -331,7 +331,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0x3f800000;
}
@@ -350,7 +350,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0x40400000;
}
@@ -372,7 +372,7 @@
ScopedExecRegion exec(&code);
- typedef void TestFunc(void*, void*);
+ using TestFunc = void(void*, void*);
uint8_t res1[8];
uint8_t res2[16];
exec.get<TestFunc>()(res1, res2);
@@ -452,7 +452,7 @@
ScopedExecRegion exec(&code);
- typedef int TestFunc();
+ using TestFunc = int();
int result = exec.get<TestFunc>()();
return result == uint8_t(239 + 0xc3) + 12;
}
@@ -470,7 +470,7 @@
std::string code_str;
code.AsString(&code_str);
- typedef uint32_t TestFunc(int, int);
+ using TestFunc = uint32_t(int, int);
auto target_func = exec.get<TestFunc>();
uint32_t result;
result = target_func(1, 2);
@@ -503,7 +503,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc(int, int);
+ using TestFunc = uint32_t(int, int);
auto target_func = exec.get<TestFunc>();
uint32_t result = target_func(0x11, 1);
if (result != 0x1) {
@@ -548,7 +548,7 @@
ScopedExecRegion exec(&code);
- typedef int TestFunc(int, int);
+ using TestFunc = int(int, int);
auto target_func = exec.get<TestFunc>();
int result;
result = target_func(1, 1);
@@ -583,7 +583,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc(uint8_t*, uint32_t*);
+ using TestFunc = uint32_t(uint8_t*, uint32_t*);
uint8_t p1[4] = {0x12, 0x34, 0x56, 0x78};
uint32_t p2 = 0x239;
uint32_t result = exec.get<TestFunc>()(p1, &p2);
@@ -604,7 +604,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0x3f800000;
}
@@ -626,7 +626,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0x40c00000;
}
@@ -649,7 +649,7 @@
char bits[16], *p = bits + 5;
memcpy(p, &d, sizeof(d));
- typedef uint64_t TestFunc(char* p);
+ using TestFunc = uint64_t(char* p);
uint64_t result = exec.get<TestFunc>()(p);
uint64_t doubled = *reinterpret_cast<uint64_t*>(p);
return result == 0x406de00000000000ULL && doubled == 0x407de00000000000ULL;
@@ -669,7 +669,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0xffffffff;
@@ -689,7 +689,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0x000000ff;
@@ -718,7 +718,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0x1212;
@@ -747,7 +747,7 @@
ScopedExecRegion exec(&code);
- typedef uint32_t TestFunc();
+ using TestFunc = uint32_t();
uint32_t result = exec.get<TestFunc>()();
return result == 0x78780000;
@@ -774,7 +774,7 @@
ScopedExecRegion exec(&code);
- typedef void TestFunc(void*, void*);
+ using TestFunc = void(void*, void*);
uint8_t res1[8];
uint8_t res2[16];
exec.get<TestFunc>()(res1, res2);
@@ -801,7 +801,7 @@
ScopedExecRegion exec(&code);
- typedef int TestFunc(int x);
+ using TestFunc = int(int x);
int result = exec.get<TestFunc>()(0x10);
return result == 0x20;
diff --git a/backend/include/berberis/backend/x86_64/context_liveness_analyzer.h b/backend/include/berberis/backend/x86_64/context_liveness_analyzer.h
index 833e70d..c5b0084 100644
--- a/backend/include/berberis/backend/x86_64/context_liveness_analyzer.h
+++ b/backend/include/berberis/backend/x86_64/context_liveness_analyzer.h
@@ -34,7 +34,7 @@
bool IsLiveIn(const MachineBasicBlock* bb, uint32_t offset) const;
private:
- typedef std::bitset<sizeof(CPUState)> ContextLiveness;
+ using ContextLiveness = std::bitset<sizeof(CPUState)>;
bool VisitBasicBlock(const MachineBasicBlock* bb);
diff --git a/backend/include/berberis/backend/x86_64/machine_ir.h b/backend/include/berberis/backend/x86_64/machine_ir.h
index 259c9fd..4a8c7fb 100644
--- a/backend/include/berberis/backend/x86_64/machine_ir.h
+++ b/backend/include/berberis/backend/x86_64/machine_ir.h
@@ -270,10 +270,10 @@
template <typename Absolute_, typename BaseDisp_, typename IndexDisp_, typename BaseIndexDisp_>
class MemInsns {
public:
- typedef Absolute_ Absolute;
- typedef BaseDisp_ BaseDisp;
- typedef IndexDisp_ IndexDisp;
- typedef BaseIndexDisp_ BaseIndexDisp;
+ using Absolute = Absolute_;
+ using BaseDisp = BaseDisp_;
+ using IndexDisp = IndexDisp_;
+ using BaseIndexDisp = BaseIndexDisp_;
};
using MachineInsnForArch = MachineInsnX86_64;
diff --git a/base/arena_test.cc b/base/arena_test.cc
index ea364d0..c502fa9 100644
--- a/base/arena_test.cc
+++ b/base/arena_test.cc
@@ -56,8 +56,8 @@
explicit Node(unsigned e) : elem1(e), elem2(e + 11) {}
};
-typedef ArenaList<Node*> FastList;
-typedef ArenaVector<Node*> FastVector;
+using FastList = ArenaList<Node*>;
+using FastVector = ArenaVector<Node*>;
TEST_F(ArenaTest, Smoke) {
char* p;
diff --git a/base/include/berberis/base/arena_alloc.h b/base/include/berberis/base/arena_alloc.h
index d6d5e07..bda3bc5 100644
--- a/base/include/berberis/base/arena_alloc.h
+++ b/base/include/berberis/base/arena_alloc.h
@@ -135,7 +135,7 @@
template <class T>
class ArenaAllocator {
public:
- typedef T value_type;
+ using value_type = T;
// Allow passing arena as allocator arg of STL container ctor.
ArenaAllocator(Arena* arena) : arena_(arena) {} // NOLINT(runtime/explicit)
diff --git a/base/include/berberis/base/forever_pool.h b/base/include/berberis/base/forever_pool.h
index bb5f848..8c8af16 100644
--- a/base/include/berberis/base/forever_pool.h
+++ b/base/include/berberis/base/forever_pool.h
@@ -61,7 +61,7 @@
template <class T>
class ForeverPoolAllocator {
public:
- typedef T value_type;
+ using value_type = T;
ForeverPoolAllocator() {}
diff --git a/code_gen_lib/code_gen_lib_riscv64_test.cc b/code_gen_lib/code_gen_lib_riscv64_test.cc
index da2ba64..db81612 100644
--- a/code_gen_lib/code_gen_lib_riscv64_test.cc
+++ b/code_gen_lib/code_gen_lib_riscv64_test.cc
@@ -175,7 +175,7 @@
ScopedExecRegion exec(&machine_code);
- typedef int Func(int, int, int, int, int, int, int, int, int, int);
+ using Func = int(int, int, int, int, int, int, int, int, int, int);
int res = exec.get<Func>()(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
ASSERT_EQ(45, res);
}
@@ -221,7 +221,7 @@
ScopedExecRegion exec(&machine_code);
- typedef float Func(float, float, float, float, float, float, float, float, float, float);
+ using Func = float(float, float, float, float, float, float, float, float, float, float);
float res = exec.get<Func>()(0.0f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f);
ASSERT_FLOAT_EQ(45.45f, res);
}
diff --git a/decoder/include/berberis/decoder/riscv64/decoder.h b/decoder/include/berberis/decoder/riscv64/decoder.h
index 67641f5..3ebf144 100644
--- a/decoder/include/berberis/decoder/riscv64/decoder.h
+++ b/decoder/include/berberis/decoder/riscv64/decoder.h
@@ -1352,7 +1352,7 @@
static auto SignExtend(const Type val) {
static_assert(std::is_integral_v<Type>, "Only integral types are supported");
static_assert(size > 0 && size < (sizeof(Type) * CHAR_BIT), "Invalid size value");
- typedef std::make_signed_t<Type> SignedType;
+ using SignedType = std::make_signed_t<Type>;
struct {
SignedType val : size;
} holder = {.val = static_cast<SignedType>(val)};
diff --git a/guest_loader/include/berberis/guest_loader/guest_loader.h b/guest_loader/include/berberis/guest_loader/guest_loader.h
index a07383e..76d8e30 100644
--- a/guest_loader/include/berberis/guest_loader/guest_loader.h
+++ b/guest_loader/include/berberis/guest_loader/guest_loader.h
@@ -34,7 +34,7 @@
// <android/dlext.h>
struct android_namespace_t;
-typedef struct {
+struct android_dlextinfo {
uint64_t flags;
void* reserved_addr;
size_t reserved_size;
@@ -42,35 +42,35 @@
int library_fd;
off64_t library_fd_offset;
struct android_namespace_t* library_namespace;
-} android_dlextinfo;
+};
#endif
namespace berberis {
struct LinkerCallbacks {
- typedef android_namespace_t* (*android_create_namespace_fn_t)(
- const char* name,
- const char* ld_library_path,
- const char* default_library_path,
- uint64_t type,
- const char* permitted_when_isolated_path,
- android_namespace_t* parent_namespace,
- const void* caller_addr);
- typedef void* (*android_dlopen_ext_fn_t)(const char* filename,
- int flags,
- const android_dlextinfo* extinfo,
- const void* caller_addr);
- typedef android_namespace_t* (*android_get_exported_namespace_fn_t)(const char* name);
- typedef bool (*android_init_anonymous_namespace_fn_t)(const char* shared_libs_sonames,
- const char* library_search_path);
- typedef bool (*android_link_namespaces_fn_t)(android_namespace_t* namespace_from,
- android_namespace_t* namespace_to,
- const char* shared_libs_sonames);
- typedef void (*android_set_application_target_sdk_version_fn_t)(int target);
- typedef uintptr_t (*dl_unwind_find_exidx_fn_t)(uintptr_t pc, int* pcount);
- typedef int (*dladdr_fn_t)(const void* addr, Dl_info* info);
- typedef char* (*dlerror_fn_t)();
- typedef void* (*dlsym_fn_t)(void* handle, const char* symbol, const void* caller_addr);
+ using android_create_namespace_fn_t =
+ android_namespace_t* (*)(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ android_namespace_t* parent_namespace,
+ const void* caller_addr);
+ using android_dlopen_ext_fn_t = void* (*)(const char* filename,
+ int flags,
+ const android_dlextinfo* extinfo,
+ const void* caller_addr);
+ using android_get_exported_namespace_fn_t = android_namespace_t* (*)(const char* name);
+ using android_init_anonymous_namespace_fn_t = bool (*)(const char* shared_libs_sonames,
+ const char* library_search_path);
+ using android_link_namespaces_fn_t = bool (*)(android_namespace_t* namespace_from,
+ android_namespace_t* namespace_to,
+ const char* shared_libs_sonames);
+ using android_set_application_target_sdk_version_fn_t = void (*)(int target);
+ using dl_unwind_find_exidx_fn_t = uintptr_t (*)(uintptr_t pc, int* pcount);
+ using dladdr_fn_t = int (*)(const void* addr, Dl_info* info);
+ using dlerror_fn_t = char* (*)();
+ using dlsym_fn_t = void* (*)(void* handle, const char* symbol, const void* caller_addr);
android_create_namespace_fn_t create_namespace_fn_ = nullptr;
android_dlopen_ext_fn_t dlopen_ext_fn_ = nullptr;
diff --git a/guest_os_primitives/guest_signal_action.h b/guest_os_primitives/guest_signal_action.h
index 342fac0..e98076c 100644
--- a/guest_os_primitives/guest_signal_action.h
+++ b/guest_os_primitives/guest_signal_action.h
@@ -30,7 +30,7 @@
// is a wrapper that invokes guest code (or suspends handling until region exit).
class GuestSignalAction {
public:
- typedef void (*host_sa_sigaction_t)(int, siginfo_t*, void*);
+ using host_sa_sigaction_t = void (*)(int, siginfo_t*, void*);
constexpr GuestSignalAction()
: claimed_guest_sa_{.guest_sa_sigaction = Guest_SIG_DFL, .sa_flags = 0, .sa_mask = {}} {}
diff --git a/guest_os_primitives/include/berberis/guest_os_primitives/guest_signal.h b/guest_os_primitives/include/berberis/guest_os_primitives/guest_signal.h
index 215f1e0..545478e 100644
--- a/guest_os_primitives/include/berberis/guest_os_primitives/guest_signal.h
+++ b/guest_os_primitives/include/berberis/guest_os_primitives/guest_signal.h
@@ -39,16 +39,16 @@
// Guest sigset_t, as expected by guest rt_sigprocmask syscall.
#if defined(BERBERIS_GUEST_LP64)
-typedef struct {
+struct Guest_sigset_t {
unsigned long __bits[1];
-} Guest_sigset_t;
+};
CHECK_STRUCT_LAYOUT(Guest_sigset_t, 64, 64);
#else
// TODO(b/283352810): Explicitly support ILP32 guest data model.
// This condition currently assumes ILP32 support.
-typedef struct {
+struct Guest_sigset_t {
unsigned long __bits[2];
-} Guest_sigset_t;
+};
CHECK_STRUCT_LAYOUT(Guest_sigset_t, 64, 32);
#endif
diff --git a/intrinsics/common_to_x86/include/berberis/intrinsics/common_to_x86/text_assembler_common.h b/intrinsics/common_to_x86/include/berberis/intrinsics/common_to_x86/text_assembler_common.h
index b1e379b..f9c7b35 100644
--- a/intrinsics/common_to_x86/include/berberis/intrinsics/common_to_x86/text_assembler_common.h
+++ b/intrinsics/common_to_x86/include/berberis/intrinsics/common_to_x86/text_assembler_common.h
@@ -282,13 +282,13 @@
};
constexpr static char kSpl[] = "%%spl";
- typedef RegisterTemplate<kSpl, 'b'> Register8Bit;
+ using Register8Bit = RegisterTemplate<kSpl, 'b'>;
constexpr static char kSp[] = "%%sp";
- typedef RegisterTemplate<kSp, 'w'> Register16Bit;
+ using Register16Bit = RegisterTemplate<kSp, 'w'>;
constexpr static char kEsp[] = "%%esp";
- typedef RegisterTemplate<kEsp, 'k'> Register32Bit;
+ using Register32Bit = RegisterTemplate<kEsp, 'k'>;
constexpr static char kRsp[] = "%%rsp";
- typedef RegisterTemplate<kRsp, 'q'> Register64Bit;
+ using Register64Bit = RegisterTemplate<kRsp, 'q'>;
void SetRequiredFeatureAVX() {
need_avx = true;
diff --git a/intrinsics/riscv64_to_x86_64/text_assembler.h b/intrinsics/riscv64_to_x86_64/text_assembler.h
index 300ec34..c3de26e 100644
--- a/intrinsics/riscv64_to_x86_64/text_assembler.h
+++ b/intrinsics/riscv64_to_x86_64/text_assembler.h
@@ -38,7 +38,7 @@
static constexpr char kNamespaceName[] = "berberis";
protected:
- typedef RegisterTemplate<kRsp, 'q'> RegisterDefaultBit;
+ using RegisterDefaultBit = RegisterTemplate<kRsp, 'q'>;
private:
using Assembler = TextAssembler;
diff --git a/jni/guest_jni_trampolines.cc b/jni/guest_jni_trampolines.cc
index 955c2ae..e1f7f96 100644
--- a/jni/guest_jni_trampolines.cc
+++ b/jni/guest_jni_trampolines.cc
@@ -73,7 +73,7 @@
}
// from external/icu/icu4c/source/common/unicode/uversion.h
-typedef uint8_t UVersionInfo[4];
+using UVersionInfo = uint8_t[4];
void GuestCall_u_getVersion(GuestAddr addr, UVersionInfo version_info) {
CHECK_NE(addr, berberis::kNullGuestAddr);
diff --git a/lite_translator/riscv64_to_x86_64/call_intrinsic.h b/lite_translator/riscv64_to_x86_64/call_intrinsic.h
index 06c886a..a281601 100644
--- a/lite_translator/riscv64_to_x86_64/call_intrinsic.h
+++ b/lite_translator/riscv64_to_x86_64/call_intrinsic.h
@@ -180,8 +180,8 @@
// Helper wrapper to pass the intrinsic type down the generic lambda.
template <typename T, typename U>
struct ArgWrap {
- typedef T AssemblerType;
- typedef U IntrinsicType;
+ using AssemblerType = T;
+ using IntrinsicType = U;
AssemblerType value;
};
diff --git a/native_bridge/native_bridge.h b/native_bridge/native_bridge.h
index b6cf48d..0540095 100644
--- a/native_bridge/native_bridge.h
+++ b/native_bridge/native_bridge.h
@@ -40,7 +40,7 @@
// Function pointer type for sigaction. This is mostly the signature of a signal handler, except
// for the return type. The runtime needs to know whether the signal was handled or should be given
// to the chain.
-typedef bool (*NativeBridgeSignalHandlerFn)(int, siginfo_t*, void*);
+using NativeBridgeSignalHandlerFn = bool (*)(int, siginfo_t*, void*);
struct native_bridge_namespace_t;
diff --git a/proxy_loader/proxy_loader.cc b/proxy_loader/proxy_loader.cc
index 64ecb09..b213384 100644
--- a/proxy_loader/proxy_loader.cc
+++ b/proxy_loader/proxy_loader.cc
@@ -43,7 +43,7 @@
return false;
}
- typedef void (*InitProxyLibraryFunc)(ProxyLibraryBuilder*);
+ using InitProxyLibraryFunc = void (*)(ProxyLibraryBuilder*);
InitProxyLibraryFunc init =
reinterpret_cast<InitProxyLibraryFunc>(dlsym(proxy, "InitProxyLibrary"));
if (!init) {
@@ -66,7 +66,7 @@
static std::mutex g_guard_mutex;
std::lock_guard<std::mutex> guard(g_guard_mutex);
- typedef std::map<std::string, ProxyLibraryBuilder> Libraries;
+ using Libraries = std::map<std::string, ProxyLibraryBuilder>;
static Libraries g_libraries;
auto res = g_libraries.insert({library_name, {}});
diff --git a/runtime_primitives/include/berberis/runtime_primitives/host_code.h b/runtime_primitives/include/berberis/runtime_primitives/host_code.h
index 5991330..c48a4f2 100644
--- a/runtime_primitives/include/berberis/runtime_primitives/host_code.h
+++ b/runtime_primitives/include/berberis/runtime_primitives/host_code.h
@@ -21,7 +21,7 @@
namespace berberis {
// Pointer to host executable machine code.
-typedef const void* HostCode;
+using HostCode = const void*;
template <typename T>
inline HostCode AsHostCode(T ptr) {
diff --git a/tests/ndk_program_tests/arm/handle_not_executable_test.cc b/tests/ndk_program_tests/arm/handle_not_executable_test.cc
index a51e8a1..d618f5b 100644
--- a/tests/ndk_program_tests/arm/handle_not_executable_test.cc
+++ b/tests/ndk_program_tests/arm/handle_not_executable_test.cc
@@ -35,13 +35,13 @@
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0));
- typedef void (*Func)();
+ using Func = void (*)();
ASSERT_EXIT((reinterpret_cast<Func>(code))(), testing::KilledBySignal(SIGSEGV), "");
munmap(code, sysconf(_SC_PAGESIZE));
}
TEST(HandleNotExecutable, PcLessThan4096) {
- typedef void (*Func)();
+ using Func = void (*)();
ASSERT_EXIT((reinterpret_cast<Func>(const_cast<void*>(g_null_addr)))(),
testing::KilledBySignal(SIGSEGV),
"");
@@ -99,7 +99,7 @@
uint32_t* start_addr = second_page - kFirstPageInsnNum;
memcpy(start_addr, kPageCrossingCode, sizeof(kPageCrossingCode));
- typedef void (*Func)(void (*)());
+ using Func = void (*)(void (*)());
ASSERT_EXIT((reinterpret_cast<Func>(start_addr))(&FirstPageExecutionHelper),
testing::KilledBySignal(SIGSEGV),
"First page has executed");
diff --git a/tests/ndk_program_tests/arm/runtime_code_patching_test.cc b/tests/ndk_program_tests/arm/runtime_code_patching_test.cc
index f6159e6..c0ae26d 100644
--- a/tests/ndk_program_tests/arm/runtime_code_patching_test.cc
+++ b/tests/ndk_program_tests/arm/runtime_code_patching_test.cc
@@ -64,7 +64,7 @@
// ATTENTION: flush insn cache! Otherwise just mmaped page might remain cached with wrong prot!
ClearInsnCache(code, code + 1024);
- typedef int32_t (*Func)();
+ using Func = int32_t (*)();
int32_t result = (reinterpret_cast<Func>(code))();
EXPECT_EQ(result, 11);
@@ -95,7 +95,7 @@
volatile int func_thread_started = 0;
- typedef void* (*Func)(void*);
+ using Func = void* (*)(void*);
pthread_t func_thread;
ASSERT_EQ(pthread_create(&func_thread,
nullptr,
diff --git a/tests/ndk_program_tests/arm/syscall_test.cc b/tests/ndk_program_tests/arm/syscall_test.cc
index 67a3741..1dd2593 100644
--- a/tests/ndk_program_tests/arm/syscall_test.cc
+++ b/tests/ndk_program_tests/arm/syscall_test.cc
@@ -48,7 +48,7 @@
memcpy(start, code_template, sizeof(code_template));
uint8_t* end = start + sizeof(code_template);
ASSERT_EQ(syscall(kCacheFlushSyscall, start, end, 0), 0);
- typedef int (*TestFunc)(void);
+ using TestFunc = int (*)(void);
TestFunc func = reinterpret_cast<TestFunc>(start);
ASSERT_EQ(func(), 0x1);
*reinterpret_cast<uint32_t*>(start) = 0xe3000011; // movw r0, #0x11
diff --git a/tests/ndk_program_tests/arm64/handle_not_executable_test.cc b/tests/ndk_program_tests/arm64/handle_not_executable_test.cc
index 9fa45bc..fc5a217 100644
--- a/tests/ndk_program_tests/arm64/handle_not_executable_test.cc
+++ b/tests/ndk_program_tests/arm64/handle_not_executable_test.cc
@@ -35,13 +35,13 @@
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0));
- typedef void (*Func)();
+ using Func = void (*)();
ASSERT_EXIT((reinterpret_cast<Func>(code))(), testing::KilledBySignal(SIGSEGV), "");
munmap(code, sysconf(_SC_PAGESIZE));
}
TEST(HandleNotExecutable, PcLessThan4096) {
- typedef void (*Func)();
+ using Func = void (*)();
ASSERT_EXIT((reinterpret_cast<Func>(const_cast<void*>(g_null_addr)))(),
testing::KilledBySignal(SIGSEGV),
"");
@@ -99,7 +99,7 @@
uint32_t* start_addr = second_page - kFirstPageInsnNum;
memcpy(start_addr, kPageCrossingCode, sizeof(kPageCrossingCode));
- typedef void (*Func)(void (*)());
+ using Func = void (*)(void (*)());
ASSERT_EXIT((reinterpret_cast<Func>(start_addr))(&FirstPageExecutionHelper),
testing::KilledBySignal(SIGSEGV),
"First page has executed");
diff --git a/tests/ndk_program_tests/ctype_test.cc b/tests/ndk_program_tests/ctype_test.cc
index 12b2a46..14dc8fb 100644
--- a/tests/ndk_program_tests/ctype_test.cc
+++ b/tests/ndk_program_tests/ctype_test.cc
@@ -69,7 +69,7 @@
EXPECT_FALSE(isascii(-1));
}
-typedef int (*CharTypeFunc)(int chr);
+using CharTypeFunc = int (*)(int chr);
// The ctype functions must not be inlined to test their function trampolines. To prevent inlining,
// make an indirect call through a volatile function pointer.
diff --git a/tests/ndk_program_tests/file_test.cc b/tests/ndk_program_tests/file_test.cc
index 61dcbad..eab9ff0 100644
--- a/tests/ndk_program_tests/file_test.cc
+++ b/tests/ndk_program_tests/file_test.cc
@@ -259,7 +259,7 @@
TEST(File, FdPrintf) {
TempFile f;
- typedef int (*FdPrintf)(int fd, const char* format, ...);
+ using FdPrintf = int (*)(int fd, const char* format, ...);
FdPrintf fdprintf = reinterpret_cast<FdPrintf>(dlsym(RTLD_DEFAULT, "fdprintf"));
ASSERT_GT(fdprintf(f.fd(), "%.1lf %d %lld\n", 1.0, 2, 3LL), 0);
ASSERT_EQ(fseek(f.get(), 0, SEEK_SET), 0);
diff --git a/tests/ndk_program_tests/riscv64/handle_not_executable_test.cc b/tests/ndk_program_tests/riscv64/handle_not_executable_test.cc
index 2a654ba..2c61a3e 100644
--- a/tests/ndk_program_tests/riscv64/handle_not_executable_test.cc
+++ b/tests/ndk_program_tests/riscv64/handle_not_executable_test.cc
@@ -35,13 +35,13 @@
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0));
- typedef void (*Func)();
+ using Func = void (*)();
ASSERT_EXIT((reinterpret_cast<Func>(code))(), testing::KilledBySignal(SIGSEGV), "");
munmap(code, sysconf(_SC_PAGESIZE));
}
TEST(HandleNotExecutable, PcLessThan4096) {
- typedef void (*Func)();
+ using Func = void (*)();
ASSERT_EXIT((reinterpret_cast<Func>(const_cast<void*>(g_null_addr)))(),
testing::KilledBySignal(SIGSEGV),
"");
@@ -105,7 +105,7 @@
uint32_t* start_addr = second_page - kFirstPageInsnNum;
memcpy(start_addr, kPageCrossingCode, sizeof(kPageCrossingCode));
- typedef void (*Func)(void (*)());
+ using Func = void (*)(void (*)());
ASSERT_EXIT((reinterpret_cast<Func>(start_addr))(&FirstPageExecutionHelper),
testing::KilledBySignal(SIGSEGV),
"First page has executed");
diff --git a/tests/ndk_program_tests/signal_test.cc b/tests/ndk_program_tests/signal_test.cc
index c37564d..fc38b0b 100644
--- a/tests/ndk_program_tests/signal_test.cc
+++ b/tests/ndk_program_tests/signal_test.cc
@@ -214,7 +214,7 @@
ScopedSigaction scoped_sa(SIGSEGV, &sa);
if (setjmp(g_recover_no_exec) == 0) {
- typedef void (*Func)();
+ using Func = void (*)();
(reinterpret_cast<Func>(kNoExecAddr))();
// Signal handler should longjmp out!
FAIL();
diff --git a/tests/perf_tests/perf_test.cc b/tests/perf_tests/perf_test.cc
index ef027a4..4115098 100644
--- a/tests/perf_tests/perf_test.cc
+++ b/tests/perf_tests/perf_test.cc
@@ -89,7 +89,7 @@
}
TEST(BerberisPerf, FuncPtr) {
- typedef int (*FuncPtr)(void);
+ using FuncPtr = int (*)(void);
static const FuncPtr fptrs[4] = {f0, f1, f2, f3};
// Call functions with their pointers 100 million times.
diff --git a/tiny_loader/include/berberis/tiny_loader/elf_types.h b/tiny_loader/include/berberis/tiny_loader/elf_types.h
index 4d2a118..b0886a3 100644
--- a/tiny_loader/include/berberis/tiny_loader/elf_types.h
+++ b/tiny_loader/include/berberis/tiny_loader/elf_types.h
@@ -32,13 +32,13 @@
constexpr int kSupportedElfClass = ELFCLASS32;
#endif
-typedef ElfW(Addr) ElfAddr;
-typedef ElfW(Dyn) ElfDyn;
-typedef ElfW(Ehdr) ElfEhdr;
-typedef ElfW(Half) ElfHalf;
-typedef ElfW(Phdr) ElfPhdr;
-typedef ElfW(Shdr) ElfShdr;
-typedef ElfW(Sym) ElfSym;
-typedef ElfW(Word) ElfWord;
+using ElfAddr = ElfW(Addr);
+using ElfDyn = ElfW(Dyn);
+using ElfEhdr = ElfW(Ehdr);
+using ElfHalf = ElfW(Half);
+using ElfPhdr = ElfW(Phdr);
+using ElfShdr = ElfW(Shdr);
+using ElfSym = ElfW(Sym);
+using ElfWord = ElfW(Word);
#endif // BERBERIS_TINY_LOADER_ELF_TYPES_H_
diff --git a/tiny_loader/include/berberis/tiny_loader/tiny_loader.h b/tiny_loader/include/berberis/tiny_loader/tiny_loader.h
index 672013f..9ebc1da 100644
--- a/tiny_loader/include/berberis/tiny_loader/tiny_loader.h
+++ b/tiny_loader/include/berberis/tiny_loader/tiny_loader.h
@@ -27,9 +27,9 @@
class TinyLoader {
public:
- typedef void* (*mmap64_fn_t)(void* addr, size_t length, int prot, int flags, int fd,
- off64_t offset);
- typedef int (*munmap_fn_t)(void* addr, size_t length);
+ using mmap64_fn_t =
+ void* (*)(void* addr, size_t length, int prot, int flags, int fd, off64_t offset);
+ using munmap_fn_t = int (*)(void* addr, size_t length);
static bool LoadFromFile(const char* path, size_t align, mmap64_fn_t mmap64_fn,
munmap_fn_t munmap_fn, LoadedElfFile* loaded_elf_file,