Added epicsLoadLibrary() and some implementations.

This commit is contained in:
Andrew Johnson
2009-02-27 23:26:20 +00:00
parent 19409d9c74
commit 9c3fa668f3
6 changed files with 137 additions and 9 deletions
+4 -3
View File
@@ -1,10 +1,9 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
#ifndef epicsFindSymbolh
@@ -16,6 +15,8 @@ extern "C" {
#include "shareLib.h"
epicsShareFunc void * epicsLoadLibrary(const char *name);
epicsShareFunc const char *epicsLoadError(void);
epicsShareFunc void * epicsShareAPI epicsFindSymbol(const char *name);
#ifdef __cplusplus
+27
View File
@@ -0,0 +1,27 @@
/*************************************************************************\
* Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* osi/os/default/epicsFindSymbol.c */
#include <dlfcn.h>
#define epicsExportSharedSymbols
#include "epicsFindSymbol.h"
epicsShareFunc void * epicsLoadLibrary(const char *name)
{
return dlopen(name, RTLD_LAZY | RTLD_GLOBAL);
}
epicsShareFunc const char *epicsLoadError(void)
{
return dlerror();
}
epicsShareFunc void * epicsShareAPI epicsFindSymbol(const char *name)
{
return dlsym(0, name);
}
+27
View File
@@ -0,0 +1,27 @@
/*************************************************************************\
* Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* osi/os/default/epicsFindSymbol.c */
#include <dlfcn.h>
#define epicsExportSharedSymbols
#include "epicsFindSymbol.h"
epicsShareFunc void * epicsLoadLibrary(const char *name)
{
return dlopen(name, RTLD_LAZY | RTLD_GLOBAL);
}
epicsShareFunc const char *epicsLoadError(void)
{
return dlerror();
}
epicsShareFunc void * epicsShareAPI epicsFindSymbol(const char *name)
{
return dlsym(0, name);
}
+8 -3
View File
@@ -1,10 +1,9 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* osi/os/default/epicsFindSymbol.c */
@@ -12,5 +11,11 @@
#define epicsExportSharedSymbols
#include "epicsFindSymbol.h"
epicsShareFunc void * epicsLoadLibrary(const char *name)
{ return 0; }
epicsShareFunc const char *epicsLoadError(void)
{ return "epicsLoadLibrary not implemented"; }
epicsShareFunc void * epicsShareAPI epicsFindSymbol(const char *name)
{ return 0;}
+27
View File
@@ -0,0 +1,27 @@
/*************************************************************************\
* Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* osi/os/default/epicsFindSymbol.c */
#include <dlfcn.h>
#define epicsExportSharedSymbols
#include "epicsFindSymbol.h"
epicsShareFunc void * epicsLoadLibrary(const char *name)
{
return dlopen(name, RTLD_LAZY | RTLD_GLOBAL);
}
epicsShareFunc const char *epicsLoadError(void)
{
return dlerror();
}
epicsShareFunc void * epicsShareAPI epicsFindSymbol(const char *name)
{
return dlsym(0, name);
}
+44 -3
View File
@@ -1,10 +1,9 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* Copyright (c) 2009 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* osi/os/vxWorks/osiFindSymbol */
@@ -15,9 +14,51 @@
#include <string.h>
#include <symLib.h>
#include <sysSymTbl.h>
#include <fcntl.h>
#include <unistd.h>
#include <loadLib.h>
#include "dbmf.h"
#include "epicsString.h"
#include "epicsFindSymbol.h"
static char *errmsg = NULL;
static char *oldmsg = NULL;
epicsShareFunc void * epicsLoadLibrary(const char *name)
{
MODULE_ID m = 0;
int fd;
if (oldmsg) {
free(oldmsg);
oldmsg = NULL;
}
if (errmsg) {
free(errmsg);
errmsg = NULL;
}
fd = open(name, O_RDONLY, 0);
if (fd != ERROR) {
m = loadModule(fd, GLOBAL_SYMBOLS);
close(fd);
}
if (!m) {
errmsg = epicsStrDup(strerror(errno));
}
return m;
}
epicsShareFunc const char *epicsLoadError(void)
{
if (oldmsg) free(oldmsg);
oldmsg = errmsg;
errmsg = NULL;
return oldmsg;
}
void *epicsFindSymbol(const char *name)
{
STATUS status;