summaryrefslogtreecommitdiff
path: root/ruth/ruth.c
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2009-01-16 21:18:32 +0100
committerNeal H. Walfield <neal@gnu.org>2009-01-16 21:18:32 +0100
commit8e7249d8deae3a82c086f435b7e31ec16d1457da (patch)
treef1b309d53e2452b7bfe99cdfbfda0a1697f24e02 /ruth/ruth.c
parent992370c0219936911f3bba6c62b00c886ecae392 (diff)
Conditionalize use of l4 functions on USE_L4.
/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * Makefile.am (L4_SUBDIRS): New variable. Set to l4 directories if USE_L4 is true, otherwise leave empty. (SUBDIRS): Remove libl4 and laden. Replace with $(USE_L4). Rearrange order. benchmarks/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * activity-distribution.c (main): Use vg_thread_id_t and hurd_myself, not l4_thread_id_t and l4_myself. [USE_L4]: Only l4_sleep in this case. * cache.c (helper_fork): Use hurd_myself, not l4_myself. (main) [USE_L4]: Only call _L4_kdb in this case. * shared-memory-distribution.c (main): Use vg_thread_id_t and hurd_myself, not l4_thread_id_t and l4_myself. hieronymus/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * hieronymus.c (main): Use uint64_t, not l4_uint64_t. (main) [USE_L4]: Don't sleep in this case. hurd/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * lock.h (ss_mutex_trace_add) [! USE_L4]: Set SS_LOCK_TRACE[I].TID to zero. * thread.h (hurd_myself) [USE_L4]: Return l4_myself. * trace.h (trace_buffer_add) [! USE_L4 && ! RM_INTERN]: Use hurd_myself, not l4_myself. [! USE_L4 && RM_INTERN]: Don't print a tid. libc-parts/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * _exit.c (_exit): Use sched_yield, not l4_yield. * backtrace.c [USE_L4]: Only include <l4.h> in this case. [! RM_INTERN]: Include <hurd/thread.h>. (backtrace_print) [! USE_L4 && ! RM_INTERN]: Use hurd_myself to get the caller's tid. [! USE_L4 && RM_INTERN]: Don't print a tid. * ia32-cmain.c [! USE_L4]: Don't include <l4/globals.h>, <l4/init.h>, <l4/stubs.h>, or <l4/stubs-init.h>. (cmain) [! USE_L4]: Don't call l4_init or l4_init_stubs. * loader.c: Don't include <l4.h>. Include <bits/wordsize.h> and <endian.h>. (loader_elf_load): Use __WORDSIZE, __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN instead of their L4 names. * panic.c: Include <viengoos/thread.h>. [! RM_INTERN]: Include <hurd/thread.h>. (panic_) [! USE_L4 && ! RM_INTERN]: Use hurd_myself, not l4_myself. [! USE_L4 && RM_INTERN]: Don't print a tid. (panic_): Call sched_yield, not l4_yield. * process-spawn.c (process_spawn) [! USE_L4]: Don't pass utcb and kip information. Change sp from a l4_word_to to a uintptr_t. * profile.c [! USE_L4]: Don't include <l4.h>. (now) [__gnu_hurd_viengoos__ && ! USE_L4]: Just return 0. (struct profile_block): Change tid to a vg_thread_id_t. (MYSELF) [__gnu_hurd_viengoos__ && ! USE_L4]: Just return 0. * s_printf.c (io_buffer_flush) [! USE_L4]: Abort. libhurd-mm/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * anonymous.h: Don't include <l4/thread.h>. Include <viengoos/thread.h>. (struct anonymous_pager): Change fill_thread's type to vg_thread_id_t. * anonymous.c (fault): Use hurd_myself and vg_niltid, not l4_myself and l4_nilthread. * as-build.c: Don't include <l4.h>. * as.h: Include <hurd/thread.h>. Don't include <l4/types.h>. (as_lock): Change as_rwlock_owner's type to vg_thread_id_t. Use hurd_myself, not l4_myself. (as_lock_readonly): Likewise. (as_unlock): Likewise. * as.c [! USE_L4]: Don't include <l4/types.h> or <l4/kip.h>. Include <bits/wordsize.h>. (DATA_ADDR_MAX): Define for 64-bit virtual address spaces. (as_rwlock_owner): Change type to vg_thread_id_t. (as_alloc_slow) [USE_L4]: Only check for conflicts with the kip and utcb in this case. (as_init) [USE_L4]: Only reserve the kip and utcb in this case. * exceptions.c [USE_L4]: Only include <l4/thread.h> in this case. (l4_utcb_state_save) [! USE_L4]: Make a no-op. (l4_utcb_state_restore) [! USE_L4]: Likewise. (hurd_activation_handler_normal): Use hurd_myself, not l4_myself. * map.c: Don't include <l4.h>. (map_fault): Use VG_WRITE, not L4_FPAGE_WRITABLE. * storage.c (storage_check_reserve_internal): Change as_rwlock_owner's type to vg_thread_id_t. libpthread/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * sysdeps/viengoos/pt-spin.c [USE_L4]: Only include <l4.h> in this case. (_pthread_spin_lock): Only implement exponential back off if a sleep function is available. * sysdeps/viengoos/pt-stack-alloc.c: Don't include <l4.h>. * sysdeps/viengoos/pt-sysdep.c (sched_yield) [! USE_L4]: Just return. (init_routine) [USE_L4]: Abort. * sysdeps/viengoos/pt-sysdep.h [USE_L4]: Only include <l4.h> in this case. (_pthread_self) [! USE_L4]: Abort. * sysdeps/viengoos/pt-thread-alloc.c (__pthread_thread_alloc): Use hurd_myself, not l4_myself. [! USE_L4]: Abort. * sysdeps/viengoos/pt-thread-start.c (__pthread_thread_start): Use hurd_myself, not l4_myself. use uintptr_t, not l4_word_t. * sysdeps/viengoos/sig-sysdep.h (SIGNAL_DISPATCH_ENTRY) [! USE_L4]: Abort. (SIGNAL_DISPATCH_EXIT) [! USE_L4]: Likewise. libviengoos/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * viengoos/thread.h (VG_READ): Define. (VG_WRITE): Define. (VG_EXECUTE): Likewise. (VG_ACTIVATION_FAULT_INFO_PRINTF): Use them. ruth/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * ruth.c [USE_L4]: Only include <l4.h> in this case. (main) [! USE_L4]: Don't print resource manager's thread id. (main): Use uintptr_t, not l4_word_t. Use hurd_myself, not l4_myself. Use sched_yield, not l4_yield. Improve synchronization for object_reply_on_destruction test in case sched_yield is a no-op. viengoos/ 2009-01-16 Neal H. Walfield <neal@gnu.org> * cap.h: Don't include <l4.h>. * mutex.h [USE_L4]: Only include <l4/thread.h> in this case. (ss_mutex_t) [! USE_L4]: Define to be an int. (ss_mutex_lock) [! USE_L4]: Make a no-op. (ss_mutex_unlock) [! USE_L4]: Likewise. (ss_mutex_trylock) [! USE_L4]: Likewise. * object.h [USE_L4]: Only include <l4.h> in this case. (object_desc_unmap) [! USE_L4]: Make a no-op. (object_desc_flush) [! USE_L4]: Likewise. * thread.h: Don't include <l4.h>. (struct thread): Make tid a vg_thread_id_t, not an l4_thread_id_t. (thread_lookup): Make threadid a vg_thread_id_t, not an l4_thread_id_t.
Diffstat (limited to 'ruth/ruth.c')
-rw-r--r--ruth/ruth.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/ruth/ruth.c b/ruth/ruth.c
index 82be037..5af88dc 100644
--- a/ruth/ruth.c
+++ b/ruth/ruth.c
@@ -22,6 +22,10 @@
#include <config.h>
#endif
+#ifdef USE_L4
+# include <l4.h>
+#endif
+
#include <viengoos/cap.h>
#include <viengoos/folio.h>
#include <viengoos/activity.h>
@@ -45,8 +49,6 @@
#include <signal.h>
#include <setjmp.h>
-#include <l4.h>
-
extern int output_debug;
static vg_addr_t activity;
@@ -70,8 +72,10 @@ main (int argc, char *argv[])
printf ("%s " PACKAGE_VERSION "\n", program_name);
printf ("Hello, here is Ruth, your friendly root server!\n");
+#ifdef USE_L4
debug (2, "RM: %x.%x", l4_thread_no (__hurd_startup_data->rm),
l4_version (__hurd_startup_data->rm));
+#endif
activity = __hurd_startup_data->activity;
@@ -79,7 +83,7 @@ main (int argc, char *argv[])
printf ("Checking shadow page tables... ");
int visit (vg_addr_t addr,
- l4_word_t type, struct vg_cap_properties properties,
+ uintptr_t type, struct vg_cap_properties properties,
bool writable,
void *cookie)
{
@@ -138,7 +142,7 @@ main (int argc, char *argv[])
if (0 <= i && i < VG_FOLIO_OBJECTS)
{
- l4_word_t type;
+ uintptr_t type;
struct vg_cap_properties properties;
err = vg_cap_read (activity, VG_ADDR_VOID, addr, &type, &properties);
assert (! err);
@@ -189,7 +193,7 @@ main (int argc, char *argv[])
int j;
for (j = 0; j <= i; j ++)
{
- l4_word_t type;
+ uintptr_t type;
struct vg_cap_properties properties;
error_t err = vg_cap_read (activity, VG_ADDR_VOID,
@@ -319,13 +323,11 @@ main (int argc, char *argv[])
do_debug (4)
as_dump ("thread");
- debug (4, "I'm running (%x.%x)!",
- l4_thread_no (l4_myself ()),
- l4_version (l4_myself ()));
+ debug (4, "I'm running (%x)!", hurd_myself ());
done = 1;
do
- l4_yield ();
+ sched_yield ();
while (1);
}
@@ -341,8 +343,8 @@ main (int argc, char *argv[])
in.aspace_cap_properties = VG_CAP_PROPERTIES_DEFAULT;
in.aspace_cap_properties_flags = VG_CAP_COPY_COPY_SOURCE_GUARD;
- in.sp = (l4_word_t) ((void *) stack + sizeof (stack));
- in.ip = (l4_word_t) &start;
+ in.sp = (uintptr_t) ((void *) stack + sizeof (stack));
+ in.ip = (uintptr_t) &start;
struct vg_thread_exregs_out out;
@@ -355,7 +357,7 @@ main (int argc, char *argv[])
debug (5, "Waiting for thread");
while (done == 0)
- l4_yield ();
+ sched_yield ();
debug (5, "Thread done!");
storage_free (storage, true);
@@ -380,22 +382,21 @@ main (int argc, char *argv[])
{
uintptr_t i = (uintptr_t) arg;
- debug (5, "%d (%x.%x) started", (int) i,
- l4_thread_no (l4_myself ()), l4_version (l4_myself ()));
+ debug (5, "%d (%x) started", (int) i, hurd_myself ());
int c;
for (c = 0; c < FACTOR; c ++)
{
int w;
for (w = 0; w < 10; w ++)
- l4_yield ();
+ sched_yield ();
pthread_mutex_lock (&mutex);
debug (5, "%d calling, count=%d", (int) i, shared_resource);
for (w = 0; w < 10; w ++)
- l4_yield ();
+ sched_yield ();
shared_resource ++;
@@ -497,7 +498,7 @@ main (int argc, char *argv[])
/* Block. */
while (i != 1)
- l4_yield ();
+ sched_yield ();
i = 0;
@@ -679,7 +680,7 @@ main (int argc, char *argv[])
assert (err == 0);
assert (! VG_ADDR_IS_VOID (a[i].page));
- l4_word_t type;
+ uintptr_t type;
struct vg_cap_properties properties;
err = vg_cap_read (a[i].child, VG_ADDR_VOID,
@@ -888,8 +889,11 @@ main (int argc, char *argv[])
VG_ADDR_VOID);
assert (! VG_ADDR_IS_VOID (storage.addr));
+ volatile int in = 0;
void *start (void *arg)
{
+ __sync_fetch_and_add (&in, 1);
+
uintptr_t ret = 0;
error_t err;
err = vg_object_reply_on_destruction (VG_ADDR_VOID, storage.addr, &ret);
@@ -903,9 +907,8 @@ main (int argc, char *argv[])
error_t err = pthread_create (&tid, NULL, start, 0);
assert (err == 0);
- int i;
- for (i = 0; i < 100; i ++)
- l4_yield ();
+ while (! in)
+ sched_yield ();
/* Deallocate the object. */
debug (5, "Destroying object");