DLL Programmer's Guide for TNS/E Systems
Dynamic Use of DLLs
DLL Programmer’s Guide for TNS/E Systems—527252-006
3-9
Thread Considerations
Calling dlresultcode() does not reset the error code. dlerror() and
dlresultcode() can be called in either order; neither affects the value returned by
the other.
dlresultcode() is an HP NonStop operating system addition to the conventional
set of dynamic loading functions.
Thread Considerations
The loader is not aware of threads that may be used in a multi-threaded application.
Therefore, if you create such an application, you must ensure that no thread switch
occurs between a dynamic library call and the invocation of dlerror or dlresultcode that
retrieves information about that call. Because the NonStop operating system supports
only user-level threads, this means that during this interval, you must avoid invoking
functions that can cause explicit thread switching.
Using Dynamically Loaded DLLs to Extend an
Application
You can take advantage of dynamically loaded DLLs to build your application to
incorporate anticipated but as yet undefined functions. There are several ways to
accomplish this. For example:
If the application is interactive or has an interactive control mechanism, the
operator can supply the name of a DLL to load.
In a transaction processing system, individual transaction requests could name a
DLL to process the transaction, or include a transaction type code that maps into a
table of DLL file names; the program might update that table dynamically at
operator command.
In either event, the program can load the required DLL if it is not already present. Or it
could unload an existing DLL (of that name or for that transaction type) and load
another, thus dynamically updating part of the application code.
Of course, loading the DLL is only the first step; the application must also find and
access the necessary symbols. Again, multiple approaches are possible:
In the simplest situation, all the DLLs that support this application export a small
set of functions (and perhaps data) with canonical symbol names. The application
uses dlsym() to find the addresses of these symbols. Each canonical function
has the same prototype, so it can receive and process the same set of parameters.
The DLLs differ in what their functions do. A classical example from engineering or
scientific applications is a numerical integration program: a DLL supplies a function
(subroutine) to compute the mathematical function to be integrated. The program
calls that function repeatedly to compute an approximate definite integral over
some range.










