Header And Logo

PostgreSQL
| The world's most advanced open source database.

hpux.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * dynloader.c
00004  *    dynamic loader for HP-UX using the shared library mechanism
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  * Portions Copyright (c) 1994, Regents of the University of California
00008  *
00009  *
00010  * IDENTIFICATION
00011  *    src/backend/port/dynloader/hpux.c
00012  *
00013  *  NOTES
00014  *      all functions are defined here -- it's impossible to trace the
00015  *      shl_* routines from the bundled HP-UX debugger.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #include "postgres.h"
00020 
00021 /* System includes */
00022 #include <a.out.h>
00023 #include <dl.h>
00024 
00025 #include "dynloader.h"
00026 #include "utils/dynamic_loader.h"
00027 
00028 void *
00029 pg_dlopen(char *filename)
00030 {
00031     /*
00032      * Use BIND_IMMEDIATE so that undefined symbols cause a failure return
00033      * from shl_load(), rather than an abort() later on when we attempt to
00034      * call the library!
00035      */
00036     shl_t       handle = shl_load(filename,
00037                                 BIND_IMMEDIATE | BIND_VERBOSE | DYNAMIC_PATH,
00038                                   0L);
00039 
00040     return (void *) handle;
00041 }
00042 
00043 PGFunction
00044 pg_dlsym(void *handle, char *funcname)
00045 {
00046     PGFunction  f;
00047 
00048     if (shl_findsym((shl_t *) & handle, funcname, TYPE_PROCEDURE, &f) == -1)
00049         f = (PGFunction) NULL;
00050     return f;
00051 }
00052 
00053 void
00054 pg_dlclose(void *handle)
00055 {
00056     shl_unload((shl_t) handle);
00057 }
00058 
00059 char *
00060 pg_dlerror(void)
00061 {
00062     static char errmsg[] = "shl_load failed";
00063 
00064     if (errno)
00065         return strerror(errno);
00066 
00067     return errmsg;
00068 }