Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

int kldrInit ( void   ) 

Initializes the loader.

Returns:
0 on success, non-zero OS status code on failure.

Todo:
atomic test and set if we care.

Definition at line 78 of file kLdr.c.

References g_fInitialized, kHlpSleep(), kldrDyldInit(), kLdrDyldSemInit(), and kLdrDyldSemTerm().

Referenced by _DLL_InitTerm(), DllMain(), and kLdrDyldLoadExe().

{
    int rc;

    /* check we're already good. */
    if (g_fInitialized == 1)
        return 0;

    /* a tiny serialization effort. */
    for (;;)
    {
        if (g_fInitialized == 1)
            return 0;
        if (g_fInitialized == -2)
            return -1;
        /** @todo atomic test and set if we care. */
        if (g_fInitialized == 0)
        {
            g_fInitialized = -1;
            break;
        }
        kHlpSleep(1);
    }

    /*
     * Do the initialization.
     */
    rc = kHlpHeapInit();
    if (!rc)
    {
        rc = kLdrDyldSemInit();
        if (!rc)
        {
            rc = kldrDyldInit();
            if (!rc)
            {
                g_fInitialized = 1;
                return 0;
            }
            kLdrDyldSemTerm();
        }
        kHlpHeapTerm();
    }
    g_fInitialized = -2;
    return rc;
}


Generated by  Doxygen 1.6.0   Back to index