summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@nexedi.com>2019-03-14 21:11:14 +0300
committerStefan Behnel <stefan_ml@behnel.de>2019-07-19 17:18:15 +0200
commit7047d62cfee083c2b708f22e53e7d7503728383a (patch)
treec985c1646fee565c3b54e2593b661e30384b0e96
parentd24b343141a0ec8f73670e04716d72ed7bceb948 (diff)
downloadcython-7047d62cfee083c2b708f22e53e7d7503728383a.tar.gz
include: posix.mman += MAP_FAILED
mmap returns void* and indicates failure via MAP_FAILED that is defined to be ((void *)-1). Every mmap call has to be checked for failure and thus posix.mman with mmap, but without MAP_FAILED is not very useful. We cannot declare MAP_FAILED as enum, because enum assumes int. However Cython documentation says 4. If the header file uses macros to define constants, translate them into a normal external variable declaration. ... (https://cython.readthedocs.io/en/latest/src/userguide/external_C_code.html#referencing-c-header-files) So add proper declaration for MAP_FAILED to make posix.mman.mmap usable. (cherry picked from commit 6725304967f4c4235cb0113c6f0e8b56bc683478)
-rw-r--r--Cython/Includes/posix/mman.pxd2
1 files changed, 2 insertions, 0 deletions
diff --git a/Cython/Includes/posix/mman.pxd b/Cython/Includes/posix/mman.pxd
index f4a5503fb..e8d0ddd54 100644
--- a/Cython/Includes/posix/mman.pxd
+++ b/Cython/Includes/posix/mman.pxd
@@ -24,6 +24,8 @@ cdef extern from "<sys/mman.h>" nogil:
enum: MAP_NOCORE # Typically available only on BSD
enum: MAP_NOSYNC
+ void *MAP_FAILED
+
void *mmap(void *addr, size_t Len, int prot, int flags, int fd, off_t off)
int munmap(void *addr, size_t Len)
int mprotect(void *addr, size_t Len, int prot)