Changeset 2942


Ignore:
Timestamp:
Jan 8, 2007, 9:15:42 AM (19 years ago)
Author:
bird
Message:

fixed signals (requires nasm w/ patch), broken fstat, missing headers, library names, ...

Location:
trunk/libc
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/Config.kmk

    r2901 r2942  
    112112TEMPLATE_libcasm_TOOL = GCC3
    113113TEMPLATE_libcasm_TOOL.os2 = GCC3OMF
    114 TEMPLATE_libcasm_ASTOOL = ALP
    115114TEMPLATE_libcasm_INCS = $(PATH_LIBC_INC) $(dir $(LIBC-STD.H))
    116115TEMPLATE_libcasm_INST = usr/lib/
     116ifeq (1,0) # ALP sucks.
     117TEMPLATE_libcasm_ASTOOL = ALP
    117118TEMPLATE_libcasm_ASFLAGS = -Sv:ALP
     119else # NASM sucks too, but differently.
     120TEMPLATE_libcasm_ASTOOL = NASM
     121TEMPLATE_libcasm_ASFLAGS = -f obj -w+orphan-labels
     122endif
    118123
    119124TEMPLATE_libcasm.logstrict =
  • trunk/libc/Makefile.kmk

    r2939 r2942  
    120120# libc.a
    121121#
    122 LIBRARIES += libc
    123 libc_TEMPLATE = libc
    124 libc_SOURCES = \
     122LIBRARIES += libc_s
     123libc_s_TEMPLATE = libc
     124libc_s_SOURCES = \
    125125        $(TARGET_libc_frontend) \
    126126        $(TARGET_libc_kNIX)
    127 libc_SOURCES.nt = $(TARGET_kNIX.nt)
     127libc_s_SOURCES.nt = $(TARGET_kNIX.nt)
    128128
    129129ifdef CFG_LIBC_LOGSTRICT_LIBS
    130 LIBRARIES += libc_l
    131 libc_l_TEMPLATE = libc.profiled
    132 libc_l_SOURCES = \
     130LIBRARIES += libc_s_l
     131libc_s_l_TEMPLATE = libc.profiled
     132libc_s_l_SOURCES = \
    133133        $(TARGET_libc_frontend_l) \
    134134        $(TARGET_libc_kNIX_l)
    135 libc_l_SOURCES.nt = $(TARGET_kNIX_l.nt)
    136 endif
    137 
    138 ifdef CFG_LIBC_PROFILED_LIBS
    139 LIBRARIES += libc_p
    140 libc_p_TEMPLATE = libc.profiled
    141 libc_p_SOURCES = \
     135libc_s_l_SOURCES.nt = $(TARGET_kNIX_l.nt)
     136endif
     137
     138ifdef CFG_LIBC_PROFILED_LIBS
     139LIBRARIES += libc_s_p
     140libc_s_p_TEMPLATE = libc.profiled
     141libc_s_p_SOURCES = \
    142142        $(TARGET_libc_frontend_p) \
    143143        $(TARGET_libc_kNIX_p)
    144 libc_p_SOURCES.nt = $(TARGET_kNIX_p.nt)
     144libc_s_p_SOURCES.nt = $(TARGET_kNIX_p.nt)
    145145endif
    146146
     
    184184libc07_LDFLAGS = -g -Zomf -nostdlib
    185185libc07_LIBS = \
    186         $(TARGET_libc) \
     186        $(TARGET_libc_s) \
    187187        $(TARGET_libc_asm) \
    188188        $(TARGET_libos2_unicode_lazy) \
     
    204204libc07.logstrict_LDFLAGS = -g -Zomf -nostdlib
    205205libc07.logstrict_LIBS = \
    206         $(TARGET_libc_l) \
     206        $(TARGET_libc_s_l) \
    207207        $(TARGET_libc_asm_l) \
    208208        $(TARGET_libos2_unicode_lazy) \
     
    225225libc07.profiled_LDFLAGS = -g -Zomf -nostdlib
    226226libc07.profiled_LIBS = \
    227         $(TARGET_libc_p) \
     227        $(TARGET_libc_s_p) \
    228228        $(TARGET_libc_asm_p) \
    229229        $(TARGET_libos2_unicode_lazy) \
     
    246246libc_dll_SOURCES = \
    247247        $(PATH_TARGET)/libc.def
     248libc_dll_SOURCES.os2 = \
     249        src/libc/startup/os2/dllinit-os2.c
     250       
    248251# todo add socket ++.
    249252
     
    252255#
    253256$(PATH_TARGET)/libc.def: \
    254                 $(TARGET_libc) \
     257                $(TARGET_libc_s) \
    255258                $(PATH_LIBC_SRC)/libc/libc.def
    256259        $(RM) -f $@ $@.tmp.def
     
    260263        $(APPEND) $@.tmp.def "CODE SHARED"
    261264        $(APPEND) $@.tmp.def "EXPORTS"
    262         emxexp $(TARGET_libc) \
     265        emxexp $(TARGET_libc_s) \
    263266                | $(SED) -e "/\"___pfn/d" -e "/\"__sys_/d" -e "/\"___sys_/d" -e "/\"___libc_[a-z]/d" -e "/\"__nsyy/d" \
    264267                >> $@.tmp.def
     
    289292        $(foreach hdr, $(wildcard include/emx/*.h), $(hdr)=>$(subst include/,,$(hdr))) \
    290293        $(foreach hdr, $(wildcard include/InnoTekLIBC/*.h), $(hdr)=>$(subst include/,,$(hdr))) \
     294        $(foreach hdr, $(wildcard include/klibc/*.h), $(hdr)=>$(subst include/,,$(hdr))) \
     295        $(foreach hdr, $(wildcard include/klibc/*/*.h), $(hdr)=>$(subst include/,,$(hdr))) \
    291296        $(foreach hdr, $(wildcard include/machine/*.h), $(hdr)=>$(subst include/,,$(hdr))) \
    292297        $(foreach hdr, $(wildcard include/net/*.h), $(hdr)=>$(subst include/,,$(hdr))) \
  • trunk/libc/include/klibc/backend.h

    r2941 r2942  
    6969 * @param   pvOS        OS specific argument.
    7070 * @param   fFlags      Termination flags.
     71 *                      __LIBC_INIT_FLAGS_PROCESS is set when doing the process init call (__libc_InitExe).
    7172 */
    7273int __libc_Back_init(uintptr_t hmod, void *pvOS, unsigned fFlags);
     
    8182 *                      When invoked via _exit() it's NULL.
    8283 * @param   fFlags      Termination flags.
    83  *                      When invoked via _exit() it's 0.
     84 *                      When invoked via _exit() it's __LIBC_INIT_FLAGS_PROCESS.
    8485 */
    8586void __libc_Back_term(uintptr_t hmod, void *pvOS, unsigned fFlags);
  • trunk/libc/include/klibc/initterm.h

    r2941 r2942  
    6666#define __LIBC_INIT_FLAGS_EXPAND_RESPONSE_FILE     4
    6767#define __LIBC_INIT_FLAGS_EXPAND_WILDCARDS         8
     68/** @internal */
     69#define __LIBC_INIT_FLAGS_PROCESS                  0x40000000
    6870/** @} */
    6971
  • trunk/libc/src/kNIX/b_initterm.c

    r2941 r2942  
    5050 * @param   pvOS    OS specific argument.
    5151 * @param   fFlags  Initialization flags, a combination of the __LIBC_INIT_FLAGS_* \#defines.
     52 *                  __LIBC_INIT_FLAGS_PROCESS is set when doing the process init call (__libc_InitExe).
    5253 */
    5354static int __libc_back_init(uintptr_t hmod, void *pvOS, unsigned fFlags)
     
    138139        rc = __libc_back_init(hmod, pvOS, fFlags);
    139140    else
    140         /* (Might later add initialization code for every module here.) */
    141         rc = 0;
     141    {
     142#ifdef __OS2__
     143        /* Install the 16-bit signal handler. */
     144        if (fFlags & __LIBC_INIT_FLAGS_PROCESS)
     145            rc = __libc_back_signalInitExe();
     146        else
     147#endif
     148            rc = 0;
     149
     150    }
    142151    if (!rc)
    143152        LIBCLOG_RETURN_INT(0);
     
    184193 *                      When invoked via _exit() it's NULL.
    185194 * @param   fFlags      Termination flags.
    186  *                      When invoked via _exit() it's 0.
     195 *                      When invoked via _exit() it's __LIBC_INIT_FLAGS_PROCESS.
    187196 */
    188197void __libc_Back_term(uintptr_t hmod, void *pvOS, unsigned fFlags)
  • trunk/libc/src/kNIX/os2/386/signal16bit.asm

    r2929 r2942  
    22;; @file
    33;
    4 ; LIBC SYS Backend - Signals, 16-bit handler.
     4; kNIX - Signals, OS/2 16-bit handler.
    55;
    6 ; Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
     6; Copyright (c) 2004-2007 knut st. osmundsen <bird-src-spam@anduin.net>
    77;
    88;
     
    2525;
    2626
    27     .386
     27extern Dos32TIB
     28extern ___libc_back_signalOS2V1Handler32bit
    2829
    29 extrn Dos32TIB:abs
    30 extrn ___libc_back_signalOS2V1Handler32bit:near
    31 
    32 
    33 CODE16 segment use16 para public 'CODE'
     30segment CODE16 use16 align=16 public class=CODE
    3431
    3532;;
     
    3835;    void FAR PASCAL __libc_back_signalOS2V1Handler16bit(USHORT sig_arg, USHORT sig_num);
    3936;
    40 public ___libc_back_signalOS2V1Handler16bit
     37global ___libc_back_signalOS2V1Handler16bit
    4138___libc_back_signalOS2V1Handler16bit:
    4239    ; save registers.
     
    5653    push    edx                         ; dword old sp.
    5754
    58     jmp far ptr FLAT:CODE32:thunked_32
    59 CODE16 ends
    60 CODE32 segment use32 para public 'CODE'
     55    ;jmp far dword CODE32:thunked_32 wrt FLAT
     56    db      066h
     57    db      0eah
     58    dd      thunked_32 wrt FLAT
     59    dw      CODE32 wrt FLAT
     60
     61segment CODE32 use32 flat align=16 public class=CODE
    6162thunked_32:
     63
    6264    ; thunk the stack.
    6365    mov     edx, ss
     
    6567    shl     edx, 13
    6668    mov     dx, sp
    67     mov     eax, seg FLAT:DATA32
     69    mov     ax, DATA32 wrt FLAT
    6870    mov     esp, edx
    6971    mov     ss, eax
     
    7274    mov     ds, eax
    7375    mov     es, eax
    74     mov     edx, Dos32TIB
     76    mov     edx, Dos32TIB ;wrt abs
    7577    mov     fs, edx
    7678
    7779    ; call 32-bit worker
    78     movzx   eax, word ptr [esp + (4 * 5) + (2 * 4) + 6] ; sig_arg
    79     movzx   edx, word ptr [esp + (4 * 5) + (2 * 4) + 4] ; sig_num
     80    movzx   eax, word [esp + (4 * 5) + (2 * 4) + 6] ; sig_arg
     81    movzx   edx, word [esp + (4 * 5) + (2 * 4) + 4] ; sig_num
    8082    push    eax
    8183    push    edx
    82     call    ___libc_back_signalOS2V1Handler32bit
     84    call    ___libc_back_signalOS2V1Handler32bit wrt FLAT
    8385    add     esp, 8h
    8486
    8587    ; restore the stack and jump to 16-bit.
    8688    lss     esp, [esp]
    87     jmp far ptr CODE16:thunked_16
    88 CODE32 ends
    89 CODE16 segment
     89    ;jmp word far thunked_16
     90    db      066h
     91    db      0eah
     92    dw      thunked_16 wrt CODE16
     93    dw      CODE16
     94
     95segment CODE16
    9096thunked_16:
    9197
     
    100106
    101107    retf    4
    102 CODE16 ends
    103108
    104 DATA32 segment use32 para public 'DATA32'
    105 DATA32 ends
     109segment DATA32 use32 flat align=16 public class=DATA32
    106110
    107 end
  • trunk/libc/src/kNIX/os2/fhOS2File.c

    r2935 r2942  
    873873            }
    874874            pStat->st_attr = rc;
     875            rc = 0;
    875876            if (rc & FILE_READONLY)
    876877                pStat->st_mode |= S_IROTH | S_IRGRP | S_IRUSR;
  • trunk/libc/src/kNIX/os2/kNIX-os2.h

    r2936 r2942  
    261261
    262262int         __libc_back_signalInit(void);
    263 int         __libc_back_signalInitExe(void *pvRegRec);
     263int         __libc_back_signalInitExe(void);
    264264int         __libc_back_signalSemRequest(void);
    265265void        __libc_back_signalSemRelease(void);
  • trunk/libc/src/kNIX/os2/signals.c

    r2929 r2942  
    613613 * @returns 0 on success.
    614614 * @returns Negative error code (errno.h) on failure.
    615  * @param   pvRegRec    Pointer to the exception registartion record to use.
    616  */
    617 int __libc_back_signalInitExe(void *pvRegRec)
     615 */
     616int __libc_back_signalInitExe(void)
    618617{
    619618    LIBCLOG_ENTER("\n");
    620 
    621     /*
    622      * Exception handler.
    623      */
    624     PEXCEPTIONREGISTRATIONRECORD pRegRec = (PEXCEPTIONREGISTRATIONRECORD)pvRegRec;
    625     pRegRec->prev_structure   = END_OF_CHAIN;
    626     pRegRec->ExceptionHandler = __libc_Back_exceptionHandler;
    627     int rc = DosSetExceptionHandler(pRegRec);
     619    LIBC_ASSERT(!gfOS2V1Handler);
     620    FS_VAR_SAVE_LOAD();
    628621
    629622    /*
    630623     * Signal handling.
    631624     */
    632     rc = DosSetSigHandler((PFNSIGHANDLER)__libc_back_signalOS2V1Handler16bit, NULL, NULL, SIGA_ACCEPT, SIG_PFLG_A);
     625    int rc = DosSetSigHandler((PFNSIGHANDLER)__libc_back_signalOS2V1Handler16bit, NULL, NULL, SIGA_ACCEPT, SIG_PFLG_A);
    633626    if (!rc)
    634627    {
     
    636629        ULONG cTimes = 0;
    637630        DosSetSignalExceptionFocus(SIG_SETFOCUS, &cTimes); /* (Will fail with rc 303 for PM apps - which we ignore.) */
     631        FS_RESTORE();
    638632        LIBCLOG_RETURN_INT(0);
    639633    }
    640634    LIBC_ASSERTM_FAILED("DosSetSigHandler failed with rc=%d\n", rc);
    641635    rc = -__libc_back_native2errno(rc);
     636    FS_RESTORE();
    642637    LIBCLOG_ERROR_RETURN_INT(rc);
    643638}
  • trunk/libc/src/libc/startup/initterm.c

    r2941 r2942  
    2727
    2828/** @page pg_initterm   Initialization and Termination
    29  * 
    30  * kLIBC tries to provides a well defined, portable and hopefully relativly stable 
    31  * interface for initialization and termination of it's operation. The dll0 and 
     29 *
     30 * kLIBC tries to provides a well defined, portable and hopefully relativly stable
     31 * interface for initialization and termination of it's operation. The dll0 and
    3232 * crt0 objects are considered mere users of this interface. The days where the
    3333 * __init() function did cool stuff to ESP is over.
    34  * 
     34 *
    3535 * The general event flow is as follows:
    3636 *      -# dll0/crt0 calls __libc_InitDll()/__libc_initExe().
     
    3939 *      -# If __libc_InitExe() was invoked, the argument vector is initialized.
    4040 *      -# exit() is called.
    41  * 
     41 *
    4242 * Both the backend and the frontend performs usage accounting most of the work
    4343 * is done on the first call. Likewise for termination.
    44  * 
     44 *
    4545 */
    4646
     
    8585{
    8686    LIBCLOG_ENTER("hmod=%tx pvOS=%p fFlags=%#x\n", hmod, pvOS, fFlags);
     87    LIBC_ASSERT(!(fFlags & __LIBC_INIT_FLAGS_PROCESS));
    8788    int rc = __libc_init(hmod, pvOS, fFlags);
    8889    LIBCLOG_RETURN_INT(rc);
     
    103104{
    104105    LIBCLOG_ENTER("hmod=%tx pvOS=%p fFlags=%#x pArgs=%p\n", hmod, pvOS, fFlags, (void *)pArgs);
     106    LIBC_ASSERT(!(fFlags & __LIBC_INIT_FLAGS_PROCESS));
    105107
    106108    /* Flag that we've been called. */
     
    111113     * Do normal CRT init - necessary for static linking.
    112114     */
     115    fFlags |= __LIBC_INIT_FLAGS_PROCESS;
    113116    int rc = __libc_init(hmod, pvOS, fFlags);
    114117    if (rc)
     
    135138 * @param   pvOS    OS specific argument.
    136139 * @param   fFlags  Initialization flags, a combination of the __LIBC_INIT_FLAGS_* \#defines.
     140 *                  __LIBC_INIT_FLAGS_PROCESS is set when doing the process init call (__libc_InitExe).
    137141 */
    138142static int __libc_init(uintptr_t hmod, void *pvOS, unsigned fFlags)
     
    212216/**
    213217 * LIBC termination entry point used by an 'exit' function.
    214  * 
     218 *
    215219 * This call is 'paired' with the __libc_InitExe call.
    216220 */
     
    225229    LIBC_ASSERTM(cRefs >= 0, "cRefs=%d\n", cRefs);
    226230    if (cRefs >= 0)
    227         __libc_term(0, NULL, 0);
     231        __libc_term(0, NULL, __LIBC_INIT_FLAGS_PROCESS);
    228232
    229233    LIBCLOG_RETURN_MSG_VOID("ret void (g_cExecUsers=%d)\n", cRefs);
     
    242246 *                  When invoked via _exit() it's NULL.
    243247 * @param   fFlags  Initialization flags, a combination of the __LIBC_INIT_FLAGS_* \#defines.
    244  *                  When invoked via _exit() it's 0.
     248 *                  When invoked via _exit() it's __LIBC_INIT_FLAGS_PROCESS.
    245249 */
    246250static void __libc_term(uintptr_t hmod, void *pvOS, unsigned fFlags)
Note: See TracChangeset for help on using the changeset viewer.