summaryrefslogtreecommitdiffstats
path: root/Python/dynload_hpux.c
blob: c9554148cc5f5caad7e79fdfa68481f4cef3a8cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

/* Support for dynamic loading of extension modules */

#include "dl.h"
#include <errno.h>

#include "Python.h"
#include "importdl.h"

#if defined(__hp9000s300)
#define FUNCNAME_PATTERN "_PyInit_%.200s"
#else
#define FUNCNAME_PATTERN "PyInit_%.200s"
#endif

const char *_PyImport_DynLoadFiletab[] = {SHLIB_EXT, NULL};

dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
                                    const char *pathname, FILE *fp)
{
    dl_funcptr p;
    shl_t lib;
    int flags;
    char funcname[258];

    flags = BIND_FIRST | BIND_DEFERRED;
    if (Py_VerboseFlag) {
        flags = BIND_FIRST | BIND_IMMEDIATE |
            BIND_NONFATAL | BIND_VERBOSE;
        printf("shl_load %s\n",pathname);
    }
    lib = shl_load(pathname, flags, 0);
    /* XXX Chuck Blake once wrote that 0 should be BIND_NOSTART? */
    if (lib == NULL) {
        char buf[256];
        PyObject *pathname_ob = NULL;
        PyObject *buf_ob = NULL;
        PyObject *shortname_ob = NULL;

        if (Py_VerboseFlag)
            perror(pathname);
        PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s",
                      pathname);
        buf_ob = PyUnicode_FromString(buf);
        shortname_ob = PyUnicode_FromString(shortname);
        pathname_ob = PyUnicode_FromString(pathname);
        PyErr_SetImportError(buf_ob, shortname_ob, pathname_ob);
        Py_DECREF(buf_ob);
        Py_DECREF(shortname_ob);
        Py_DECREF(pathname_ob);
        return NULL;
    }
    PyOS_snprintf(funcname, sizeof(funcname), FUNCNAME_PATTERN, shortname);
    if (Py_VerboseFlag)
        printf("shl_findsym %s\n", funcname);
    if (shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p) == -1) {
        shl_unload(lib);
        p = NULL;
    }
    if (p == NULL && Py_VerboseFlag)
        perror(funcname);

    return p;
}
2100500; // 528.5.0 #endif using namespace JSC; JSContextGroupRef JSContextGroupCreate() { return toRef(JSGlobalData::create().releaseRef()); } JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) { toJS(group)->ref(); return group; } void JSContextGroupRelease(JSContextGroupRef group) { toJS(group)->deref(); } JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) { #if PLATFORM(DARWIN) // When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed // to use a unique JSGlobalData, we use a shared one for compatibility. #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) { #else { #endif JSLock lock(true); return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass); } #endif // PLATFORM(DARWIN) return JSGlobalContextCreateInGroup(0, globalObjectClass); } JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) { initializeThreading(); JSLock lock(true); RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::create(); #if ENABLE(JSC_MULTIPLE_THREADS) globalData->makeUsableFromMultipleThreads(); #endif if (!globalObjectClass) { JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject; return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); } JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass); ExecState* exec = globalObject->globalExec(); JSValuePtr prototype = globalObjectClass->prototype(exec); if (!prototype) prototype = jsNull(); globalObject->resetPrototype(prototype); return JSGlobalContextRetain(toGlobalRef(exec)); } JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx) { ExecState* exec = toJS(ctx); JSLock lock(exec); JSGlobalData& globalData = exec->globalData(); globalData.heap.registerThread(); gcProtect(exec->dynamicGlobalObject()); globalData.ref(); return ctx; } void JSGlobalContextRelease(JSGlobalContextRef ctx) { ExecState* exec = toJS(ctx); JSLock lock(exec); gcUnprotect(exec->dynamicGlobalObject()); JSGlobalData& globalData = exec->globalData(); if (globalData.refCount() == 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain(). // The last reference was released, this is our last chance to collect. ASSERT(!globalData.heap.protectedObjectCount()); ASSERT(!globalData.heap.isBusy()); globalData.heap.destroy(); } else globalData.heap.collect(); globalData.deref(); } JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) { ExecState* exec = toJS(ctx); exec->globalData().heap.registerThread(); JSLock lock(exec); // It is necessary to call toThisObject to get the wrapper object when used with WebCore. return toRef(exec->lexicalGlobalObject()->toThisObject(exec)); } JSContextGroupRef JSContextGetGroup(JSContextRef ctx) { ExecState* exec = toJS(ctx); return toRef(&exec->globalData()); }