Mercurial > ecos-v3_0-branch
changeset 1541:871b38a618f4
* src/input/vfscanf.cxx (vfscanf): Silence warning.
* include/stdio.h:
Add file operation functions which weren't here before!
While I'm here, add __THROW everywhere and use __externC not externC.
* cdl/stdio.cdl: We implement stdio fileops in isoinfra now.
Also set header for that.
Build fileops.cxx.
L_tmpnam must be at least 4.
TMP_MAX must be at least 1, and ISO C says it should be >=25.
Add description for CYGPKG_LIBC_STDIO_FILEIO and move up from
bottom so it goes with others.
* src/common/fileops.cxx: New file. Implements rename(), remove(),
tmpnam() and tmpfile().
* src/common/fclose.cxx: Add throw specifiers to match stdio.h.
* src/common/feof.cxx: Ditto.
* src/common/fflush.cxx: Ditto.
* src/common/fopen.cxx: Ditto.
* src/common/freopen.cxx: Ditto.
* src/common/fseek.cxx: Ditto.
* src/common/setvbuf.cxx: Ditto.
* src/common/snprintf.cxx: Ditto.
* src/common/sprintf.cxx: Ditto.
* src/common/sscanf.cxx: Ditto.
* src/common/stdioinlines.cxx: Ditto.
* src/common/ungetc.cxx: Ditto.
* src/common/vsnprintf.cxx: Ditto.
* src/common/vsscanf.cxx: Ditto.
* src/input/fgetc.cxx: Ditto.
* src/input/fgets.cxx: Ditto.
* src/input/fread.cxx: Ditto.
* src/input/fscanf.cxx: Ditto.
* src/input/gets.cxx: Ditto.
* src/input/scanf.cxx: Ditto.
* src/input/vfscanf.cxx: Ditto.
* src/output/fnprintf.cxx: Ditto.
* src/output/fprintf.cxx: Ditto.
* src/output/fputc.cxx: Ditto.
* src/output/fputs.cxx: Ditto.
* src/output/fwrite.cxx: Ditto.
* src/output/printf.cxx: Ditto.
* src/output/vfnprintf.cxx: Ditto.
line wrap: on
line diff
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,57 @@ +2004-03-12 Jonathan Larmour <jifl@eCosCentric.com> + + * src/input/vfscanf.cxx (vfscanf): Silence warning. + + * include/stdio.h: + Add file operation functions which weren't here before! + While I'm here, add __THROW everywhere and use __externC not externC. + + * cdl/stdio.cdl: We implement stdio fileops in isoinfra now. + Also set header for that. + Build fileops.cxx. + L_tmpnam must be at least 4. + TMP_MAX must be at least 1, and ISO C says it should be >=25. + Add description for CYGPKG_LIBC_STDIO_FILEIO and move up from + bottom so it goes with others. + + * src/common/fileops.cxx: New file. Implements rename(), remove(), + tmpnam() and tmpfile(). + + * src/common/fclose.cxx: Add throw specifiers to match stdio.h. + * src/common/feof.cxx: Ditto. + * src/common/fflush.cxx: Ditto. + * src/common/fopen.cxx: Ditto. + * src/common/freopen.cxx: Ditto. + * src/common/fseek.cxx: Ditto. + * src/common/setvbuf.cxx: Ditto. + * src/common/snprintf.cxx: Ditto. + * src/common/sprintf.cxx: Ditto. + * src/common/sscanf.cxx: Ditto. + * src/common/stdioinlines.cxx: Ditto. + * src/common/ungetc.cxx: Ditto. + * src/common/vsnprintf.cxx: Ditto. + * src/common/vsscanf.cxx: Ditto. + * src/input/fgetc.cxx: Ditto. + * src/input/fgets.cxx: Ditto. + * src/input/fread.cxx: Ditto. + * src/input/fscanf.cxx: Ditto. + * src/input/gets.cxx: Ditto. + * src/input/scanf.cxx: Ditto. + * src/input/vfscanf.cxx: Ditto. + * src/output/fnprintf.cxx: Ditto. + * src/output/fprintf.cxx: Ditto. + * src/output/fputc.cxx: Ditto. + * src/output/fputs.cxx: Ditto. + * src/output/fwrite.cxx: Ditto. + * src/output/printf.cxx: Ditto. + * src/output/vfnprintf.cxx: Ditto. + +2004-02-17 Jonathan Larmour <jifl@eCosCentric.com> + + * cdl/stdio.cdl (CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS): Can + be inactive when no kernel. + * cdl/stdio.cdl: Implements file positioning functions in isoinfra. + 2003-09-03 Thomas Koeller <thomas.koeller@baslerweb.com> * cdl/stdio.cdl: only require "/dev/haldiag" if actually using it.
--- a/packages/language/c/libc/stdio/current/cdl/stdio.cdl +++ b/packages/language/c/libc/stdio/current/cdl/stdio.cdl @@ -61,6 +61,8 @@ cdl_package CYGPKG_LIBC_STDIO { requires CYGPKG_LIBC_I18N implements CYGINT_ISO_STDIO_FILETYPES implements CYGINT_ISO_STDIO_FILEACCESS + implements CYGINT_ISO_STDIO_FILEPOS + implements CYGINT_ISO_STDIO_FILEOPS implements CYGINT_ISO_STDIO_FORMATTED_IO implements CYGINT_ISO_STDIO_CHAR_IO implements CYGINT_ISO_STDIO_DIRECT_IO @@ -72,6 +74,10 @@ cdl_package CYGPKG_LIBC_STDIO { "<cyg/libc/stdio/stdio.h>" } requires { CYGBLD_ISO_STDIO_FILEACCESS_HEADER == \ "<cyg/libc/stdio/stdio.h>" } + requires { CYGBLD_ISO_STDIO_FILEPOS_HEADER == \ + "<cyg/libc/stdio/stdio.h>" } + requires { CYGBLD_ISO_STDIO_FILEOPS_HEADER == \ + "<cyg/libc/stdio/stdio.h>" } requires { CYGBLD_ISO_STDIO_FORMATTED_IO_HEADER == \ "<cyg/libc/stdio/stdio.h>" } requires { CYGBLD_ISO_STDIO_CHAR_IO_HEADER == \ @@ -102,7 +108,7 @@ cdl_package CYGPKG_LIBC_STDIO { common/stdiosupp.cxx common/stdout.cxx \ common/stream.cxx common/streambuf.cxx \ common/ungetc.cxx common/vsnprintf.cxx \ - common/vsscanf.cxx \ + common/vsscanf.cxx common/fileops.cxx \ \ input/fgetc.cxx input/fgets.cxx \ input/fread.cxx input/fscanf.cxx \ @@ -156,7 +162,7 @@ cdl_package CYGPKG_LIBC_STDIO { cdl_option L_tmpnam { display "Maximum length of filenames for temporary files" flavor data - legal_values 1 to 0x7fffffff + legal_values 4 to 0x7fffffff default_value 16 description " This option defines the maximum allowed size of @@ -169,13 +175,15 @@ cdl_package CYGPKG_LIBC_STDIO { cdl_option TMP_MAX { display "Unique file names generated by tmpnam()" flavor data - legal_values 0 to 0x7fffffff - default_value 0 + legal_values 1 to 0x7fffffff + default_value 25 description " This option defines the minimum number of unique file names generated by tmpnam(). The ISO C standard requires it to be defined (para - 7.9.1)." + 7.9.1) and for ISO compliance it should be at least + 25. Note that TMP_MAX names may not be generated + if L_tmpnam is too small." } cdl_component CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO { @@ -344,8 +352,8 @@ cdl_package CYGPKG_LIBC_STDIO { cdl_option CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS { display "Thread safe I/O streams" doc ref/libc-thread-safety.html - requires CYGPKG_KERNEL - default_value { 0 != CYGPKG_KERNEL } + active_if CYGPKG_KERNEL + default_value 1 description " This option controls whether standard I/O streams are thread-safe. Having this option set allows @@ -356,6 +364,21 @@ cdl_package CYGPKG_LIBC_STDIO { # ==================================================================== + cdl_option CYGPKG_LIBC_STDIO_FILEIO { + display "Enable use of FILEIO package for IO operations." + active_if CYGPKG_IO_FILEIO + requires CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + calculated 1 + description " + This CDL exists to control how the standard I/O functions + interface to the underlying I/O system. Either using the + File I/O package, or the generic I/O package which is used + by fewer devices." + } +} + +# ==================================================================== + cdl_component CYGPKG_LIBC_STDIO_OPTIONS { display "C library stdio functions build options" flavor none @@ -403,14 +426,4 @@ cdl_package CYGPKG_LIBC_STDIO { } # ==================================================================== - - cdl_option CYGPKG_LIBC_STDIO_FILEIO { - display "Enable use of FILEIO package for IO operations." - active_if CYGPKG_IO_FILEIO - requires CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO - calculated 1 - } -} - -# ==================================================================== # EOF stdio.cdl
--- a/packages/language/c/libc/stdio/current/include/stdio.h +++ b/packages/language/c/libc/stdio/current/include/stdio.h @@ -119,97 +119,113 @@ typedef CYG_ADDRESS FILE[9999]; //======================================================================== -// ISO C 7.9.5 File access functions +// ISO C89 7.9.4 Functions for operations on files -externC int -fclose( FILE * /* stream */ ); +__externC int +remove( const char * /* pathname */ ) __THROW; + +__externC int +rename( const char * /* oldpath */, const char * /* newpath */ ) __THROW; -externC int -fflush( FILE * /* stream */ ); +__externC FILE * +tmpfile( void ) __THROW; -externC FILE * -fopen( const char * /* filename */, const char * /* mode */ ); +__externC char * +tmpnam(char * /* s */ ) __THROW; + +//======================================================================== + +// ISO C89 7.9.5 File access functions -externC FILE * -freopen( const char * /* filename */, const char * /* mode */, - FILE * /* stream */ ); +__externC int +fclose( FILE * /* stream */ ) __THROW; + +__externC int +fflush( FILE * /* stream */ ) __THROW; + +__externC FILE * +fopen( const char * /* filename */, const char * /* mode */ ) __THROW; -externC void -setbuf( FILE * /* stream */, char * /* buffer */ ); +__externC FILE * +freopen( const char * /* filename */, const char * /* mode */, + FILE * /* stream */ ) __THROW; -externC int +__externC void +setbuf( FILE * /* stream */, char * /* buffer */ ) __THROW; + +__externC int setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */, - size_t /* size */ ); + size_t /* size */ ) __THROW; //======================================================================== -// ISO C 7.9.6 Formatted input/output functions +// ISO C89 7.9.6 Formatted input/output functions -externC int -fprintf( FILE * /* stream */, const char * /* format */, ... ); +__externC int +fprintf( FILE * /* stream */, const char * /* format */, ... ) __THROW; -externC int -fscanf( FILE * /* stream */, const char * /* format */, ... ); +__externC int +fscanf( FILE * /* stream */, const char * /* format */, ... ) __THROW; -externC int -printf( const char * /* format */, ... ); +__externC int +printf( const char * /* format */, ... ) __THROW; -externC int -scanf( const char * /* format */, ... ); +__externC int +scanf( const char * /* format */, ... ) __THROW; -externC int -sprintf( char * /* str */, const char * /* format */, ... ); +__externC int +sprintf( char * /* str */, const char * /* format */, ... ) __THROW; -externC int -sscanf( const char * /* str */, const char * /* format */, ... ); +__externC int +sscanf( const char * /* str */, const char * /* format */, ... ) __THROW; -externC int +__externC int vfprintf( FILE * /* stream */, const char * /* format */, - va_list /* args */ ); + va_list /* args */ ) __THROW; -externC int -vprintf( const char * /* format */, va_list /* args */ ); +__externC int +vprintf( const char * /* format */, va_list /* args */ ) __THROW; -externC int +__externC int vsprintf( char * /* str */, const char * /* format */, - va_list /* args */ ); + va_list /* args */ ) __THROW; //======================================================================== -// ISO C 7.9.7 Character input/output functions +// ISO C89 7.9.7 Character input/output functions -externC int -fgetc( FILE * /* stream */ ); +__externC int +fgetc( FILE * /* stream */ ) __THROW; -externC char * -fgets( char * /* str */, int /* length */, FILE * /* stream */ ); +__externC char * +fgets( char * /* str */, int /* length */, FILE * /* stream */ ) __THROW; -externC int -fputc( int /* c */, FILE * /* stream */ ); +__externC int +fputc( int /* c */, FILE * /* stream */ ) __THROW; -externC int -putc( int /* c */, FILE * /* stream */ ); +__externC int +putc( int /* c */, FILE * /* stream */ ) __THROW; -externC int -putchar( int /* c */ ); +__externC int +putchar( int /* c */ ) __THROW; -externC int -fputs( const char * /* str */, FILE * /* stream */ ); +__externC int +fputs( const char * /* str */, FILE * /* stream */ ) __THROW; -externC char * -gets( char * ); +__externC char * +gets( char * ) __THROW; -externC int -getc( FILE * /* stream */ ); +__externC int +getc( FILE * /* stream */ ) __THROW; -externC int -getchar( void ); +__externC int +getchar( void ) __THROW; -externC int -puts( const char * /* str */ ); +__externC int +puts( const char * /* str */ ) __THROW; -externC int -ungetc( int /* c */, FILE * /* stream */ ); +__externC int +ungetc( int /* c */, FILE * /* stream */ ) __THROW; // no function equivalent is required for getchar() or putchar(), so we can // just #define them @@ -220,81 +236,81 @@ ungetc( int /* c */, FILE * /* stream */ //======================================================================== -// ISO C 7.9.8 Direct input/output functions +// ISO C89 7.9.8 Direct input/output functions -externC size_t +__externC size_t fread( void * /* ptr */, size_t /* object_size */, - size_t /* num_objects */, FILE * /* stream */ ); + size_t /* num_objects */, FILE * /* stream */ ) __THROW; -externC size_t +__externC size_t fwrite( const void * /* ptr */, size_t /* object_size */, - size_t /* num_objects */, FILE * /* stream */ ); + size_t /* num_objects */, FILE * /* stream */ ) __THROW; //======================================================================== -// ISO C 7.9.9 File positioning functions +// ISO C89 7.9.9 File positioning functions -externC int -fgetpos( FILE * /* stream */, fpos_t * /* pos */ ); +__externC int +fgetpos( FILE * /* stream */, fpos_t * /* pos */ ) __THROW; -externC int -fseek( FILE * /* stream */, long int /* offset */, int /* whence */ ); +__externC int +fseek( FILE * /* stream */, long int /* offset */, int /* whence */ ) __THROW; -externC int -fsetpos( FILE * /* stream */, const fpos_t * /* pos */ ); +__externC int +fsetpos( FILE * /* stream */, const fpos_t * /* pos */ ) __THROW; -externC long int -ftell( FILE * /* stream */ ); +__externC long int +ftell( FILE * /* stream */ ) __THROW; -externC void -rewind( FILE * /* stream */ ); +__externC void +rewind( FILE * /* stream */ ) __THROW; //======================================================================== -// ISO C 7.9.10 Error-handling functions +// ISO C89 7.9.10 Error-handling functions -externC void -clearerr( FILE * /* stream */ ); +__externC void +clearerr( FILE * /* stream */ ) __THROW; -externC int -feof( FILE * /* stream */ ); +__externC int +feof( FILE * /* stream */ ) __THROW; -externC int -ferror( FILE * /* stream */ ); +__externC int +ferror( FILE * /* stream */ ) __THROW; -externC void -perror( const char * /* prefix_str */ ); +__externC void +perror( const char * /* prefix_str */ ) __THROW; //======================================================================== // Other non-ISO C functions -externC int +__externC int fnprintf( FILE * /* stream */, size_t /* length */, - const char * /* format */, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4); + const char * /* format */, ... ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4); -externC int +__externC int snprintf( char * /* str */, size_t /* length */, const char * /* format */, - ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4); + ... ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4); -externC int +__externC int vfnprintf( FILE * /* stream */, size_t /* length */, - const char * /* format */, va_list /* args */ ); + const char * /* format */, va_list /* args */ ) __THROW; -externC int +__externC int vsnprintf( char * /* str */, size_t /* length */, - const char * /* format */, va_list /* args */ ); + const char * /* format */, va_list /* args */ ) __THROW; -externC int -vscanf( const char * /* format */, va_list /* args */ ); +__externC int +vscanf( const char * /* format */, va_list /* args */ ) __THROW; -externC int +__externC int vsscanf( const char * /* str */, const char * /* format */, - va_list /* args */ ); + va_list /* args */ ) __THROW; -externC int +__externC int vfscanf( FILE * /* stream */, const char * /* format */, - va_list /* args */ ); + va_list /* args */ ) __THROW; // INLINE FUNCTIONS
--- a/packages/language/c/libc/stdio/current/include/stdio.inl +++ b/packages/language/c/libc/stdio/current/include/stdio.inl @@ -74,7 +74,7 @@ // 7.9.5 File access functions extern __inline__ void -setbuf( FILE *stream, char *buf ) +setbuf( FILE *stream, char *buf ) __THROW { if (buf == NULL) setvbuf( stream, NULL, _IONBF, 0 ); @@ -91,21 +91,21 @@ setbuf( FILE *stream, char *buf ) // 7.9.6 Formatted input/output functions extern __inline__ int -vfprintf( FILE *stream, const char *format, va_list arg ) +vfprintf( FILE *stream, const char *format, va_list arg ) __THROW { return vfnprintf(stream, INT_MAX, format, arg); } // vfprintf() extern __inline__ int -vprintf( const char *format, va_list arg ) +vprintf( const char *format, va_list arg ) __THROW { return vfnprintf(stdout, INT_MAX, format, arg); } // vprintf() extern __inline__ int -vsprintf( char *s, const char *format, va_list arg ) +vsprintf( char *s, const char *format, va_list arg ) __THROW { return vsnprintf(s, INT_MAX, format, arg); } // vsprintf() @@ -116,7 +116,7 @@ vsprintf( char *s, const char *format, v // 7.9.7 Character input/output functions extern __inline__ int -puts( const char *s ) +puts( const char *s ) __THROW { int rc; @@ -134,7 +134,7 @@ puts( const char *s ) // 7.9.10 Error-handling functions extern __inline__ void -perror( const char *s ) +perror( const char *s ) __THROW { if (s && *s) fprintf( stderr, "%s: %s\n", s, strerror(errno) ); @@ -148,7 +148,7 @@ perror( const char *s ) // Other non-ANSI functions extern __inline__ int -vscanf( const char *format, va_list arg ) +vscanf( const char *format, va_list arg ) __THROW { return vfscanf( stdin, format, arg ); } // vscanf()
--- a/packages/language/c/libc/stdio/current/include/stream.hxx +++ b/packages/language/c/libc/stdio/current/include/stream.hxx @@ -79,7 +79,7 @@ cyg_libc_stdio_flush_all_but( Cyg_StdioS class Cyg_StdioStream { - friend int setvbuf( FILE *, char *, int, size_t ); + friend int setvbuf( FILE *, char *, int, size_t ) __THROW; friend Cyg_ErrNo cyg_libc_stdio_flush_all_but( Cyg_StdioStream * );
--- a/packages/language/c/libc/stdio/current/src/common/fclose.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fclose.cxx @@ -75,7 +75,7 @@ externC int -fclose( FILE *stream ) +fclose( FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; int i;
--- a/packages/language/c/libc/stdio/current/src/common/feof.cxx +++ b/packages/language/c/libc/stdio/current/src/common/feof.cxx @@ -63,7 +63,7 @@ #include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream class externC int -feof( FILE *stream ) +feof( FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; @@ -71,7 +71,7 @@ feof( FILE *stream ) } // feof() externC int -ferror( FILE *stream ) +ferror( FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; @@ -79,7 +79,7 @@ ferror( FILE *stream ) } // ferror() externC void -clearerr( FILE *stream ) +clearerr( FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
--- a/packages/language/c/libc/stdio/current/src/common/fflush.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fflush.cxx @@ -127,7 +127,7 @@ cyg_libc_stdio_flush_all_but( Cyg_StdioS } // cyg_libc_stdio_flush_all_but() externC int -fflush( FILE *stream ) +fflush( FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err;
new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/fileops.cxx @@ -0,0 +1,250 @@ +/*======================================================================== +// +// fileops.cxx +// +// Implementation of ISO C rename(),remove(),tmpnam(),tmpfile() functions +// +//======================================================================== +//####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2004 eCosCentric Ltd. +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with eCos; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or inline functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. However the source code for this file must still be made available +// in accordance with section (3) of the GNU General Public License. +// +// This exception does not invalidate any other reasons why a work based on +// this file might be covered by the GNU General Public License. +// ------------------------------------------- +//####ECOSGPLCOPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2004-02-30 +// Purpose: Implementation of ISO C rename(),remove(),tmpnam(),tmpfile() +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +//======================================================================*/ + +// CONFIGURATION + +#include <pkgconf/system.h> +#include <pkgconf/isoinfra.h> +#include <pkgconf/libc_stdio.h> // Configuration header + +// INCLUDES + +#include <cyg/infra/cyg_type.h> // Common type definitions and support +#include <cyg/infra/cyg_ass.h> // Common assertion functions +#include <cyg/infra/cyg_trac.h> // Common tracing functions +#include <stdio.h> // Header for this file +#include <errno.h> // errno +#ifdef CYGPKG_LIBC_STDIO_FILEIO // unix-y functions, e.g. stat,rmdir,unlink,... +# include <unistd.h> +# include <fcntl.h> +# include <sys/stat.h> +#endif +#include <cyg/libc/stdio/io.hxx> // I/O definitions +#ifdef CYGPKG_POSIX +# include <pkgconf/posix.h> +# include <cyg/posix/export.h> +#endif + +#if defined(CYGINT_ISO_EXIT) && (CYGINT_ISO_EXIT+0) +# include <stdlib.h> // used by tmpfile() for atexit() +#endif + +// DEFINES + +#ifdef CYGPKG_POSIX +# define CYG_STDIO_FUNCTION_START() CYG_POSIX_FUNCTION_START() +# define CYG_STDIO_FUNCTION_FINISH() CYG_POSIX_FUNCTION_FINISH() +#else +# define CYG_STDIO_FUNCTION_START() CYG_EMPTY_STATEMENT +# define CYG_STDIO_FUNCTION_FINISH() CYG_EMPTY_STATEMENT +#endif + +// Handle entry +#define STDIO_ENTRY() \ + CYG_REPORT_FUNCTYPE( "returning %d" ); \ + CYG_STDIO_FUNCTION_START(); \ + +#define STDIO_RETURN(err) \ +CYG_MACRO_START \ + int __retval = 0; \ + CYG_STDIO_FUNCTION_FINISH(); \ + if( err != 0 ) __retval = -1, errno = err; \ + CYG_REPORT_RETVAL( __retval ); \ + return __retval; \ +CYG_MACRO_END + +#define STDIO_RETURN_VALUE(val) \ +CYG_MACRO_START \ + CYG_STDIO_FUNCTION_FINISH(); \ + CYG_REPORT_RETVAL( val ); \ + return val; \ +CYG_MACRO_END + +// FUNCTIONS + +/////////////////////////////////////////////////////////////////////////// +// remove() + +__externC int remove( const char *path ) __THROW +{ + int ret; + STDIO_ENTRY(); + CYG_CHECK_DATA_PTR( path, "path pointer invalid" ); + +#ifdef CYGPKG_LIBC_STDIO_FILEIO + struct stat sbuf; + ret = stat( path, &sbuf ); + + if (0 == ret) + { + if ( S_ISDIR(sbuf.st_mode) ) + { + ret = rmdir( path ); + } else { + ret = unlink( path ); + } + } +#else // !defined(CYGPKG_LIBC_STDIO_FILEIO) + ret = ENOSYS; +#endif + STDIO_RETURN(ret); +} // remove() + +/////////////////////////////////////////////////////////////////////////// +// rename() +// +// The File I/O package supplies its own complete version of this, so we +// only implement a dummy here. + +#ifndef CYGPKG_LIBC_STDIO_FILEIO +__externC int rename( const char *oldname, const char *newname ) __THROW +{ + STDIO_ENTRY(); + CYG_CHECK_DATA_PTR(oldname, "oldname pointer invalid"); + CYG_CHECK_DATA_PTR(newname, "newname pointer invalid"); + STDIO_RETURN(ENOSYS); +} +#endif // ifndef CYGPKG_LIBC_STDIO_FILEIO + +/////////////////////////////////////////////////////////////////////////// +// tmpnam() + +__externC char *tmpnam( char *s ) __THROW +{ + STDIO_ENTRY(); + static char staticbuf[ L_tmpnam ]; +#if (TMP_MAX < 256) + typedef cyg_uint8 counttype; +#elif (TMP_MAX < 65536) + typedef cyg_uint16 counttype; +#else + typedef cyg_ucount32 counttype; +#endif + static counttype count; + counttype totaliters=0; + int i; + + if ( NULL != s ) + CYG_CHECK_DATA_PTR( s, "supplied string pointer invalid" ); + else + s = staticbuf; + + // start off by making it "tmp00000" etc. so we can fill backwards + // from end without spaces + s[0] = 't'; s[1] = 'm'; s[2] = 'p'; + + while (totaliters < TMP_MAX) + { + for (i=3; i < (L_tmpnam-1); i++) + { + s[i] = '0'; + } + s[i] = '\0'; + + counttype counttmp = count; + for (i=(L_tmpnam-1); i>2; i--) + { + const char tohex[] = "0123456789abcdef"; + s[i] = tohex[counttmp & 0xf]; + counttmp = counttmp >> 4; + } + count++; + count %= TMP_MAX; // cycle round + totaliters++; + + // s now points to a name candidate +#ifdef CYGPKG_LIBC_STDIO_FILEIO + int fd = open( s, O_RDONLY ); + close(fd); + if (fd < 0 && ENOENT == errno) // we have a winner + break; +#else + break; // no real filesystem, so just go with what we've come up with +#endif + } + + if ( totaliters == TMP_MAX ) // oops, looped right the way round + s = NULL; + + STDIO_RETURN_VALUE( s ); +} // tmpnam() + +/////////////////////////////////////////////////////////////////////////// +// tmpfile() + +__externC FILE *tmpfile( void ) __THROW +{ + FILE *f; + char fname[L_tmpnam]; + char *s; + + STDIO_ENTRY(); + + s = tmpnam( fname ); + if ( s == NULL) + f = NULL; + else + { + // fname is now a valid name to use + f = fopen( fname, "wb+" ); +#ifdef CYGPKG_LIBC_STDIO_FILEIO + // We can use remove which should mean the file is removed on program + // exit.We ignore the return code though - the standard seems to + // indicate that the return status from this function is solely + // dictated by whether the file could be created. + if (f) + remove( fname ); +#endif + } + + STDIO_RETURN_VALUE( f ); +} // tmpfile() + +/////////////////////////////////////////////////////////////////////////// +// EOF fileops.cxx
--- a/packages/language/c/libc/stdio/current/src/common/fopen.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fopen.cxx @@ -202,7 +202,7 @@ static FILE *fopen_inner( cyg_stdio_hand } // fopen_inner() externC FILE * -fopen( const char *filename, const char *mode ) +fopen( const char *filename, const char *mode ) __THROW { cyg_stdio_handle_t dev; Cyg_ErrNo err; @@ -232,14 +232,14 @@ fopen( const char *filename, const char #ifdef CYGPKG_LIBC_STDIO_FILEIO -externC int fileno( FILE *stream ) +externC int fileno( FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; return real_stream->get_dev(); } -externC FILE *fdopen( int fd, const char *mode ) +externC FILE *fdopen( int fd, const char *mode ) __THROW { Cyg_StdioStream::OpenMode open_mode; cyg_bool binary, append;
--- a/packages/language/c/libc/stdio/current/src/common/freopen.cxx +++ b/packages/language/c/libc/stdio/current/src/common/freopen.cxx @@ -69,7 +69,7 @@ externC FILE * -freopen( const char *, const char *, FILE * ) +freopen( const char *, const char *, FILE * ) __THROW { return NULL; // Returning NULL is valid! FIXME } // freopen()
--- a/packages/language/c/libc/stdio/current/src/common/fseek.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fseek.cxx @@ -69,7 +69,7 @@ // ISO C 7.9.9 File positioning functions externC int -fgetpos( FILE * stream , fpos_t *pos ) +fgetpos( FILE * stream , fpos_t *pos ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err; @@ -90,7 +90,7 @@ fgetpos( FILE * stream , fpos_t *pos ) } externC int -fseek( FILE * stream , long int offset , int whence ) +fseek( FILE * stream , long int offset , int whence ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err; @@ -111,7 +111,7 @@ fseek( FILE * stream , long int offset , } externC int -fsetpos( FILE * stream , const fpos_t * pos ) +fsetpos( FILE * stream , const fpos_t * pos ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err; @@ -132,7 +132,7 @@ fsetpos( FILE * stream , const fpos_t * } externC long int -ftell( FILE * stream ) +ftell( FILE * stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err; @@ -155,7 +155,7 @@ ftell( FILE * stream ) } externC void -rewind( FILE * stream ) +rewind( FILE * stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; (void)fseek( stream, 0L, SEEK_SET );
--- a/packages/language/c/libc/stdio/current/src/common/setvbuf.cxx +++ b/packages/language/c/libc/stdio/current/src/common/setvbuf.cxx @@ -68,7 +68,7 @@ externC int -setvbuf( FILE *stream, char *buf, int mode, size_t size ) +setvbuf( FILE *stream, char *buf, int mode, size_t size ) __THROW { #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
--- a/packages/language/c/libc/stdio/current/src/common/snprintf.cxx +++ b/packages/language/c/libc/stdio/current/src/common/snprintf.cxx @@ -64,7 +64,7 @@ // FUNCTIONS externC int -snprintf( char *s, size_t size, const char *format, ... ) +snprintf( char *s, size_t size, const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/common/sprintf.cxx +++ b/packages/language/c/libc/stdio/current/src/common/sprintf.cxx @@ -65,7 +65,7 @@ // FUNCTIONS externC int -sprintf( char *s, const char *format, ... ) +sprintf( char *s, const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/common/sscanf.cxx +++ b/packages/language/c/libc/stdio/current/src/common/sscanf.cxx @@ -64,7 +64,7 @@ // FUNCTIONS externC int -sscanf( const char *s, const char *format, ... ) +sscanf( const char *s, const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/common/stdioinlines.cxx +++ b/packages/language/c/libc/stdio/current/src/common/stdioinlines.cxx @@ -79,7 +79,7 @@ // 7.9.5 File access functions externC void -setbuf( FILE *stream, char *buf ) +setbuf( FILE *stream, char *buf ) __THROW { if (buf == NULL) setvbuf( stream, NULL, _IONBF, 0 ); @@ -97,21 +97,21 @@ setbuf( FILE *stream, char *buf ) externC int -vfprintf( FILE *stream, const char *format, va_list arg ) +vfprintf( FILE *stream, const char *format, va_list arg ) __THROW { return vfnprintf(stream, INT_MAX, format, arg); } // vfprintf() externC int -vprintf( const char *format, va_list arg) +vprintf( const char *format, va_list arg) __THROW { return vfnprintf( stdout, INT_MAX, format, arg ); } // vprintf() externC int -vsprintf( char *s, const char *format, va_list arg ) +vsprintf( char *s, const char *format, va_list arg ) __THROW { return vsnprintf(s, INT_MAX, format, arg); } // vsprintf() @@ -122,7 +122,7 @@ vsprintf( char *s, const char *format, v // 7.9.7 Character input/output functions externC int -puts( const char *s ) +puts( const char *s ) __THROW { int rc; @@ -140,7 +140,7 @@ puts( const char *s ) // 7.9.10 Error-handling functions externC void -perror( const char *s ) +perror( const char *s ) __THROW { if (s && *s) fprintf( stderr, "%s: %s\n", s, strerror(errno) ); @@ -155,7 +155,7 @@ perror( const char *s ) #ifdef CYGFUN_LIBC_STDIO_ungetc externC int -vscanf( const char *format, va_list arg ) +vscanf( const char *format, va_list arg ) __THROW { return vfscanf( stdin, format, arg ); } // vscanf()
--- a/packages/language/c/libc/stdio/current/src/common/ungetc.cxx +++ b/packages/language/c/libc/stdio/current/src/common/ungetc.cxx @@ -67,7 +67,7 @@ // FUNCTIONS externC int -ungetc( int c, FILE *stream ) +ungetc( int c, FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err;
--- a/packages/language/c/libc/stdio/current/src/common/vsnprintf.cxx +++ b/packages/language/c/libc/stdio/current/src/common/vsnprintf.cxx @@ -102,7 +102,7 @@ static DEVIO_TABLE(devio_table, NULL); // set_config externC int -vsnprintf( char *s, size_t size, const char *format, va_list arg ) +vsnprintf( char *s, size_t size, const char *format, va_list arg ) __THROW { int rc; // construct a fake device with the address of the string we've @@ -131,7 +131,7 @@ vsnprintf( char *s, size_t size, const c #else externC int -vsnprintf( char *s, size_t size, const char *format, va_list arg ) +vsnprintf( char *s, size_t size, const char *format, va_list arg ) __THROW { int rc;
--- a/packages/language/c/libc/stdio/current/src/common/vsscanf.cxx +++ b/packages/language/c/libc/stdio/current/src/common/vsscanf.cxx @@ -119,7 +119,7 @@ static DEVIO_TABLE(devio_table, externC int -vsscanf( const char *s, const char *format, va_list arg ) +vsscanf( const char *s, const char *format, va_list arg ) __THROW { // construct a fake device with the address of the string we've // been passed as its private data. This way we can use the data @@ -141,7 +141,7 @@ vsscanf( const char *s, const char *form #else externC int -vsscanf( const char *s, const char *format, va_list arg ) +vsscanf( const char *s, const char *format, va_list arg ) __THROW { Cyg_StdioStream my_stream( Cyg_StdioStream::CYG_STREAM_READ, strlen(s), (cyg_uint8 *)s );
--- a/packages/language/c/libc/stdio/current/src/input/fgetc.cxx +++ b/packages/language/c/libc/stdio/current/src/input/fgetc.cxx @@ -69,7 +69,7 @@ // FUNCTIONS externC int -fgetc( FILE *stream ) +fgetc( FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; cyg_ucount32 bytes_read; @@ -113,7 +113,7 @@ fgetc( FILE *stream ) #undef getchar externC int -getchar( void ) +getchar( void ) __THROW { return fgetc( stdin ); } // getchar() @@ -126,6 +126,6 @@ getchar( void ) #undef getc externC int -getc( FILE * ) CYGBLD_ATTRIB_WEAK_ALIAS(fgetc); +getc( FILE * ) __THROW CYGBLD_ATTRIB_WEAK_ALIAS(fgetc); // EOF fgetc.cxx
--- a/packages/language/c/libc/stdio/current/src/input/fgets.cxx +++ b/packages/language/c/libc/stdio/current/src/input/fgets.cxx @@ -71,7 +71,7 @@ // for newlines, rather than reading byte at a time. externC char * -fgets( char *s, int n, FILE *stream ) +fgets( char *s, int n, FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err=ENOERR;
--- a/packages/language/c/libc/stdio/current/src/input/fread.cxx +++ b/packages/language/c/libc/stdio/current/src/input/fread.cxx @@ -68,7 +68,7 @@ // FUNCTIONS externC size_t -fread( void *ptr, size_t object_size, size_t num_objects, FILE *stream ) +fread( void *ptr, size_t object_size, size_t num_objects, FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; cyg_ucount32 bytes_read;
--- a/packages/language/c/libc/stdio/current/src/input/fscanf.cxx +++ b/packages/language/c/libc/stdio/current/src/input/fscanf.cxx @@ -65,7 +65,7 @@ // FUNCTIONS externC int -fscanf( FILE *stream, const char *format, ... ) +fscanf( FILE *stream, const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/input/gets.cxx +++ b/packages/language/c/libc/stdio/current/src/input/gets.cxx @@ -71,7 +71,7 @@ // for newlines, rather than reading byte at a time. externC char * -gets( char *s ) +gets( char *s ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stdin; Cyg_ErrNo err=ENOERR;
--- a/packages/language/c/libc/stdio/current/src/input/scanf.cxx +++ b/packages/language/c/libc/stdio/current/src/input/scanf.cxx @@ -65,7 +65,7 @@ externC int -scanf( const char *format, ... ) +scanf( const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/input/vfscanf.cxx +++ b/packages/language/c/libc/stdio/current/src/input/vfscanf.cxx @@ -178,7 +178,7 @@ externC mbtowc_fn_type __get_current_loc #endif externC int -vfscanf (FILE *fp, const char *fmt0, va_list ap) +vfscanf (FILE *fp, const char *fmt0, va_list ap) __THROW { u_char *fmt = (u_char *) fmt0; int c; /* character from format, or conversion */ @@ -517,7 +517,7 @@ literal: if (flags & SUPPRESS) { n = 0; - while (ccltab[*CURR_POS]) + while (ccltab[(int)*CURR_POS]) { n++, INC_CURR_POS; if (--width == 0) @@ -535,7 +535,7 @@ literal: else { p0 = p = va_arg (ap, char *); - while (ccltab[*CURR_POS]) + while (ccltab[(int)*CURR_POS]) { *p++ = *CURR_POS; INC_CURR_POS;
--- a/packages/language/c/libc/stdio/current/src/output/fnprintf.cxx +++ b/packages/language/c/libc/stdio/current/src/output/fnprintf.cxx @@ -64,7 +64,7 @@ // FUNCTIONS externC int -fnprintf( FILE *stream, size_t size, const char *format, ... ) +fnprintf( FILE *stream, size_t size, const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/output/fprintf.cxx +++ b/packages/language/c/libc/stdio/current/src/output/fprintf.cxx @@ -65,7 +65,7 @@ // FUNCTIONS externC int -fprintf( FILE *stream, const char *format, ... ) +fprintf( FILE *stream, const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/output/fputc.cxx +++ b/packages/language/c/libc/stdio/current/src/output/fputc.cxx @@ -69,7 +69,7 @@ // FUNCTIONS externC int -fputc( int c, FILE *stream ) +fputc( int c, FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; Cyg_ErrNo err; @@ -101,7 +101,7 @@ fputc( int c, FILE *stream ) #undef putchar externC int -putchar( int c ) +putchar( int c ) __THROW { return fputc( c, stdout ); } // putchar() @@ -111,6 +111,6 @@ putchar( int c ) #undef putc externC int -putc( int, FILE * ) CYGBLD_ATTRIB_WEAK_ALIAS(fputc); +putc( int, FILE * ) __THROW CYGBLD_ATTRIB_WEAK_ALIAS(fputc); // EOF fputc.cxx
--- a/packages/language/c/libc/stdio/current/src/output/fputs.cxx +++ b/packages/language/c/libc/stdio/current/src/output/fputs.cxx @@ -67,7 +67,7 @@ // FUNCTIONS externC int -fputs( const char *s, FILE *stream ) +fputs( const char *s, FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; cyg_ucount32 size = strlen(s);
--- a/packages/language/c/libc/stdio/current/src/output/fwrite.cxx +++ b/packages/language/c/libc/stdio/current/src/output/fwrite.cxx @@ -69,7 +69,7 @@ externC size_t fwrite( const void *ptr, size_t object_size, size_t num_objects, - FILE *stream ) + FILE *stream ) __THROW { Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; cyg_ucount32 written;
--- a/packages/language/c/libc/stdio/current/src/output/printf.cxx +++ b/packages/language/c/libc/stdio/current/src/output/printf.cxx @@ -65,7 +65,7 @@ // FUNCTIONS externC int -printf( const char *format, ... ) +printf( const char *format, ... ) __THROW { int rc; // return code va_list ap; // for variable args
--- a/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx +++ b/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx @@ -153,7 +153,7 @@ externC mbtowc_fn_type __get_current_loc #define SIZET 0x200 /* size_t */ externC int -vfnprintf ( FILE *stream, size_t n, const char *format, va_list arg) +vfnprintf ( FILE *stream, size_t n, const char *format, va_list arg) __THROW { char *fmt; /* format string */ int ch; /* character from fmt */
