Last change
on this file since 3613 was 3605, checked in by ansari, 16 years ago |
Remplacement (MacOS X) des fonctions deprecated NSxxx de chargement dynamique par dlopen()... , Reza 29/04/2009
|
File size:
1.7 KB
|
Rev | Line | |
---|
[219] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Gestionnaire de lien dynamique - R. Ansari 12/98
|
---|
| 3 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 4 |
|
---|
| 5 | #ifndef PDYNLINKMGR_SEEN
|
---|
| 6 | #define PDYNLINKMGR_SEEN
|
---|
| 7 |
|
---|
[241] | 8 | #include "machdefs.h"
|
---|
[219] | 9 | #include <string>
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | #if defined(HPUX)
|
---|
| 13 | #include <dl.h>
|
---|
[3605] | 14 | /* Les fonction NSCreateObjectFile...() sont deprecated - Il faut utiliser les dlopen()...
|
---|
| 15 | qui sont plus efficaces a partir de 10.4 - On se cale donc sur les versions de GCC */
|
---|
| 16 | #elif defined(Darwin) && ( GCC_VERSION <= 3350 )
|
---|
[2496] | 17 | #include <mach-o/dyld.h>
|
---|
[230] | 18 | #else
|
---|
| 19 | #include <dlfcn.h>
|
---|
[219] | 20 | #endif
|
---|
| 21 |
|
---|
[895] | 22 | namespace SOPHYA {
|
---|
| 23 |
|
---|
[219] | 24 | typedef void (* DlFunction) (void);
|
---|
| 25 |
|
---|
[895] | 26 | //! Dynamic Link Manager.
|
---|
[219] | 27 | class PDynLinkMgr {
|
---|
| 28 | public:
|
---|
| 29 | // ---- Methodes globales (static)
|
---|
| 30 | static PDynLinkMgr* BuildFromCFile(string const & fname); // Compil+link fichier C
|
---|
| 31 | static void SetTmpDir(string const & path); // Repertoire des fichiers temporaires
|
---|
| 32 |
|
---|
| 33 | // ---- Constructeur et methodes
|
---|
| 34 | // Constructeur a partir d'un shared lib - copie en zone temporaire si cp==true
|
---|
| 35 | PDynLinkMgr(string& soname, bool cp=true);
|
---|
| 36 | virtual ~PDynLinkMgr();
|
---|
| 37 |
|
---|
| 38 | virtual DlFunction GetFunction(string const & funcname);
|
---|
[2496] | 39 | inline DlFunction GetFunction(const char * funcname)
|
---|
| 40 | { string fname = funcname; return GetFunction(fname); }
|
---|
[219] | 41 |
|
---|
[2496] | 42 | inline string GetName() const { return soName; }
|
---|
| 43 |
|
---|
[219] | 44 | protected :
|
---|
| 45 | static string& GetTmpDir();
|
---|
| 46 | static int numSO;
|
---|
| 47 | static string* tmpDir;
|
---|
| 48 |
|
---|
| 49 | #if defined(HPUX)
|
---|
| 50 | shl_t dlhandle;
|
---|
[3605] | 51 | #elif defined(Darwin) && ( GCC_VERSION <= 3350 )
|
---|
[2496] | 52 | NSObjectFileImage nsobjfile;
|
---|
| 53 | NSModule nsmod;
|
---|
[480] | 54 | #else
|
---|
[230] | 55 | void * dlhandle;
|
---|
[219] | 56 | #endif
|
---|
[2496] | 57 | bool dylok;
|
---|
[219] | 58 | string soName;
|
---|
| 59 | bool copy;
|
---|
| 60 | };
|
---|
| 61 |
|
---|
[895] | 62 | } // namespace SOPHYA
|
---|
| 63 |
|
---|
[219] | 64 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.