bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'fseterr'


From: Bruno Haible
Subject: Re: new module 'fseterr'
Date: Sat, 10 Mar 2007 17:07:53 +0100
User-agent: KMail/1.5.4

Simon Josefsson wrote:
> Consider making it possible to not use this workaround, but
> rather fail with a compilation error.  I wouldn't want code that
> invoke abort in a library, for example.

Makes sense. The Solaris 10 include files contain comments like this:

 * Even though the contents of the stdio FILE structure have always been
 * private to the stdio implementation, over the years some programs have
 * needed to get information about a stdio stream that was not accessible
 * through a supported interface. These programs have resorted to accessing
 * fields of the FILE structure directly, rendering them possibly non-portable
 * to new implementations of stdio, or more likely, preventing enhancements
 * to stdio because those programs will break.
 *
 * In the 64-bit world, the FILE structure is opaque. ...

so this will require a bit if porting for Solaris/x86_64. I'm applying this:

2007-03-10  Bruno Haible  <address@hidden>

        * lib/fseterr.c (fseterr): Port to Solaris/SPARC64. Deactivate the
        fallback; use #error instead.
        Suggested by Simon Josefsson.

*** lib/fseterr.c       9 Mar 2007 02:41:51 -0000       1.2
--- lib/fseterr.c       10 Mar 2007 16:05:37 -0000
***************
*** 33,42 ****
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    fp->_flags |= __SERR;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
mingw */
    fp->_flag |= _IOERR;
! #else                               /* unknown  */
    /* Portable fallback, based on an idea by Rich Felker.
!      Wow! 6 system calls for something that is just a bit operation!  */
    int saved_errno;
    int fd;
    int fd2;
--- 33,49 ----
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    fp->_flags |= __SERR;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
mingw */
+ # if defined __sun && defined __sparc && defined _LP64 /* Solaris/SPARC 
64-bit */
+   ((unsigned int *) fp) [9] |= 0x20;
+ # else
    fp->_flag |= _IOERR;
! # endif
! #elif 0                             /* unknown  */
    /* Portable fallback, based on an idea by Rich Felker.
!      Wow! 6 system calls for something that is just a bit operation!
!      Not activated on any system, because there is no way to repair FP when
!      the sequence of system calls fails, and library code should not call
!      abort().  */
    int saved_errno;
    int fd;
    int fd2;
***************
*** 56,60 ****
--- 63,69 ----
        close (fd2);
      }
    errno = saved_errno;
+ #else
+  #error "Please port gnulib fseterr.c to your platform! Look at the 
definitions of ferror and clearerr on your system, then report this to 
bug-gnulib."
  #endif
  }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]