From 1783963cab9e938b04b936f61d287384d7f11f2a Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Sat, 20 Dec 1997 04:48:11 +0000 Subject: Move more to dynloader subdir --- src/backend/port/dgux/Makefile | 34 ------------ src/backend/port/dgux/dynloader.c | 101 ------------------------------------ src/backend/port/dgux/port-protos.h | 30 ----------- src/backend/port/dgux/port.c | 13 ----- src/backend/port/dynloader/dgux.c | 101 ++++++++++++++++++++++++++++++++++++ src/backend/port/dynloader/dgux.h | 30 +++++++++++ src/backend/port/dynloader/hpux.c | 59 +++++++++++++++++++++ src/backend/port/hpux/dynloader.c | 59 --------------------- 8 files changed, 190 insertions(+), 237 deletions(-) delete mode 100644 src/backend/port/dgux/Makefile delete mode 100644 src/backend/port/dgux/dynloader.c delete mode 100644 src/backend/port/dgux/port-protos.h delete mode 100644 src/backend/port/dgux/port.c create mode 100644 src/backend/port/dynloader/dgux.c create mode 100644 src/backend/port/dynloader/dgux.h create mode 100644 src/backend/port/dynloader/hpux.c delete mode 100644 src/backend/port/hpux/dynloader.c (limited to 'src') diff --git a/src/backend/port/dgux/Makefile b/src/backend/port/dgux/Makefile deleted file mode 100644 index 736a2ba6c79..00000000000 --- a/src/backend/port/dgux/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#------------------------------------------------------------------------- -# -# Makefile-- -# Makefile for port/dgux -# -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/Makefile,v 1.3 1997/12/20 00:25:27 scrappy Exp $ -# -#------------------------------------------------------------------------- - -SRCDIR = ../../.. -include ../../../Makefile.global - -INCLUDE_OPT = -I../.. - -CFLAGS+=$(INCLUDE_OPT) - -OBJS = port.o - -all: SUBSYS.o - -SUBSYS.o: $(OBJS) - $(LD) -r -o SUBSYS.o $(OBJS) - -depend dep: - $(CC) -MM $(INCLUDE_OPT) *.c >depend - -clean: - rm -f SUBSYS.o $(OBJS) - -ifeq (depend,$(wildcard depend)) -include depend -endif - diff --git a/src/backend/port/dgux/dynloader.c b/src/backend/port/dgux/dynloader.c deleted file mode 100644 index 47834c74863..00000000000 --- a/src/backend/port/dgux/dynloader.c +++ /dev/null @@ -1,101 +0,0 @@ -/*------------------------------------------------------------------------- - * - * dynloader.c-- - * Dynamic Loader for Postgres for DG/UX, generated from those for - * Linux. - * - * Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/dynloader.c,v 1.3 1997/09/08 02:26:05 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#include -#include -#include "postgres.h" -#include "port-protos.h" -#include "utils/elog.h" -#include "fmgr.h" - -extern char pg_pathname[]; - -void * -pg_dlopen(char *filename) -{ - static int dl_initialized = 0; - - /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) - */ - if (!dl_initialized) - { - if (dld_init(dld_find_executable(pg_pathname))) - { - return NULL; - } - - /* - * if there are undefined symbols, we want dl to search from the - * following libraries also. - */ - dl_initialized = 1; - } - - /* - * link the file, then check for undefined symbols! - */ - if (dld_link(filename)) - { - return NULL; - } - - /* - * If undefined symbols: try to link with the C and math libraries! - * This could be smarter, if the dynamic linker was able to handle - * shared libs! - */ - if (dld_undefined_sym_count > 0) - { - if (dld_link("/usr/lib/libc.a")) - { - elog(NOTICE, "dld: Cannot link C library!"); - return NULL; - } - if (dld_undefined_sym_count > 0) - { - if (dld_link("/usr/lib/libm.a")) - { - elog(NOTICE, "dld: Cannot link math library!"); - return NULL; - } - if (dld_undefined_sym_count > 0) - { - int count = dld_undefined_sym_count; - char **list = dld_list_undefined_sym(); - - /* list the undefined symbols, if any */ - elog(NOTICE, "dld: Undefined:"); - do - { - elog(NOTICE, " %s", *list); - list++; - count--; - } while (count > 0); - - dld_unlink_by_file(filename, 1); - return NULL; - } - } - } - - return (void *) strdup(filename); -} - -char * -pg_dlerror() -{ - return dld_strerror(dld_errno); -} diff --git a/src/backend/port/dgux/port-protos.h b/src/backend/port/dgux/port-protos.h deleted file mode 100644 index 9ca45ba234a..00000000000 --- a/src/backend/port/dgux/port-protos.h +++ /dev/null @@ -1,30 +0,0 @@ -/*------------------------------------------------------------------------- - * - * port-protos.h-- - * port-specific prototypes for SunOS 4 - * - * - * Copyright (c) 1994, Regents of the University of California - * - * $Id: port-protos.h,v 1.2 1997/09/07 04:45:39 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#ifndef PORT_PROTOS_H -#define PORT_PROTOS_H - -#include "fmgr.h" /* for func_ptr */ -#include "utils/dynamic_loader.h" -#include "dlfcn.h" - -/* dynloader.c */ - -/* #define pg_dlopen(f) dlopen(f, 1) */ -#define pg_dlopen(f) dlopen(f, 2) -#define pg_dlsym dlsym -#define pg_dlclose dlclose -#define pg_dlerror dlerror - -/* port.c */ - -#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dgux/port.c b/src/backend/port/dgux/port.c deleted file mode 100644 index 1cc325c0db0..00000000000 --- a/src/backend/port/dgux/port.c +++ /dev/null @@ -1,13 +0,0 @@ -/*------------------------------------------------------------------------- - * - * port.c-- - * Linux-specific routines - * - * Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/port.c,v 1.2 1997/09/07 04:45:42 momjian Exp $ - * - *------------------------------------------------------------------------- - */ diff --git a/src/backend/port/dynloader/dgux.c b/src/backend/port/dynloader/dgux.c new file mode 100644 index 00000000000..adc81b62151 --- /dev/null +++ b/src/backend/port/dynloader/dgux.c @@ -0,0 +1,101 @@ +/*------------------------------------------------------------------------- + * + * dynloader.c-- + * Dynamic Loader for Postgres for DG/UX, generated from those for + * Linux. + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/dgux.c,v 1.1 1997/12/20 04:48:02 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include +#include +#include "postgres.h" +#include "port-protos.h" +#include "utils/elog.h" +#include "fmgr.h" + +extern char pg_pathname[]; + +void * +pg_dlopen(char *filename) +{ + static int dl_initialized = 0; + + /* + * initializes the dynamic loader with the executable's pathname. + * (only needs to do this the first time pg_dlopen is called.) + */ + if (!dl_initialized) + { + if (dld_init(dld_find_executable(pg_pathname))) + { + return NULL; + } + + /* + * if there are undefined symbols, we want dl to search from the + * following libraries also. + */ + dl_initialized = 1; + } + + /* + * link the file, then check for undefined symbols! + */ + if (dld_link(filename)) + { + return NULL; + } + + /* + * If undefined symbols: try to link with the C and math libraries! + * This could be smarter, if the dynamic linker was able to handle + * shared libs! + */ + if (dld_undefined_sym_count > 0) + { + if (dld_link("/usr/lib/libc.a")) + { + elog(NOTICE, "dld: Cannot link C library!"); + return NULL; + } + if (dld_undefined_sym_count > 0) + { + if (dld_link("/usr/lib/libm.a")) + { + elog(NOTICE, "dld: Cannot link math library!"); + return NULL; + } + if (dld_undefined_sym_count > 0) + { + int count = dld_undefined_sym_count; + char **list = dld_list_undefined_sym(); + + /* list the undefined symbols, if any */ + elog(NOTICE, "dld: Undefined:"); + do + { + elog(NOTICE, " %s", *list); + list++; + count--; + } while (count > 0); + + dld_unlink_by_file(filename, 1); + return NULL; + } + } + } + + return (void *) strdup(filename); +} + +char * +pg_dlerror() +{ + return dld_strerror(dld_errno); +} diff --git a/src/backend/port/dynloader/dgux.h b/src/backend/port/dynloader/dgux.h new file mode 100644 index 00000000000..89705cac27f --- /dev/null +++ b/src/backend/port/dynloader/dgux.h @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * + * port-protos.h-- + * port-specific prototypes for SunOS 4 + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: dgux.h,v 1.1 1997/12/20 04:48:04 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef PORT_PROTOS_H +#define PORT_PROTOS_H + +#include "fmgr.h" /* for func_ptr */ +#include "utils/dynamic_loader.h" +#include "dlfcn.h" + +/* dynloader.c */ + +/* #define pg_dlopen(f) dlopen(f, 1) */ +#define pg_dlopen(f) dlopen(f, 2) +#define pg_dlsym dlsym +#define pg_dlclose dlclose +#define pg_dlerror dlerror + +/* port.c */ + +#endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/dynloader/hpux.c b/src/backend/port/dynloader/hpux.c new file mode 100644 index 00000000000..68cc085ca7e --- /dev/null +++ b/src/backend/port/dynloader/hpux.c @@ -0,0 +1,59 @@ +/*------------------------------------------------------------------------- + * + * dynloader.c-- + * dynamic loader for HP-UX using the shared library mechanism + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/hpux.c,v 1.1 1997/12/20 04:48:06 scrappy Exp $ + * + * NOTES + * all functions are defined here -- it's impossible to trace the + * shl_* routines from the bundled HP-UX debugger. + * + *------------------------------------------------------------------------- + */ +/* System includes */ +#include +#include +#include +#include "c.h" +#include "fmgr.h" +#include "utils/dynamic_loader.h" +#include "port-protos.h" + +void * +pg_dlopen(char *filename) +{ + shl_t handle = shl_load(filename, BIND_DEFERRED, 0); + + return ((void *) handle); +} + +func_ptr +pg_dlsym(void *handle, char *funcname) +{ + func_ptr f; + + if (shl_findsym((shl_t *) & handle, funcname, TYPE_PROCEDURE, &f) == -1) + { + f = (func_ptr) NULL; + } + return (f); +} + +void +pg_dlclose(void *handle) +{ + shl_unload((shl_t) handle); +} + +char * +pg_dlerror() +{ + static char errmsg[] = "shl_load failed"; + + return errmsg; +} diff --git a/src/backend/port/hpux/dynloader.c b/src/backend/port/hpux/dynloader.c deleted file mode 100644 index 972654adb50..00000000000 --- a/src/backend/port/hpux/dynloader.c +++ /dev/null @@ -1,59 +0,0 @@ -/*------------------------------------------------------------------------- - * - * dynloader.c-- - * dynamic loader for HP-UX using the shared library mechanism - * - * Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/dynloader.c,v 1.3 1997/09/08 02:26:15 momjian Exp $ - * - * NOTES - * all functions are defined here -- it's impossible to trace the - * shl_* routines from the bundled HP-UX debugger. - * - *------------------------------------------------------------------------- - */ -/* System includes */ -#include -#include -#include -#include "c.h" -#include "fmgr.h" -#include "utils/dynamic_loader.h" -#include "port-protos.h" - -void * -pg_dlopen(char *filename) -{ - shl_t handle = shl_load(filename, BIND_DEFERRED, 0); - - return ((void *) handle); -} - -func_ptr -pg_dlsym(void *handle, char *funcname) -{ - func_ptr f; - - if (shl_findsym((shl_t *) & handle, funcname, TYPE_PROCEDURE, &f) == -1) - { - f = (func_ptr) NULL; - } - return (f); -} - -void -pg_dlclose(void *handle) -{ - shl_unload((shl_t) handle); -} - -char * -pg_dlerror() -{ - static char errmsg[] = "shl_load failed"; - - return errmsg; -} -- cgit v1.2.3