Node and Host Name Sizes on HP-UX: Using the Expanded Capabilities of HP-UX

32
Fortunately, for node names, it is possible to switch to using the host name with a large buffer and
avoid using the versioned utsname structure and uname() function, thereby avoiding use of the FLV
mechanisms. For a description of this approach see Building for Execution on Multiple Releases.”
Providing Multiple Interface Versions in a Library
FLV enables a library provider to export multiple versions of the same interface. This is done by
including in the library two object files. One exports the original version of the interface, the second
exports an enhanced version, with a version identifier in the binary name. (In theory, any number of
different versions can be supplied in this way.)
It is not possible to provide multiple versions of an interface in a single program source file. This is
because the compilation environment cannot handle multiple versions of a definition.
The developer must be careful to not export any other symbols from these compiled objects. Multiple
objects exporting the same binary names can cause ambiguity when the linker must resolve
references.
The following sections describe two general approaches to supplying multiple versions of a function
interface.
Parallel Implementation
In a parallel implementation, the modules that provide the original and enhanced versions of an
interface are completely separate and do not interact. They might use common supporting functions.
In some cases, to the modules can have a common source, but that source is used to generate multiple
objects.
As an example, consider again the std_hdr structure and the fetch_hdr() function from a
previous example in this appendix. The following program source is called fetch_hdr.c:
#include “std_hdr.h”
int fetch_hdr(struct std_hdr *hdrp) {
hdrp->hdr_identifier = get_header_id();
hdrp->hdr_data_size = get_data_size();
hdrp->hdr_creationtime = get_creation_time();
hdrp->hdr_lastmodifytime = get_modify_time();
#ifdef NEWVERS
hdrp->hdr_lastaccesstime = get_access_time();
#endif
return(0);
}
where the std_hdr.h header has:
#ifdef NEWVERS
#define ATTR __attribute((version_id(“rev2”)))
#else
#define ATTR /* no version identifier if not the new version */
#endif
struct ATTR std_hdr {
int hdr_identifier;
size_t hdr_data_size;
time_t hdr_creationtime;