[comp.sys.hp] #pragma _HP_SECONDARY_DEF

tml@tik.vtt.fi (Tor Lillqvist) (05/15/91)

How do you use the undocumented _HP_SECONDARY_DEF pragma?  (I found it
with `strings /lib/ccom`.)  I suppose this is what causes the "sdef"
entries as output by nm.

I ask because I want to use it in a replacement malloc library (for
debugging), so that calls to for example strcpy also from library
functions go to the debugging versions.  Yes, I know I could simply
provide a one-line glue function named _strcpy that calls the actual
(debugging) strcpy function, but it would seem more elegant to use the
same mechanism that HP uses for secondary entry points.
--
Tor Lillqvist,
working, but not speaking, for the Technical Research Centre of Finland

jenings@hpfcbig.SDE.HP.COM (Byron Jenings) (05/18/91)

 Tor Lillqvist <tml@tik.vtt.fi> writes:
|How do you use the undocumented _HP_SECONDARY_DEF pragma?  (I found it
|with `strings /lib/ccom`.)  I suppose this is what causes the "sdef"
|entries as output by nm.

This is an example from when I wanted to wrap an extra layer around
brk and sbrk.  You'll need to look at the nm output in libc to see
when your replacement functions should have a name starting with one
or two underscores.

#ifdef _HPUX_SOURCE
#       pragma _HP_SECONDARY_DEF _sbrk sbrk
#       define sbrk _sbrk
#       pragma _HP_SECONDARY_DEF __brk brk
#       define brk __brk
#endif

char *sbrk(incr)
{
    ...
}

int brk(endds)
{
    ...
}