Hi,

The system that Elbert Pol is talking about is derived from emx+gcc (the
old but well-known POSIX implementation for DOS and OS/2 [the DOS part was
much more reliable than DJGPP]).

I'm committing first a port for emx+gcc. Untested.

Jim, at the end you find a patch to m4/fpending.m4, part of the same family
of functions. Is that OK to commit? I derived that information from the fflush
implementation which goes roughly like this:

      n = stream->_ptr - stream->_buffer;
      if (n > 0 && _stream_write (stream->_handle, stream->_buffer, n) <= 0)
        {
          stream->_flags |= _IOERR;
          result = EOF;
        }

I put the EMX case quite far down in the list, to minimize the risk of
disturbing an already supported platform.


2008-04-08  Bruno Haible  <[EMAIL PROTECTED]>

        Add tentative support for emx+gcc.
        * lib/fbufmode.c (fbufmode) [__EMX__]: Add conditional code.
        * lib/fpurge.c (fpurge): Likewise.
        * lib/freadable.c (freadable): Likewise.
        * lib/freadahead.c (freadahead): Likewise.
        * lib/freading.c (freading): Likewise.
        * lib/freadptr.c (freadptr): Likewise.
        * lib/freadseek.c (freadptrinc): Likewise.
        * lib/fseeko.c (rpl_fseeko): Likewise.
        * lib/fseterr.c (fseterr): Likewise.
        * lib/fwritable.c (fwritable): Likewise.
        * lib/fwriting.c (fwriting): Likewise.

*** lib/fbufmode.c.orig 2008-04-10 00:52:26.000000000 +0200
--- lib/fbufmode.c      2008-04-09 13:05:04.000000000 +0200
***************
*** 46,51 ****
--- 46,53 ----
    if (fp->_flags & __SNBF)
      return _IONBF;
    return _IOFBF;
+ #elif defined __EMX__               /* emx+gcc */
+   return fp->_flags & (_IOLBF | _IONBF | _IOFBF);
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if HAVE___FLBF                    /* Solaris >= 7 */
    if (__flbf (fp))
*** lib/fpurge.c.orig   2008-04-10 00:52:26.000000000 +0200
--- lib/fpurge.c        2008-04-10 00:20:27.000000000 +0200
***************
*** 90,95 ****
--- 90,101 ----
        fp_ub._base = NULL;
      }
    return 0;
+ # elif defined __EMX__              /* emx+gcc */
+   fp->_ptr = fp->_buffer;
+   fp->_rcount = 0;
+   fp->_wcount = 0;
+   fp->_ungetc_count = 0;
+   return 0;
  # elif defined _IOERR               /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  #  if defined _SCO_DS               /* OpenServer */
  #   define _base __base
*** lib/freadable.c.orig        2008-04-10 00:52:26.000000000 +0200
--- lib/freadable.c     2008-04-09 13:10:21.000000000 +0200
***************
*** 29,34 ****
--- 29,36 ----
    return (fp->_flags & _IO_NO_READS) == 0;
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    return (fp->_flags & (__SRW | __SRD)) != 0;
+ #elif defined __EMX__               /* emx+gcc */
+   return (fp->_flags & (_IORW | _IOREAD)) != 0;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined _SCO_DS                /* OpenServer */
  #  define _flag __flag
*** lib/freadahead.c.orig       2008-04-10 00:52:26.000000000 +0200
--- lib/freadahead.c    2008-04-10 00:41:06.000000000 +0200
***************
*** 43,48 ****
--- 43,56 ----
      return 0;
    return fp->_r
         + (HASUB (fp) ? fp->_ur : 0);
+ #elif defined __EMX__               /* emx+gcc */
+   if ((fp->_flags & _IOWRT) != 0)
+     return 0;
+   /* Note: fp->_ungetc_count > 0 implies fp->_rcount <= 0,
+            fp->_ungetc_count = 0 implies fp->_rcount >= 0.  */
+   /* equivalent to
+      (fp->_ungetc_count == 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount) 
*/
+   return (fp->_rcount > 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount);
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
  #  define fp_ ((struct { unsigned char *_ptr; \
*** lib/freading.c.orig 2008-04-10 00:52:26.000000000 +0200
--- lib/freading.c      2008-04-09 23:56:35.000000000 +0200
***************
*** 35,40 ****
--- 35,42 ----
              && fp->_IO_read_base != NULL));
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    return (fp->_flags & __SRD) != 0;
+ #elif defined __EMX__               /* emx+gcc */
+   return (fp->_flags & _IOREAD) != 0;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined _SCO_DS                /* OpenServer */
  #  define _flag __flag
*** lib/freadptr.c.orig 2008-04-10 00:52:26.000000000 +0200
--- lib/freadptr.c      2008-04-10 00:41:49.000000000 +0200
***************
*** 19,24 ****
--- 19,26 ----
  /* Specification.  */
  #include "freadptr.h"
  
