Closed tieugene closed 3 years ago
I committed the change to emulate mremap on non-Linux environments. For Windows, I'll have to replace the whole file (tkrzw_file_mmap.cc) using Win32 API like CreateFile and CreateFileMapping, as I did for Kyoto Cabinet.
I cannot check it on Windows host but macOS built ok (with some warnings). build.log.gz
Another issue - I have to exclude -D_POSIX_C_SOURCE=200809L
during compilation on macOS host:
tkrzw_str_util.cc:507:10: error: use of undeclared identifier 'memmem'
return memmem(text.data(), text.size(), pattern.data(), pattern.size()) != nullptr;
^
tkrzw_str_util.cc:598:7: error: use of undeclared identifier 'memmem'
memmem(text.data(), text.size(), pattern.data(), pattern.size());
^
2 errors generated.
This is because of:
string.h:
#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
...
void *memmem()
cdefs.h:
#define __DARWIN_C_ANSI 010000L
#define __DARWIN_C_FULL 900000L
...
#if defined(_ANSI_SOURCE)
#define __DARWIN_C_LEVEL __DARWIN_C_ANSI
#elif defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) && !defined(_NONSTD_SOURCE)
#define __DARWIN_C_LEVEL _POSIX_C_SOURCE
#else
#define __DARWIN_C_LEVEL __DARWIN_C_FULL
#endif
After solving the equition:
__DARWIN_C_LEVEL = 200809L # == _POSIX_C_SOURCE
__DARWIN_C_FULL = 900000L
__DARWIN_C_LEVEL < __DARWIN_C_FULL
Thanks. I committed the change to suppress the warnings and the error.
As for _POSIX_C_SOURCE, they say "Greater values for _POSIX_C_SOURCE will enable future extensions." So, I set it 999999L for easy maintenance. https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
Thanks. I committed the change to suppress the warnings and the error.
It works, thank you. Build quiet on macOS 10.5.
macOS has no mremap() (tkrzw_file_mmap.cc). And MREMAP_MAYMOVE not defined in it. PS. seems Windows ™ has no mremap() too