/* * $Header: /afs/pdc.kth.se/src/projects/perftools/iotrack/iotrack/callmacros-ia64-linux.h,v 1.6 2004/10/15 16:14:48 mucci Exp $ * * pek@pdc.kth.se $Date: 2004/10/15 16:14:48 $ * * Linux x86 glibc syscalls * */ #include #include #include #include #include #define REAL_OPEN __open #define REAL_OPEN64 __open64 #define REAL_CLOSE __close #define REAL_DUP2 __dup2 /* #define REAL_READV __libc_readv */ /* #define REAL_WRITEV __libc_writev */ #define REAL_READ __read #define REAL_WRITE __write #define REAL_FCNTL __fcntl #define REAL_LSEEK __lseek #define REAL_FORK __libc_fork #define REAL_RECVFROM __libc_recvfrom #define REAL_RECV __libc_recv #define REAL_RECVMSG __libc_recvmsg #define REAL_SENDTO __libc_sendto #define REAL_SEND __libc_send #define REAL_SENDMSG __libc_sendmsg /* #define REAL_SOCKET __libc_socket */ #define REAL_ACCEPT __libc_accept /* #define REAL_DUP __libc_dup */ #define REAL_LSEEK64 __libc_lseek64 #define REAL_PREAD #define REAL_PWRITE #define REAL_FDOPEN _IO_fdopen #define REAL_FCLOSE _IO_fclose #define REAL_FWRITE _IO_fwrite #define REAL_FREAD _IO_fread #define REAL_FSEEK #define REAL_FSEEK64 #define REAL_REWIND #define REAL_FSETPOS _IO_fsetpos #define REAL_FGETC _IO_getc #define REAL_FGETS _IO_fgets #define REAL_GETC _IO_getc #define REAL_GETS _IO_gets /* #define REAL_FPUTC */ #define REAL_FPUTS _IO_fputs #define REAL_PUTC _IO_putc #define REAL_PUTS _IO_puts #define REAL_UNGETC _IO_ungetc #define REAL_VFSCANF __vfscanf #define REAL_FPRINTF _IO_vfprintf #define REAL_FSCANF _vfscanf #define REAL_VFPRINTF _IO_vfprintf extern FILE *_IO_fdopen(); static inline int REAL_CREAT(const char *file, mode_t mode) { return REAL_OPEN(file, O_WRONLY|O_CREAT|O_TRUNC, mode); } static inline int REAL_CREAT64(const char *file, mode_t mode) { return REAL_OPEN64(file, O_WRONLY|O_CREAT|O_TRUNC, mode); } static inline int REAL_DUP(int fd) { static int (*real_dup)(int fd) = NULL; if (real_dup == NULL) { real_dup = dlsym(RTLD_NEXT,"dup"); if (real_dup == NULL) { char *error = dlerror(); if (error != NULL) { fprintf(stderr,"iowrap : Failed to find symbol for dup: %s\n", error); exit(1); } else { fprintf(stderr,"iowrap : Failed to find non-NULL symbol for dup\n"); exit(1); } } } return (*real_dup)(fd); } static inline int REAL_READV(int fd, const struct iovec *vector, int count) { static int (*real_readv)(int fd, const struct iovec *, int) = NULL; if (real_readv == NULL) { real_readv = dlsym(RTLD_NEXT,"readv"); if (real_readv == NULL) { char *error = dlerror(); if (error != NULL) { fprintf(stderr,"iowrap : Failed to find symbol for readv: %s\n", error); exit(1); } else { fprintf(stderr,"iowrap : Failed to find non-NULL symbol for readv\n"); exit(1); } } } return (*real_readv)(fd, vector, count); } static inline int REAL_WRITEV(int fd, const struct iovec *vector, int count) { static int (*real_writev)(int fd, const struct iovec *, int) = NULL; if (real_writev == NULL) { real_writev = dlsym(RTLD_NEXT,"writev"); if (real_writev == NULL) { char *error = dlerror(); if (error != NULL) { fprintf(stderr,"iowrap : Failed to find symbol for writev: %s\n", error); exit(1); } else { fprintf(stderr,"iowrap : Failed to find non-NULL symbol for writev\n"); exit(1); } } } return (*real_writev)(fd, vector, count); } static inline int REAL_SOCKET(int domain, int type, int protocol) { static int (*real_socket)(int, int, int) = NULL; if (real_socket == NULL) { real_socket = dlsym(RTLD_NEXT,"socket"); if (real_socket == NULL) { char *error = dlerror(); if (error != NULL) { fprintf(stderr,"iowrap : Failed to find symbol for socket: %s\n", error); exit(1); } else { fprintf(stderr,"iowrap : Failed to find non-NULL symbol for socket\n"); exit(1); } } } return (*real_socket)(domain, type, protocol); } static inline FILE *REAL_FOPEN(const char *path, const char *mode) { static FILE *(*real_fopen)(const char *, const char *) = NULL; if (real_fopen == NULL) { real_fopen = dlsym(RTLD_NEXT,"fopen"); if (real_fopen == NULL) { char *error = dlerror(); if (error != NULL) { fprintf(stderr,"iowrap : Failed to find symbol for fopen: %s\n", error); exit(1); } else { fprintf(stderr,"iowrap : Failed to find non-NULL symbol for fopen\n"); exit(1); } } } return (*real_fopen)(path,mode); } static inline FILE *REAL_FOPEN64(const char *path, const char *mode) { static FILE *(*real_fopen64)(const char *, const char *) = NULL; if (real_fopen64 == NULL) { real_fopen64 = dlsym(RTLD_NEXT,"fopen64"); if (real_fopen64 == NULL) { char *error = dlerror(); if (error != NULL) { fprintf(stderr,"iowrap : Failed to find symbol for fopen64: %s\n", error); exit(1); } else { fprintf(stderr,"iowrap : Failed to find non-NULL symbol for fopen64\n"); exit(1); } } } return (*real_fopen64)(path,mode); }