Re: [PATCH 1/6] Add memory pool library
- From
Erik Faye-Lund <kusmabite@googlemail.com>
- Date
- Jun 7, 2010, 14:00 UTC
- Message-ID
- <AANLkTimd_l0uKHTqgS211fv30hxd-k0pR55YoY4xCua1@mail.gmail.com>
- In-Reply-To
- <AANLkTimzuJXjX4OJUkmQtLwjGDgHBaZUHSGA0xUUi6kY@mail.gmail.com>
On Mon, Jun 7, 2010 at 3:28 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
Show 5 quoted lines
>> Probably an ignorant question, but why? I do not think the win32 mmap >> emulation in git currently supports sysconf(). > > I'm not sure why the pool capacity should be dependent on the page size. >
My guess would be that it's a performance-thing.
Adding a win32-implementation of sysconf for this purpose isn't tricky, but perhaps it's a little bit overkill. Can't we just use some large power of two number? Hopefully, we could chose a size that is a multiple of the page-size on all systems...
Anyway, this is roughly what a Windows-implementation of sysconf would look like (not tested - only checked that it compiles):
diff --git a/compat/mingw.c b/compat/mingw.c index f90a114..526f0f9 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1473,3 +1473,13 @@ struct dirent *mingw_readdir(DIR *dir) return (struct dirent*)&dir->dd_dir; } #endif // !NO_MINGW_REPLACE_READDIR + +long mingw_sysconf(int name) +{ + SYSTEM_INFO si; + if (name != _SC_PAGESIZE) + return errno = EINVAL, + error("sysconf emulation only supports _SC_PAGESIZE"); + GetSystemInfo(&si); + return si.dwPageSize; +} diff --git a/compat/mingw.h b/compat/mingw.h index 6c6cbda..db28b0d 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -322,3 +322,7 @@ struct dirent *mingw_readdir(DIR *dir); * Used by Pthread API implementation for Windows */ extern int err_win_to_posix(DWORD winerr); + +#define _SC_PAGESIZE 0 +long mingw_sysconf(int name); +#define sysconf mingw_sysconf
-- Erik "kusma" Faye-Lund