Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] want to #undef HAVE_SBRK and HAVE_POLL on Interix
@ 2002-10-20 23:11 Joel Brobecker
  2002-10-21 12:08 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2002-10-20 23:11 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1744 bytes --]

Hello,

This is something I did sometime ago, and wanted to discuss with you
before proposing a change more formally. 

Here goes: On Interix, the sbrk() function exists, but is not
sufficiently implemented to be used in GDB. Because it exists,
AC_CHECK_FUNCS (sbrk) finds it, and therefore configure adds the
associated "#define HAVE_SBRK" in config.h.

If you look at xm-interix.h in the files I recently submitted, you will
see that there is a "#undef HAVE_SBRK" to counter the result of
AC_CHECK_FUNCS. I would like to get rid of this #undef. To do that, the
only way I found is to either:
  1. let configure test for sbrk() on Interix, but then override the
     test result afterward by undefining (in the configure sense)
     HAVE_SBRK. Something like:

     AC_CHECK_FUNCS (....)     # this line is unchanged
     case "${host}" in
       *-*-interix* )
         undefine (HAVE_BRK)
         ;;
       * )
         ;;
     esac
     
  2. do not do the AC_CHECK_FUNCS test for sbrk() on Interix. This way,
     HAVE_SBRK will never be defined, and we don't need the undef in
     xm-interix.h anymore.

I did not find a way in the documentation to undefine a variable that
was previously defined. So I could not implement 1. I also thought that
a user might find it confusing to see the output of configure show

     Checking for sbrk... yes

and then no see HAVE_SBRK defined in config.h...
     
So I implemented 2. A patch is attached (it is only the configure.in
part, the rest will follow if the approach to the problem is approved).
I also did the same for the poll() function, which should not be used
on Interix as well.

Is it the best approach to the problem? Would such a patch be accepted
for inclusion?

Thanks,
-- 
Joel

[-- Attachment #2: configure.in.diff --]
[-- Type: text/plain, Size: 1607 bytes --]

Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.91
diff -c -3 -p -r1.91 configure.in
*** configure.in	20 Sep 2002 00:24:01 -0000	1.91
--- configure.in	21 Oct 2002 05:52:28 -0000
*************** AC_HEADER_STAT
*** 134,141 ****
  AC_C_CONST
  AC_C_INLINE
  
! AC_CHECK_FUNCS(bcopy btowc bzero canonicalize_file_name isascii poll \
! 	realpath sbrk setpgid setpgrp sigaction sigprocmask sigsetmask )
  AC_FUNC_ALLOCA
  AC_FUNC_VFORK
  dnl AC_FUNC_SETPGRP does not work when cross compiling
--- 134,161 ----
  AC_C_CONST
  AC_C_INLINE
  
! AC_CHECK_FUNCS(bcopy btowc bzero canonicalize_file_name isascii \
! 	realpath setpgid setpgrp sigaction sigprocmask sigsetmask )
! 
! # Certain systems implement broken or incomplete versions of some
! # functions, which cause AC_CHECK_FUNCS to define the associated HAVE_*
! # macro.  But we actually do not want to this macro to be defined on
! # these systems where we know it is broken. So we simply skip the test
! # for these functions and pretend that it does not exist.
! case "${host}" in
!   *-*-interix*) 
!     # On Interix, there is only a minimal sbrk(). This function does not
!     # provide the functionality that is needed in the case of GDB (there
!     # is no relationship at all with environ). 
! 
!     # The poll() function is only partially implemented so far...
!     ;;
!   *)
!     AC_CHECK_FUNCS(sbrk)
!     AC_CHECK_FUNCS(poll)
!     ;;
! esac
! 
  AC_FUNC_ALLOCA
  AC_FUNC_VFORK
  dnl AC_FUNC_SETPGRP does not work when cross compiling

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] want to #undef HAVE_SBRK and HAVE_POLL on Interix
  2002-10-20 23:11 [RFC] want to #undef HAVE_SBRK and HAVE_POLL on Interix Joel Brobecker
@ 2002-10-21 12:08 ` Andrew Cagney
  2002-10-21 21:48   ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2002-10-21 12:08 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> Hello,
> 
> This is something I did sometime ago, and wanted to discuss with you
> before proposing a change more formally. 
> 
> Here goes: On Interix, the sbrk() function exists, but is not
> sufficiently implemented to be used in GDB. Because it exists,
> AC_CHECK_FUNCS (sbrk) finds it, and therefore configure adds the
> associated "#define HAVE_SBRK" in config.h.
> 
> If you look at xm-interix.h in the files I recently submitted, you will
> see that there is a "#undef HAVE_SBRK" to counter the result of
> AC_CHECK_FUNCS. I would like to get rid of this #undef. To do that, the
> only way I found is to either:

I've been wondering if the interix patch should even be allowed to add 
xm-interix.h.  New hosts shouldn't need it, instead using autoconf for 
everything.

>   1. let configure test for sbrk() on Interix, but then override the
>      test result afterward by undefining (in the configure sense)
>      HAVE_SBRK. Something like:
> 
>      AC_CHECK_FUNCS (....)     # this line is unchanged
>      case "${host}" in
>        *-*-interix* )
>          undefine (HAVE_BRK)
>          ;;
>        * )
>          ;;
>      esac
>      
>   2. do not do the AC_CHECK_FUNCS test for sbrk() on Interix. This way,
>      HAVE_SBRK will never be defined, and we don't need the undef in
>      xm-interix.h anymore.
> 
> I did not find a way in the documentation to undefine a variable that
> was previously defined. So I could not implement 1. I also thought that
> a user might find it confusing to see the output of configure show

aclocal.m4 is always a good source of ideas.

>      Checking for sbrk... yes
> 
> and then no see HAVE_SBRK defined in config.h...
>      
> So I implemented 2. A patch is attached (it is only the configure.in
> part, the rest will follow if the approach to the problem is approved).
> I also did the same for the poll() function, which should not be used
> on Interix as well.
> 
> Is it the best approach to the problem? Would such a patch be accepted
> for inclusion?

As you note, it's definitly better than 1.  As for best I'm not an 
autoconf person so ...

I'd just suggest tweaking it a little so that it:


> ! AC_CHECK_FUNCS(bcopy btowc bzero canonicalize_file_name isascii \
> ! 	realpath setpgid setpgrp sigaction sigprocmask sigsetmask )
> ! 
> ! # Certain systems implement broken or incomplete versions of some
> ! # functions, which cause AC_CHECK_FUNCS to define the associated HAVE_*
> ! # macro.  But we actually do not want to this macro to be defined on
> ! # these systems where we know it is broken. So we simply skip the test
> ! # for these functions and pretend that it does not exist.
> ! case "${host}" in
> !   *-*-interix*) 
> !     # On Interix, there is only a minimal sbrk(). This function does not
> !     # provide the functionality that is needed in the case of GDB (there
> !     # is no relationship at all with environ). 
> ! 
> !     # The poll() function is only partially implemented so far...

Here, report that it wasn't even testing for sbrk() or poll().  That 
way, there would be no confusion over a missing test.  Use AC_MSG_WARN() 
I think.

> !     ;;
> !   *)
> !     AC_CHECK_FUNCS(sbrk)
> !     AC_CHECK_FUNCS(poll)
> !     ;;
> ! esac
> ! 
>   AC_FUNC_ALLOCA
>   AC_FUNC_VFORK
>   dnl AC_FUNC_SETPGRP does not work when cross compiling

Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] want to #undef HAVE_SBRK and HAVE_POLL on Interix
  2002-10-21 12:08 ` Andrew Cagney
@ 2002-10-21 21:48   ` Joel Brobecker
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2002-10-21 21:48 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

> I'd just suggest tweaking it a little so that it:
[snip]
> 
> Here, report that it wasn't even testing for sbrk() or poll().  That 
> way, there would be no confusion over a missing test.  Use AC_MSG_WARN() 
> I think.

Makes sense. If nobody objects to this approach in the next few days,
I will submit for approval a patch with the warnings (I will also go
fishing in aclocal, just in case I find something better).

Thanks,
-- 
Joel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-22  4:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-20 23:11 [RFC] want to #undef HAVE_SBRK and HAVE_POLL on Interix Joel Brobecker
2002-10-21 12:08 ` Andrew Cagney
2002-10-21 21:48   ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox