Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Posix_Wrapp.h
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 #ifndef POSIX_WRAPP_H
20 #define POSIX_WRAPP_H
21 
22 #define _GNU_SOURCE
23 #include <dlfcn.h>
24 
25 #include "Wrapped_Symbols.h"
26 
27 /********** Pointer to func **********/
32  void *p;
33  void (*p_func) ();
34 };
35 
36 /********** Resolution func **********/
41 
47 static inline void * Tracelib_resolve_symbol (int id)
48 {
49  return Tracelib_symbol_table[id].p;
50 }
51 
52 /********** useful macros **********/
57 #define to_string(a) _to_string(a)
58 #define _to_string(a) #a
59 
60 #if DO_POSIX_INSTRUM
61 
64 #define REAL(a) (( FOOTPRINT_ ## a ) Tracelib_resolve_symbol( T_POSIX_ENUM( a ) ))
65 #define pREAL(a) ( Tracelib_resolve_symbol( T_POSIX_ENUM(a) ) )
66 
67 void ___TEST_LOAD_SYMBOL( Wrapped_symbol symb, const char * const symbol );
68 
69 #define _TEST_LOAD_SYMBOL(a) do{ \
70  ___TEST_LOAD_SYMBOL( T_POSIX_ENUM( a ), to_string(a) );\
71  } while (0)
72 
76 #define TEST_LOAD_SYMBOL(a) _TEST_LOAD_SYMBOL(a);
77 
78 #else /*DO_POSIX_INSTRUM */
79 
80 /* Do not intercept POSIX */
81 #define REAL(a) a
82 #define pREAL(a) a
83 #define TEST_LOAD_SYMBOL(a)
84 
85 #endif /* DO_POSIX_INSTRUM */
86 
87 void Posix_Wrapp_init();
88 void Wrapp_enable();
89 void Wrapp_disable();
90 
91 
92 #endif /* POSIX_WRAPP_H */
void(* p_func)()
the function pointer (to be used as a function)
Definition: Posix_Wrapp.h:33
void Wrapp_enable()
Definition: Posix_Wrapp.c:44
void * p
the void* (to be get by dlsym)
Definition: Posix_Wrapp.h:32
void ___TEST_LOAD_SYMBOL(Wrapped_symbol symb, const char *const symbol)
Definition: Posix_Wrapp.c:55
Wrapped_symbol
enum indicating which symbols are wrapped
Union defining a function pointer.
Definition: Posix_Wrapp.h:31
void Wrapp_disable()
Definition: Posix_Wrapp.c:50
void Posix_Wrapp_init()
Definition: Posix_Wrapp.c:69
union function_table_elem Tracelib_symbol_table[T_POSIX_COUNT]
The table containing every wrapped symbols.
Definition: Posix_Wrapp.c:40
static void * Tracelib_resolve_symbol(int id)
Gets a symbol with its ID.
Definition: Posix_Wrapp.h:47