Changeset 2819


Ignore:
Timestamp:
Oct 10, 2006, 4:55:35 AM (19 years ago)
Author:
bird
Message:

Work in progress.

Location:
trunk/libc
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/Config.kmk

    r2805 r2819  
    7676## @todo I need recursive inheritance!
    7777TEMPLATE_libc =
     78TEMPLATE_libc_EXTENDS = lib
    7879TEMPLATE_libc_TOOL = GCC3
    7980TEMPLATE_libc_INCS = $(PATH_LIBC_INC) $(dir $(LIBC-STD.H))
     
    8687
    8788TEMPLATE_libc.logstrict =
    88 TEMPLATE_libc.logstrict_TOOL = GCC3
    89 TEMPLATE_libc.logstrict_INCS = $(TEMPLATE_libc_INCS)
    90 TEMPLATE_libc.logstrict_INCS.nt = $(TEMPLATE_libc_INCS.nt)
     89TEMPLATE_libc.logstrict_EXTENDS = libc
    9190TEMPLATE_libc.logstrict_DEFS = $(TEMPLATE_libc_DEFS) __LIBC_STRICT DEBUG_LOGGING
    92 TEMPLATE_libc.logstrict_DEPS = $(TEMPLATE_libc_DEPS)
    93 TEMPLATE_libc.logstrict_INST = $(TEMPLATE_libc_INST)
    94 TEMPLATE_libc.logstrict_CFLAGS = $(TEMPLATE_libc_CFLAGS)
    9591
    9692TEMPLATE_libc.profiled =
    97 TEMPLATE_libc.profiled_TOOL = GCC3
    98 TEMPLATE_libc.profiled_INCS = $(TEMPLATE_libc_INCS)
    99 TEMPLATE_libc.profiled_INCS.nt = $(TEMPLATE_libc_INCS.nt)
     93TEMPLATE_libc.profiled_EXTENDS = libc
    10094TEMPLATE_libc.profiled_DEFS = $(TEMPLATE_libc_DEFS) __LIBC_PROFILED
    101 TEMPLATE_libc.profiled_DEPS = $(TEMPLATE_libc_DEPS)
    102 TEMPLATE_libc.profiled_INST = $(TEMPLATE_libc_INST)
    103 TEMPLATE_libc.profiled_CFLAGS = $(TEMPLATE_libc_CFLAGS)
    10495
    10596TEMPLATE_libcsub = LIBC Sub-Library.
     
    127118
    128119TEMPLATE_libcasm.logstrict =
    129 TEMPLATE_libcasm.logstrict_TOOL = GCC3
    130 TEMPLATE_libcasm.logstrict_TOOL.os2 = GCC3OMF
    131 TEMPLATE_libcasm.logstrict_ASTOOL = ALP
     120TEMPLATE_libcasm.logstrict_EXTENDS = libcasm
    132121TEMPLATE_libcasm.logstrict_DEFS = $(TEMPLATE_libcasm_DEFS) __LIBC_STRICT DEBUG_LOGGING
    133 TEMPLATE_libcasm.logstrict_INCS = $(TEMPLATE_libcasm_INCS)
    134 TEMPLATE_libcasm.logstrict_INST = $(TEMPLATE_libcasm_INST)
    135 TEMPLATE_libcasm.logstrict_ASFLAGS = $(TEMPLATE_libcasm_ASFLAGS)
    136122
    137123TEMPLATE_libcasm.profiled =
    138 TEMPLATE_libcasm.profiled_TOOL = GCC3
    139 TEMPLATE_libcasm.profiled_TOOL.os2 = GCC3OMF
    140 TEMPLATE_libcasm.profiled_ASTOOL = ALP
     124TEMPLATE_libcasm.profiled_EXTENDS = libcasm
    141125TEMPLATE_libcasm.profiled_DEFS = $(TEMPLATE_libcasm_DEFS) __LIBC_PROFILED
    142 TEMPLATE_libcasm.profiled_INCS = $(TEMPLATE_libcasm_INCS)
    143 TEMPLATE_libcasm.profiled_INST = $(TEMPLATE_libcasm_INST)
    144 TEMPLATE_libcasm.profiled_ASFLAGS = $(TEMPLATE_libcasm_ASFLAGS)
    145126
    146127TEMPLATE_libcsubasm =
  • trunk/libc/include/InnoTekLIBC/sharedpm.h

    r2672 r2819  
    652652
    653653
    654 
     654/**
     655 * Initializes the shared process management for this process.
     656 *
     657 * This might actually initialize the SPM globally too if this is the
     658 * first process using it.
     659 *
     660 * @returns 0 on success.
     661 * @returns Negative error code (errno.h) on failure.
     662 */
     663int __libc_spmInit(void);
    655664
    656665/**
  • trunk/libc/include/klibc/initterm.h

    r2806 r2819  
    4747} __LIBC_INITMAINARGS, *__LIBC_PINITMAINARGS;
    4848
    49 int __libc_InitExe(uintptr_t hmod, void *pvOS, unsigned fFlags, __LIBC_PINITMAINARGS pMainArgs);
    50 int __libc_InitDll(uintptr_t hmod, void *pvOS, unsigned fFlags);
    51 int __libc_TermDll(uintptr_t hmod, void *pvOS, unsigned fFlags);
     49void __libc_InitExe(uintptr_t hmod, void *pvOS, unsigned fFlags, __LIBC_PINITMAINARGS pMainArgs);
     50int  __libc_InitDll(uintptr_t hmod, void *pvOS, unsigned fFlags);
     51void __libc_TermDll(uintptr_t hmod, void *pvOS, unsigned fFlags);
    5252
    5353__END_DECLS
  • trunk/libc/src/kNIX/b_initterm.c

    r2805 r2819  
    3333
    3434
     35
     36/**
     37 * Initialize the kNIX backend.
     38 *
     39 * This is only called once.
     40 *
     41 * @returns 0 on success.
     42 * @returns negated errno on failure.
     43 *
     44 * @param   hmod    The native module handle of the DLL/EXE.
     45 * @param   pvOS    OS specific argument.
     46 * @param   fFlags  Initialization flags, a combination of the __LIBC_INIT_FLAGS_* \#defines.
     47 */
     48static int __libc_init(uintptr_t hmod, void *pvOS, unsigned fFlags)
     49{
     50    LIBCLOG_ENTER("hmod=%tx pvOS=%p fFlags=%#x\n", hmod, pvOs, fFlags);
     51    int rc;
     52
     53    /*
     54     * Do OS specific initialization of the process.
     55     */
     56#ifdef __NT__
     57#endif
     58#ifdef __OS2__
     59    rc = __libc_spmInit();
     60    if (rc)
     61        LIBCLOG_ERROR_RETURN_INT(rc);
     62#endif
     63
     64    /*
     65     * Initialize the thread database entering this thread as the first one.
     66     */
     67    rc = __libc_back_threadInit()
     68    if (!rc)
     69    {
     70        /*
     71         * Init the other
     72         */
     73
     74        rc = __libc_back_fsInit();
     75        if (!rc)
     76        {
     77        }
     78
     79    }
     80
     81
     82    /*
     83     * Initialize all backend mutexes residing in parts that doesn't have
     84     * special initializers.
     85     */
     86
     87
     88    if (__libc_back_fsInit())
     89    {
     90        LIBC_ASSERTM_FAILED("__libc_back_fsInit() failed\n");
     91        return -1;
     92    }
     93
     94    /*
     95     * Init file handles.
     96     */
     97    rc = __libc_fhInit();
     98    if (rc)
     99    {
     100        LIBC_ASSERTM_FAILED("__libc_fhInit() failed\n");
     101        return -1;
     102    }
     103
     104    /*
     105     * Init signals
     106     */
     107    rc = __libc_back_signalInit();
     108    if (rc)
     109    {
     110        LIBC_ASSERTM_FAILED("__libc_back_signalInit() failed\n");
     111        return -1;
     112    }
     113
     114    /*
     115     * Setup environment (org_environ and _STD(environ))
     116     */
     117    rc = _sys_init_environ(fibGetEnv());
     118    if (rc)
     119    {
     120        LIBC_ASSERTM_FAILED("_sys_init_environ() failed\n");
     121        return -1;
     122    }
     123
     124
     125    LIBCLOG_RETURN_INT(0);
     126}
     127
     128
     129
    35130/**
    36131 * Invoked by the crt0 and dll0 code.
  • trunk/libc/src/kNIX/kNIX.h

    r2805 r2819  
    4343#include <string.h>
    4444#include <signal.h>
     45#include <sys/builtin.h>
    4546#include <sys/fmutex.h>
    4647#include <sys/fcntl.h>
    4748#include <sys/resource.h>
     49#include <sys/smutex.h>
    4850#include <sys/time.h>
    4951#include <sys/types.h>
    5052#include <klibc/io.h>
    5153#include <klibc/umalloc.h>
     54#include <klibc/thread.h>
    5255#include <klibc/backend.h>
    5356#ifdef __LIBC_LOG_GROUP
  • trunk/libc/src/kNIX/os2/sharedpm.c

    r2732 r2819  
    112112*******************************************************************************/
    113113static int  spmForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation);
    114 static void spmCrtInit1(void);
    115114static int  spmRequestMutexErrno(__LIBC_PSPMXCPTREGREC pRegRec);
    116115static int  spmRequestMutex(__LIBC_PSPMXCPTREGREC pRegRec);
    117116static int  spmReleaseMutex(__LIBC_PSPMXCPTREGREC pRegRec);
    118 static int  spmInit(void);
    119117static VOID APIENTRY spmExitList(ULONG ulReason);
    120118static void spmCleanup(void);
     
    377375     * If we have we'll simply return.
    378376     */
    379     if (gpSPMSelf)
    380         pProcess = gpSPMSelf;
    381     else
     377    pProcess = gpSPMSelf;
     378    if (!pProcess)
    382379    {
    383380        __LIBC_SPMXCPTREGREC    RegRec;
     
    19721969
    19731970
    1974 _CRT_INIT1(spmCrtInit1)
    1975 /**
    1976  * Initializes the process database while we're still 100%
    1977  * sure we're single threaded. This avoids trouble.
    1978  *
    1979  * To tell the truth chances are _very_ high that this
    1980  * is not necessary because we will soon get the current
    1981  * process structure very early in the LIBC init process.
    1982  */
    1983 static void spmCrtInit1(void)
    1984 {
    1985     static void *hack = (void *)spmCrtInit1;
    1986     LIBCLOG_ENTER("\n");
    1987     hack = hack;
    1988     if (!gpSPMSelf)
    1989         __libc_spmSelf();
    1990     LIBCLOG_RETURN_VOID();
    1991 }
    1992 
    19931971
    19941972_FORK_CHILD1(0xfffffff0, spmForkChild1)
     
    21252103    if (!ghmtxSPM || !gpSPMHdr)
    21262104    {
    2127         /*
    2128          * Perform lazy init.
    2129          */
    2130         rc = spmInit();
    2131         if (!rc)
    2132         {
    2133             FS_RESTORE();
    2134             LIBCLOG_RETURN_INT(0);
    2135         }
    2136 
    21372105        LIBC_ASSERTM_FAILED("not initialized!\n");
    21382106        DosUnsetExceptionHandler(&pRegRec->Core);
     
    22242192#endif /* unused */
    22252193
    2226 /**
    2227  * Open and if needed creates the LIBC shared memory.
    2228  *
    2229  * This is called lazily by the mutex request function.
    2230  *
    2231  * @returns 0 on success. Mutex is owned.
     2194
     2195/**
     2196 * Initializes the shared process management for this process.
     2197 *
     2198 * This might actually initialize the SPM globally too if this is the
     2199 * first process using it.
     2200 *
     2201 * @returns 0 on success.
    22322202 * @returns Negative error code (errno.h) on failure.
    22332203 */
    2234 static int spmInit(void)
     2204int __libc_spmInit(void)
    22352205{
    22362206    LIBCLOG_ENTER("\n");
     
    23812351
    23822352            /*
    2383              * Register exit list handler and return with
    2384              * mutex ownership. This must have a priority lower than
    2385              * the TCPIP library of OS/2 to prevent it from closing
    2386              * sockets.
     2353             * Register exit list handler.
     2354             *
     2355             * This must have a priority lower than the TCPIP library of
     2356             * OS/2 to prevent it from closing sockets.
    23872357             */
    23882358            rc = DosExitList(0x9800 | EXLST_ADD, spmExitList);
    23892359            FS_RESTORE();
     2360            DosReleaseMutexSem(ghmtxSPM);
     2361            DosExitMustComplete(&ul);
    23902362            LIBC_ASSERTM(!rc, "DosExitList failed with rc=%d\n", rc);
    23912363            LIBCLOG_RETURN_INT(0);
  • trunk/libc/src/libc/startup/Makefile.kmk

    r2805 r2819  
    3737    $(PATH_LIBC_SRC)/libc/startup/dtor1.c \
    3838    $(PATH_LIBC_SRC)/libc/startup/exit.c \
    39     $(PATH_LIBC_SRC)/libc/startup/startup.c \
     39    $(PATH_LIBC_SRC)/libc/startup/initterm.c \
    4040    $(PATH_LIBC_SRC)/libc/startup/_exit.c \
    4141
Note: See TracChangeset for help on using the changeset viewer.