Userspace x86 mmap() calls portability
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 9 Feb 2010 22:47:27 +0000 (14:47 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 9 Feb 2010 22:47:27 +0000 (14:47 -0800)
Passing -1 for the fd when making anonymous mappings.

user/apps/roslib/mproctests.c
user/parlib/src/i386/ldt.c
user/roslib/src/i386/entry.S

index 6d947bd..289c72d 100644 (file)
@@ -51,7 +51,7 @@ int main(int argc, char** argv)
                                cprintf("Testing MMAP\n");
                                void *CT(8*PGSIZE) addr;
                                addr = sys_mmap((void*SNT)USTACKTOP - 20*PGSIZE, 8*PGSIZE, 3,
-                                               MAP_FIXED, 0, 0);
+                                               MAP_FIXED | MAP_ANONYMOUS, -1, 0);
                                cprintf("got addr = 0x%08x\n", addr);
                                *(int*)addr = 0xdeadbeef;
                                *(int*)(addr + 3*PGSIZE) = 0xcafebabe;
index 0d67a8b..8fcd012 100644 (file)
@@ -37,7 +37,7 @@ void ldt_init(uint32_t core_id) {
                procdata.ldt = sys_mmap((void*)USTACKBOT - LDT_SIZE,
                                        sizeof(segdesc_t) * hart_max_harts(),
                                        PROT_READ | PROT_WRITE,
-                                       MAP_ANONYMOUS | MAP_FIXED | MAP_POPULATE, 0, 0);
+                                       MAP_ANONYMOUS | MAP_FIXED | MAP_POPULATE, -1, 0);
                sys_getpid(); // force a kernel crossing to reload the LDT
                if (!procdata.ldt) {
                        debug("Unable to mmap() an LDT!  Exiting...\n");
index 0ae8544..e8df9b7 100644 (file)
@@ -83,7 +83,7 @@ new_core:
 .data
 mmap_args:
        .long MAP_ANONYMOUS|MAP_FIXED|MAP_STACK|MAP_POPULATE|MAP_GROWSDOWN // arg4
-       .long              // arg5
+       .long -1             // arg5
        .long 0              // arg6
 .globl in_multi_mode
 in_multi_mode: