/ thread.s (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes

#if defined (__MT__)

#include <emx/asm386.h>

        .globl  __thread

        .text

        ALIGN

__thread:
        cmpb    $0, __osmode            /* _osmode == DOS_MODE? */
        je      1f                      /* Yes -> */
        fs
        movl    12, %eax                /* ptib2 */
        movl    0(%eax), %edx           /* TID */
        movl    __thread_tab(,%edx,4), %eax
        testl   %eax, %eax
        jz      2f
Lreturn:EPILOGUE(_thread)

        ALIGN
1:      movl    __thread_tab+4, %eax
        jmp     Lreturn

        ALIGN
2:      pushl   %edx
        call    ___alloc_thread
        popl    %edx
        testl   %eax, %eax
        jz      Lreturn
        movl    %eax, __thread_tab(,%edx,4)
        jmp     Lreturn

#endif
