Autoconfigure the dlopen functions.

This commit is contained in:
steve 2000-12-15 05:45:25 +00:00
parent 8fe6324aec
commit 8c680d158a
3 changed files with 90 additions and 19 deletions

View File

@ -7,13 +7,25 @@ AC_PROG_CXX
AC_CHECK_TOOL(STRIP, strip, true) AC_CHECK_TOOL(STRIP, strip, true)
AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(getopt.h)
AC_CHECK_HEADER(ipal.h, HAVE_IPAL=yes, HAVE_IPAL=) AC_CHECK_HEADER(ipal.h, HAVE_IPAL=yes, HAVE_IPAL=)
AC_SUBST(HAVE_IPAL)
AC_PROG_INSTALL AC_PROG_INSTALL
AC_CHECK_LIB(dl,main,[DLLIB=-ldl])
# --
# Look for a dl library to use. First look for the standard dlopen
# functions, and failing that look for the HP specific shl_load function.
AC_CHECK_HEADERS(dlfcn.h dl.h, break)
DLLIB=''
AC_CHECK_LIB(dl,dlopen,[DLLIB=-ldl])
if test -z "$DLLIB" ; then
AC_CHECK_LIB(dld,shl_load,[DLLIB=-ldld])
fi
AC_SUBST(DLLIB) AC_SUBST(DLLIB)
AC_CANONICAL_HOST AC_CANONICAL_HOST
# $host # $host
AC_SUBST(HAVE_IPAL)
####################### #######################
## test for underscores. The vpi module loader in vvm needs to know this ## test for underscores. The vpi module loader in vvm needs to know this
@ -22,6 +34,7 @@ AC_SUBST(HAVE_IPAL)
AC_CYGWIN AC_CYGWIN
AC_EXEEXT AC_EXEEXT
AC_SUBST(CYGWIN)
AC_SUBST(EXEEXT) AC_SUBST(EXEEXT)
AC_MSG_CHECKING("for leading and/or trailing underscores") AC_MSG_CHECKING("for leading and/or trailing underscores")
@ -39,14 +52,7 @@ if test ! -z "$output" -a -z "$CYGWIN" ; then
AC_DEFINE(NEED_LU) AC_DEFINE(NEED_LU)
fi fi
PICFLAG=-fPIC
if test ! -z "$CYGWIN" ; then
PICFLAG=
fi
AC_SUBST(CYGWIN)
AC_SUBST(PICFLAG)
output=`nm underscore.o|grep underscore_ 2>&1` output=`nm underscore.o|grep underscore_ 2>&1`
if test ! -z "$output"; then if test ! -z "$output"; then
@ -69,6 +75,26 @@ AC_MSG_RESULT("$CC_LEADING_UNDERSCORE $CC_TRAILING_UNDERSCORE")
## end of test for underscores ## end of test for underscores
####################### #######################
# The -fPIC flag is used to tell the compiler to make position
# independent code. It is needed when making shared objects.
AC_MSG_CHECKING("for flag to make position independent code")
PICFLAG=-fPIC
case "${host}" in
*-*-cygwin*)
PICFLAG=
;;
*-*-hpux*)
PICFLAG=+z
;;
esac
AC_SUBST(PICFLAG)
AC_MSG_RESULT($PICFLAG)
# The -rdynamic flag is used by iverilog when compiling the target, # The -rdynamic flag is used by iverilog when compiling the target,
# to know how to export symbols of the main program to loadable modules # to know how to export symbols of the main program to loadable modules
# that are brought in by -ldl # that are brought in by -ldl
@ -89,18 +115,25 @@ case "${host}" in
rdynamic="" rdynamic=""
;; ;;
*-*-hpux*)
rdynamic="-E"
;;
esac esac
AC_SUBST(rdynamic) AC_SUBST(rdynamic)
AC_MSG_RESULT($rdynamic) AC_MSG_RESULT($rdynamic)
AC_MSG_CHECKING("for shared library build flag") AC_MSG_CHECKING("for shared library link flag")
shared=-shared shared=-shared
case "${host}" in case "${host}" in
*-*-cygwin*) *-*-cygwin*)
shared="-mdll -Wl,--enable-auto-image-base" shared="-mdll -Wl,--enable-auto-image-base"
;; ;;
*-*-hpux*)
shared="-b"
;;
esac esac
AC_SUBST(shared) AC_SUBST(shared)

View File

@ -17,14 +17,38 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.cc,v 1.21 2000/12/14 23:23:07 steve Exp $" #ident "$Id: t-dll.cc,v 1.22 2000/12/15 05:45:25 steve Exp $"
#endif #endif
# include "compiler.h" # include "compiler.h"
# include "t-dll.h" # include "t-dll.h"
# include <dlfcn.h>
# include <malloc.h> # include <malloc.h>
#if defined(HAVE_DLFCN_H)
inline ivl_dll_t ivl_dlopen(const char*name)
{ return dlopen(name,RTLD_NOW); }
inline void* ivl_dlsym(ivl_dll_t dll, const char*nm)
{ return dlsym(dll, nm); }
inline void ivl_dlclose(ivl_dll_t dll)
{ dlclose(dll); }
#elif defined(HAVE_DL_H)
inline ivl_dll_t ivl_dlopen(const char*name)
{ return shl_load(name, BIND_IMMEDIATE, 0); }
inline void* ivl_dlsym(ivl_dll_t dll, const char*nm)
{
void*sym;
int rc = shl_findsym(&dll, nm, TYPE_PROCEDURE, &sym);
return (rc == 0) ? sym : 0;
}
inline void ivl_dlclose(ivl_dll_t dll)
{ shl_unload(dll); }
#endif
static struct dll_target dll_target_obj; static struct dll_target dll_target_obj;
/* /*
@ -149,7 +173,7 @@ static void scope_add_lpm(ivl_scope_t scope, ivl_lpm_t net)
bool dll_target::start_design(const Design*des) bool dll_target::start_design(const Design*des)
{ {
dll_path_ = des->get_flag("DLL"); dll_path_ = des->get_flag("DLL");
dll_ = dlopen(dll_path_.c_str(), RTLD_NOW); dll_ = ivl_dlopen(dll_path_.c_str());
if (dll_ == 0) { if (dll_ == 0) {
cerr << dll_path_ << ": " << dlerror() << endl; cerr << dll_path_ << ": " << dlerror() << endl;
return false; return false;
@ -170,7 +194,7 @@ bool dll_target::start_design(const Design*des)
des_.root_->nlpm_ = 0; des_.root_->nlpm_ = 0;
des_.root_->lpm_ = 0; des_.root_->lpm_ = 0;
target_ = (target_design_f)dlsym(dll_, LU "target_design" TU); target_ = (target_design_f)ivl_dlsym(dll_, LU "target_design" TU);
if (target_ == 0) { if (target_ == 0) {
cerr << dll_path_ << ": error: target_design entry " cerr << dll_path_ << ": error: target_design entry "
"point is missing." << endl; "point is missing." << endl;
@ -187,7 +211,7 @@ bool dll_target::start_design(const Design*des)
void dll_target::end_design(const Design*) void dll_target::end_design(const Design*)
{ {
(target_)(&des_); (target_)(&des_);
dlclose(dll_); ivl_dlclose(dll_);
} }
/* /*
@ -617,6 +641,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/* /*
* $Log: t-dll.cc,v $ * $Log: t-dll.cc,v $
* Revision 1.22 2000/12/15 05:45:25 steve
* Autoconfigure the dlopen functions.
*
* Revision 1.21 2000/12/14 23:23:07 steve * Revision 1.21 2000/12/14 23:23:07 steve
* Support more logic gate types. * Support more logic gate types.
* *

15
t-dll.h
View File

@ -19,12 +19,20 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-dll.h,v 1.19 2000/12/05 06:29:33 steve Exp $" #ident "$Id: t-dll.h,v 1.20 2000/12/15 05:45:25 steve Exp $"
#endif #endif
# include "target.h" # include "target.h"
# include "ivl_target.h" # include "ivl_target.h"
#if defined(HAVE_DLFCN_H)
# include <dlfcn.h>
typedef void* ivl_dll_t;
#elif defined(HAVE_DL_H)
# include <dl.h>
typedef shl_t ivl_dll_t;
#endif
struct ivl_design_s { struct ivl_design_s {
ivl_scope_t root_; ivl_scope_t root_;
@ -58,7 +66,7 @@ struct dll_target : public target_t, public expr_scan_t {
void scope(const NetScope*); void scope(const NetScope*);
void signal(const NetNet*); void signal(const NetNet*);
void*dll_; ivl_dll_t dll_;
string dll_path_; string dll_path_;
ivl_design_s des_; ivl_design_s des_;
@ -355,6 +363,9 @@ struct ivl_statement_s {
/* /*
* $Log: t-dll.h,v $ * $Log: t-dll.h,v $
* Revision 1.20 2000/12/15 05:45:25 steve
* Autoconfigure the dlopen functions.
*
* Revision 1.19 2000/12/05 06:29:33 steve * Revision 1.19 2000/12/05 06:29:33 steve
* Make signal attributes available to ivl_target API. * Make signal attributes available to ivl_target API.
* *