1 /* This header makes it possible to redefine system calls to the 2 * file system. This way, minix servers can re-route the data 3 * that libgcov tries to send to the file system. This is 4 * necessary, because the servers can't access the file system 5 * directly. Instead, they will copy the data to a helping user 6 * space process, which will call the file system for them. 7 * For more information, see the <minix/gcov.h> header file. 8 */ 9 10 #include <stdio.h> 11 #include <unistd.h> 12 #include <sys/types.h> 13 14 15 /* These function pointers initially point to the standard system library 16 * functions (fopen, etc). All calls to these system library functions are 17 * then redefined to calls to these function pointers. Because the pointers 18 * still point to the original functions, all functionality is unchanged. 19 * Therefore, libgcov won't act differently when linked to applications. 20 * But, when these pointers are redefined by code within the minix servers, 21 * the file system calls get replaced by other functionality. 22 */ 23 24 #define fopen(...) _gcov_fopen(__VA_ARGS__) 25 #define fread(...) _gcov_fread(__VA_ARGS__) 26 #define fwrite(...) _gcov_fwrite(__VA_ARGS__) 27 #define fclose(...) _gcov_fclose(__VA_ARGS__) 28 #define fseek(...) _gcov_fseek(__VA_ARGS__) 29 #define getenv(...) _gcov_getenv(__VA_ARGS__) 30 31 32 /* wrapper to make it possible to disable gcov_exit on a process exit (for mfs) */ 33 34 int do_gcov_exit = 1; 35 36 void gcov_exit_wrapper(void){ 37 if(do_gcov_exit) 38 gcov_exit(); 39 } 40