From d98fe558ee903b95e7fe2ed641fb78d621d523eb Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Sat, 8 May 2004 01:36:41 +0000 Subject: [PATCH] Move the dynlib and C++ name mangling routines into a separate "jitdynamic" library, which will handle all of the cross-language naming and dynamic invocation logic. --- ChangeLog | 9 +++ Makefile.am | 2 +- configure.in | 1 + doc/Makefile.am | 6 +- doc/libjit.texi | 2 +- include/jit/Makefile.am | 1 + include/jit/jit-dynamic.h | 64 +++++++++++++++++++ include/jit/jit-util.h | 30 --------- jit/Makefile.am | 2 - jitdynamic/.cvsignore | 3 + jitdynamic/Makefile.am | 9 +++ .../jit-cpp-mangle.c | 3 +- {jit => jitdynamic}/jit-dynlib.c | 7 +- 13 files changed, 100 insertions(+), 39 deletions(-) create mode 100644 include/jit/jit-dynamic.h create mode 100644 jitdynamic/.cvsignore create mode 100644 jitdynamic/Makefile.am rename jit/jit-mangle.c => jitdynamic/jit-cpp-mangle.c (99%) rename {jit => jitdynamic}/jit-dynlib.c (98%) diff --git a/ChangeLog b/ChangeLog index 11976bd..30210d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,15 @@ they aren't used in libjit, and front ends will normally have their own functions for this purpose. + * Makefile.am, configure.in, doc/Makefile.am, doc/libjit.texi, + include/jit/Makefile.am, include/jit/jit-dynamic.h, + include/jit/jit-util.h, jit/Makefile.am, jit/jit-dynlib.c, + jit/jit-mangle.c, jitdynamic/.cvsignore, jitdynamic/Makefile.am, + jitdynamic/jit-cpp-mangle.c, jitdynamic/jit-dynlib.c: + move the dynlib and C++ name mangling routines into a separate + "jitdynamic" library, which will handle all of the cross-language + naming and dynamic invocation logic. + 2004-05-07 Rhys Weatherley * dpas/dpas-function.c, dpas/dpas-internal.h, dpas/dpas-main.c, diff --git a/Makefile.am b/Makefile.am index 5e82876..bdd5ba5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = include tools jit jitplus dpas tutorial doc +SUBDIRS = include tools jit jitdynamic jitplus dpas tutorial doc diff --git a/configure.in b/configure.in index 637b654..3b582e9 100644 --- a/configure.in +++ b/configure.in @@ -370,6 +370,7 @@ include/jit/Makefile include/jit/jit-defs.h tools/Makefile jit/Makefile +jitdynamic/Makefile jitplus/Makefile dpas/Makefile tutorial/Makefile diff --git a/doc/Makefile.am b/doc/Makefile.am index f536ef6..475edb6 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -15,7 +15,7 @@ libjit_TEXINFOS = \ $(srcdir)/libjitext-init.texi \ $(srcdir)/libjitext-insn.texi \ $(srcdir)/libjitext-intrinsic.texi \ - $(srcdir)/libjitext-mangle.texi \ + $(srcdir)/libjitext-cpp-mangle.texi \ $(srcdir)/libjitext-memory.texi \ $(srcdir)/libjitext-meta.texi \ $(srcdir)/libjitext-reg-alloc.texi \ @@ -40,7 +40,7 @@ $(srcdir)/libjitext-block.texi: $(top_srcdir)/jit/jit-block.c $(srcdir)/libjitext-context.texi: $(top_srcdir)/jit/jit-context.c $(SHELL) $(srcdir)/extract-docs.sh $< >$@ -$(srcdir)/libjitext-dynlib.texi: $(top_srcdir)/jit/jit-dynlib.c +$(srcdir)/libjitext-dynlib.texi: $(top_srcdir)/jitdynamic/jit-dynlib.c $(SHELL) $(srcdir)/extract-docs.sh $< >$@ $(srcdir)/libjitext-elf-read.texi: $(top_srcdir)/jit/jit-elf-read.c @@ -61,7 +61,7 @@ $(srcdir)/libjitext-insn.texi: $(top_srcdir)/jit/jit-insn.c $(srcdir)/libjitext-intrinsic.texi: $(top_srcdir)/jit/jit-intrinsic.c $(SHELL) $(srcdir)/extract-docs.sh $< >$@ -$(srcdir)/libjitext-mangle.texi: $(top_srcdir)/jit/jit-mangle.c +$(srcdir)/libjitext-cpp-mangle.texi: $(top_srcdir)/jitdynamic/jit-cpp-mangle.c $(SHELL) $(srcdir)/extract-docs.sh $< >$@ $(srcdir)/libjitext-memory.texi: $(top_srcdir)/jit/jit-memory.c diff --git a/doc/libjit.texi b/doc/libjit.texi index 47d7db5..b840437 100644 --- a/doc/libjit.texi +++ b/doc/libjit.texi @@ -1003,7 +1003,7 @@ that it itself uses internally, but which may also be useful to front ends. @include libjitext-apply.texi @include libjitext-walk.texi @include libjitext-dynlib.texi -@include libjitext-mangle.texi +@include libjitext-cpp-mangle.texi @c ----------------------------------------------------------------------- diff --git a/include/jit/Makefile.am b/include/jit/Makefile.am index b6e1a80..6993c73 100644 --- a/include/jit/Makefile.am +++ b/include/jit/Makefile.am @@ -7,6 +7,7 @@ libjitinclude_HEADERS = jit.h \ jit-context.h \ jit-defs.h \ jit-dump.h \ + jit-dynamic.h \ jit-elf.h \ jit-except.h \ jit-function.h \ diff --git a/include/jit/jit-dynamic.h b/include/jit/jit-dynamic.h new file mode 100644 index 0000000..65c9bc6 --- /dev/null +++ b/include/jit/jit-dynamic.h @@ -0,0 +1,64 @@ +/* + * jit-dynamic.h - Managing dynamic libraries and cross-language invocation. + * + * Copyright (C) 2004 Southern Storm Software, Pty Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _JIT_DYNAMIC_H +#define _JIT_DYNAMIC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Dynamic library routines. + */ +typedef void *jit_dynlib_handle_t; +jit_dynlib_handle_t jit_dynlib_open(const char *name) JIT_NOTHROW; +void jit_dynlib_close(jit_dynlib_handle_t handle) JIT_NOTHROW; +void *jit_dynlib_get_symbol + (jit_dynlib_handle_t handle, const char *symbol) JIT_NOTHROW; +const char *jit_dynlib_get_suffix(void) JIT_NOTHROW; +void jit_dynlib_set_debug(int flag) JIT_NOTHROW; + +/* + * C++ name mangling definitions. + */ +#define JIT_MANGLE_PUBLIC 0x0001 +#define JIT_MANGLE_PROTECTED 0x0002 +#define JIT_MANGLE_PRIVATE 0x0003 +#define JIT_MANGLE_STATIC 0x0008 +#define JIT_MANGLE_VIRTUAL 0x0010 +#define JIT_MANGLE_CONST 0x0020 +#define JIT_MANGLE_EXPLICIT_THIS 0x0040 +#define JIT_MANGLE_IS_CTOR 0x0080 +#define JIT_MANGLE_IS_DTOR 0x0100 +#define JIT_MANGLE_BASE 0x0200 +char *jit_mangle_global_function + (const char *name, jit_type_t signature, int form) JIT_NOTHROW; +char *jit_mangle_member_function + (const char *class_name, const char *name, + jit_type_t signature, int form, int flags) JIT_NOTHROW; + +#ifdef __cplusplus +}; +#endif + +#endif /* _JIT_DYNAMIC_H */ diff --git a/include/jit/jit-util.h b/include/jit/jit-util.h index 3c8894e..7ee93b7 100644 --- a/include/jit/jit-util.h +++ b/include/jit/jit-util.h @@ -71,36 +71,6 @@ int jit_sprintf(char *str, const char *format, ...) JIT_NOTHROW; int jit_snprintf (char *str, unsigned int len, const char *format, ...) JIT_NOTHROW; -/* - * Dynamic library routines. - */ -typedef void *jit_dynlib_handle_t; -jit_dynlib_handle_t jit_dynlib_open(const char *name) JIT_NOTHROW; -void jit_dynlib_close(jit_dynlib_handle_t handle) JIT_NOTHROW; -void *jit_dynlib_get_symbol - (jit_dynlib_handle_t handle, const char *symbol) JIT_NOTHROW; -const char *jit_dynlib_get_suffix(void) JIT_NOTHROW; -void jit_dynlib_set_debug(int flag) JIT_NOTHROW; - -/* - * C++ name mangling definitions. - */ -#define JIT_MANGLE_PUBLIC 0x0001 -#define JIT_MANGLE_PROTECTED 0x0002 -#define JIT_MANGLE_PRIVATE 0x0003 -#define JIT_MANGLE_STATIC 0x0008 -#define JIT_MANGLE_VIRTUAL 0x0010 -#define JIT_MANGLE_CONST 0x0020 -#define JIT_MANGLE_EXPLICIT_THIS 0x0040 -#define JIT_MANGLE_IS_CTOR 0x0080 -#define JIT_MANGLE_IS_DTOR 0x0100 -#define JIT_MANGLE_BASE 0x0200 -char *jit_mangle_global_function - (const char *name, jit_type_t signature, int form) JIT_NOTHROW; -char *jit_mangle_member_function - (const char *class_name, const char *name, - jit_type_t signature, int form, int flags) JIT_NOTHROW; - #ifdef __cplusplus }; #endif diff --git a/jit/Makefile.am b/jit/Makefile.am index 128cbf7..a3a08dc 100644 --- a/jit/Makefile.am +++ b/jit/Makefile.am @@ -13,7 +13,6 @@ libjit_a_SOURCES = \ jit-cache.c \ jit-context.c \ jit-dump.c \ - jit-dynlib.c \ jit-elf-defs.h \ jit-elf-read.c \ jit-elf-write.c \ @@ -28,7 +27,6 @@ libjit_a_SOURCES = \ jit-interp.cpp \ jit-intrinsic.c \ jit-live.c \ - jit-mangle.c \ jit-memory.c \ jit-memory.h \ jit-meta.c \ diff --git a/jitdynamic/.cvsignore b/jitdynamic/.cvsignore new file mode 100644 index 0000000..051d1bd --- /dev/null +++ b/jitdynamic/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +.deps diff --git a/jitdynamic/Makefile.am b/jitdynamic/Makefile.am new file mode 100644 index 0000000..5ceb183 --- /dev/null +++ b/jitdynamic/Makefile.am @@ -0,0 +1,9 @@ + +lib_LIBRARIES = libjitdynamic.a + +libjitdynamic_a_SOURCES = \ + jit-dynlib.c \ + jit-cpp-mangle.c + +AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ + -I. -I$(srcdir) -I$(top_srcdir)/jit -I$(top_builddir)/jit diff --git a/jit/jit-mangle.c b/jitdynamic/jit-cpp-mangle.c similarity index 99% rename from jit/jit-mangle.c rename to jitdynamic/jit-cpp-mangle.c index 83e839e..ee028e5 100644 --- a/jit/jit-mangle.c +++ b/jitdynamic/jit-cpp-mangle.c @@ -1,5 +1,5 @@ /* - * jit-mangle.c - Perform C++ name mangling. + * jit-cpp-mangle.c - Perform C++ name mangling. * * Copyright (C) 2004 Southern Storm Software, Pty Ltd. * @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include "jit-internal.h" #include #include diff --git a/jit/jit-dynlib.c b/jitdynamic/jit-dynlib.c similarity index 98% rename from jit/jit-dynlib.c rename to jitdynamic/jit-dynlib.c index b0ea6d4..95a6f67 100644 --- a/jit/jit-dynlib.c +++ b/jitdynamic/jit-dynlib.c @@ -18,8 +18,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include #include -#include "jit-internal.h" +#include #ifdef JIT_WIN32_PLATFORM #include #ifndef JIT_WIN32_NATIVE @@ -43,6 +45,9 @@ libraries. They should be used in place of the traditional @code{dlopen}, @code{dlclose}, and @code{dlsym} functions, which are not portable across operating systems. +You must include @code{} to use these routines, +and then link with @code{-ljitdynamic -ljit}. + @deftypefun jit_dynlib_handle_t jit_dynlib_open ({const char *} name) Opens the dynamic library called @code{name}, returning a handle for it. @end deftypefun -- 2.47.3