nh2 / nh2/shared-memory

mmap fails when compiled for 32bit

Offen
#4 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Haskell
Sterne
9
Forks
2
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

https://users.suse.com/~aj/linux_lfs.html

```
#ifndef __USE_FILE_OFFSET64
extern void *mmap (void *__addr, size_t __len, int __prot,
int __flags, int __fd, __off_t __offset) __THROW;
#else
# ifdef __REDIRECT_NTH
extern void * __REDIRECT_NTH (mmap,
(void *__addr, size_t __len, int __prot,
int __flags, int __fd, __off64_t __offset),
mmap64);
# else
# define mmap mmap64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern void *mmap64 (void *__addr, size_t __len, int __prot,
int __flags, int __fd, __off64_t __offset) __THROW;
#endif
```

on 32bit platforms, behind the scenes, the type of `off_t` changes depending on how a program is compiled
glibc then uses a macro to map `mmap` to either the real `mmap` or the `mmap64` version, based on the size of `off_t`

haskell base was compiled with large-file-support, so `COff` is 64bits, but then the ffi grabs the raw `mmap` symbol, the 32bit version

the simplest solution is to use cbits and `Word64` to get the values into c code, then (with LFS enabled), call mmap from c, and let the macro do its job

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.