2 Copyright (C) 2004, 2005 Jeroen Frijters
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
28 JNIEXPORT
void* JNICALL
ikvm_LoadLibrary(char* psz
)
30 return LoadLibrary(psz
);
33 JNIEXPORT
void JNICALL
ikvm_FreeLibrary(HMODULE handle
)
38 JNIEXPORT
void* JNICALL
ikvm_GetProcAddress(HMODULE handle
, char* name
, jint argc
)
41 return GetProcAddress(handle
, name
);
45 if(strlen(name
) > sizeof(buf
) - 11)
49 wsprintf(buf
, "_%s@%d", name
, argc
);
50 pfunc
= GetProcAddress(handle
, buf
);
53 // If we didn't find the mangled name, try the unmangled name (this happens if you have an
54 // explicit EXPORT in the linker def).
55 return GetProcAddress(handle
, name
);
60 #include <sys/types.h>
64 void* JNICALL
ikvm_LoadLibrary(char* psz
);
66 JNIEXPORT
void* JNICALL
ikvm_LoadLibrary(char* psz
)
68 return g_module_open(psz
, 0);
71 void JNICALL
ikvm_FreeLibrary(GModule
* handle
);
73 JNIEXPORT
void JNICALL
ikvm_FreeLibrary(GModule
* handle
)
75 g_module_close(handle
);
78 void* JNICALL
ikvm_GetProcAddress(GModule
* handle
, char* name
, jint argc
);
80 JNIEXPORT
void* JNICALL
ikvm_GetProcAddress(GModule
* handle
, char* name
, jint argc
)
84 gboolean res
= g_module_symbol(handle
, name
, &symbol
);
92 void* JNICALL
ikvm_mmap(int fd
, jboolean writeable
, jboolean copy_on_write
, jlong position
, jint size
);
94 JNIEXPORT
void* JNICALL
ikvm_mmap(int fd
, jboolean writeable
, jboolean copy_on_write
, jlong position
, jint size
)
96 return mmap(0, size
, writeable
? PROT_WRITE
| PROT_READ
: PROT_READ
, copy_on_write
? MAP_PRIVATE
: MAP_SHARED
, fd
, position
);
99 int JNICALL
ikvm_munmap(void* address
, jint size
);
101 JNIEXPORT
int JNICALL
ikvm_munmap(void* address
, jint size
)
103 return munmap(address
, size
);
106 int JNICALL
ikvm_msync(void* address
, jint size
);
108 JNIEXPORT
int JNICALL
ikvm_msync(void* address
, jint size
)
110 #if defined(__native_client__) && defined(USE_NEWLIB)
111 g_assert_not_reached ();
114 return msync(address
, size
, MS_SYNC
);