Message ID | 20121209195737.GA20382@hiauly1.hia.nrc.ca |
---|---|
State | New |
Headers | show |
On Sun, Dec 9, 2012 at 11:57 AM, John David Anglin <dave@hiauly1.hia.nrc.ca> wrote: > > #ifndef HAVE_GETEXECNAME > +#if defined(__hpux) && (defined(__ia64) || defined(_LP64)) > +#include <dlfcn.h> > +#define getexecname getexecname_hpux > + > +static char * > +getexecname_hpux (void) > +{ > + struct load_module_desc desc; > + > + dlget(-2, &desc, sizeof(desc)); > + return dlgetname(&desc, sizeof(desc), NULL, 0, 0); > +} > + This is the kind of thing that is normally done via configure tests rather than #ifdef tests. And once the configure tests are written, I would prefer to see this as another pass in fileline.c, rather than this rather complex reuse of getexecname. Ian
Index: fileline.c =================================================================== --- fileline.c (revision 194325) +++ fileline.c (working copy) @@ -42,8 +42,23 @@ #include "internal.h" #ifndef HAVE_GETEXECNAME +#if defined(__hpux) && (defined(__ia64) || defined(_LP64)) +#include <dlfcn.h> +#define getexecname getexecname_hpux + +static char * +getexecname_hpux (void) +{ + struct load_module_desc desc; + + dlget(-2, &desc, sizeof(desc)); + return dlgetname(&desc, sizeof(desc), NULL, 0, 0); +} + +#else #define getexecname() NULL #endif +#endif /* Initialize the fileline information from the executable. Returns 1 on success, 0 on failure. */