Merge branch 'master' of https://github.com/mono/mono
[mono.git] / ikvm-native / os.c
index 9098d269b379430202a771b1fa672be77a665be5..9f2115f712ba6c2726969e963ebe4aa246048529 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2004 Jeroen Frijters
+  Copyright (C) 2004, 2005 Jeroen Frijters
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -57,6 +57,8 @@
        }
 #else
        #include <gmodule.h>
+       #include <sys/types.h>
+       #include <sys/mman.h>
        #include "jni.h"
 
        JNIEXPORT void* JNICALL ikvm_LoadLibrary(char* psz)
                else
                        return NULL;
        }
+
+       JNIEXPORT void* JNICALL ikvm_mmap(int fd, jboolean writeable, jboolean copy_on_write, jlong position, jint size)
+       {
+               return mmap(0, size, writeable ? PROT_WRITE | PROT_READ : PROT_READ, copy_on_write ? MAP_PRIVATE : MAP_SHARED, fd, position);
+       }
+
+       JNIEXPORT int JNICALL ikvm_munmap(void* address, jint size)
+       {
+               return munmap(address, size);
+       }
+
+       JNIEXPORT int JNICALL ikvm_msync(void* address, jint size)
+       {
+#if defined(__native_client__) && defined(USE_NEWLIB)
+               g_assert_not_reached ();
+               return -1;
+#else
+               return msync(address, size, MS_SYNC);
+#endif
+       }
 #endif