From 8e7249d8deae3a82c086f435b7e31ec16d1457da Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Fri, 16 Jan 2009 21:18:32 +0100 Subject: Conditionalize use of l4 functions on USE_L4. / 2009-01-16 Neal H. Walfield * 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 * 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 * 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 * 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 * _exit.c (_exit): Use sched_yield, not l4_yield. * backtrace.c [USE_L4]: Only include in this case. [! RM_INTERN]: Include . (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 , , , or . (cmain) [! USE_L4]: Don't call l4_init or l4_init_stubs. * loader.c: Don't include . Include and . (loader_elf_load): Use __WORDSIZE, __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN instead of their L4 names. * panic.c: Include . [! RM_INTERN]: Include . (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 . (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 * anonymous.h: Don't include . Include . (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 . * as.h: Include . Don't include . (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 or . Include . (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 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 . (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 * sysdeps/viengoos/pt-spin.c [USE_L4]: Only include 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 . * 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 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 * 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 * ruth.c [USE_L4]: Only include 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 * cap.h: Don't include . * mutex.h [USE_L4]: Only include 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 in this case. (object_desc_unmap) [! USE_L4]: Make a no-op. (object_desc_flush) [! USE_L4]: Likewise. * thread.h: Don't include . (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. --- ChangeLog | 7 +++++ Makefile.am | 16 +++++++--- benchmarks/ChangeLog | 10 ++++++ benchmarks/activity-distribution.c | 14 ++++++--- benchmarks/cache.c | 6 ++-- benchmarks/shared-memory-distribution.c | 10 +++--- hieronymus/ChangeLog | 5 +++ hieronymus/hieronymus.c | 6 +++- hurd/ChangeLog | 9 ++++++ hurd/lock.h | 4 +++ hurd/thread.h | 8 +++++ hurd/trace.h | 10 +++++- libc-parts/ChangeLog | 29 +++++++++++++++++ libc-parts/_exit.c | 2 +- libc-parts/backtrace.c | 18 ++++++++++- libc-parts/ia32-cmain.c | 6 +++- libc-parts/loader.c | 12 +++---- libc-parts/panic.c | 18 +++++++++-- libc-parts/process-spawn.c | 8 +++-- libc-parts/profile.c | 18 +++++++++-- libc-parts/s_printf.c | 5 +++ libhurd-mm/ChangeLog | 30 ++++++++++++++++++ libhurd-mm/anonymous.c | 8 ++--- libhurd-mm/anonymous.h | 4 +-- libhurd-mm/as-build.c | 1 - libhurd-mm/as.c | 24 ++++++++++---- libhurd-mm/as.h | 16 +++++----- libhurd-mm/exceptions.c | 16 +++++++--- libhurd-mm/map.c | 5 ++- libhurd-mm/storage.c | 39 +++++++++-------------- libpthread/ChangeLog | 22 +++++++++++++ libpthread/sysdeps/viengoos/pt-spin.c | 17 +++++++--- libpthread/sysdeps/viengoos/pt-stack-alloc.c | 3 +- libpthread/sysdeps/viengoos/pt-sysdep.c | 9 ++++++ libpthread/sysdeps/viengoos/pt-sysdep.h | 9 +++++- libpthread/sysdeps/viengoos/pt-thread-alloc.c | 6 +++- libpthread/sysdeps/viengoos/pt-thread-start.c | 8 ++--- libpthread/sysdeps/viengoos/sig-sysdep.h | 10 ++++++ libviengoos/ChangeLog | 7 +++++ libviengoos/viengoos/thread.h | 19 ++++++++--- ruth/ChangeLog | 9 ++++++ ruth/ruth.c | 45 ++++++++++++++------------- viengoos/ChangeLog | 16 ++++++++++ viengoos/cap.h | 1 - viengoos/mutex.h | 21 ++++++++++++- viengoos/object.h | 17 ++++++++-- viengoos/thread.h | 7 ++--- 47 files changed, 457 insertions(+), 133 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5173e00..5472d9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-01-16 Neal H. Walfield + + * 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. + 2009-01-16 Neal H. Walfield * configure.ac (--enable-l4-abi): Replace option with... diff --git a/Makefile.am b/Makefile.am index 297e44b..12f66d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,15 +30,23 @@ else NEWLIB_SUBDIRS = endif +if USE_L4 + L4_SUBDIRS = libl4 laden +else + L4_SUBDIRS = +endif + if TRAVERSE_HIERARCHY -SUBDIRS = libl4 libviengoos platform \ +SUBDIRS = libviengoos platform \ $(LIBC_SUBDIRS) $(NEWLIB_SUBDIRS) \ - hurd libhurd-ihash libhurd-btree libbitarray \ + libhurd-ihash libhurd-btree libbitarray \ + hurd \ + libc-parts \ + $(L4_SUBDIRS) \ libhurd-slab \ libpthread \ libhurd-mm \ - libc-parts \ - laden viengoos \ + viengoos \ . \ ruth \ benchmarks \ diff --git a/benchmarks/ChangeLog b/benchmarks/ChangeLog index c42d4d1..f49b400 100644 --- a/benchmarks/ChangeLog +++ b/benchmarks/ChangeLog @@ -1,3 +1,13 @@ +2009-01-16 Neal H. Walfield + + * 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. + 2008-12-12 Neal H. Walfield * cache.c (object_fill): Replace use of `struct exception_info' diff --git a/benchmarks/activity-distribution.c b/benchmarks/activity-distribution.c index 1710090..372849b 100644 --- a/benchmarks/activity-distribution.c +++ b/benchmarks/activity-distribution.c @@ -54,9 +54,9 @@ main (int argc, char *argv[]) } bool terminate = false; - l4_thread_id_t tids[THREADS]; + vg_thread_id_t tids[THREADS]; for (i = 0; i < THREADS; i ++) - tids[i] = l4_nilthread; + tids[i] = vg_niltid; int available; { @@ -78,7 +78,7 @@ main (int argc, char *argv[]) { uintptr_t *p = pages[0]; p[0] = offset; - p[1] = l4_myself (); + p[1] = hurd_myself (); return true; } @@ -86,7 +86,7 @@ main (int argc, char *argv[]) { int w = (intptr_t) arg; - tids[w] = l4_myself (); + tids[w] = hurd_myself (); pthread_setactivity_np (activities[w]); @@ -123,15 +123,19 @@ main (int argc, char *argv[]) for (j = 0; j < SIZE; j += PAGESIZE) { uintptr_t *p = buffers[i] + j; - assertx (p[0] == j && p[1] == l4_myself (), + assertx (p[0] == j && p[1] == hurd_myself (), "%x: %x =? %x, thread: %x", p, p[0], j, p[1]); t += * (int *) (buffers[i] + j); } +#ifdef USE_L4 /* 100ms. */ l4_sleep (l4_time_period (100 * 1000)); +#else +# warning Need a sleep function. +#endif } /* We need to return t, otherwise, the above loop will be diff --git a/benchmarks/cache.c b/benchmarks/cache.c index 40aa9f2..904d718 100644 --- a/benchmarks/cache.c +++ b/benchmarks/cache.c @@ -397,7 +397,7 @@ helper_fork (void) panic ("Failed to allocate main activity"); struct vg_object_name name; - snprintf (&name.name[0], sizeof (name.name), "main.%x", l4_myself ()); + snprintf (&name.name[0], sizeof (name.name), "main.%x", hurd_myself ()); vg_object_name (VG_ADDR_VOID, main_activity, name); hog_activity = storage_alloc (VG_ADDR_VOID, @@ -406,7 +406,7 @@ helper_fork (void) if (VG_ADDR_IS_VOID (hog_activity)) panic ("Failed to allocate hog activity"); - snprintf (&name.name[0], sizeof (name.name), "hog.%x", l4_myself ()); + snprintf (&name.name[0], sizeof (name.name), "hog.%x", hurd_myself ()); vg_object_name (VG_ADDR_VOID, hog_activity, name); /* We give the main thread and the hog the same priority and @@ -1034,7 +1034,9 @@ main (int argc, char *argv[]) printf ("Object %d is at: %p (%d/%d)\n", id, object, i[0], i[1]); } +#ifdef USE_L4 _L4_kdb (""); +#endif abort (); } diff --git a/benchmarks/shared-memory-distribution.c b/benchmarks/shared-memory-distribution.c index 6267a5c..ea2429b 100644 --- a/benchmarks/shared-memory-distribution.c +++ b/benchmarks/shared-memory-distribution.c @@ -46,15 +46,15 @@ main (int argc, char *argv[]) VG_ADDR_VOID).addr; bool terminate = false; - l4_thread_id_t tids[THREADS]; + vg_thread_id_t tids[THREADS]; for (i = 0; i < THREADS; i ++) - tids[i] = l4_nilthread; + tids[i] = vg_niltid; void *worker (void *arg) { int w = (intptr_t) arg; - tids[w] = l4_myself (); + tids[w] = hurd_myself (); pthread_setactivity_np (activities[w]); @@ -77,7 +77,7 @@ main (int argc, char *argv[]) #if 0 /* ~128Hz. */ l4_sleep (l4_time_period (1 << 13)); -#elif 1 +#elif 0 l4_thread_switch (tids[rand () % THREADS]); #endif } @@ -106,7 +106,7 @@ main (int argc, char *argv[]) uintptr_t next_period = 0; for (i = 0; i < ITERATIONS; i ++) { - debug (0, DEBUG_BOLD ("starting iteration %d (%x)"), i, l4_myself ()); + debug (0, DEBUG_BOLD ("starting iteration %d (%x)"), i, hurd_myself ()); struct vg_activity_info info; diff --git a/hieronymus/ChangeLog b/hieronymus/ChangeLog index 4952cdc..1a7a864 100644 --- a/hieronymus/ChangeLog +++ b/hieronymus/ChangeLog @@ -1,3 +1,8 @@ +2009-01-16 Neal H. Walfield + + * hieronymus.c (main): Use uint64_t, not l4_uint64_t. + (main) [USE_L4]: Don't sleep in this case. + 2008-12-12 Neal H. Walfield Update according to new RPC interfaces. diff --git a/hieronymus/hieronymus.c b/hieronymus/hieronymus.c index 4a7190e..af5913d 100644 --- a/hieronymus/hieronymus.c +++ b/hieronymus/hieronymus.c @@ -293,7 +293,7 @@ main (int argc, char *argv[]) int started = 0; while (started < module_count) { - l4_uint64_t start = now (); + uint64_t start = now (); uint64_t deadline = -1ULL; const char *next = NULL; @@ -327,7 +327,11 @@ main (int argc, char *argv[]) debug (0, "Waiting %llu seconds before starting %s", (deadline - (start - epoch)) / 1000000, next); +#ifdef USE_L4 l4_sleep (l4_time_period (deadline - (start - epoch))); +#else +# warning Need a sleep function. +#endif } } diff --git a/hurd/ChangeLog b/hurd/ChangeLog index 659488a..90abee2 100644 --- a/hurd/ChangeLog +++ b/hurd/ChangeLog @@ -1,3 +1,12 @@ +2009-01-16 Neal H. Walfield + + * 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. + 2009-01-16 Neal H. Walfield * thread.h (AF_REGS_FMT): New macro. diff --git a/hurd/lock.h b/hurd/lock.h index 18aacfb..4a5ab30 100644 --- a/hurd/lock.h +++ b/hurd/lock.h @@ -141,7 +141,11 @@ ss_mutex_trace_add (int func, __const char *caller, int line, void *lock) ss_lock_trace[i].caller = caller; ss_lock_trace[i].line = line; ss_lock_trace[i].lock = lock; +# ifdef USE_L4 ss_lock_trace[i].tid = l4_myself (); +# else + ss_lock_trace[i].tid = 0; +# endif #endif /* NDEBUG */ } diff --git a/hurd/thread.h b/hurd/thread.h index 653bbf6..1ca8ebe 100644 --- a/hurd/thread.h +++ b/hurd/thread.h @@ -259,8 +259,16 @@ extern void hurd_fault_catcher_unregister (struct hurd_fault_catcher *catcher); static inline vg_thread_id_t hurd_myself (void) { +#ifdef USE_L4 + /* XXX: Annoyingly, we need the tid before UTCB->TID is initialized. + This needs to be fixed, but for now... */ + return l4_myself (); +#endif struct hurd_utcb *utcb = hurd_utcb (); + assert (utcb); + assert (utcb->tid); + return utcb->tid; } diff --git a/hurd/trace.h b/hurd/trace.h index 24c1c89..c566e9f 100644 --- a/hurd/trace.h +++ b/hurd/trace.h @@ -86,7 +86,15 @@ trace_buffer_add (const char *func, const int lineno, ss_mutex_lock (&buffer->lock); if (! buffer->notid) - s_cprintf (pc, "%x:", l4_myself ()); + { +#ifdef USE_L4 + s_cprintf (pc, "%x:", l4_myself ()); +#elif !defined (RM_INTERN) + s_cprintf (pc, "%x:", hurd_myself ()); +#else +# warning Don't know how to get tid. +#endif + } s_cprintf (pc, "%s:%d: ", func, lineno); va_start (ap, fmt); diff --git a/libc-parts/ChangeLog b/libc-parts/ChangeLog index 8c55f39..ebd9833 100644 --- a/libc-parts/ChangeLog +++ b/libc-parts/ChangeLog @@ -1,3 +1,32 @@ +2009-01-16 Neal H. Walfield + + * _exit.c (_exit): Use sched_yield, not l4_yield. + * backtrace.c [USE_L4]: Only include in this case. + [! RM_INTERN]: Include . + (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 , + , , or . + (cmain) [! USE_L4]: Don't call l4_init or l4_init_stubs. + * loader.c: Don't include . Include and + . + (loader_elf_load): Use __WORDSIZE, __BYTE_ORDER, __LITTLE_ENDIAN + and __BIG_ENDIAN instead of their L4 names. + * panic.c: Include . + [! RM_INTERN]: Include . + (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 . + (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. + 2008-12-17 Neal H. Walfield * process-spawn.c (process_spawn): Don't use vg_cap_copy but diff --git a/libc-parts/_exit.c b/libc-parts/_exit.c index d2e6a8a..835b06b 100644 --- a/libc-parts/_exit.c +++ b/libc-parts/_exit.c @@ -80,7 +80,7 @@ _exit (int ret) j --; #ifndef RM_INTERN /* XXX: This doesn't work for laden. */ - l4_yield (); + sched_yield (); #endif } } diff --git a/libc-parts/backtrace.c b/libc-parts/backtrace.c index 4fbe875..8e73557 100644 --- a/libc-parts/backtrace.c +++ b/libc-parts/backtrace.c @@ -17,7 +17,13 @@ . */ #include -#include + +#ifndef RM_INTERN +# include +#endif +#ifdef USE_L4 +# include +#endif #ifdef RM_INTERN # define RA(level) \ @@ -134,7 +140,17 @@ backtrace_print (void) void *bt[20]; int count = backtrace (bt, sizeof (bt) / sizeof (bt[0])); +#ifdef USE_L4 s_printf ("Backtrace for %x: ", l4_myself ()); +#else +# ifndef RM_INTERN + s_printf ("Backtrace for %x: ", hurd_myself ()); +# else +# warning Don't know how to get tid. + s_printf ("Backtrace: "); +# endif +#endif + int i; for (i = 0; i < count; i ++) s_printf ("%p ", bt[i]); diff --git a/libc-parts/ia32-cmain.c b/libc-parts/ia32-cmain.c index 10390f6..a81a2da 100644 --- a/libc-parts/ia32-cmain.c +++ b/libc-parts/ia32-cmain.c @@ -26,10 +26,12 @@ #include #include +#ifdef USE_L4 #include #include #include #include +#endif #include #include @@ -58,7 +60,7 @@ finish (void) /* We are not running on the initial stack. Free it. */ { void *p; - for (p = &_stack; p < &_stack_end; p += PAGESIZE) + for (p = &_stack; p < (void *) &_stack_end; p += PAGESIZE) { struct hurd_object_desc *desc; int i; @@ -125,8 +127,10 @@ finish (void) void cmain (void) { +#ifdef USE_L4 l4_init (); l4_init_stubs (); +#endif s_printf ("In cmain\n"); diff --git a/libc-parts/loader.c b/libc-parts/loader.c index 2db7bb3..d0f26b8 100644 --- a/libc-parts/loader.c +++ b/libc-parts/loader.c @@ -24,8 +24,8 @@ #include #include - -#include +#include +#include #include "loader.h" #include "elf.h" @@ -62,18 +62,18 @@ loader_elf_load (loader_allocate_object_callback_t alloc, /* FIXME: Some architectures support both word sizes. */ if (!((elf->e_ident[EI_CLASS] == ELFCLASS32 - && L4_WORDSIZE == 32) + && __WORDSIZE == 32) || (elf->e_ident[EI_CLASS] == ELFCLASS64 - && L4_WORDSIZE == 64))) + && __WORDSIZE == 64))) { debug (0, "Invalid word size"); return false; } if (!((elf->e_ident[EI_DATA] == ELFDATA2LSB - && L4_BYTE_ORDER == L4_LITTLE_ENDIAN) + && __BYTE_ORDER == __LITTLE_ENDIAN) || (elf->e_ident[EI_DATA] == ELFDATA2MSB - && L4_BYTE_ORDER == L4_BIG_ENDIAN))) + && __BYTE_ORDER == __BIG_ENDIAN))) { debug (0, "Invalid byte order"); return false; diff --git a/libc-parts/panic.c b/libc-parts/panic.c index 71ef763..0c88343 100644 --- a/libc-parts/panic.c +++ b/libc-parts/panic.c @@ -22,6 +22,11 @@ #include #include #include +#include + +#ifndef RM_INTERN +# include +#endif extern char *program_name; @@ -34,7 +39,16 @@ panic_ (const char *func, int line, const char *fmt, ...) va_start (ap, fmt); - s_printf ("%s:%s:%d:%x: error: ", program_name, func, line, l4_myself ()); + vg_thread_id_t tid = 0; +#ifdef USE_L4 + tid = l4_myself (); +#elif !defined (RM_INTERN) + tid = hurd_myself (); +#else +# warning Unable to determine thread id for this platform. +#endif + + s_printf ("%s:%s:%d:%x: error: ", program_name, func, line, tid); s_vprintf (fmt, ap); s_printf ("\n"); va_end (ap); @@ -43,6 +57,6 @@ panic_ (const char *func, int line, const char *fmt, ...) _exit (127); for (;;) - l4_yield (); + sched_yield (); } diff --git a/libc-parts/process-spawn.c b/libc-parts/process-spawn.c index 77de8a7..a89ade2 100644 --- a/libc-parts/process-spawn.c +++ b/libc-parts/process-spawn.c @@ -268,16 +268,18 @@ process_spawn (vg_addr_t activity, startup_data->version_major = HURD_STARTUP_VERSION_MAJOR; startup_data->version_minor = HURD_STARTUP_VERSION_MINOR; -#ifdef RM_INTERN +#ifdef USE_L4 +# ifdef RM_INTERN startup_data->utcb_area = UTCB_AREA_BASE; startup_data->rm = l4_myself (); -#else +# else { extern struct hurd_startup_data *__hurd_startup_data; startup_data->utcb_area = __hurd_startup_data->utcb_area; startup_data->rm = __hurd_startup_data->rm; } +# endif #endif startup_data->descs = (void *) STARTUP_DATA_ADDR + descs_offset; @@ -747,7 +749,7 @@ process_spawn (vg_addr_t activity, thread->aspace = *as_root_cap; thread->activity = object_to_cap ((struct vg_object *) root_activity); - l4_word_t sp = STARTUP_DATA_ADDR; + uintptr_t sp = STARTUP_DATA_ADDR; error_t err; err = thread_exregs (root_activity, thread, diff --git a/libc-parts/profile.c b/libc-parts/profile.c index 46b34a4..6507589 100644 --- a/libc-parts/profile.c +++ b/libc-parts/profile.c @@ -30,7 +30,9 @@ #include #ifdef __gnu_hurd_viengoos__ -# include +# ifdef USE_L4 +# include +# endif # include # include #else @@ -63,7 +65,12 @@ static inline uint64_t now (void) { #ifdef __gnu_hurd_viengoos__ +# ifdef USE_L4 return l4_system_clock (); +# else +# warning Not ported to this platform. + return 0; +# endif #else struct timeval t; struct timezone tz; @@ -93,8 +100,13 @@ static int thread_count; struct profile_block { #ifdef __gnu_hurd_viengoos__ -#define MYSELF() l4_myself () - l4_thread_id_t tid; +# ifdef USE_L4 +# define MYSELF() l4_myself () +# else +# warning Profile code broken. +# define MYSELF() 0 +# endif + vg_thread_id_t tid; #else #define MYSELF() pthread_self () pthread_t tid; diff --git a/libc-parts/s_printf.c b/libc-parts/s_printf.c index f7e55f9..94caaa2 100644 --- a/libc-parts/s_printf.c +++ b/libc-parts/s_printf.c @@ -41,6 +41,7 @@ io_buffer_flush (struct io_buffer *buffer) return; // rm_write_send_nonblocking (VG_ADDR_VOID, VG_ADDR_VOID, *buffer, VG_ADDR_VOID); +#ifdef USE_L4 l4_msg_tag_t tag = l4_niltag; l4_msg_tag_set_label (&tag, 2132); @@ -61,6 +62,10 @@ io_buffer_flush (struct io_buffer *buffer) extern struct hurd_startup_data *__hurd_startup_data; l4_send (__hurd_startup_data->rm); +#else +# warning Not ported to this platform. + assert (0); +#endif buffer->len = 0; } diff --git a/libhurd-mm/ChangeLog b/libhurd-mm/ChangeLog index 121e73c..aad6471 100644 --- a/libhurd-mm/ChangeLog +++ b/libhurd-mm/ChangeLog @@ -1,3 +1,33 @@ +2009-01-16 Neal H. Walfield + + * anonymous.h: Don't include . Include + . + (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 . + * as.h: Include . Don't include . + (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 or . + Include . + (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 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 . + (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. + 2009-01-16 Neal H. Walfield * exceptions.c (hurd_activation_stack_dump): Use AF_REGS_FMT and diff --git a/libhurd-mm/anonymous.c b/libhurd-mm/anonymous.c index a653ae2..1827711 100644 --- a/libhurd-mm/anonymous.c +++ b/libhurd-mm/anonymous.c @@ -161,7 +161,7 @@ fault (struct pager *pager, uintptr_t offset, int count, bool read_only, if (! ss_mutex_trylock (&anon->fill_lock)) /* The fill lock is held. */ { - if (anon->fill_thread == l4_myself ()) + if (anon->fill_thread == hurd_myself ()) /* By us! */ recursive = true; @@ -172,8 +172,8 @@ fault (struct pager *pager, uintptr_t offset, int count, bool read_only, /* We have the lock. */ if (! recursive) - assert (anon->fill_thread == l4_nilthread); - anon->fill_thread = l4_myself (); + assert (anon->fill_thread == vg_niltid); + anon->fill_thread = hurd_myself (); if (! recursive && (anon->flags & ANONYMOUS_THREAD_SAFE)) /* Revoke access to the visible region. */ @@ -424,7 +424,7 @@ fault (struct pager *pager, uintptr_t offset, int count, bool read_only, })); } - anon->fill_thread = l4_nilthread; + anon->fill_thread = vg_niltid; ss_mutex_unlock (&anon->fill_lock); } } diff --git a/libhurd-mm/anonymous.h b/libhurd-mm/anonymous.h index 28d1b9a..291d7f6 100644 --- a/libhurd-mm/anonymous.h +++ b/libhurd-mm/anonymous.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include /* Forward. */ struct anonymous_pager; @@ -125,7 +125,7 @@ struct anonymous_pager anonymous_pager_fill_t fill; /* The thread in the fill function. (If none, NULL.) */ - l4_thread_id_t fill_thread; + vg_thread_id_t fill_thread; /* Used to serialize the fill function. Also protects FILL_THREAD. If ANONYMOUS_THREAD_SAFE is set, then this lock protects the staging area. Must be taken while holding LOCK. */ diff --git a/libhurd-mm/as-build.c b/libhurd-mm/as-build.c index 5097117..0ccf16a 100644 --- a/libhurd-mm/as-build.c +++ b/libhurd-mm/as-build.c @@ -18,7 +18,6 @@ along with this program. If not, see . */ -#include #include #include diff --git a/libhurd-mm/as.c b/libhurd-mm/as.c index 1a291db..de3bc8f 100644 --- a/libhurd-mm/as.c +++ b/libhurd-mm/as.c @@ -28,18 +28,26 @@ #include #include #include -#include -#include + +#ifdef USE_L4 +# include +# include +#endif #include extern struct hurd_startup_data *__hurd_startup_data; /* The top of the data address space. */ -#if L4_WORDSIZE == 32 -#define DATA_ADDR_MAX (0xC0000000ULL) +#include +#if __WORDSIZE == 32 +# define DATA_ADDR_MAX (0xC0000000ULL) +#elif __WORDSIZE == 64 +/* XXX: For now, assume that we have 48 bits of virtual address + space. */ +# define DATA_ADDR_MAX (1ULL << 48) #else -#error define DATA_ADDR_MAX +# error __WORDSIZE not defined or invalid. #endif /* Set to true before as_init returns. Indicates that the shadow page @@ -47,7 +55,7 @@ extern struct hurd_startup_data *__hurd_startup_data; bool as_init_done; pthread_rwlock_t as_rwlock; -l4_thread_id_t as_rwlock_owner; +vg_thread_id_t as_rwlock_owner; /* We keep track of the regions which are unallocated. These regions are kept in a btree allowing for fast allocation, fast searching @@ -399,6 +407,7 @@ as_alloc_slow (int width) if (end >= DATA_ADDR_MAX) return 0; +#ifdef USE_L4 if (! (end < (uintptr_t) l4_kip () || (uintptr_t) l4_kip () + l4_kip_area_size () <= start)) /* Overlaps the KIP. */ @@ -408,6 +417,7 @@ as_alloc_slow (int width) || ((uintptr_t) _L4_utcb () + l4_utcb_size () <= start))) /* Overlaps the UTCB. */ return 0; +#endif /* Be sure we haven't already given this address out. */ int i; @@ -615,9 +625,11 @@ as_init (void) } } +#ifdef USE_L4 /* Reserve the kip and the utcb. */ as_alloc_at (VG_ADDR ((uintptr_t) l4_kip (), VG_ADDR_BITS), l4_kip_area_size ()); as_alloc_at (VG_ADDR ((uintptr_t) _L4_utcb (), VG_ADDR_BITS), l4_utcb_size ()); +#endif /* And the page at 0. */ as_alloc_at (vg_addr_chop (VG_PTR_TO_ADDR (0), PAGESIZE_LOG2), 1); diff --git a/libhurd-mm/as.h b/libhurd-mm/as.h index 24f8f3e..96a37e2 100644 --- a/libhurd-mm/as.h +++ b/libhurd-mm/as.h @@ -24,8 +24,8 @@ #include #include +#include #include -#include /* The address space allocator keeps track of which addresses are allocated and which are available. The allocator supports the @@ -104,7 +104,7 @@ static inline void as_lock (void) { extern pthread_rwlock_t as_rwlock; - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; as_lock_ensure_stack (AS_STACK_SPACE); @@ -112,10 +112,10 @@ as_lock (void) for (;;) { - assert (as_rwlock_owner != l4_myself ()); + assert (as_rwlock_owner != hurd_myself ()); pthread_rwlock_wrlock (&as_rwlock); assert (as_rwlock_owner == 0); - as_rwlock_owner = l4_myself (); + as_rwlock_owner = hurd_myself (); if (! storage_have_reserve ()) { @@ -133,7 +133,7 @@ static inline void as_lock_readonly (void) { extern pthread_rwlock_t as_rwlock; - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; as_lock_ensure_stack (AS_STACK_SPACE); @@ -141,7 +141,7 @@ as_lock_readonly (void) for (;;) { - assert (as_rwlock_owner != l4_myself ()); + assert (as_rwlock_owner != hurd_myself ()); pthread_rwlock_rdlock (&as_rwlock); assert (as_rwlock_owner == 0); @@ -160,12 +160,12 @@ static inline void as_unlock (void) { extern pthread_rwlock_t as_rwlock; - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; if (as_rwlock_owner) /* Only set for a write lock. */ { - assert (as_rwlock_owner == l4_myself ()); + assert (as_rwlock_owner == hurd_myself ()); as_rwlock_owner = 0; } diff --git a/libhurd-mm/exceptions.c b/libhurd-mm/exceptions.c index 6ad928a..76026bd 100644 --- a/libhurd-mm/exceptions.c +++ b/libhurd-mm/exceptions.c @@ -25,7 +25,10 @@ #include #include #include -#include + +#ifdef USE_L4 +# include +#endif #include #include @@ -102,6 +105,7 @@ hurd_activation_frame_longjmp (struct activation_frame *activation_frame, #endif } +#ifdef USE_L4 static void l4_utcb_state_save (struct activation_frame *activation_frame) { @@ -131,6 +135,10 @@ l4_utcb_state_restore (struct activation_frame *activation_frame) memcpy (&utcb[_L4_UTCB_MR0], &activation_frame->saved_message, L4_NUM_MRS * sizeof (uintptr_t)); } +#else +# define l4_utcb_state_save(f) +# define l4_utcb_state_restore(f) +#endif /* Fetch any pending activation. */ void @@ -345,10 +353,10 @@ hurd_activation_handler_normal (struct activation_frame *activation_frame, VG_ADDR_PRINTF (fault), AF_REGS_PRINTF (activation_frame)); - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; bool r = false; - if (likely (as_rwlock_owner != l4_myself ())) + if (likely (as_rwlock_owner != hurd_myself ())) r = map_fault (fault, ip, info); if (! r) { @@ -378,7 +386,7 @@ hurd_activation_handler_normal (struct activation_frame *activation_frame, if (! catcher) { - if (as_rwlock_owner == l4_myself ()) + if (as_rwlock_owner == hurd_myself ()) debug (0, "I hold as_rwlock!"); debug (0, "SIGSEGV at " VG_ADDR_FMT " " AF_REGS_FMT, diff --git a/libhurd-mm/map.c b/libhurd-mm/map.c index 2147d6b..370f2f0 100644 --- a/libhurd-mm/map.c +++ b/libhurd-mm/map.c @@ -25,7 +25,6 @@ #include #include #include -#include #include @@ -346,11 +345,11 @@ map_fault (vg_addr_t fault_addr, uintptr_t ip, struct vg_activation_fault_info i } /* Note: write access implies read access. */ - if (((info.access & L4_FPAGE_WRITABLE) && ! (map->access & MAP_ACCESS_WRITE)) + if (((info.access & VG_WRITE) && ! (map->access & MAP_ACCESS_WRITE)) || ! map->access) { debug (0, "Invalid %s access at " VG_ADDR_FMT ": " MAP_FMT, - info.access & L4_FPAGE_WRITABLE ? "write" : "read", + info.access & VG_WRITE ? "write" : "read", VG_ADDR_PRINTF (fault_addr), MAP_PRINTF (map)); maps_lock_unlock (); diff --git a/libhurd-mm/storage.c b/libhurd-mm/storage.c index 585b9d9..433bf4c 100644 --- a/libhurd-mm/storage.c +++ b/libhurd-mm/storage.c @@ -390,7 +390,7 @@ storage_check_reserve_internal (bool force_allocate, pages and if not to call some as-yet unwritten function which forces the reserve to grow. */ { - extern l4_thread_id_t as_rwlock_owner; + extern vg_thread_id_t as_rwlock_owner; if (as_rwlock_owner) { if (as_rwlock_owner == hurd_myself ()) @@ -738,23 +738,6 @@ storage_free_ (vg_addr_t object, bool unmap_now) ss_mutex_lock (&storage_descs_lock); - { - int cnt = 0; - struct storage_desc *desc; - for (desc = hurd_btree_storage_desc_first (&storage_descs); - desc; - desc = hurd_btree_storage_desc_next (desc)) - cnt += desc->free; - - if (cnt != free_count) - for (desc = hurd_btree_storage_desc_first (&storage_descs); - desc; - desc = hurd_btree_storage_desc_next (desc)) - debug (0, "Folio at " VG_ADDR_FMT " %d free", - VG_ADDR_PRINTF (desc->folio), desc->free); - assertx (cnt == free_count, "%d != %d", cnt, free_count); - } - /* Find the storage descriptor. */ struct storage_desc *storage; storage = hurd_btree_storage_desc_find (&storage_descs, &folio); @@ -810,7 +793,8 @@ storage_free_ (vg_addr_t object, bool unmap_now) vg_addr_t shadow_addr = vg_addr_chop (VG_PTR_TO_ADDR (shadow), PAGESIZE_LOG2); - if (VG_ADDR_EQ (vg_addr_chop (shadow_addr, VG_FOLIO_OBJECTS_LOG2), folio)) + if (VG_ADDR_EQ (vg_addr_chop (shadow_addr, + VG_FOLIO_OBJECTS_LOG2), folio)) { /* The shadow was allocate from ourself, which we already freed. */ @@ -848,11 +832,18 @@ storage_free_ (vg_addr_t object, bool unmap_now) int idx = vg_addr_extract (object, VG_FOLIO_OBJECTS_LOG2); bit_dealloc (storage->alloced, idx); - error_t err = vg_folio_object_alloc (meta_data_activity, - folio, idx, vg_cap_void, - VG_OBJECT_POLICY_DEFAULT, 0, - NULL, NULL); - assert (err == 0); + if (unmap_now +#ifndef NDEBUG + || 1 +#endif + ) + { + error_t err = vg_folio_object_alloc (meta_data_activity, + folio, idx, vg_cap_void, + VG_OBJECT_POLICY_DEFAULT, 0, + NULL, NULL); + assert (err == 0); + } if (likely (!! shadow)) { diff --git a/libpthread/ChangeLog b/libpthread/ChangeLog index 6a47452..ead918b 100644 --- a/libpthread/ChangeLog +++ b/libpthread/ChangeLog @@ -1,3 +1,25 @@ +2009-01-16 Neal H. Walfield + + * sysdeps/viengoos/pt-spin.c [USE_L4]: Only include 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 . + * 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 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. + 2008-11-19 Neal H. Walfield * sysdeps/generic/bits/memory.h: New file. diff --git a/libpthread/sysdeps/viengoos/pt-spin.c b/libpthread/sysdeps/viengoos/pt-spin.c index b6978b0..6d6df7e 100644 --- a/libpthread/sysdeps/viengoos/pt-spin.c +++ b/libpthread/sysdeps/viengoos/pt-spin.c @@ -1,5 +1,5 @@ -/* Spin locks. L4 version. - Copyright (C) 2000, 2004 Free Software Foundation, Inc. +/* Spin locks. Viengoos version. + Copyright (C) 2000, 2004, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,7 +17,9 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#ifdef USE_L4 +# include +#endif #include #include @@ -38,12 +40,16 @@ int __pthread_spin_count = __PTHREAD_SPIN_COUNT; int _pthread_spin_lock (__pthread_spinlock_t *lock) { - l4_time_t timeout; int i; +#ifdef USE_L4 /* Start with a small timeout of 2 microseconds, then back off exponentially. */ + l4_time_t timeout; timeout = l4_time_period (2); +#else +# warning Don't know how to sleep on this platform. +#endif while (1) { @@ -52,11 +58,14 @@ _pthread_spin_lock (__pthread_spinlock_t *lock) if (__pthread_spin_trylock (lock) == 0) return 0; } + +#ifdef USE_L4 l4_sleep (timeout); timeout = l4_time_mul2 (timeout); if (timeout == L4_NEVER) timeout = L4_TIME_PERIOD_MAX; +#endif } } diff --git a/libpthread/sysdeps/viengoos/pt-stack-alloc.c b/libpthread/sysdeps/viengoos/pt-stack-alloc.c index b7ec12b..7dfea2a 100644 --- a/libpthread/sysdeps/viengoos/pt-stack-alloc.c +++ b/libpthread/sysdeps/viengoos/pt-stack-alloc.c @@ -1,4 +1,4 @@ -/* Allocate a new stack. L4 Hurd version. +/* Allocate a new stack. Viengoos version. Copyright (C) 2000, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -17,7 +17,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include #include diff --git a/libpthread/sysdeps/viengoos/pt-sysdep.c b/libpthread/sysdeps/viengoos/pt-sysdep.c index c23364c..d4d6fed 100644 --- a/libpthread/sysdeps/viengoos/pt-sysdep.c +++ b/libpthread/sysdeps/viengoos/pt-sysdep.c @@ -26,7 +26,11 @@ int sched_yield (void) { +#ifdef USE_L4 l4_yield (); +#else +# warning Not ported to this platform. +#endif return 0; } @@ -56,6 +60,11 @@ init_routine (void (*entry) (void *), void *arg) assert_perror (err); /* Switch stacks. */ +#ifdef USE_L4 l4_start_sp_ip (l4_myself (), thread->mcontext.sp, thread->mcontext.pc); +#else +# warning Not ported to this platform. + assert (0); +#endif } diff --git a/libpthread/sysdeps/viengoos/pt-sysdep.h b/libpthread/sysdeps/viengoos/pt-sysdep.h index f7ababa..db89112 100644 --- a/libpthread/sysdeps/viengoos/pt-sysdep.h +++ b/libpthread/sysdeps/viengoos/pt-sysdep.h @@ -20,7 +20,10 @@ #ifndef _PT_SYSDEP_H #define _PT_SYSDEP_H 1 -#include +#ifdef USE_L4 +# include +#endif + #include #include @@ -46,7 +49,11 @@ extern inline struct __pthread * __attribute__((__always_inline__)) _pthread_self (void) { +#if USE_L4 return (struct __pthread *) l4_user_defined_handle (); +#else + assert (0); +#endif } extern inline void diff --git a/libpthread/sysdeps/viengoos/pt-thread-alloc.c b/libpthread/sysdeps/viengoos/pt-thread-alloc.c index e47377c..266444f 100644 --- a/libpthread/sysdeps/viengoos/pt-thread-alloc.c +++ b/libpthread/sysdeps/viengoos/pt-thread-alloc.c @@ -45,9 +45,13 @@ __pthread_thread_alloc (struct __pthread *thread) if (__pthread_num_threads == 1) { thread->object = __hurd_startup_data->thread; - thread->threadid = l4_myself (); + thread->threadid = hurd_myself (); +#ifdef USE_L4 l4_set_user_defined_handle ((l4_word_t) thread); +#else + assert (0); +#endif /* Get the thread's UTCB and stash it. */ thread->utcb = hurd_utcb (); diff --git a/libpthread/sysdeps/viengoos/pt-thread-start.c b/libpthread/sysdeps/viengoos/pt-thread-start.c index 41d0fbf..5a3867d 100644 --- a/libpthread/sysdeps/viengoos/pt-thread-start.c +++ b/libpthread/sysdeps/viengoos/pt-thread-start.c @@ -33,7 +33,7 @@ __pthread_thread_start (struct __pthread *thread) /* The main thread is already running of course. */ { assert (__pthread_total == 1); - assert (l4_is_thread_equal (l4_myself (), thread->threadid)); + assert (hurd_myself () == thread->threadid); } else { @@ -46,10 +46,10 @@ __pthread_thread_start (struct __pthread *thread) vg_addr_t activity = VG_ADDR_VOID; - in.sp = (l4_word_t) thread->mcontext.sp; - in.ip = (l4_word_t) thread->mcontext.pc; + in.sp = (uintptr_t) thread->mcontext.sp; + in.ip = (uintptr_t) thread->mcontext.pc; - in.user_handle = (l4_word_t) thread; + in.user_handle = (uintptr_t) thread; err = vg_thread_exregs (VG_ADDR_VOID, thread->object, VG_EXREGS_SET_ASPACE | VG_EXREGS_SET_ACTIVITY diff --git a/libpthread/sysdeps/viengoos/sig-sysdep.h b/libpthread/sysdeps/viengoos/sig-sysdep.h index 33e1385..c1cbe92 100644 --- a/libpthread/sysdeps/viengoos/sig-sysdep.h +++ b/libpthread/sysdeps/viengoos/sig-sysdep.h @@ -18,6 +18,8 @@ License along with this program. If not, see . */ + +#ifdef USE_L4 #include #include @@ -67,3 +69,11 @@ utcb_state_restore (struct utcb *buffer) #define SIGNAL_DISPATCH_EXIT \ utcb_state_restore (&buffer); + +#else + +#warning Signal dispatch entry and exit unimplemented for this platform. +#define SIGNAL_DISPATCH_ENTRY assert (0) +#define SIGNAL_DISPATCH_EXIT assert (0) + +#endif diff --git a/libviengoos/ChangeLog b/libviengoos/ChangeLog index 180a7a4..1c061f1 100644 --- a/libviengoos/ChangeLog +++ b/libviengoos/ChangeLog @@ -1,3 +1,10 @@ +2009-01-16 Neal H. Walfield + + * viengoos/thread.h (VG_READ): Define. + (VG_WRITE): Define. + (VG_EXECUTE): Likewise. + (VG_ACTIVATION_FAULT_INFO_PRINTF): Use them. + 2008-12-18 Neal H. Walfield * viengoos/cap.h (object_discarded_clear): Take additional diff --git a/libviengoos/viengoos/thread.h b/libviengoos/viengoos/thread.h index a61859f..1f04e39 100644 --- a/libviengoos/viengoos/thread.h +++ b/libviengoos/viengoos/thread.h @@ -303,13 +303,24 @@ vg_activation_method_id_string (uintptr_t id) } } +enum + { + VG_READ = 1 << 0, +#define VG_READ VG_READ + VG_WRITE = 1 << 1, +#define VG_WRITE VG_WRITE + VG_EXECUTE = 1 << 2, +#define VG_EXECUTE VG_EXECUTE + }; + struct vg_activation_fault_info { union { struct { - /* Type of access. */ + /* Type of access. A bitwise or of VG_READ, VG_WRITE and + VG_EXECUTE. */ uintptr_t access: 3; /* Type of object that was attempting to be accessed. */ uintptr_t type : VG_CAP_TYPE_BITS; @@ -322,9 +333,9 @@ struct vg_activation_fault_info #define VG_ACTIVATION_FAULT_INFO_FMT "%c%c%c %s%s" #define VG_ACTIVATION_FAULT_INFO_PRINTF(info) \ - ((info).access & L4_FPAGE_READABLE ? 'r' : '~'), \ - ((info).access & L4_FPAGE_WRITABLE ? 'w' : '~'), \ - ((info).access & L4_FPAGE_EXECUTABLE ? 'x' : '~'), \ + ((info).access & VG_READ ? 'r' : '~'), \ + ((info).access & VG_WRITE ? 'w' : '~'), \ + ((info).access & VG_EXECUTE ? 'x' : '~'), \ vg_cap_type_string ((info).type), \ (info.discarded) ? " discarded" : "" diff --git a/ruth/ChangeLog b/ruth/ChangeLog index edba36d..0ad77ef 100644 --- a/ruth/ChangeLog +++ b/ruth/ChangeLog @@ -1,3 +1,12 @@ +2009-01-16 Neal H. Walfield + + * ruth.c [USE_L4]: Only include 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. + 2008-12-12 Neal H. Walfield * ruth.c (main): When done with all tests, don't spin, just 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 #endif +#ifdef USE_L4 +# include +#endif + #include #include #include @@ -45,8 +49,6 @@ #include #include -#include - 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"); diff --git a/viengoos/ChangeLog b/viengoos/ChangeLog index 4acd0a4..7113eb0 100644 --- a/viengoos/ChangeLog +++ b/viengoos/ChangeLog @@ -1,3 +1,19 @@ +2009-01-16 Neal H. Walfield + + * cap.h: Don't include . + * mutex.h [USE_L4]: Only include 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 in this case. + (object_desc_unmap) [! USE_L4]: Make a no-op. + (object_desc_flush) [! USE_L4]: Likewise. + * thread.h: Don't include . + (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. + 2009-01-16 Neal H. Walfield * Makefile.am (viengoos_LDADD): Link to diff --git a/viengoos/cap.h b/viengoos/cap.h index 8ce0820..01285f6 100644 --- a/viengoos/cap.h +++ b/viengoos/cap.h @@ -21,7 +21,6 @@ #ifndef RM_CAP_H #define RM_CAP_H -#include #include /* The number of slots in a capability object of the given type. */ diff --git a/viengoos/mutex.h b/viengoos/mutex.h index f6ed2ff..245cb3a 100644 --- a/viengoos/mutex.h +++ b/viengoos/mutex.h @@ -21,12 +21,18 @@ #ifndef _MUTEX_H #define _MUTEX_H -#include +#ifdef USE_L4 +# include +#endif #include #include #include +#ifdef USE_L4 typedef l4_thread_id_t ss_mutex_t; +#else +typedef int ss_mutex_t; +#endif /* Used by the atomic operations. */ extern void abort (void); @@ -34,6 +40,7 @@ extern void abort (void); static inline void ss_mutex_lock (__const char *caller, int line, ss_mutex_t *lock) { +#ifdef USE_L4 l4_thread_id_t owner; for (;;) @@ -53,6 +60,9 @@ ss_mutex_lock (__const char *caller, int line, ss_mutex_t *lock) __ss_lock_wait (l4_anylocalthread); } +#else +# warning Unimplemened on this platform. +#endif } #define ss_mutex_lock(__sml_lockp) \ @@ -66,6 +76,7 @@ ss_mutex_lock (__const char *caller, int line, ss_mutex_t *lock) static inline void ss_mutex_unlock (__const char *caller, int line, ss_mutex_t *lock) { +#ifdef USE_L4 l4_thread_id_t waiter; waiter = atomic_exchange_acq (lock, l4_nilthread); @@ -80,6 +91,9 @@ ss_mutex_unlock (__const char *caller, int line, ss_mutex_t *lock) /* Signal the waiter. */ __ss_lock_wakeup (waiter); +#else +# warning Unimplemened on this platform. +#endif } #define ss_mutex_unlock(__smu_lockp) \ @@ -93,6 +107,7 @@ ss_mutex_unlock (__const char *caller, int line, ss_mutex_t *lock) static inline bool ss_mutex_trylock (__const char *caller, int line, ss_mutex_t *lock) { +#ifdef USE_L4 l4_thread_id_t owner; owner = atomic_compare_and_exchange_val_acq (lock, l4_myself (), @@ -106,6 +121,10 @@ ss_mutex_trylock (__const char *caller, int line, ss_mutex_t *lock) // ss_mutex_trace_add (SS_MUTEX_TRYLOCK_BLOCKED, caller, line, lock); return false; +#else +# warning Unimplemened on this platform. + return true; +#endif } #define ss_mutex_trylock(__sml_lockp) \ diff --git a/viengoos/object.h b/viengoos/object.h index 789e35d..ea7e6ec 100644 --- a/viengoos/object.h +++ b/viengoos/object.h @@ -21,7 +21,10 @@ #ifndef RM_OBJECT_H #define RM_OBJECT_H -#include +#ifdef USE_L4 +# include +#endif + #include #include #include @@ -377,7 +380,8 @@ object_desc_unmap (struct object_desc *desc) if (desc->mapped) { -#ifndef _L4_TEST_ENVIRONMENT +#ifdef USE_L4 +# ifndef _L4_TEST_ENVIRONMENT struct vg_object *object = object_desc_to_object (desc); l4_fpage_t fpage = l4_fpage ((l4_word_t) object, PAGESIZE); @@ -389,6 +393,9 @@ object_desc_unmap (struct object_desc *desc) desc->user_referenced |= !!l4_was_referenced (result); desc->user_dirty |= !!l4_was_written (result); +# endif +#else +# warning Unimplemened on this platform. #endif desc->mapped = false; @@ -405,7 +412,8 @@ object_desc_flush (struct object_desc *desc, bool clear_kernel) if (clear_kernel || ! desc->dirty || ! desc->user_referenced) /* We only need to see if we dirtied or referenced it. */ { -#ifndef _L4_TEST_ENVIRONMENT +#ifdef USE_L4 +# ifndef _L4_TEST_ENVIRONMENT struct vg_object *object = object_desc_to_object (desc); l4_fpage_t fpage = l4_fpage ((l4_word_t) object, PAGESIZE); @@ -415,6 +423,9 @@ object_desc_flush (struct object_desc *desc, bool clear_kernel) desc->user_referenced |= !!l4_was_referenced (result); desc->user_dirty |= !!l4_was_written (result); +# endif +#else +# warning Unimplemened on this platform. #endif } } diff --git a/viengoos/thread.h b/viengoos/thread.h index b8006e5..73b6c4f 100644 --- a/viengoos/thread.h +++ b/viengoos/thread.h @@ -21,7 +21,6 @@ #ifndef RM_THREAD_H #define RM_THREAD_H -#include #include #include #include @@ -50,7 +49,7 @@ struct thread /* Non-user-accessible fields. */ /* Allocated thread id. */ - l4_thread_id_t tid; + vg_thread_id_t tid; /* XXX: Register state, blah, blah, blah. */ l4_word_t sp; @@ -122,7 +121,7 @@ extern void thread_raise_exception (struct activity *activity, extern void thread_deliver_pending (struct activity *activity, struct thread *thread); -/* Given the L4 thread id THREADID, find the associated thread. */ -extern struct thread *thread_lookup (l4_thread_id_t threadid); +/* Given the thread id THREADID, find the associated thread. */ +extern struct thread *thread_lookup (vg_thread_id_t threadid); #endif -- cgit v1.2.3