iconv: add euro symbol to GBK as single byte 0x80
[musl.git] / src / time / __map_file.c
blobc2b29fe81b9056e13ca95d8c213f1cbcb6d4f1e2
1 #include <sys/mman.h>
2 #include <fcntl.h>
3 #include <sys/stat.h>
4 #include "syscall.h"
6 const char unsigned *__map_file(const char *pathname, size_t *size)
8 struct stat st;
9 const unsigned char *map = MAP_FAILED;
10 int fd = sys_open(pathname, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
11 if (fd < 0) return 0;
12 if (!__fstat(fd, &st)) {
13 map = __mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
14 *size = st.st_size;
16 __syscall(SYS_close, fd);
17 return map == MAP_FAILED ? 0 : map;