Przemyslaw,
yes, DosAllocMem() and DosQueryMem() should be enough. I'm not sure about the
coalescing thing, since DosQueryMem() gives you back size of a memory object
in bytes and access control flags while the windows version seems to be giving
back more infos.
Maurilio.
Przemysław Czerpak wrote:
> On Mon, 23 Nov 2009, Maurilio Longo wrote:
>> there is no MMAP api on OS/2.
>
> Just like in MS-Windows.
>
>> Long ago I write an emulation layer which is
>> still around to help porting miniSQL to OS/2. It worked ok, but it was an
>> hack
>> with several limitations (in particular for mmapping shared regions).
>> In my opinion dlmalloc should not be used on OS/2 if it does not work without
>> mmap().
>
> It works without MMAP.
> It does not need strict MMAPs but only access to functions which allocates
> and frees range of memory pages from system. See code below used in
> MS-Windows builds. I do not know details of OS2 API but seems that adding
> support for OS2 is only simple replacing Virtual*() WIN-API functions with
> Dos*Mem() OS2-API functions. If I'm right then above modification can be
> done in few minutes. What do you think about it?
>
> best regards,
> Przemek
>
>
>>> This code is used for WIN32 builds:
>>>
>>> /* Win32 MMAP via VirtualAlloc */
>>> static void* win32mmap(size_t size) {
>>> void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT,
>>> PAGE_READWRITE);
>>> return (ptr != 0)? ptr: MFAIL;
>>> }
>>>
>>> /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */
>>> static void* win32direct_mmap(size_t size) {
>>> void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN,
>>> PAGE_READWRITE);
>>> return (ptr != 0)? ptr: MFAIL;
>>> }
>>>
>>> /* This function supports releasing coalesed segments */
>>> static int win32munmap(void* ptr, size_t size) {
>>> MEMORY_BASIC_INFORMATION minfo;
>>> char* cptr = (char*)ptr; /* NOTE: Harbour fix for MSVC C++ mode
>>> compile error. Also fixed in dlmalloc 2.8.4b. [vszakats] */
>>> while (size) {
>>> if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0)
>>> return -1;
>>> if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr ||
>>> minfo.State != MEM_COMMIT || minfo.RegionSize > size)
>>> return -1;
>>> if (VirtualFree(cptr, 0, MEM_RELEASE) == 0)
>>> return -1;
>>> cptr += minfo.RegionSize;
>>> size -= minfo.RegionSize;
>>> }
>>> return 0;
>>> }
>>>
>>> #define CALL_MMAP(s) win32mmap(s)
>>> #define CALL_MUNMAP(a, s) win32munmap((a), (s))
>>> #define DIRECT_MMAP(s) win32direct_mmap(s)
> _______________________________________________
> Harbour mailing list (attachment size limit: 40KB)
> [email protected]
> http://lists.harbour-project.org/mailman/listinfo/harbour
>
--
__________
| | | |__| Maurilio Longo
|_|_|_|____| farmaconsult s.r.l.
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour