jamvm

view src/os/linux/os.c @ 402:24373fc1d951

Add additional tracing support.

2008-08-04 Andrew John Hughes <gnu_andrew@member.fsf.org>

* .hgignore: Updated with autogen.sh output.
* configure.ac: Add new trace options.
* src/class.c,
* src/excep.c,
* src/natives.c,
* src/resolve.c: Add trace support.
* src/jam.h,
* src/dll.c,
* src/os/linux/os.c: Add support for reporting
the linking error using dlerror.
author andrew
date Tue Aug 05 05:46:09 2008 +0100 (2008-08-05)
parents 38790927e2eb
children
line source
1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007
3 * Robert Lougher <rob@lougher.org.uk>.
4 *
5 * This file is part of JamVM.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2,
10 * or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <dlfcn.h>
26 #include <sys/sysinfo.h>
27 #include <pthread.h>
29 #include "../../jam.h"
31 void *nativeStackBase() {
32 #ifdef __UCLIBC__
33 return NULL;
34 #else
35 pthread_attr_t attr;
36 void *addr;
37 size_t size;
39 pthread_getattr_np(pthread_self(), &attr);
40 pthread_attr_getstack(&attr, &addr, &size);
42 return addr+size;
43 #endif
44 }
46 int nativeAvailableProcessors() {
47 #ifdef __UCLIBC__
48 return 1;
49 #else
50 return get_nprocs();
51 #endif
52 }
54 char *nativeLibPath() {
55 return getenv("LD_LIBRARY_PATH");
56 }
58 void *nativeLibOpen(char *path) {
59 return dlopen(path, RTLD_LAZY);
60 }
62 void nativeLibClose(void *handle) {
63 dlclose(handle);
64 }
66 void *nativeLibSym(void *handle, char *symbol) {
67 return dlsym(handle, symbol);
68 }
70 char *nativeLibMapName(char *name) {
71 char *buff = sysMalloc(strlen(name) + sizeof("lib.so") + 1);
73 sprintf(buff, "lib%s.so", name);
74 return buff;
75 }
77 char *nativeLibError() {
78 return dlerror();
79 }