Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions graalpython/com.oracle.graal.python.test/src/tests/test_mmap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -38,11 +38,25 @@
# SOFTWARE.

import mmap
import sys

PAGESIZE = mmap.PAGESIZE
FIND_BUFFER_SIZE = 1024 # keep in sync with FindNode#BUFFER_SIZE


def test_map_private_constant_matches_platform():
assert hasattr(mmap, "MAP_PRIVATE") == (sys.platform != "win32")


def test_access_copy_without_map_private_constant():
m = mmap.mmap(-1, 1, access=mmap.ACCESS_COPY)
try:
m[0] = b'a'[0]
assert m[:] == b'a'
finally:
m.close()


def test_find():
cases = [
# (size, needle_pos)
Expand Down Expand Up @@ -103,4 +117,4 @@ def test_iter():
for i in m:
l.append(i)

assert l == [b'\x02', b'\x03', b'\x04']
assert l == [b'\x02', b'\x03', b'\x04']
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static PMMap doFile(VirtualFrame frame, Object clazz, int fd, long lengthIn, int
prot = PROT_READ.value | PROT_WRITE.value;
break;
case ACCESS_COPY:
flags = MAP_PRIVATE.value;
flags = MAP_PRIVATE.defined ? MAP_PRIVATE.getValueIfDefined() : 0;
prot = PROT_READ.value | PROT_WRITE.value;
break;
case PMMap.ACCESS_DEFAULT:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -150,7 +150,7 @@ public final class PosixConstants {
public static final MandatoryIntConstant S_IFCHR;
public static final MandatoryIntConstant S_IFIFO;
public static final MandatoryIntConstant MAP_SHARED;
public static final MandatoryIntConstant MAP_PRIVATE;
public static final OptionalIntConstant MAP_PRIVATE;
public static final MandatoryIntConstant MAP_ANONYMOUS;
public static final OptionalIntConstant MAP_DENYWRITE;
public static final OptionalIntConstant MAP_EXECUTABLE;
Expand Down Expand Up @@ -483,7 +483,7 @@ public final class PosixConstants {
S_IFCHR = reg.createMandatoryInt("S_IFCHR");
S_IFIFO = reg.createMandatoryInt("S_IFIFO");
MAP_SHARED = reg.createMandatoryInt("MAP_SHARED");
MAP_PRIVATE = reg.createMandatoryInt("MAP_PRIVATE");
MAP_PRIVATE = reg.createOptionalInt("MAP_PRIVATE");
MAP_ANONYMOUS = reg.createMandatoryInt("MAP_ANONYMOUS");
MAP_DENYWRITE = reg.createOptionalInt("MAP_DENYWRITE");
MAP_EXECUTABLE = reg.createOptionalInt("MAP_EXECUTABLE");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -85,7 +85,6 @@ static void getConstants(PosixConstants.Registry constants) {
constants.put("S_IFCHR", 0x00002000);
constants.put("S_IFIFO", 0);
constants.put("MAP_SHARED", 1);
constants.put("MAP_PRIVATE", 2);
constants.put("MAP_ANONYMOUS", 4);
constants.put("PROT_NONE", 0);
constants.put("PROT_READ", 1);
Expand Down
4 changes: 2 additions & 2 deletions scripts/gen_native_cfg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -209,7 +209,7 @@

[mmapFlags]
1 x MAP_SHARED
2 x MAP_PRIVATE
* x MAP_PRIVATE
4 x MAP_ANONYMOUS
* x MAP_DENYWRITE
* x MAP_EXECUTABLE
Expand Down
Loading