Changeset 34712

Show
Ignore:
Timestamp:
08/02/09 22:46:36 (4 years ago)
Author:
kazuho
Message:

hook more functions

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/linux/morememory/trunk/morememory.c

    r34711 r34712  
    88#include <fcntl.h> 
    99#include <malloc.h> 
     10#include <poll.h> 
     11#include <pthread.h> 
    1012#include <stdio.h> 
    1113#include <stdlib.h> 
    1214#include <string.h> 
    1315#include <sys/mman.h> 
     16#include <sys/select.h> 
    1417#include <sys/stat.h> 
     18#include <sys/time.h> 
    1519#include <sys/types.h> 
    1620#include <unistd.h> 
    17 #include <bits/libc-lock.h> 
    1821 
    1922#define MAXMEM (1024*1024*1024) 
     
    4447  int fd; 
    4548   
    46   /* create a sparse temporary file and mmap it */ 
    4749  assert((fd = mkstemp(tmpfile)) != -1); 
    4850  assert(unlink(tmpfile) == 0); 
    4951  assert(ftruncate(fd, MAXMEM) == 0); 
    50    
    5152  /* TODO move fd to a higher number (maybe necessary) */ 
    5253  return fd; 
     
    9899DEF_ORIG(waitpid, pid_t, (pid_t pid, int* status, int options), 
    99100         (pid, status, options)); 
     101DEF_ORIG(fgetc, int, (FILE* stream), (stream)); 
     102DEF_ORIG(fgets, char*, (char* s, int size, FILE* stream), (s, size, stream)); 
     103DEF_ORIG(select, int, (int nfds, fd_set* readfds, fd_set* writefds, 
     104                       fd_set* exceptfds, struct timeval* timeout), 
     105         (nfds, readfds, writefds, exceptfds, timeout)); 
     106DEF_ORIG(poll, int, (struct pollfd* fds, nfds_t nfds, int timeout), 
     107         (fds, nfds, timeout)); 
    100108 
    101109#undef DEF_ORIG 
     
    104112extern void moremem_init(void)  
    105113{ 
     114  /* create temporary file and mmap */ 
    106115  memfd = create_memfile(); 
    107116  assert((moremem = mmap(NULL, MAXMEM, PROT_READ | PROT_WRITE | PROT_EXEC, 
     
    120129  DLSYM(wait); 
    121130  DLSYM(waitpid); 
     131  DLSYM(fgetc); 
     132  DLSYM(fgets); 
     133  DLSYM(select); 
     134  DLSYM(poll); 
    122135#undef DLSYM 
    123136}