# HG changeset patch # User jwe # Date 828914563 0 # Node ID 098edb40c89bc6eb574dde9a7094f483c794f387 # Parent 7e430470e098cb55c804a9571caba26c90ca46e5 [project @ 1996-04-07 21:56:15 by jwe] diff --git a/configure.in b/configure.in --- a/configure.in +++ b/configure.in @@ -20,7 +20,7 @@ ### along with Octave; see the file COPYING. If not, write to the Free ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -AC_REVISION($Revision: 1.185 $) +AC_REVISION($Revision: 1.186 $) AC_PREREQ(2.9) AC_INIT(src/octave.cc) AC_CONFIG_HEADER(config.h) @@ -671,7 +671,7 @@ AC_CHECK_FUNCS(setvbuf getcwd gethostname bzero bcopy rindex vfprintf vsprintf) AC_CHECK_FUNCS(stricmp strnicmp strcasecmp strncasecmp strerror atexit) -AC_CHECK_FUNCS(on_exit tempnam memmove putenv) +AC_CHECK_FUNCS(on_exit tempnam memmove putenv strdup) AC_CHECK_FUNCS(mkdir rmdir rename umask) AC_CHECK_FUNCS(sigaction sigprocmask sigpending sigsuspend) diff --git a/dlfcn/dlfcn.c b/dlfcn/dlfcn.c --- a/dlfcn/dlfcn.c +++ b/dlfcn/dlfcn.c @@ -4,6 +4,18 @@ * 30159 Hannover, Germany */ +/* + * Changes marked with `--jwe' were made on April 7 1996 by John W. Eaton + * to support g++ and/or use with Octave. + */ + +/* + * This makes my life easier with Octave. --jwe + */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -35,6 +47,8 @@ void (*term)(void); /* call static destructors */ } Cdtor, *CdtorPtr; +typedef void (*GccCDtorPtr)(void); + /* * The void * handle returned from dlopen is actually a ModulePtr. */ @@ -45,6 +59,8 @@ void *entry; /* entry point from load */ struct dl_info *info; /* optional init/terminate functions */ CdtorPtr cdtors; /* optional C++ constructors */ + GccCDtorPtr gcc_ctor; /* g++ constructors --jwe */ + GccCDtorPtr gcc_dtor; /* g++ destructors --jwe */ int nExports; /* the number of exports found */ ExportPtr exports; /* the array of exports */ } Module, *ModulePtr; @@ -62,7 +78,13 @@ static char errbuf[BUFSIZ]; static int errvalid; +/* + * The `fixed' gcc header files on AIX 3.2.5 provide a prototype for + * strdup(). --jwe + */ +#ifndef HAVE_STRDUP extern char *strdup(const char *); +#endif static void caterr(char *); static int readExports(ModulePtr); static void terminate(void); @@ -181,6 +203,15 @@ (*cp->init)(); cp++; } + /* + * If the shared object was compiled using g++, we will need + * to call global constructors using the _GLOBAL__DI function, + * and later, global destructors using the _GLOBAL_DD + * funciton. --jwe + */ + } else if (mp->gcc_ctor = (GccCDtorPtr)dlsym(mp, "_GLOBAL__DI")) { + (*mp->gcc_ctor)(); + mp->gcc_dtor = (GccCDtorPtr)dlsym(mp, "_GLOBAL__DD"); } else errvalid = 0; return mp; @@ -270,6 +301,12 @@ (*cp->term)(); cp++; } + /* + * If the function to handle global destructors for g++ + * exists, call it. --jwe + */ + } else if (mp->gcc_dtor) { + (*mp->gcc_dtor)(); } result = unload(mp->entry); if (result == -1) {