1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef POSIX_ERROR_MAPPER_H 6#define POSIX_ERROR_MAPPER_H 7 8#include <dlfcn.h> 9#include <errno.h> 10 11#include <Errors.h> 12 13 14#define GET_REAL_FUNCTION(returnValue, function, parameters) \ 15 static returnValue (*sReal_##function)parameters \ 16 = (returnValue (*)parameters)dlsym(RTLD_DEFAULT, #function) 17 18#define HIDDEN_FUNCTION(function) asm volatile(".hidden " #function) 19 20#define WRAPPER_FUNCTION(returnValue, function, parameters, body) \ 21returnValue function parameters \ 22{ \ 23 HIDDEN_FUNCTION(function); \ 24 GET_REAL_FUNCTION(returnValue, function, parameters); \ 25 body \ 26} 27 28#endif // POSIX_ERROR_MAPPER_H 29