[comp.unix.aux] missing routine from A/UX library?

beser@aplcomm.JHUAPL.EDU (Nick Beser) (06/19/91)

I am attempting to compile and link xxgdb using the gcc compiler, A/UX 2.01 and
Apple's X11 (new version). I noticed that one of the programs is 
calling rewinddir. I have the correct include files in the program:

#include <sys/types.h>
#include <dirent.h>

however, when linking the program, the linker states that rewinddir is
missing. The man page on rewinddir suggests that #include<dirent.h> is 
ok to use. Any Ideas what could be going on? By substituting 
#include <sys/dir.h> I get it to link, however the program bombs
as soon as it runs. The first time I run it from the window, I get
an openning of the xxgdb window, but the program exits right away.
If I try it again, it just returns without openning a window at all.

Has anyone been successfull in getting xxgdb operating on A/UX?

Thanks,
Nick Beser
beser@aplcomm.jhuapl.edu

rmtodd@servalan.uucp (Richard Todd) (06/20/91)

beser@aplcomm.JHUAPL.EDU (Nick Beser) writes:
>#include <sys/types.h>
>#include <dirent.h>

>however, when linking the program, the linker states that rewinddir is
>missing. The man page on rewinddir suggests that #include<dirent.h> is 
>ok to use. Any Ideas what could be going on? By substituting 

Yeah.  The problem is that rewinddir is actually a macro, not a function, and
it's defined in sys/dir.h (which is included by dirent.h, so the two are 
equivalent)---however, it's defined inside of a maze of Stupid Apple Ifdefs.
Actually, there are two problems--#1, that the Apple include files are a 
twisty turny maze of Stupid Preprocessor Tricks such that most programs won't
compile unless the _SYSV_SOURCE and _BSD_SOURCE preprocessor macros are
defined, and #2, while cc by default *does* turn on those preprocessor flags,
gcc does not.  You can either fix gcc to turn these on by default (it's a 
fairly simple patch to config/tm-aux.h in the GCC source), or stick 
   -D_SYSV_SOURCE -D_BSD_SOURCE
in the CFLAGS line in the Makefile.  

>#include <sys/dir.h> I get it to link, however the program bombs
>as soon as it runs. The first time I run it from the window, I get
>an openning of the xxgdb window, but the program exits right away.
>If I try it again, it just returns without openning a window at all.

Ah.  This sounds like the dreaded 4.2-signal problem (programs that expect 
4.[23]BSD signal semantics failing catastrophically on A/UX, where the default
is SysV signal semantics).  Stick a call to "set42sig()" at the beginning 
of the main function.  

>Has anyone been successfull in getting xxgdb operating on A/UX?

Well, I haven't :-(.  The problem I ran into was that when you issue a 
gdb command, the gdb subprocess goes into an infinite loop, printing its
prompt over and over.  I didn't have time to look into exactly why it does
this, so I gave up on it.  If you figure out what the problem is, let us all
know :-).  
--
Richard Todd	rmtodd@uokmax.ecn.uoknor.edu  rmtodd@chinet.chi.il.us
	rmtodd@servalan.uucp
"We're thinking about upgrading from SunOS 4.1.1 to SunOS 3.5."--Henry Spencer

beser@aplcomm.JHUAPL.EDU (Nick Beser) (06/20/91)

Thank-you to everyone who replied. The solution that took care of the
missing rewinddir function was including the -lposix library during link.
I have #include <dirent.h> put back in, and no longer get any error messages.
Of course the program also bombs right away, but it is still progress of sorts.

I will try out the suggestion to add set42sig() in the main routine. I will let
you know if that gets xxgdb on the air. I have not noticed any problems with
gdb blowing up on A/UX, the way it has been reported in this group. I am
using the version copied from  wuarchive.wustl.edu. Although Apple has
just announced a set of tools that include dbx, the price is outside of my
budget.

If anyone would like to experiment with the version of xxgdb (ie, help in 
debugging, I can make it available via anonymous ftp.

Nick Beser
beser@aplcomm.jhuapl.edu
Applied Physics Lab
Johns Hopkins University

alexis@panix.uucp (Alexis Rosen) (06/23/91)

>Ah.  This sounds like the dreaded 4.2-signal problem (programs that expect 
>4.[23]BSD signal semantics failing catastrophically on A/UX, where the default
>is SysV signal semantics).  Stick a call to "set42sig()" at the beginning 
>of the main function.  

I may not be remembering things right here, but didn't someone mention a while
ago that linking with -lbsd would do the same thing? (I use the set42sig()
myself in a patch for rn, but the link command is non-invasive, so to speak.
When I patched rn, I didn't know about -lbsd.)

---
Alexis Rosen
Owner/Sysadmin, PANIX Public Access Unix, NY
alexis@panix.com
{cmcl2,apple}!panix!alexis