/* src/vmcore/system.h - system (OS) functions
- Copyright (C) 2007
+ Copyright (C) 2007, 2008
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
# 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
/* inline functions ***********************************************************/
+inline static void system_abort(void)
+{
+#if defined(HAVE_ABORT)
+ abort();
+#else
+# error abort not available
+#endif
+}
+
inline static int system_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
#if defined(HAVE_ACCEPT)
#endif
}
+inline static int system_atoi(const char *nptr)
+{
+#if defined(HAVE_ATOI)
+ return atoi(nptr);
+#else
+# error atoi not available
+#endif
+}
+
inline static void *system_calloc(size_t nmemb, size_t size)
{
#if defined(HAVE_CALLOC)
#endif
}
-#if defined(WITH_JRE_LAYOUT)
+#if defined(ENABLE_JRE_LAYOUT)
inline static char *system_dirname(char *path)
{
#if defined(HAVE_DIRNAME)
}
#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)
#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)
#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);
#endif
}
-inline static int system_stat(const char *path, struct stat *buf)
-{
-#if defined(HAVE_STAT)
- return stat(path, buf);
-#else
-# error stat not available
-#endif
-}
-
inline static int system_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
{
#if defined(HAVE_SETSOCKOPT)
#endif
}
+inline static int system_stat(const char *path, struct stat *buf)
+{
+#if defined(HAVE_STAT)
+ return stat(path, buf);
+#else
+# error stat not available
+#endif
+}
+
+inline static char *system_strcat(char *dest, const char *src)
+{
+#if defined(HAVE_STRCAT)
+ return strcat(dest, src);
+#else
+# error strcat not available
+#endif
+}
+
+inline static char *system_strcpy(char *dest, const char *src)
+{
+#if defined(HAVE_STRCPY)
+ return strcpy(dest, src);
+#else
+# error strcpy not available
+#endif
+}
+
+inline static char *system_strdup(const char *s)
+{
+#if defined(HAVE_STRDUP)
+ return strdup(s);
+#else
+# error strdup not available
+#endif
+}
+
+inline static char *system_strerror(int errnum)
+{
+#if defined(HAVE_STRERROR)
+ return strerror(errnum);
+#else
+# error strerror not available
+#endif
+}
+
+inline static size_t system_strlen(const char *s)
+{
+#if defined(HAVE_STRLEN)
+ return strlen(s);
+#else
+# error strlen not available
+#endif
+}
+
inline static ssize_t system_write(int fd, const void *buf, size_t count)
{
#if defined(HAVE_WRITE)