https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97461

Liu Hao <lh_mouse at 126 dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lh_mouse at 126 dot com

--- Comment #31 from Liu Hao <lh_mouse at 126 dot com> ---
(In reply to Jakub Jelinek from comment #29)
> CCing some folks familiar with Windows, while Martin has committed a mmap
> based solution, I think it will not work on Windows, but
> CreateFileMapping/MapViewOfFile/UnmapViewOfFile/CloseHandle could be a
> Windows replacement for that:
> https://gcc.gnu.org/pipermail/gcc-patches/2021-February/565575.html
> Can anyone of you please have a look into that?
> I don't have access to Windows (and my experience with it is 25+ years old
> anyway), and Martin doesn't have either.

Windows has native heap management functions [1] so there is no need to play
with file mappings like `mmap()`.

`malloc(size)` becomes `HeapAlloc(GetProcessHeap(), 0, size)`, and
`calloc(nmemb, size)` becomes `HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
nmemb * size)` except for the overflow check, and
`realloc(ptr, size)` becomes `ptr ? HeapReAlloc(GetProcessHeap(), 0, ptr, size)
: HeapAlloc(GetProcessHeap(), 0, size)`, and
`free(ptr)` becomes `ptr && HeapFree(GetProcessHeap(), ptr)`.


[1]
https://docs.microsoft.com/en-us/windows/win32/api/heapapi/nf-heapapi-heapalloc

Reply via email to