Changeset 145

Show
Ignore:
Timestamp:
05/18/06 05:47:27 (2 years ago)
Author:
aldacron
Message:

* added Anders' patch to loader.d to make it work with GDC

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/DerelictUtil/derelict/util/loader.d

    r132 r145  
    141141    } 
    142142} 
     143else version(Unix) 
     144{ 
     145extern(C) 
     146{ 
     147    /* From <dlfcn.h> 
     148    *  See http://www.opengroup.org/onlinepubs/007908799/xsh/dlsym.html 
     149    */ 
     150 
     151    const int RTLD_NOW = 2; 
     152 
     153    void *dlopen(char* file, int mode); 
     154    int dlclose(void* handle); 
     155    void *dlsym(void* handle, char* name); 
     156    char* dlerror(); 
     157} 
     158 
     159    SharedLib Platform_LoadSharedLib(char[] libName) 
     160    { 
     161        void *hlib = dlopen(toStringz(libName), RTLD_NOW); 
     162        if(null is hlib) 
     163            throw new SharedLibLoadException("Failed to load shared library " ~ libName); 
     164 
     165        return new SharedLib(hlib, libName); 
     166    } 
     167 
     168    void Plaform_UnloadSharedLib(SharedLib lib) 
     169    { 
     170        dlclose(lib._handle); 
     171        lib._handle = null; 
     172    } 
     173 
     174    void* Platform_GetProc(SharedLib lib, char[] procName) 
     175    { 
     176        void *proc = dlsym(lib._handle, toStringz(procName)); 
     177        if(null is proc) 
     178            Derelict_HandleMissingProc(lib._name, procName); 
     179 
     180        return proc; 
     181    } 
     182} 
    143183else 
    144184{