summaryrefslogtreecommitdiff
path: root/cpan/dist/Unicode-Japanese/xs_test.c
blob: b29903e05b9c5ed3deeaac803a0ab278ce4fc975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* $Id: xs_test.c,v 1.1 2002/01/18 17:17:19 hio Exp $ */

#include "mediate.h"
#include <unistd.h>   // memmap
#include <sys/mman.h> // memmap
#include <sys/stat.h> // stat
#include <fcntl.h>    // open

#ifndef MAP_FAILED
#define MAP_FAILED ((void*)-1)
#endif

void* do_memmap(char* filepath)
{
  int fd = open(filepath,O_RDONLY|O_NONBLOCK);
  struct stat st;
  int res = fstat(fd,&st);
  void* ptr = mmap(NULL,st.st_size,PROT_READ,MAP_PRIVATE,fd,0);
  close(fd);
  return ptr;
}

void do_unmemmap(void* ptr)
{
  munmap(ptr,0);
}