Mercurial > hg > Game > Cerium
changeset 1709:8792afbb0cf0 draft
merge
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Oct 2013 17:53:27 +0900 |
parents | 9392f4d97cff (current diff) 64bb17ddc3e6 (diff) |
children | d32d5659695a |
files | |
diffstat | 1 files changed, 4 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/example/regex_mas/main.cc Tue Oct 08 17:50:02 2013 +0900 +++ b/example/regex_mas/main.cc Tue Oct 08 17:53:27 2013 +0900 @@ -57,12 +57,10 @@ static st_mmap_t -my_mmap(char *filename) +my_read(TaskManager *manager,char *filename) { - /*マッピングだよ!*/ int fd = -1; - int map = MAP_PRIVATE; st_mmap_t st_mmap; struct stat sb; @@ -76,39 +74,10 @@ /*sizeをページングサイズの倍数にあわせる*/ st_mmap.size = fix_byte(sb.st_size,4096); - - st_mmap.file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_READ,map,fd,(off_t)0); - if (st_mmap.file_mmap == (caddr_t)-1) { - fprintf(stderr,"Can't mmap file\n"); - perror(NULL); - exit(0); - } - - return st_mmap; - -} + st_mmap.file_mmap = (char*)manager->allocate(st_mmap.size); -static st_mmap_t -my_fread(TaskManager *manager,char *filename) -{ - /*マッピングだよ!*/ - FILE *fd; - st_mmap_t st_mmap; - struct stat sb; + read(fd,st_mmap.file_mmap,st_mmap.size); - if ((fd=fopen(filename,"r"))==NULL) { - fprintf(stderr,"can't open %s\n",filename); - } - - if (fstat(fileno(fd),&sb)) { - fprintf(stderr,"can't fstat %s\n",filename); - } - - /*sizeをページングサイズの倍数にあわせる*/ - st_mmap.size = fix_byte(sb.st_size,4096); - - st_mmap.file_mmap = (char*)manager->allocate(st_mmap.size); - fread(st_mmap.file_mmap,st_mmap.size,1,fd); if (st_mmap.file_mmap == (caddr_t)-1) { fprintf(stderr,"Can't mmap file\n"); perror(NULL); @@ -285,7 +254,7 @@ st_mmap_t st_mmap; //st_mmap = my_mmap(filename); - st_mmap = my_fread(manager,filename); + st_mmap = my_read(manager,filename); WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount)); // bzero(w,sizeof(WordCount));