/* src/vmcore/system.h - system (OS) functions
Copyright (C) 2007
- CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
/* NOTE: In this file we check for all system headers, because we wrap
all system calls into inline functions for better portability. */
+#if defined(HAVE_FCNTL_H)
+# include <fcntl.h>
+#endif
+
#if defined(HAVE_STDINT_H)
# include <stdint.h>
#endif
# include <sys/mman.h>
#endif
+#if defined(HAVE_SYS_SOCKET_H)
+# include <sys/socket.h>
+#endif
+
+#if defined(HAVE_SYS_TYPES_H)
+# include <sys/types.h>
+#endif
+
/* inline functions ***********************************************************/
+inline static int system_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
+{
+#if defined(HAVE_ACCEPT)
+ return accept(sockfd, addr, addrlen);
+#else
+# error accept not available
+#endif
+}
+
inline static void *system_calloc(size_t nmemb, size_t size)
{
#if defined(HAVE_CALLOC)
#endif
}
+inline static int system_close(int fd)
+{
+#if defined(HAVE_CLOSE)
+ return close(fd);
+#else
+# error close not available
+#endif
+}
+
+inline static int system_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
+{
+#if defined(HAVE_CONNECT)
+ return connect(sockfd, serv_addr, addrlen);
+#else
+# error connect not available
+#endif
+}
+
inline static void system_free(void *ptr)
{
#if defined(HAVE_FREE)
#endif
}
+inline static int system_fsync(int fd)
+{
+#if defined(HAVE_FSYNC)
+ return fsync(fd);
+#else
+# error fsync not available
+#endif
+}
+
+inline static int system_ftruncate(int fd, off_t length)
+{
+#if defined(HAVE_FTRUNCATE)
+ return ftruncate(fd, length);
+#else
+# error ftruncate not available
+#endif
+}
+
+inline static int system_gethostname(char *name, size_t len)
+{
+#if defined(HAVE_GETHOSTNAME)
+ return gethostname(name, len);
+#else
+# error gethostname not available
+#endif
+}
+
inline static int system_getpagesize(void)
{
#if defined(HAVE_GETPAGESIZE)
#endif
}
+inline static int system_getsockname(int s, struct sockaddr *name, socklen_t *namelen)
+{
+#if defined(HAVE_GETSOCKNAME)
+ return getsockname(s, name, namelen);
+#else
+# error getsockname not available
+#endif
+}
+
+inline static int system_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
+{
+#if defined(HAVE_GETSOCKOPT)
+ return getsockopt(s, level, optname, optval, optlen);
+#else
+# error getsockopt not available
+#endif
+}
+
+inline static int system_listen(int sockfd, int backlog)
+{
+#if defined(HAVE_LISTEN)
+ return listen(sockfd, backlog);
+#else
+# error listen not available
+#endif
+}
+
+inline static off_t system_lseek(int fildes, off_t offset, int whence)
+{
+#if defined(HAVE_LSEEK)
+ return lseek(fildes, offset, whence);
+#else
+# error lseek not available
+#endif
+}
+
inline static void *system_malloc(size_t size)
{
#if defined(HAVE_MALLOC)
#endif
}
+inline static int system_open(const char *pathname, int flags, mode_t mode)
+{
+#if defined(HAVE_OPEN)
+ return open(pathname, flags, mode);
+#else
+# error open not available
+#endif
+}
+
+inline static ssize_t system_read(int fd, void *buf, size_t count)
+{
+#if defined(HAVE_READ)
+ return read(fd, buf, count);
+#else
+# error read not available
+#endif
+}
+
inline static void *system_realloc(void *ptr, size_t size)
{
#if defined(HAVE_REALLOC)
#endif
}
+inline static int system_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
+{
+#if defined(HAVE_SETSOCKOPT)
+ return setsockopt(s, level, optname, optval, optlen);
+#else
+# error setsockopt not available
+#endif
+}
+
+inline static int system_shutdown(int s, int how)
+{
+#if defined(HAVE_SHUTDOWN)
+ return shutdown(s, how);
+#else
+# error shutdown not available
+#endif
+}
+
+inline static int system_socket(int domain, int type, int protocol)
+{
+#if defined(HAVE_SOCKET)
+ return socket(domain, type, protocol);
+#else
+# error socket not available
+#endif
+}
+
+inline static ssize_t system_write(int fd, const void *buf, size_t count)
+{
+#if defined(HAVE_WRITE)
+ return write(fd, buf, count);
+#else
+# error write not available
+#endif
+}
+
/* function prototypes ********************************************************/