1 /* src/vmcore/system.h - system (OS) functions
4 CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #ifndef _VMCORE_SYSTEM_H
27 #define _VMCORE_SYSTEM_H
31 /* NOTE: In this file we check for all system headers, because we wrap
32 all system calls into inline functions for better portability. */
34 #if defined(HAVE_FCNTL_H)
38 #if defined(HAVE_STDINT_H)
42 #if defined(HAVE_STDLIB_H)
46 #if defined(HAVE_STRING_H)
50 #if defined(HAVE_UNISTD_H)
54 #if defined(HAVE_SYS_MMAN_H)
55 # include <sys/mman.h>
59 /* inline functions ***********************************************************/
61 inline static void *system_calloc(size_t nmemb, size_t size)
63 #if defined(HAVE_CALLOC)
64 return calloc(nmemb, size);
66 # error calloc not available
70 inline static int system_close(int fd)
72 #if defined(HAVE_CLOSE)
75 # error close not available
79 inline static void system_free(void *ptr)
81 #if defined(HAVE_FREE)
84 # error free not available
88 inline static int system_getpagesize(void)
90 #if defined(HAVE_GETPAGESIZE)
93 # error getpagesize not available
97 inline static void *system_malloc(size_t size)
99 #if defined(HAVE_MALLOC)
102 # error malloc not available
106 inline static void *system_memcpy(void *dest, const void *src, size_t n)
108 #if defined(HAVE_MEMCPY)
109 return memcpy(dest, src, n);
111 # error memcpy not available
115 inline static void *system_memset(void *s, int c, size_t n)
117 #if defined(HAVE_MEMSET)
118 return memset(s, c, n);
120 # error memset not available
124 inline static int system_mprotect(void *addr, size_t len, int prot)
126 #if defined(HAVE_MPROTECT)
127 return mprotect(addr, len, prot);
129 # error mprotect not available
133 inline static int system_open(const char *pathname, int flags, mode_t mode)
135 #if defined(HAVE_OPEN)
136 return open(pathname, flags, mode);
138 # error open not available
142 inline static ssize_t system_read(int fd, void *buf, size_t count)
144 #if defined(HAVE_READ)
145 return read(fd, buf, count);
147 # error read not available
151 inline static void *system_realloc(void *ptr, size_t size)
153 #if defined(HAVE_REALLOC)
154 return realloc(ptr, size);
156 # error realloc not available
160 inline static ssize_t system_write(int fd, const void *buf, size_t count)
162 #if defined(HAVE_WRITE)
163 return write(fd, buf, count);
165 # error write not available
170 /* function prototypes ********************************************************/
172 void *system_mmap_anonymous(void *addr, size_t len, int prot, int flags);
173 int system_processors_online(void);
175 #endif /* _VMCORE_SYSTEM_H */
179 * These are local overrides for various environment variables in Emacs.
180 * Please do not remove this and leave it at the end of the file, where
181 * Emacs will automagically detect them.
182 * ---------------------------------------------------------------------
185 * indent-tabs-mode: t
189 * vim:noexpandtab:sw=4:ts=4: