|
| 1 | +/*------------------------------------------------------------------------- |
| 2 | + * |
| 3 | + * dynloader.c-- |
| 4 | + * Dynamic Loader for Postgres for DG/UX, generated from those for |
| 5 | + * Linux. |
| 6 | + * |
| 7 | + * Copyright (c) 1994, Regents of the University of California |
| 8 | + * |
| 9 | + * |
| 10 | + * IDENTIFICATION |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/dynloader.c,v 1.1 1996/07/25 20:43:58 scrappy Exp $ |
| 12 | + * |
| 13 | + *------------------------------------------------------------------------- |
| 14 | + */ |
| 15 | +#include<stdio.h> |
| 16 | +#include<dld.h> |
| 17 | +#include"postgres.h" |
| 18 | +#include"port-protos.h" |
| 19 | +#include"utils/elog.h" |
| 20 | +#include"fmgr.h" |
| 21 | + |
| 22 | +externcharpg_pathname[]; |
| 23 | + |
| 24 | +void* |
| 25 | +pg_dlopen(char*filename) |
| 26 | +{ |
| 27 | +staticintdl_initialized=0; |
| 28 | + |
| 29 | +/* |
| 30 | + * initializes the dynamic loader with the executable's pathname. |
| 31 | + * (only needs to do this the first time pg_dlopen is called.) |
| 32 | + */ |
| 33 | +if (!dl_initialized) { |
| 34 | +if (dld_init (dld_find_executable (pg_pathname))) { |
| 35 | +returnNULL; |
| 36 | +} |
| 37 | +/* |
| 38 | + * if there are undefined symbols, we want dl to search from the |
| 39 | + * following libraries also. |
| 40 | + */ |
| 41 | +dl_initialized=1; |
| 42 | + } |
| 43 | + |
| 44 | +/* |
| 45 | + * link the file, then check for undefined symbols! |
| 46 | + */ |
| 47 | +if (dld_link(filename)) { |
| 48 | +returnNULL; |
| 49 | + } |
| 50 | + |
| 51 | +/* |
| 52 | + * If undefined symbols: try to link with the C and math libraries! |
| 53 | + * This could be smarter, if the dynamic linker was able to handle |
| 54 | + * shared libs! |
| 55 | + */ |
| 56 | +if(dld_undefined_sym_count>0) { |
| 57 | +if (dld_link("/usr/lib/libc.a")) { |
| 58 | +elog(NOTICE,"dld: Cannot link C library!"); |
| 59 | +returnNULL; |
| 60 | +} |
| 61 | +if(dld_undefined_sym_count>0) { |
| 62 | +if (dld_link("/usr/lib/libm.a")) { |
| 63 | +elog(NOTICE,"dld: Cannot link math library!"); |
| 64 | +returnNULL; |
| 65 | + } |
| 66 | +if(dld_undefined_sym_count>0) { |
| 67 | +intcount=dld_undefined_sym_count; |
| 68 | +char**list=dld_list_undefined_sym(); |
| 69 | + |
| 70 | +/* list the undefined symbols, if any */ |
| 71 | +elog(NOTICE,"dld: Undefined:"); |
| 72 | +do { |
| 73 | +elog(NOTICE," %s",*list); |
| 74 | +list++; |
| 75 | +count--; |
| 76 | +}while(count>0); |
| 77 | + |
| 78 | +dld_unlink_by_file(filename,1); |
| 79 | +returnNULL; |
| 80 | + } |
| 81 | +} |
| 82 | + } |
| 83 | + |
| 84 | +return (void*)strdup(filename); |
| 85 | +} |
| 86 | + |
| 87 | +char* |
| 88 | +pg_dlerror() |
| 89 | +{ |
| 90 | +returndld_strerror(dld_errno); |
| 91 | +} |