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_STDINT_H)
38 #if defined(HAVE_STDLIB_H)
42 #if defined(HAVE_STRING_H)
46 #if defined(HAVE_UNISTD_H)
50 #if defined(HAVE_SYS_MMAN_H)
51 # include <sys/mman.h>
55 /* inline functions ***********************************************************/
57 inline static void *system_calloc(size_t nmemb, size_t size)
59 #if defined(HAVE_CALLOC)
60 return calloc(nmemb, size);
62 # error calloc not available
66 inline static void system_free(void *ptr)
68 #if defined(HAVE_FREE)
71 # error free not available
75 inline static int system_getpagesize(void)
77 #if defined(HAVE_GETPAGESIZE)
80 # error getpagesize not available
84 inline static void *system_malloc(size_t size)
86 #if defined(HAVE_MALLOC)
89 # error malloc not available
93 inline static void *system_memcpy(void *dest, const void *src, size_t n)
95 #if defined(HAVE_MEMCPY)
96 return memcpy(dest, src, n);
98 # error memcpy not available
102 inline static void *system_memset(void *s, int c, size_t n)
104 #if defined(HAVE_MEMSET)
105 return memset(s, c, n);
107 # error memset not available
111 inline static int system_mprotect(void *addr, size_t len, int prot)
113 #if defined(HAVE_MPROTECT)
114 return mprotect(addr, len, prot);
116 # error mprotect not available
120 inline static void *system_realloc(void *ptr, size_t size)
122 #if defined(HAVE_REALLOC)
123 return realloc(ptr, size);
125 # error realloc not available
130 /* function prototypes ********************************************************/
132 void *system_mmap_anonymous(void *addr, size_t len, int prot, int flags);
133 int system_processors_online(void);
135 #endif /* _VMCORE_SYSTEM_H */
139 * These are local overrides for various environment variables in Emacs.
140 * Please do not remove this and leave it at the end of the file, where
141 * Emacs will automagically detect them.
142 * ---------------------------------------------------------------------
145 * indent-tabs-mode: t
149 * vim:noexpandtab:sw=4:ts=4: