diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actual.h (renamed from src/actual_function.h) | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/actual_function.h b/src/actual.h index ff69a13..af64ec3 100644 --- a/src/actual_function.h +++ b/src/actual.h @@ -16,12 +16,11 @@ namespace { template <class Result, typename... Arguments> using function_ptr = Result(*)(Arguments...); - template <class Result, typename... Arguments> - function_ptr<Result, Arguments...> get_actual_function( - const std::string& symbol_name) { + template <typename FunctionPtr> + FunctionPtr get_actual_function(const std::string& symbol_name) { const void* symbol_address{ dlsym(RTLD_NEXT, symbol_name.c_str()) }; - function_ptr<Result, Arguments...> actual_function{}; + FunctionPtr actual_function{}; std::memcpy(&actual_function, &symbol_address, sizeof(symbol_address)); return actual_function; @@ -30,38 +29,31 @@ namespace { namespace actual { static auto write = get_actual_function< - ssize_t, - int, const void*, size_t + function_ptr<ssize_t, int, const void*, size_t> >("write"); static auto writev = get_actual_function< - ssize_t, - int, const iovec*, int + function_ptr<ssize_t, int, const iovec*, int> >("writev"); static auto rename = get_actual_function< - int, - const char*, const char* + function_ptr<int, const char*, const char*> >("rename"); static auto rmdir = get_actual_function< - int, - const char* + function_ptr<int, const char*> >("rmdir"); static auto unlink = get_actual_function< - int, - const char* + function_ptr<int, const char*> >("unlink"); static auto unlinkat = get_actual_function< - int, - int, const char*, int + function_ptr<int, int, const char*, int> >("unlinkat"); static auto mmap = get_actual_function< - void*, - void*, size_t, int, int, int, off_t + function_ptr<void*, void*, size_t, int, int, int, off_t> >("mmap"); } |