Porting to OS/2: Case #16 mmap()

mmap() is used to map a file into memory. It is known that using mmap() is more efficiency than using file-related functions such as read()/write(). So many projects are using it. Unfortunately, however, OS/2 kLIBC does not support mmap(). And OS/2 itself does not have features corresponding to mmap() directly. Because of this, there is need to implement mmap() by ourselves.

When I was porting binary codec support of MPlayer to OS/2, mmap() was needed. Although it does not have all the features which mmap() has, it is useful generally.

// ----- 2014/11/04
It support MAP_PRIVATE, partially MAP_FIXED but not MAP_SHARED.
It supports MAP_PRIVATE, MAP_SHARED and partially MAP_FIXED.
// -----

mmap.c mmap.h mmap-1.c

mmap-1.c is a test program for mmap(). To build,

  • gcc -o mmap-1.exe mmap-1.c mmap.c
Finally, you should be careful for translation mode. If opening in text mode, translation of CR/LF to LF may cause unexpected behaviors. And even if opening in binary mode, you should process CR/LF of text files carefully. Nevertheless, it is recommended to open in binary mode if possible. Because it assures that at least 1 on 1 correspondence between a memory and a file.

이 블로그의 인기 게시물

토렌트: < 왕좌의 게임 > 시즌 1 ~ 시즌 8 완결편 마그넷

토렌트: NGC < 코스모스 > 우리말 더빙 전편(1편~13편) 마그넷

토렌트: < 스타워즈 > Ep.1 ~ Ep.6 마그넷