+ #include <stdlib.h>
+ 
  const char *
  freadptr (FILE *fp, size_t *sizep)
  {
***************
*** 41,46 ****
--- 43,59 ----
      return NULL;
    *sizep = size;
    return (const char *) fp->_p;
+ #elif defined __EMX__               /* emx+gcc */
+   if ((fp->_flags & _IOWRT) != 0)
+     return NULL;
+   /* Note: fp->_ungetc_count > 0 implies fp->_rcount <= 0,
+            fp->_ungetc_count = 0 implies fp->_rcount >= 0.  */
+   if (fp->_rcount <= 0)
+     return NULL;
+   if (fp->_ungetc_count == 0)
+     abort ();
+   *sizep = fp->_rcount;
+   return fp->_ptr;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
  #  define fp_ ((struct { unsigned char *_ptr; \
*** lib/freadseek.c.orig        2008-04-10 00:52:26.000000000 +0200
--- lib/freadseek.c     2008-04-10 00:00:38.000000000 +0200
***************
*** 37,42 ****
--- 37,45 ----
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    fp->_p += increment;
    fp->_r -= increment;
+ #elif defined __EMX__               /* emx+gcc */
+   fp->_ptr += increment;
+   fp->_rcount -= increment;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
  #  define fp_ ((struct { unsigned char *_ptr; \
*** lib/fseeko.c.orig   2008-04-10 00:52:26.000000000 +0200
--- lib/fseeko.c        2008-04-10 00:44:26.000000000 +0200
***************
*** 70,75 ****
--- 70,80 ----
                    ? fp->_bf._size
                    : 0)
        && fp_ub._base == NULL)
+ #elif defined __EMX__               /* emx+gcc */
+   if (fp->_ptr == fp->_buffer
+       && fp->_rcount == 0
+       && fp->_wcount == 0
+       && fp->_ungetc_count == 0)
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
  #  define fp_ ((struct { unsigned char *_ptr; \
***************
*** 117,122 ****
--- 122,129 ----
          fp->_offset = pos;
          fp->_flags |= __SOFF;
          fp->_flags &= ~__SEOF;
+ #elif defined __EMX__               /* emx+gcc */
+           fp->_flags &= ~_IOEOF;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined _SCO_DS                /* OpenServer */
  #  define _flag __flag
*** lib/fseterr.c.orig  2008-04-10 00:52:26.000000000 +0200
--- lib/fseterr.c       2008-04-09 13:08:13.000000000 +0200
***************
*** 31,36 ****
--- 31,38 ----
    fp->_flags |= _IO_ERR_SEEN;
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    fp->_flags |= __SERR;
+ #elif defined __EMX__               /* emx+gcc */
+   fp->_flags |= _IOERR;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
  #  define fp_ ((struct { unsigned char *_ptr; \
*** lib/fwritable.c.orig        2008-04-10 00:52:26.000000000 +0200
--- lib/fwritable.c     2008-04-09 13:10:49.000000000 +0200
***************
*** 29,34 ****
--- 29,36 ----
    return (fp->_flags & _IO_NO_WRITES) == 0;
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    return (fp->_flags & (__SRW | __SWR)) != 0;
+ #elif defined __EMX__               /* emx+gcc */
+   return (fp->_flags & (_IORW | _IOWRT)) != 0;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined _SCO_DS                /* OpenServer */
  #  define _flag __flag
*** lib/fwriting.c.orig 2008-04-10 00:52:26.000000000 +0200
--- lib/fwriting.c      2008-04-09 23:56:45.000000000 +0200
***************
*** 29,34 ****
--- 29,36 ----
    return (fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) != 0;
  #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, 
Cygwin */
    return (fp->_flags & __SWR) != 0;
+ #elif defined __EMX__               /* emx+gcc */
+   return (fp->_flags & _IOWRT) != 0;
  #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, 
OpenServer, mingw */
  # if defined _SCO_DS                /* OpenServer */
  #  define _flag __flag
*** m4/fpending.m4.orig 2008-04-10 00:52:26.000000000 +0200
--- m4/fpending.m4      2008-04-10 00:51:17.000000000 +0200
***************
*** 1,6 ****
! #serial 12
  
! # Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007 Free Software
  # Foundation, Inc.
  # This file is free software; the Free Software Foundation
  # gives unlimited permission to copy and/or distribute it,
--- 1,6 ----
! #serial 13
  
! # Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008 Free Software
  # Foundation, Inc.
  # This file is free software; the Free Software Foundation
  # gives unlimited permission to copy and/or distribute it,
***************
*** 53,58 ****
--- 53,61 ----
            '# old glibc iostream?'                                       \
            'fp->_pptr - fp->_pbase'                                      \
                                                                          \
+           '# emx+gcc'                                                   \
+           'fp->_ptr - fp->_buffer'                                      \
+                                                                         \
            '# VMS'                                                       \
            '(*fp)->_ptr - (*fp)->_base'                                  \
                                                                          \



Reply via email to