- created jitcache-arm-x86 branch
[cacao.git] / src / vmcore / system.h
index d98bd9010666a0befd553c3f44d0fc1fb3351a86..8a052aedc9a06a06b041c28345eda1086299c7d1 100644 (file)
 # include <dirent.h>
 #endif
 
+#if defined(HAVE_DLFCN_H)
+# include <dlfcn.h>
+#endif
+
 #if defined(HAVE_FCNTL_H)
 # include <fcntl.h>
 #endif
 
-#if defined(WITH_JRE_LAYOUT)
+#if defined(ENABLE_JRE_LAYOUT)
 # if defined(HAVE_LIBGEN_H)
 #  include <libgen.h>
 # endif
@@ -147,7 +151,7 @@ inline static int system_connect(int sockfd, const struct sockaddr *serv_addr, s
 #endif
 }
 
-#if defined(WITH_JRE_LAYOUT)
+#if defined(ENABLE_JRE_LAYOUT)
 inline static char *system_dirname(char *path)
 {
 #if defined(HAVE_DIRNAME)
@@ -158,6 +162,42 @@ inline static char *system_dirname(char *path)
 }
 #endif
 
+inline static int system_dlclose(void* handle)
+{
+#if defined(HAVE_DLCLOSE)
+       return dlclose(handle);
+#else
+# error dlclose not available
+#endif
+}
+
+inline static char* system_dlerror(void)
+{
+#if defined(HAVE_DLERROR)
+       return dlerror();
+#else
+# error dlerror not available
+#endif
+}
+
+inline static void* system_dlopen(const char* filename, int flag)
+{
+#if defined(HAVE_DLOPEN)
+       return dlopen(filename, flag);
+#else
+# error dlopen not available
+#endif
+}
+
+inline static void* system_dlsym(void* handle, const char* symbol)
+{
+#if defined(HAVE_DLSYM)
+       return dlsym(handle, symbol);
+#else
+# error dlsym not available
+#endif
+}
+
 inline static FILE *system_fopen(const char *path, const char *mode)
 {
 #if defined(HAVE_FOPEN)
@@ -185,6 +225,15 @@ inline static size_t system_fread(void *ptr, size_t size, size_t nmemb, FILE *st
 #endif
 }
 
+inline static int system_fseek(FILE *stream, off_t offset, int whence)
+{
+#if defined(HAVE_FSEEK)
+       return fseek(stream, offset, whence);
+#else
+# error fseek not available
+#endif
+}
+
 inline static void system_free(void *ptr)
 {
 #if defined(HAVE_FREE)
@@ -329,7 +378,13 @@ inline static void *system_realloc(void *ptr, size_t size)
 #endif
 }
 
+#if defined(__LINUX__)
 inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *))
+#elif defined(__IRIX__)
+inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(dirent_t *), int(*compar)(dirent_t **, dirent_t **))
+#else
+inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(struct dirent *), int(*compar)(const void *, const void *))
+#endif
 {
 #if defined(HAVE_SCANDIR)
        return scandir(dir, namelist, filter, compar);