bitwiseworks / libcx

kLIBC Extension Library
GNU Lesser General Public License v2.1
11 stars 1 forks source link

MAP_FIXED support #19

Open dmik opened 8 years ago

dmik commented 8 years ago

This issue is to discuss possibilities of adding support for MAP_FIXED in our mmap implementation.

Technically, we may provide the following MAP_FIXED functionality on OS/2:

  1. Allocate a MAP_PRIVATE region at most addresses from the private address space (excluding the first 64K and areas occupied by program code and static objects and the dynamic heap already in use by the time of the mmap call).
  2. Allocate a MAP_SHARED region at a few addresses from the shared address space (excluding all loaded DLL code and the already allocated shared memory).
  3. Allocate a MAP_FIXED subregion from an already allocated !MAP_FIXED mmap region, both the original region and the requested subregion must be either MAP_PRIVATE or MAP_SHARED.
  4. Replace the file associated with the existing mapping (this is basically a special case of 3. where the subregion has the same size as the the original region).

This is a rather limited subset of POSIX functionality and although there are some test cases that use MAP_FIXED in some of the above mentioned ways (see e.g. #12 or #14), I couldn't find a real example of such usage. One exception is Knut's helper kStuff library where fixed mappings are used to load DLLs to their pre-defined locations but it's unclear so far how and when this is used on OS/2 and how critical support for MAP_FIXED is in those applications.

That said, this task is given a low priority for the time being until we find real use cases and decide if anything of the above is worth implementing.