29 #if defined(__DARWIN__)
30 # include <mach/mach.h>
31 # include <mach/mach_host.h>
32 # include <mach/host_info.h>
185 char* buf =
MNEW(
char, size);
187 while (buf != NULL) {
188 if (
getcwd(buf, size) != NULL)
191 MFREE(buf,
char, size);
202 buf =
MNEW(
char, size);
219 #if defined(MAP_ANON) || defined(MAP_ANONYMOUS)
220 p = mmap(addr, len, prot,
221 #
if defined(MAP_ANON)
224 MAP_ANONYMOUS | flags,
230 fd = open(
"/dev/zero", O_RDONLY, 0);
235 p = mmap(addr, len, prot, flags, fd, 0);
238 #if defined(MAP_FAILED)
241 if (p == (
void *) -1)
254 #define BACKTRACE_SIZE 100
280 #if defined(_SC_NPROC_ONLN)
282 return (
int) sysconf(_SC_NPROC_ONLN);
284 #elif defined(_SC_NPROCESSORS_ONLN)
286 return (
int) sysconf(_SC_NPROCESSORS_ONLN);
288 #elif defined(__DARWIN__)
290 host_basic_info_data_t hinfo;
291 mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
294 rc = host_info(mach_host_self(), HOST_BASIC_INFO,
295 (host_info_t) &hinfo, &hinfo_count);
297 if (rc != KERN_SUCCESS) {
303 return (
int) hinfo.avail_cpus;
305 #elif defined(__FREEBSD__)
306 # error IMPLEMENT ME!
static void * memset(void *s, int c, size_t n)
static char * strerror(int errnum)
static int processors_online()
Returns the number of online processors in the system.
static int backtrace(void **array, int size)
static void abort_errno(const char *text,...)
Equal to abort_errnum, but uses errno to get the error number.
static void unimplemented()
static void print_backtrace()
Print a C backtrace.
void * os_mmap_anonymous(void *addr, size_t len, int prot, int flags)
void log_println(const char *text,...)
static void free(void *ptr)
JNIEnv jthread jobject jclass jlong size
void * os_memcpy(void *dest, const void *src, size_t n)
static size_t strlen(const char *s)
static void abort_errnum(int errnum, const char *text,...)
Prints an error message, appends ":" plus the strerror-message of errnum and aborts the VM...
static int atoi(const char *nptr)
void log_print(const char *text,...)
#define MFREE(ptr, type, num)
static int getpagesize(void)
static char ** backtrace_symbols(void *const *array, int size)
void log_vprint(const char *text, va_list ap)
static char * getcwd(void)
Return the current working directory.
static void * memcpy(void *dest, const void *src, size_t n)
char * os_strdup(const char *s)
static void * mmap_anonymous(void *addr, size_t len, int prot, int flags)
Maps anonymous memory, even on systems not defining MAP_ANON(YMOUS).
void * os_memset(void *s, int c, size_t n)
static void shouldnotreach()
int os_atoi(const char *nptr)
static void abort_verrnum(int errnum, const char *text, va_list ap)
Common code for both os::abort_errnum and os::abort_errno.
int os_strlen(const char *s)
static char * strdup(const char *s)