From 81fe603b84b9ab4565593f0b38b30274dbb73980 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 28 Feb 2009 21:24:24 +0100 Subject: [PATCH] Add tentative support for FreeMiNT. --- ChangeLog | 18 ++++++++++++++++++ lib/fbufmode.c | 6 +++++- lib/fflush.c | 6 ++++++ lib/fpurge.c | 12 +++++++++++- lib/freadable.c | 4 +++- lib/freadahead.c | 8 +++++++- lib/freading.c | 7 ++++++- lib/freadptr.c | 10 +++++++++- lib/freadseek.c | 4 +++- lib/fseeko.c | 5 +++++ lib/fseterr.c | 4 +++- lib/fwritable.c | 4 +++- lib/fwriting.c | 7 ++++++- 13 files changed, 85 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 276a9f439..fc7b505c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 2009-02-28 Bruno Haible + Add tentative support for FreeMiNT. + * lib/fbufmode.c (fbufmode) [__MINT__]: Add conditional code. + * lib/fflush.c (clear_ungetc_buffer): Likewise. + * lib/fpurge.c (fpurge): Likewise. + * lib/freadable.c (freadable): 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/freadahead.c (freadahead): Likewise, based on code by Alan + Hourihane. + Reported by Alan Hourihane . + +2009-02-28 Bruno Haible + * lib/wait-process.h (wait_subprocess): Clarify restriction regarding SIGCHLD. Reported by Jim Meyering. diff --git a/lib/fbufmode.c b/lib/fbufmode.c index d5b456ff0..7cd9df783 100644 --- a/lib/fbufmode.c +++ b/lib/fbufmode.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,6 +73,10 @@ fbufmode (FILE *fp) if (fp->_Mode & 0x800 /* _MNBF */) return _IONBF; return _IOFBF; +#elif defined __MINT__ /* Atari FreeMiNT */ + if (fp->__linebuf) + return _IOLBF; + return (fp->__bufsize > 0 ? _IOFBF : _IONBF); #else #error "Please port gnulib fbufmode.c to your platform! Look at the setvbuf implementation." #endif diff --git a/lib/fflush.c b/lib/fflush.c index 9f75ccdc1..3b1765530 100644 --- a/lib/fflush.c +++ b/lib/fflush.c @@ -63,6 +63,12 @@ clear_ungetc_buffer (FILE *fp) } # elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */ /* Nothing to do. */ +# elif defined __MINT__ /* Atari FreeMiNT */ + if (fp->__pushed_back) + { + fp->__bufp = fp->__pushback_bufp; + fp->__pushed_back = 0; + } # else /* other implementations */ fseek (fp, 0, SEEK_CUR); # endif diff --git a/lib/fpurge.c b/lib/fpurge.c index 916b17bf4..0e2931eb1 100644 --- a/lib/fpurge.c +++ b/lib/fpurge.c @@ -1,5 +1,5 @@ /* Flushing buffers of a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -114,6 +114,16 @@ fpurge (FILE *fp) /* fp->_Buf <= fp->_Next <= fp->_Rend */ fp->_Rend = fp->_Next; return 0; +# elif defined __MINT__ /* Atari FreeMiNT */ + if (fp->__pushed_back) + { + fp->__bufp = fp->__pushback_bufp; + fp->__pushed_back = 0; + } + fp->__bufp = fp->__buffer; + fp->__get_limit = fp->__bufp; + fp->__put_limit = fp->__bufp; + return 0; # else #error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib." # endif diff --git a/lib/freadable.c b/lib/freadable.c index b50140433..9895b2c0b 100644 --- a/lib/freadable.c +++ b/lib/freadable.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,8 @@ freadable (FILE *fp) return (fp->_flag & (_IORW | _IOREAD)) != 0; #elif defined __QNX__ /* QNX */ return (fp->_Mode & 0x1 /* _MOPENR */) != 0; +#elif defined __MINT__ /* Atari FreeMiNT */ + return fp->__mode.__read; #else #error "Please port gnulib freadable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib." #endif diff --git a/lib/freadahead.c b/lib/freadahead.c index 25bfc1ee8..f4b5ed702 100644 --- a/lib/freadahead.c +++ b/lib/freadahead.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,6 +70,12 @@ freadahead (FILE *fp) + (fp->_Mode & 0x4000 /* _MBYTE */ ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback : 0); +#elif defined __MINT__ /* Atari FreeMiNT */ + if (!fp->__mode.__read) + return 0; + return (fp->__pushed_back + ? fp->__get_limit - fp->__pushback_bufp + 1 + : fp->__get_limit - fp->__bufp); #elif defined SLOW_BUT_NO_HACKS /* users can define this */ abort (); return 0; diff --git a/lib/freading.c b/lib/freading.c index b08fbeaf3..f20affce3 100644 --- a/lib/freading.c +++ b/lib/freading.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,6 +46,11 @@ freading (FILE *fp) #elif defined __QNX__ /* QNX */ return ((fp->_Mode & 0x2 /* _MOPENW */) == 0 || (fp->_Mode & 0x1000 /* _MREAD */) != 0); +#elif defined __MINT__ /* Atari FreeMiNT */ + return (!fp->__mode.__write + || (fp->__mode.__read + && (fp->__buffer < fp->__get_limit + /*|| fp->__bufp == fp->__put_limit ??*/))); #else #error "Please port gnulib freading.c to your platform!" #endif diff --git a/lib/freadptr.c b/lib/freadptr.c index f78ec1abe..3abe58e63 100644 --- a/lib/freadptr.c +++ b/lib/freadptr.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -85,6 +85,14 @@ freadptr (FILE *fp, size_t *sizep) return NULL; *sizep = size; return (const char *) fp->_Next; +#elif defined __MINT__ /* Atari FreeMiNT */ + if (!fp->__mode.__read) + return NULL; + size = fp->__get_limit - fp->__bufp; + if (size == 0) + return NULL; + *sizep = size; + return fp->__bufp; #elif defined SLOW_BUT_NO_HACKS /* users can define this */ /* This implementation is correct on any ANSI C platform. It is just awfully slow. */ diff --git a/lib/freadseek.c b/lib/freadseek.c index 311c6990c..23046fa4c 100644 --- a/lib/freadseek.c +++ b/lib/freadseek.c @@ -1,5 +1,5 @@ /* Skipping input from a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -53,6 +53,8 @@ freadptrinc (FILE *fp, size_t increment) # endif #elif defined __QNX__ /* QNX */ fp->_Next += increment; +#elif defined __MINT__ /* Atari FreeMiNT */ + fp->__bufp += increment; #elif defined SLOW_BUT_NO_HACKS /* users can define this */ #else #error "Please port gnulib freadseek.c to your platform! Look at the definition of getc, getc_unlocked on your system, then report this to bug-gnulib." diff --git a/lib/fseeko.c b/lib/fseeko.c index 47beac42e..78e2b2fac 100644 --- a/lib/fseeko.c +++ b/lib/fseeko.c @@ -82,6 +82,11 @@ rpl_fseeko (FILE *fp, off_t offset, int whence) if ((fp->_Mode & _MWRITE ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend) && fp->_Rback == fp->_Back + sizeof (fp->_Back) && fp->_Rsave == NULL) +#elif defined __MINT__ /* Atari FreeMiNT */ + if (fp->__bufp == fp->__buffer + && fp->__get_limit == fp->__bufp + && fp->__put_limit == fp->__bufp + && !fp->__pushed_back) #else #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib." #endif diff --git a/lib/fseterr.c b/lib/fseterr.c index ebe358080..110716bfd 100644 --- a/lib/fseterr.c +++ b/lib/fseterr.c @@ -1,5 +1,5 @@ /* Set the error indicator of a stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,8 @@ fseterr (FILE *fp) fp->__modeflags |= __FLAG_ERROR; #elif defined __QNX__ /* QNX */ fp->_Mode |= 0x200 /* _MERR */; +#elif defined __MINT__ /* Atari FreeMiNT */ + fp->__error = 1; #elif 0 /* unknown */ /* Portable fallback, based on an idea by Rich Felker. Wow! 6 system calls for something that is just a bit operation! diff --git a/lib/fwritable.c b/lib/fwritable.c index ed7be9d9b..d295777eb 100644 --- a/lib/fwritable.c +++ b/lib/fwritable.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,8 @@ fwritable (FILE *fp) return (fp->_flag & (_IORW | _IOWRT)) != 0; #elif defined __QNX__ /* QNX */ return (fp->_Mode & 0x2 /* _MOPENW */) != 0; +#elif defined __MINT__ /* Atari FreeMiNT */ + return fp->__mode.__write; #else #error "Please port gnulib fwritable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib." #endif diff --git a/lib/fwriting.c b/lib/fwriting.c index 4ecf4b0a0..b7fa45571 100644 --- a/lib/fwriting.c +++ b/lib/fwriting.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,6 +40,11 @@ fwriting (FILE *fp) #elif defined __QNX__ /* QNX */ return ((fp->_Mode & 0x1 /* _MOPENR */) == 0 || (fp->_Mode & 0x2000 /* _MWRITE */) != 0); +#elif defined __MINT__ /* Atari FreeMiNT */ + return (!fp->__mode.__read + || (fp->__mode.__write + && (fp->__buffer < fp->__put_limit + /*|| fp->__bufp == fp->__get_limit ??*/))); #else #error "Please port gnulib fwriting.c to your platform!" #endif -- 2.11.0