/* -*- C++ -*- */ /************************************************************************* * Copyright(c) 1995~2005 Masaharu Goto (root-cint@cern.ch) * * For the licensing terms see the file COPYING * ************************************************************************/ /************************************************************************ * demo/multilibcint/mt.c * * Description: * Cint's multi-thread workaround library. * Refer to README.txt in this directory. ************************************************************************/ #include #include #include #if defined(G__WIN32) || defined(_WIN32) #include #else #include #include #include #endif /************************************************************************ * platform dependent declaration, needs to be fixed ************************************************************************/ #if defined(G__WIN32) || defined(_WIN32) typedef HINSTANCE G__SHLHANDLE; typedef HANDLE pthread_t; #else typedef void* G__SHLHANDLE; # define G__RTLD_NOW (RTLD_GLOBAL | RTLD_NOW) # define G__RTLD_LAZY (RTLD_GLOBAL | RTLD_LAZY) //static int G__RTLD_flag = RTLD_LAZY; static int G__RTLD_flag = RTLD_NOW; #endif /************************************************************************ * static declaration ************************************************************************/ #define G__MAXLIBCINT 32 static char cintsysdir[512]; typedef int (*G__f_init_cint) (char*); typedef int (*G__f_scratch_all) (); struct G__LIBCINT { char name[512]; char args[512]; G__SHLHANDLE handle; int active; G__f_init_cint f_init_cint; G__f_scratch_all f_scratch_all; }; static struct G__LIBCINT libcint[G__MAXLIBCINT]; /************************************************************************ * STATIC(PRIVATE) FUNCTIONS ************************************************************************/ /************************************************************************ * G__getlibcint() ************************************************************************/ static int G__getlibcint(char *args) { char cintlib[512]; int i; /* get cintsysdir if not set */ if(0==cintsysdir[0]) { char *p; p = getenv("CINTSYSDIR"); if(p) strcpy(cintsysdir,p); else { fprintf(stderr,"Error: Environment variable CINTSYSDIR not set\n"); return(0); } } /* If there is an already loaded libcintX.so and it is idle, reuse it */ for(i=0;i