diff options
Diffstat (limited to 'libthreads/i386')
-rw-r--r-- | libthreads/i386/cthreads.h | 21 | ||||
-rw-r--r-- | libthreads/i386/lock.s | 28 | ||||
-rw-r--r-- | libthreads/i386/thread.c | 63 |
3 files changed, 48 insertions, 64 deletions
diff --git a/libthreads/i386/cthreads.h b/libthreads/i386/cthreads.h index 8ffe4b72..643e7350 100644 --- a/libthreads/i386/cthreads.h +++ b/libthreads/i386/cthreads.h @@ -1,6 +1,6 @@ /* * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University + * Copyright (c) 1993,1991,1990 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its @@ -26,6 +26,15 @@ /* * HISTORY * $Log: cthreads.h,v $ + * Revision 2.9 93/01/24 13:24:58 danner + * Move ! in spin_try_lock to give the compiler + * a fighting chance. + * [92/11/19 rvb] + * + * Revision 2.8 93/01/14 18:05:09 danner + * asm -> __asm__ + * [93/01/10 danner] + * * Revision 2.7 92/01/03 20:36:59 dbg * Add volatile to spin_lock_t. Change spin_unlock and * spin_try_lock definitions back to memory operands, but rely on @@ -66,21 +75,21 @@ typedef volatile int spin_lock_t; #define spin_unlock(p) \ ({ register int _u__ ; \ - asm volatile("xorl %0, %0; \n\ + __asm__ volatile("xorl %0, %0; \n\ xchgl %0, %1" \ : "=&r" (_u__), "=m" (*(p)) ); \ 0; }) #define spin_try_lock(p)\ - ({ boolean_t _r__; \ - asm volatile("movl $1, %0; \n\ + (!({ boolean_t _r__; \ + __asm__ volatile("movl $1, %0; \n\ xchgl %0, %1" \ : "=&r" (_r__), "=m" (*(p)) ); \ - !_r__; }) + _r__; })) #define cthread_sp() \ ({ int _sp__; \ - asm("movl %%esp, %0" \ + __asm__("movl %%esp, %0" \ : "=g" (_sp__) ); \ _sp__; }) diff --git a/libthreads/i386/lock.s b/libthreads/i386/lock.s index e27fa7ff..f064e5bb 100644 --- a/libthreads/i386/lock.s +++ b/libthreads/i386/lock.s @@ -26,6 +26,10 @@ /* * HISTORY * $Log: lock.s,v $ + * Revision 2.6 93/05/10 17:51:38 rvb + * Use C Comment + * [93/05/04 18:14:05 rvb] + * * Revision 2.5 91/05/14 17:57:20 mrt * Correcting copyright * @@ -49,22 +53,22 @@ * boolean_t spin_try_lock(int *m) */ ENTRY(spin_try_lock) - movl 4(%esp),%ecx / point at mutex - movl $1,%eax / set locked value in acc - xchg %eax,(%ecx) / swap with mutex - / xchg with memory is automatically - / locked - xorl $1,%eax / 1 (locked) => FALSE - / 0 (locked) => TRUE + movl 4(%esp),%ecx /* point at mutex */ + movl $1,%eax /* set locked value in acc */ + xchg %eax,(%ecx) /* swap with mutex */ + /* xchg with memory is automatically */ + /* locked */ + xorl $1,%eax /* 1 (locked) => FALSE */ + /* 0 (locked) => TRUE */ ret /* * void spin_unlock(int *m) */ ENTRY(spin_unlock) - movl 4(%esp),%ecx / point at mutex - xorl %eax,%eax / set unlocked value in acc - xchg %eax,(%ecx) / swap with mutex - / xchg with memory is automatically - / locked + movl 4(%esp),%ecx /* point at mutex */ + xorl %eax,%eax /* set unlocked value in acc */ + xchg %eax,(%ecx) /* swap with mutex */ + /* xchg with memory is automatically */ + /* locked */ ret diff --git a/libthreads/i386/thread.c b/libthreads/i386/thread.c index c6781b9d..c0195a8b 100644 --- a/libthreads/i386/thread.c +++ b/libthreads/i386/thread.c @@ -1,6 +1,6 @@ /* * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University + * Copyright (c) 1992,1991,1990 Carnegie Mellon University * All Rights Reserved. * * Permission to use, copy, modify and distribute this software and its @@ -25,44 +25,20 @@ */ /* * HISTORY - * $Log: thread.c,v $ - * Revision 1.5 2001/03/31 23:03:03 roland - * 2001-03-31 Roland McGrath <roland@frob.com> + * $Log: thread.c,v $ + * Revision 2.8 93/02/02 21:54:58 mrt + * Changed include of mach/mach.h to mach.h. + * [93/02/02 mrt] * - * * cthreads.h: Fix obsolescent #endif syntax. - * * cthread_internals.h: Likewise. - * * cancel-cond.c: Likewise. - * * stack.c: Likewise. - * * cthreads.c: Likewise. - * * cprocs.c: Likewise. - * * call.c: Likewise. - * * i386/thread.c: Likewise. - * - * Revision 1.4 2001/02/26 04:15:27 roland - * 2001-02-25 Roland McGrath <roland@frob.com> - * - * * i386/thread.c: Remove superfluous bzero decl, - * just include <strings.h> instead. - * - * Revision 1.3 1997/02/18 22:53:31 miles - * (cproc_setup): - * Correctly leave space at top of stack for account for GNU per-thread - * variables. - * - * Revision 1.2 1994/05/04 19:05:26 mib - * entered into RCS + * Revision 2.7 93/01/14 18:05:15 danner + * Converted file to ANSI C. + * Fixed argument types. + * [92/12/18 pds] * * Revision 2.6 91/07/31 18:37:07 dbg * Undefine cthread_sp macro around function definition. * [91/07/30 17:36:23 dbg] * - * Revision 2.5 91/05/14 17:57:27 mrt - * Correcting copyright - * - * Revision 2.4 91/02/14 14:20:21 mrt - * Changed to new Mach copyright - * [91/02/13 12:20:10 mrt] - * * Revision 2.3 90/06/02 15:13:53 rpd * Added definition of cthread_sp. * [90/06/02 rpd] @@ -78,15 +54,13 @@ */ #ifndef lint -static char rcs_id[] = "$Header: cvs-sans-libpthread/hurd/libthreads/i386/thread.c,v 1.6 2001/12/22 21:02:31 roland Exp $"; +char rcs_id[] = "$Header: cvs-sans-libpthread/hurd/libthreads/i386/thread.c,v 1.7 2002/05/27 02:50:10 roland Exp $"; #endif /* not lint */ -#include "../cthreads.h" -#include "../cthread_internals.h" -#include <strings.h> -#include <mach/mach.h> - +#include <cthreads.h> +#include "cthread_internals.h" +#include <mach.h> /* * Set up the initial state of a MACH thread @@ -94,10 +68,7 @@ static char rcs_id[] = "$Header: cvs-sans-libpthread/hurd/libthreads/i386/thread * when it is resumed. */ void -cproc_setup(child, thread, routine) - register cproc_t child; - int thread; - int routine; +cproc_setup(register cproc_t child, thread_t thread, void (*routine)(cproc_t)) { extern unsigned int __hurd_threadvar_max; /* GNU */ register int *top = (int *) @@ -118,7 +89,7 @@ cproc_setup(child, thread, routine) count = i386_THREAD_STATE_COUNT; MACH_CALL(thread_get_state(thread,i386_THREAD_STATE,(thread_state_t) &state,&count),r); - ts->eip = routine; + ts->eip = (int) routine; *--top = (int) child; /* argument to function */ *--top = 0; /* fake return address */ ts->uesp = (int) top; /* set stack pointer */ @@ -127,12 +98,12 @@ cproc_setup(child, thread, routine) MACH_CALL(thread_set_state(thread,i386_THREAD_STATE,(thread_state_t) &state,i386_THREAD_STATE_COUNT),r); } -#ifdef cthread_sp +#if defined(cthread_sp) #undef cthread_sp #endif int -cthread_sp() +cthread_sp(void) { return (int) __thread_stack_pointer (); } |