diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-08-13 18:18:28 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-08-13 18:18:28 +0000 |
commit | 319d719d86e2278ecca219c099c5d6d343a576a1 (patch) | |
tree | 5359adefb397437feb7cf3e0c27cab895bc86cc7 | |
parent | 8a82cc302401f7beea53f0395bbba2030ffe587a (diff) | |
download | glibc-319d719d86e2278ecca219c099c5d6d343a576a1.zip glibc-319d719d86e2278ecca219c099c5d6d343a576a1.tar.gz glibc-319d719d86e2278ecca219c099c5d6d343a576a1.tar.bz2 |
Update.
2000-08-13 Ulrich Drepper <drepper@redhat.com>
Benjamin Koznik <bkoz@redhat.com>
* libio/fileops.c: Merge with libstdc++-v3.
* libio/genops.c: Likewise.
* libio/iofclose.c: Likewise.
* libio/iofopen.c: Likewise.
* libio/iofwide.c: Likewise.
* libio/libio.h: Likewise.
* libio/libioP.h: Likewise.
* libio/stdfiles.c: Likewise.
* libio/stdio.c: Likewise.
* libio/wfileops.c: Likewise.
* libio/wgenops.c: Likewise.
* libio/Versions: Export functions needed by libstdc++-v3 in GLIBC_2.2.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | libio/Versions | 10 | ||||
-rw-r--r-- | libio/fileops.c | 20 | ||||
-rw-r--r-- | libio/genops.c | 17 | ||||
-rw-r--r-- | libio/iofclose.c | 5 | ||||
-rw-r--r-- | libio/iofopen.c | 12 | ||||
-rw-r--r-- | libio/iofwide.c | 115 | ||||
-rw-r--r-- | libio/libio.h | 65 | ||||
-rw-r--r-- | libio/libioP.h | 38 | ||||
-rw-r--r-- | libio/stdfiles.c | 19 | ||||
-rw-r--r-- | libio/stdio.c | 8 | ||||
-rw-r--r-- | libio/wfileops.c | 17 | ||||
-rw-r--r-- | libio/wgenops.c | 4 |
13 files changed, 297 insertions, 50 deletions
@@ -1,3 +1,20 @@ +2000-08-13 Ulrich Drepper <drepper@redhat.com> + Benjamin Koznik <bkoz@redhat.com> + + * libio/fileops.c: Merge with libstdc++-v3. + * libio/genops.c: Likewise. + * libio/iofclose.c: Likewise. + * libio/iofopen.c: Likewise. + * libio/iofwide.c: Likewise. + * libio/libio.h: Likewise. + * libio/libioP.h: Likewise. + * libio/stdfiles.c: Likewise. + * libio/stdio.c: Likewise. + * libio/wfileops.c: Likewise. + * libio/wgenops.c: Likewise. + + * libio/Versions: Export functions needed by libstdc++-v3 in GLIBC_2.2. + 2000-08-12 Ulrich Drepper <drepper@redhat.com> * locale/programs/localedef.c: Implement --prefix option to allow diff --git a/libio/Versions b/libio/Versions index 1fbc313..0b57cce 100644 --- a/libio/Versions +++ b/libio/Versions @@ -103,6 +103,16 @@ libc { GLIBC_2.2 { # functions used in libstdc++ _IO_fgetpos; _IO_fgetpos64; _IO_fsetpos; _IO_fsetpos64; + _IO_wdo_write; _IO_wfile_jumps; _IO_wfile_overflow; _IO_wfile_seekoff; + _IO_wfile_setbuf; _IO_wfile_sync; _IO_wfile_underflow; _IO_wfile_xsputn; + _IO_adjust_wcolumn; _IO_free_wbackup_area; _IO_init_wmarker; + _IO_least_wmarker; _IO_seekwmark; _IO_sputbackwc; _IO_sungetwc; + _IO_switch_to_main_wget_area; _IO_switch_to_wbackup_area; + _IO_switch_to_wget_mode; _IO_unsave_wmarkers; _IO_wdefault_doallocate; + _IO_wdefault_finish; _IO_wdefault_pbackfail; _IO_wdefault_setbuf; + _IO_wdefault_uflow; _IO_wdefault_xsgetn; _IO_wdefault_xsputn; + _IO_wdoallocbuf; _IO_wmarker_delta; _IO_wsetb; __woverflow; __wuflow; + __wunderflow; # LinuxThreads uses this protected interface _IO_iter_begin; _IO_iter_end; _IO_iter_next; _IO_iter_file; diff --git a/libio/fileops.c b/libio/fileops.c index 462ac67..a830b5c 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -55,6 +55,20 @@ extern int errno; # define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence) # define read(FD, Buf, NBytes) __read (FD, Buf, NBytes) # define write(FD, Buf, NBytes) __write (FD, Buf, NBytes) +#else +# define _IO_new_do_write _IO_do_write +# define _IO_new_file_attach _IO_file_attach +# define _IO_new_file_close_it _IO_file_close_it +# define _IO_new_file_finish _IO_file_finish +# define _IO_new_file_fopen _IO_file_fopen +# define _IO_new_file_init _IO_file_init +# define _IO_new_file_setbuf _IO_file_setbuf +# define _IO_new_file_sync _IO_file_sync +# define _IO_new_file_overflow _IO_file_overflow +# define _IO_new_file_seekoff _IO_file_seekoff +# define _IO_new_file_underflow _IO_file_underflow +# define _IO_new_file_write _IO_file_write +# define _IO_new_file_xsputn _IO_file_xsputn #endif /* An fstream can be in at most one of put mode, get mode, or putback mode. @@ -146,12 +160,14 @@ _IO_new_file_close_it (fp) _IO_setg (fp, NULL, NULL, NULL); _IO_setp (fp, NULL, NULL); } +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T else { _IO_wsetb (fp, NULL, NULL, 0); _IO_wsetg (fp, NULL, NULL, NULL); _IO_wsetp (fp, NULL, NULL); } +#endif _IO_un_link ((struct _IO_FILE_plus *) fp); fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS; @@ -768,7 +784,7 @@ _IO_file_stat (fp, st) #ifdef _G_FSTAT64 return _G_FSTAT64 (fp->_fileno, (struct _G_stat64 *) st); #else - return fstat (fp->_fileno, (struct _G_stat64 *) st); + return fstat (fp->_fileno, (struct stat *) st); #endif } @@ -1016,6 +1032,7 @@ struct _IO_jump_t _IO_file_jumps = JUMP_INIT(imbue, _IO_default_imbue) }; +#ifdef _LIBC versioned_symbol (libc, _IO_new_do_write, _IO_do_write, GLIBC_2_1); versioned_symbol (libc, _IO_new_file_attach, _IO_file_attach, GLIBC_2_1); versioned_symbol (libc, _IO_new_file_close_it, _IO_file_close_it, GLIBC_2_1); @@ -1029,3 +1046,4 @@ versioned_symbol (libc, _IO_new_file_seekoff, _IO_file_seekoff, GLIBC_2_1); versioned_symbol (libc, _IO_new_file_underflow, _IO_file_underflow, GLIBC_2_1); versioned_symbol (libc, _IO_new_file_write, _IO_file_write, GLIBC_2_1); versioned_symbol (libc, _IO_new_file_xsputn, _IO_file_xsputn, GLIBC_2_1); +#endif diff --git a/libio/genops.c b/libio/genops.c index 381c45f..b1ae5af 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -285,8 +285,10 @@ int __underflow (fp) _IO_FILE *fp; { +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T if (fp->_vtable_offset == 0 && _IO_fwide (fp, -1) != -1) return EOF; +#endif if (fp->_mode == 0) _IO_fwide (fp, -1); @@ -315,8 +317,10 @@ int __uflow (fp) _IO_FILE *fp; { +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T if (fp->_vtable_offset == 0 && _IO_fwide (fp, -1) != -1) return EOF; +#endif if (fp->_mode == 0) _IO_fwide (fp, -11); @@ -580,6 +584,7 @@ _IO_no_init (fp, flags, orientation, wd, jmp) _IO_lock_init (*fp->_lock); #endif fp->_mode = orientation; +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T if (orientation >= 0) { fp->_wide_data = wd; @@ -597,6 +602,7 @@ _IO_no_init (fp, flags, orientation, wd, jmp) fp->_wide_data->_wide_vtable = jmp; } +#endif } int @@ -749,9 +755,12 @@ _IO_flush_all () struct _IO_FILE *fp; for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain) if (((fp->_mode < 0 && fp->_IO_write_ptr > fp->_IO_write_base) +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T || (fp->_vtable_offset == 0 && fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr - > fp->_wide_data->_IO_write_base))) + > fp->_wide_data->_IO_write_base)) +#endif + ) && _IO_OVERFLOW (fp, EOF) == EOF) result = EOF; return result; @@ -775,7 +784,9 @@ _IO_unbuffer_write () for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain) if (! (fp->_flags & _IO_UNBUFFERED) && (! (fp->_flags & _IO_NO_WRITES) - || (fp->_flags & _IO_IS_APPENDING))) + || (fp->_flags & _IO_IS_APPENDING)) + /* Iff stream is un-orientated, it wasn't used. */ + && fp->_mode != 0) _IO_SETBUF (fp, NULL, 0); } @@ -1021,7 +1032,7 @@ _IO_default_write (fp, data, n) return 0; } -size_t +int _IO_default_showmanyc (fp) _IO_FILE *fp; { diff --git a/libio/iofclose.c b/libio/iofclose.c index 04da395..43a3f58 100644 --- a/libio/iofclose.c +++ b/libio/iofclose.c @@ -30,6 +30,9 @@ #if _LIBC # include "../iconv/gconv_int.h" # include <shlib-compat.h> +#else +# define SHLIB_COMPAT(a, b, c) 0 +# define _IO_new_fclose fclose #endif int @@ -87,6 +90,8 @@ _IO_new_fclose (fp) return status; } +#ifdef _LIBC versioned_symbol (libc, _IO_new_fclose, _IO_fclose, GLIBC_2_1); strong_alias (_IO_new_fclose, __new_fclose) versioned_symbol (libc, __new_fclose, fclose, GLIBC_2_1); +#endif diff --git a/libio/iofopen.c b/libio/iofopen.c index e44423b..f34fd1e 100644 --- a/libio/iofopen.c +++ b/libio/iofopen.c @@ -27,7 +27,11 @@ #ifdef __STDC__ #include <stdlib.h> #endif -#include <shlib-compat.h> +#ifdef _LIBC +# include <shlib-compat.h> +#else +# define _IO_new_fopen fopen +#endif _IO_FILE * _IO_new_fopen (filename, mode) @@ -48,7 +52,11 @@ _IO_new_fopen (filename, mode) #ifdef _IO_MTSAFE_IO new_f->fp.file._lock = &new_f->lock; #endif +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps); +#else + _IO_no_init (&new_f->fp.file, 1, 0, NULL, NULL); +#endif _IO_JUMPS (&new_f->fp) = &_IO_file_jumps; _IO_file_init (&new_f->fp); #if !_IO_UNIFIED_JUMPTABLES @@ -61,6 +69,8 @@ _IO_new_fopen (filename, mode) return NULL; } +#ifdef _LIBC strong_alias (_IO_new_fopen, __new_fopen) versioned_symbol (libc, _IO_new_fopen, _IO_fopen, GLIBC_2_1); versioned_symbol (libc, __new_fopen, fopen, GLIBC_2_1); +#endif diff --git a/libio/iofwide.c b/libio/iofwide.c index 6c4b265..231cc56 100644 --- a/libio/iofwide.c +++ b/libio/iofwide.c @@ -77,10 +77,12 @@ struct _IO_codecvt __libio_codecvt = }; +#ifdef _LIBC static struct __gconv_trans_data libio_translit = { .__trans_fct = __gconv_transliterate }; +#endif /* Return orientation of stream. If mode is nonzero try to change @@ -102,19 +104,20 @@ _IO_fwide (fp, mode) /* Set the orientation appropriately. */ if (mode > 0) { + struct _IO_codecvt *cc = fp->_codecvt = &fp->_wide_data->_codecvt; + fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end; fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base; - /* Clear the state. We start all over again. */ - memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t)); - memset (&fp->_wide_data->_IO_last_state, '\0', sizeof (__mbstate_t)); - /* Get the character conversion functions based on the currently selected locale for LC_CTYPE. */ #ifdef _LIBC { struct gconv_fcts fcts; - struct _IO_codecvt *cc = fp->_codecvt = &fp->_wide_data->_codecvt; + + /* Clear the state. We start all over again. */ + memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t)); + memset (&fp->_wide_data->_IO_last_state, '\0', sizeof (__mbstate_t)); __wcsmbs_clone_conv (&fcts); @@ -140,11 +143,43 @@ _IO_fwide (fp, mode) cc->__cd_out.__cd.__data[0].__flags = __GCONV_IS_LAST; cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state; - /* XXX For now no transliteration. */ + /* And now the transliteration. */ +#ifdef _LIBC cc->__cd_out.__cd.__data[0].__trans = &libio_translit; +#else + cc->__cd_out.__cd.__data[0].__trans = NULL; +#endif } #else -# error "somehow determine this from LC_CTYPE" +# ifdef _GLIBCPP_USE_WCHAR_T + { + /* Determine internal and external character sets. + + XXX For now we make our life easy: we assume a fixed internal + encoding (as most sane systems have; hi HP/UX!). If somebody + cares about systems which changing internal charsets they + should come up with a solution for the determination of the + currently used internal character set. */ + const char *internal_ccs = _G_INTERNAL_CCS; + const char *external_ccs = NULL; + +# ifdef HAVE_NL_LANGINFO + external_ccs = nl_langinfo (CODESET); +# endif + if (external_ccs == NULL) + external_ccs = "ISO-8859-1"; + + cc->__cd_in = iconv_open (internal_ccs, external_ccs); + if (cc->__cd_in != (iconv_t) -1) + cc->__cd_out = iconv_open (external_ccs, internal_ccs); + + if (cc->__cd_in == (iconv_t) -1 || cc->__cd_out == (iconv_t) -1) + /* XXX */ + abort (); + } +# else +# error "somehow determine this from LC_CTYPE" +# endif #endif /* From now on use the wide character callback functions. */ @@ -205,8 +240,26 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep, break; } #else +# ifdef _GLIBCPP_USE_WCHAR_T + size_t res; + const char *from_start_copy = (const char *) from_start; + size_t from_len = from_end - from_start; + char *to_start_copy = to_start; + size_t to_len = to_end - to_start; + res = iconv (codecvt->__cd_out, &from_start_copy, &from_len, + &to_start_copy, &to_len); + + if (res == 0 || from_len == 0) + result = __codecvt_ok; + else if (to_len < codecvt->__codecvt_do_max_length (codecvt)) + result = __codecvt_partial; + else + result = __codecvt_error; + +# else /* Decide what to do. */ result = __codecvt_error; +# endif #endif return result; @@ -251,8 +304,23 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep, break; } #else +# ifdef _GLIBCPP_USE_WCHAR_T + size_t res; + char *to_start_copy = (char *) to_start; + size_t to_len = to_end - to_start; + + res = iconv (codecvt->__cd_out, NULL, NULL, &to_start_copy, &to_len); + + if (res == 0) + result = __codecvt_ok; + else if (to_len < codecvt->__codecvt_do_max_length (codecvt)) + result = __codecvt_partial; + else + result = __codecvt_error; +# else /* Decide what to do. */ result = __codecvt_error; +# endif #endif return result; @@ -300,8 +368,28 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep, break; } #else +# ifdef _GLIBCPP_USE_WCHAR_T + size_t res; + const char *from_start_copy = (const char *) from_start; + size_t from_len = from_end - from_start; + char *to_start_copy = (char *) from_start; + size_t to_len = to_end - to_start; + + res = iconv (codecvt->__cd_in, &from_start_copy, &from_len, + &to_start_copy, &to_len); + + if (res == 0) + result = __codecvt_ok; + else if (to_len == 0) + result = __codecvt_partial; + else if (from_len < codecvt->__codecvt_do_max_length (codecvt)) + result = __codecvt_partial; + else + result = __codecvt_error; +# else /* Decide what to do. */ result = __codecvt_error; +# endif #endif return result; @@ -359,8 +447,21 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep, result = cp - (const unsigned char *) from_start; #else +# ifdef _GLIBCPP_USE_WCHAR_T + const char *from_start_copy = (const char *) from_start; + size_t from_len = from_end - from_start; + wchar_t to_buf[max]; + size_t res; + char *to_start = (char *) to_buf; + + res = iconv (codecvt->__cd_in, &from_start_copy, &from_len, + &to_start, &max); + + result = from_start_copy - (char *) from_start; +# else /* Decide what to do. */ result = 0; +# endif #endif return result; diff --git a/libio/libio.h b/libio/libio.h index 0f9a890..d26a5e5 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -28,6 +28,7 @@ #define _IO_STDIO_H #include <_G_config.h> +/* ALL of these should be defined in _G_config.h */ #define _IO_pos_t _G_fpos_t /* obsolete */ #define _IO_fpos_t _G_fpos_t #define _IO_fpos64_t _G_fpos64_t @@ -197,6 +198,7 @@ enum __codecvt_result __codecvt_noconv }; +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T /* The order of the elements in the following struct must match the order of the virtual functions in the libstdc++ codecvt class. */ struct _IO_codecvt @@ -243,14 +245,19 @@ struct _IO_wide_data backup area */ wchar_t *_IO_save_end; /* Pointer to end of non-current get area. */ +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T __mbstate_t _IO_state; __mbstate_t _IO_last_state; +#endif struct _IO_codecvt _codecvt; wchar_t _shortbuf[1]; +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T struct _IO_jump_t *_wide_vtable; +#endif }; +#endif struct _IO_FILE { int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ @@ -297,9 +304,14 @@ struct _IO_FILE_complete #endif #if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001 _IO_off64_t _offset; +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T /* Wide character stream stuff. */ struct _IO_codecvt *_codecvt; struct _IO_wide_data *_wide_data; +# else + void *__pad1; + void *__pad2; +# endif int _mode; /* Make sure we don't get into trouble again. */ char _unused2[15 * sizeof (int) - 2 * sizeof (void *)]; @@ -414,31 +426,11 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t) __THROW; extern int _IO_getc (_IO_FILE *__fp) __THROW; extern int _IO_putc (int __c, _IO_FILE *__fp) __THROW; -extern _IO_wint_t _IO_getwc (_IO_FILE *__fp) __THROW; -extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp) __THROW; extern int _IO_feof (_IO_FILE *__fp) __THROW; extern int _IO_ferror (_IO_FILE *__fp) __THROW; extern int _IO_peekc_locked (_IO_FILE *__fp) __THROW; -extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW; -#if __GNUC__ >= 2 -/* A special optimized version of the function above. It optimizes the - case of initializing an unoriented byte stream. */ -# define _IO_fwide(__fp, __mode) \ - ({ int __result = (__mode); \ - if (__result < 0) \ - { \ - if ((__fp)->_mode == 0) \ - /* We know that all we have to do is to set the flag. */ \ - (__fp)->_mode = -1; \ - __result = (__fp)->_mode; \ - } \ - else \ - __result = _IO_fwide (__fp, __result); \ - __result; }) -#endif - /* This one is for Emacs. */ #define _IO_PENDING_OUTPUT_COUNT(_fp) \ ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) @@ -460,21 +452,44 @@ extern int _IO_ftrylockfile (_IO_FILE *) __THROW; extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, _IO_va_list, int *__restrict) __THROW; -extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict, - _IO_va_list, int *__restrict) __THROW; extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, _IO_va_list) __THROW; -extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict, - _IO_va_list) __THROW; extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t) __THROW; -extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t) __THROW; extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t) __THROW; extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW; extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int) __THROW; extern void _IO_free_backup_area (_IO_FILE *) __THROW; + +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +extern _IO_wint_t _IO_getwc (_IO_FILE *__fp) __THROW; +extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp) __THROW; +extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW; +# if __GNUC__ >= 2 +/* A special optimized version of the function above. It optimizes the + case of initializing an unoriented byte stream. */ +# define _IO_fwide(__fp, __mode) \ + ({ int __result = (__mode); \ + if (__result < 0) \ + { \ + if ((__fp)->_mode == 0) \ + /* We know that all we have to do is to set the flag. */ \ + (__fp)->_mode = -1; \ + __result = (__fp)->_mode; \ + } \ + else \ + __result = _IO_fwide (__fp, __result); \ + __result; }) +# endif + +extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict, + _IO_va_list, int *__restrict) __THROW; +extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict, + _IO_va_list) __THROW; +extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t) __THROW; extern void _IO_free_wbackup_area (_IO_FILE *) __THROW; +#endif #ifdef __cplusplus } diff --git a/libio/libioP.h b/libio/libioP.h index 6d3b775..4bbee9c 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -256,7 +256,7 @@ typedef int (*_IO_stat_t) __PMT ((_IO_FILE *, void *)); /* The 'showmany' hook can be used to get an image how much input is available. In many cases the answer will be 0 which means unknown but some cases one can provide real information. */ -typedef size_t (*_IO_showmanyc_t) __PMT ((_IO_FILE *)); +typedef int (*_IO_showmanyc_t) __PMT ((_IO_FILE *)); #define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP) #define _IO_WSHOWMANYC(FP) WJUMP0 (__showmanyc, FP) @@ -404,7 +404,7 @@ extern int _IO_default_stat __P ((_IO_FILE *, void *)); extern _IO_off64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int)); extern int _IO_default_sync __P ((_IO_FILE *)); #define _IO_default_close ((_IO_close_t) _IO_default_sync) -extern size_t _IO_default_showmanyc __P ((_IO_FILE *)); +extern int _IO_default_showmanyc __P ((_IO_FILE *)); extern void _IO_default_imbue __P ((_IO_FILE *, void *)); extern struct _IO_jump_t _IO_file_jumps; @@ -433,13 +433,19 @@ extern int _IO_new_fsetpos64 __P ((_IO_FILE *, const _IO_fpos64_t *)); extern int _IO_old_fsetpos64 __P ((_IO_FILE *, const _IO_fpos64_t *)); -#define _IO_do_flush(_f) \ +#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# define _IO_do_flush(_f) \ ((_f)->_mode <= 0 \ ? _IO_do_write(_f, (_f)->_IO_write_base, \ (_f)->_IO_write_ptr-(_f)->_IO_write_base) \ : _IO_wdo_write(_f, (_f)->_wide_data->_IO_write_base, \ ((_f)->_wide_data->_IO_write_ptr \ - (_f)->_wide_data->_IO_write_base))) +#else +# define _IO_do_flush(_f) \ + _IO_do_write(_f, (_f)->_IO_write_base, \ + (_f)->_IO_write_ptr-(_f)->_IO_write_base) +#endif #define _IO_old_do_flush(_f) \ _IO_old_do_write(_f, (_f)->_IO_write_base, \ (_f)->_IO_write_ptr-(_f)->_IO_write_base) @@ -708,14 +714,22 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list)); # ifdef _IO_USE_OLD_IO_FILE # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock } # else -# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\ NULL, WDP, 0 } +# else +# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ + { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ + 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\ + 0 } +# endif # endif #else # ifdef _IO_USE_OLD_IO_FILE @@ -724,11 +738,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list)); 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ 0, _IO_pos_BAD } # else -# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \ NULL, WDP, 0 } +# else +# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ + { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ + 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \ + 0 } +# endif # endif #endif diff --git a/libio/stdfiles.c b/libio/stdfiles.c index 866746d..b81fef8 100644 --- a/libio/stdfiles.c +++ b/libio/stdfiles.c @@ -33,20 +33,35 @@ #include "libioP.h" #ifdef _IO_MTSAFE_IO -#define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \ static struct _IO_wide_data _IO_wide_data_##FD \ = { ._wide_vtable = &_IO_wfile_jumps }; \ struct _IO_FILE_plus NAME \ = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \ &_IO_file_jumps}; +# else +# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ + static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \ + struct _IO_FILE_plus NAME \ + = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \ + &_IO_file_jumps}; +# endif #else -#define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ +# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ static struct _IO_wide_data _IO_wide_data_##FD \ = { ._wide_vtable = &_IO_wfile_jumps }; \ struct _IO_FILE_plus NAME \ = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \ &_IO_file_jumps}; +# else +# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ + struct _IO_FILE_plus NAME \ + = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \ + &_IO_file_jumps}; +# endif #endif DEF_STDFILE(_IO_2_1_stdin_, 0, 0, _IO_NO_WRITES); diff --git a/libio/stdio.c b/libio/stdio.c index 79d605d..3b897ce 100644 --- a/libio/stdio.c +++ b/libio/stdio.c @@ -29,13 +29,15 @@ #undef stdin #undef stdout #undef stderr -FILE *stdin = (FILE *) &_IO_2_1_stdin_; -FILE *stdout = (FILE *) &_IO_2_1_stdout_; -FILE *stderr = (FILE *) &_IO_2_1_stderr_; +_IO_FILE *stdin = (FILE *) &_IO_2_1_stdin_; +_IO_FILE *stdout = (FILE *) &_IO_2_1_stdout_; +_IO_FILE *stderr = (FILE *) &_IO_2_1_stderr_; #undef _IO_stdin #undef _IO_stdout #undef _IO_stderr +#ifdef _LIBC strong_alias (stdin, _IO_stdin); strong_alias (stdout, _IO_stdout); strong_alias (stderr, _IO_stderr); +#endif diff --git a/libio/wfileops.c b/libio/wfileops.c index 775690e..f12cb22 100644 --- a/libio/wfileops.c +++ b/libio/wfileops.c @@ -33,6 +33,23 @@ #include <string.h> +#ifndef _LIBC +# define _IO_new_do_write _IO_do_write +# define _IO_new_file_attach _IO_file_attach +# define _IO_new_file_close_it _IO_file_close_it +# define _IO_new_file_finish _IO_file_finish +# define _IO_new_file_fopen _IO_file_fopen +# define _IO_new_file_init _IO_file_init +# define _IO_new_file_setbuf _IO_file_setbuf +# define _IO_new_file_sync _IO_file_sync +# define _IO_new_file_overflow _IO_file_overflow +# define _IO_new_file_seekoff _IO_file_seekoff +# define _IO_new_file_underflow _IO_file_underflow +# define _IO_new_file_write _IO_file_write +# define _IO_new_file_xsputn _IO_file_xsputn +#endif + + _IO_FILE * _IO_wfile_setbuf (fp, p, len) _IO_FILE *fp; diff --git a/libio/wgenops.c b/libio/wgenops.c index 242f3a0..fa0aab3 100644 --- a/libio/wgenops.c +++ b/libio/wgenops.c @@ -35,6 +35,10 @@ #include <wchar.h> +#ifndef _LIBC +# define __wmemcpy(dst, src, n) wmemcpy (dst, src, n) +#endif + static int save_for_wbackup __P ((_IO_FILE *fp, wchar_t *end_p)) #ifdef _LIBC |