minix/tools/gcc/files/gcov-minix-fs-wrapper.h
Thomas Veerman c8a0e2f4c6 Import NetBSD tools and build.sh
This commit finalizes support for cross compilation. The tools
directory are all links to the actual tools and are built on the
host system to build Minix. build.sh is the work horse that takes
care of all environment settings. It's slightly adjusted for Minix.
The /usr/src/Makefile has additional targets needed for cross
compilation.
2012-06-18 10:54:51 +00:00

40 lines
1.4 KiB
C

/* This header makes it possible to redefine system calls to the
* file system. This way, minix servers can re-route the data
* that libgcov tries to send to the file system. This is
* necessary, because the servers can't access the file system
* directly. Instead, they will copy the data to a helping user
* space process, which will call the file system for them.
* For more information, see the <minix/gcov.h> header file.
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
/* These function pointers initially point to the standard system library
* functions (fopen, etc). All calls to these system library functions are
* then redefined to calls to these function pointers. Because the pointers
* still point to the original functions, all functionality is unchanged.
* Therefore, libgcov won't act differently when linked to applications.
* But, when these pointers are redefined by code within the minix servers,
* the file system calls get replaced by other functionality.
*/
#define fopen(...) _gcov_fopen(__VA_ARGS__)
#define fread(...) _gcov_fread(__VA_ARGS__)
#define fwrite(...) _gcov_fwrite(__VA_ARGS__)
#define fclose(...) _gcov_fclose(__VA_ARGS__)
#define fseek(...) _gcov_fseek(__VA_ARGS__)
#define getenv(...) _gcov_getenv(__VA_ARGS__)
/* wrapper to make it possible to disable gcov_exit on a process exit (for mfs) */
int do_gcov_exit = 1;
void gcov_exit_wrapper(void){
if(do_gcov_exit)
gcov_exit();
}