tbsd - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c54b8b69ede9d92e802baa1163d9cd734b034fb4
 (DIR) parent bc5d57712754818a2320a385afbf1c0c9558a4b3
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 27 Jan 2006 05:51:54 +0000
       
       bsd
       
       Diffstat:
         M include/libc.h                      |      11 -----------
         M include/u.h                         |       1 +
         M src/lib9/sleep.c                    |      10 ++++++++++
         M src/libthread/386-ucontext.h        |       2 ++
         M src/libthread/BSD.c                 |       2 +-
         M src/libthread/OpenBSD-386-asm.s     |       4 ++--
       
       6 files changed, 16 insertions(+), 14 deletions(-)
       ---
 (DIR) diff --git a/include/libc.h b/include/libc.h
       t@@ -904,17 +904,6 @@ extern        int        post9pservice(int, char*);
        #        endif
        #endif
        
       -/* this really shouldn't be here */
       -#if defined(__OpenBSD__) || (defined(__NetBSD__) && !defined(sched_yield))
       -#define sched_yield() \
       -        do { \
       -                struct timespec ts; \
       -                ts.tv_sec = 0; \
       -                ts.tv_nsec = 10; \
       -                nanosleep(&ts, NULL); \
       -        } while(0)
       -#endif
       -
        /* command line */
        extern char        *argv0;
        extern void __fixargv0(void);
 (DIR) diff --git a/include/u.h b/include/u.h
       t@@ -154,6 +154,7 @@ typedef int32_t s32int;
         * Gcc is too smart for its own good.
         */
        #if defined(__GNUC__)
       +#        undef strcmp        /* causes way too many warnings */
        #        if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
        #                undef AUTOLIB
        #                define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
 (DIR) diff --git a/src/lib9/sleep.c b/src/lib9/sleep.c
       t@@ -1,9 +1,19 @@
        #include <u.h>
        #define NOPLAN9DEFINES
       +#include <sys/param.h>
        #include <sys/time.h>
        #include <sched.h>
        #include <libc.h>
        
       +#if defined(__NetBSD__) || (defined(__OpenBSD__) && OpenBSD <= 200511)
       +#        define sched_yield() \
       +#                do{ struct timespec ts; \
       +#                        ts.tv_sec = 0; \
       +#                        ts.tv_nsec = 10; \
       +#                        nanosleep(&ts, 0); \
       +#                }while(0)
       +#endif
       +
        int
        p9sleep(long milli)
        {
 (DIR) diff --git a/src/libthread/386-ucontext.h b/src/libthread/386-ucontext.h
       t@@ -5,6 +5,8 @@ typedef struct ucontext ucontext_t;
        
        extern        int                swapcontext(ucontext_t*, ucontext_t*);
        extern        void                makecontext(ucontext_t*, void(*)(), int, ...);
       +extern        int                getmcontext(mcontext_t*);
       +extern        void                setmcontext(mcontetx_t*);
        
        /*-
         * Copyright (c) 1999 Marcel Moolenaar
 (DIR) diff --git a/src/libthread/BSD.c b/src/libthread/BSD.c
       t@@ -33,7 +33,7 @@ _threadlock(Lock *l, int block, ulong pc)
                for(i=0; i<1000; i++){
                        if(!_tas(&l->held))
                                return 1;
       -                sched_yield();
       +                sleep(0);
                }
                /* increasingly slow */
                for(i=0; i<10; i++){
 (DIR) diff --git a/src/libthread/OpenBSD-386-asm.s b/src/libthread/OpenBSD-386-asm.s
       t@@ -96,4 +96,5 @@ ENTRY(rfork_thread)
                movl    %ebp, %esp
                popl    %ebp
                PIC_PROLOGUE
       -        jmp     PIC_PLT(_C_LABEL(__cerror))
       -\ No newline at end of file
       +        jmp     PIC_PLT(_C_LABEL(__cerror))
       +