Changeset 4248


Ignore:
Timestamp:
Jan 13, 2010, 12:53:30 AM (8 years ago)
Author:
Sam Hocevar
Message:

Reorganise FILE structure autoconf tests.

Location:
zzuf/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r4244 r4248  
    7878AC_DEFINE_UNQUOTED(RECV_T, $ac_v_recv_t, [Define to the recv() return type])
    7979
    80 AC_MSG_CHECKING(for FILE* internal members)
    81 ac_cv_have_glibc_fp="no"
    82 ac_v_fp_base="unknown"
    83 ac_v_fp_ptr="unknown"
    84 ac_v_fp_cnt="unknown"
     80AC_MSG_CHECKING([for _IO_read_ptr and _IO_read_end in FILE (glibc-style)])
    8581AC_TRY_COMPILE([#include <stdio.h>],
    8682 [FILE *fp; fp->_IO_read_ptr++; fp->_IO_read_end++],
    87  [ac_cv_have_glibc_fp=yes; ac_v_fp_base=_IO_read_base
    88   ac_v_fp_cnt=_IO_read_end; ac_v_fp_ptr=_IO_read_ptr],
    89  [AC_TRY_COMPILE([#include <stdio.h>],
    90    [FILE *fp; fp->__cnt++; fp->__ptr++],
    91    [ac_v_fp_base=FIXME; ac_v_fp_ptr=__ptr; ac_v_fp_cnt=__cnt],
    92    [AC_TRY_COMPILE([#include <stdio.h>],
    93      [FILE *fp; fp->_cnt++; fp->_ptr++],
    94      [ac_v_fp_base=FIXME; ac_v_fp_ptr=_ptr; ac_v_fp_cnt=_cnt],
    95      [AC_TRY_COMPILE([#include <stdio.h>],
    96        [FILE *fp; fp->_c++; fp->_p++],
    97        [ac_v_fp_base=FIXME; ac_v_fp_ptr=_p; ac_v_fp_cnt=_c],
    98        [AC_TRY_COMPILE([#include <stdio.h>],
    99          [FILE *fp; fp->_bf._base++; fp->_r++; fp->_p++],
    100          [ac_v_fp_base=_bf._base; ac_v_fp_ptr=_p; ac_v_fp_cnt=_r])])])])])
    101 AC_MSG_RESULT($ac_v_fp_base/$ac_v_fp_ptr/$ac_v_fp_cnt)
    102 if test "$ac_cv_have_glibc_fp" != "no"; then
    103   AC_DEFINE(HAVE_GLIBC_FP, 1, [Define to 1 if FILE has glibc-style members])
     83 [ac_cv_have_file_io_read_ptr=yes],
     84 [ac_cv_have_file_io_read_ptr=no])
     85AC_MSG_RESULT($ac_cv_have_file_io_read_ptr)
     86if test "$ac_cv_have_file_io_read_ptr" != "no"; then
     87  AC_DEFINE(HAVE_GLIBC_FILE, 1, [Define to 1 if FILE has glibc-style members])
    10488fi
    105 AC_DEFINE_UNQUOTED(FILE_BASE, $ac_v_fp_base, [Define to the FILE::base member])
    106 AC_DEFINE_UNQUOTED(FILE_PTR, $ac_v_fp_ptr, [Define to the FILE::ptr member])
    107 AC_DEFINE_UNQUOTED(FILE_CNT, $ac_v_fp_cnt, [Define to the FILE::cnt member])
     89
     90AC_MSG_CHECKING([for _bf._base, _r and _p in FILE (FreeBSD-style)])
     91AC_TRY_COMPILE([#include <stdio.h>],
     92 [FILE *fp; fp->_bf._base++; fp->_r++; fp->_p++],
     93 [ac_cv_have_file_bf_base=yes],
     94 [ac_cv_have_file_bf_base=no])
     95AC_MSG_RESULT($ac_cv_have_file_bf_base)
     96if test "$ac_cv_have_file_bf_base" != "no"; then
     97  AC_DEFINE(HAVE_FREEBSD_FILE, 1, [Define to 1 if FILE has FreeBSD-style members])
     98fi
    10899
    109100dnl  On HP-UX, fpos64_t == int64_t, but on Linux it's a compound object.
  • zzuf/trunk/msvc/config.h

    r4137 r4248  
    3939/* #undef HAVE_FORK */
    4040/* #undef HAVE_FREAD_UNLOCKED */
     41/* #undef HAVE_FREEBSD_FILE */
    4142/* #undef HAVE_FREOPEN64 */
    4243/* #undef HAVE_FSEEKO */
     
    5354#define HAVE_GETPAGESIZE 1
    5455/* #undef HAVE_GETTIMEOFDAY */
    55 /* #undef HAVE_GLIBC_FP */
     56/* #undef HAVE_GLIBC_FILE */
    5657#define HAVE_INTTYPES_H 1
    5758#define HAVE_IO_H 1
  • zzuf/trunk/src/libzzuf/lib-stream.c

    r4238 r4248  
    2424#define __EXTENSIONS__
    2525
    26 /* Define if stdio operations use *only* the refill mechanism */
    27 #if defined HAVE___SREFILL
    28 #   define HAVE_DARWIN_STDIO
    29 #elif defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
    30 #   define HAVE_BSD_STDIO
    31 #endif
    32 
    3326/* Define the best ftell() clone */
    3427#if defined HAVE_FTELLO64
     
    176169static inline uint8_t *get_stream_ptr(FILE *stream)
    177170{
    178 #if defined HAVE_BSD_STDIO
    179     return (uint8_t *)stream->FILE_PTR;
     171#if defined HAVE_GLIBC_FILE
     172    return (uint8_t *)stream->_IO_read_ptr;
     173#elif defined HAVE_FREEBSD_FILE
     174    return (uint8_t *)stream->_p;
    180175#else
    181176    (void)stream;
     
    186181static inline int get_stream_off(FILE *stream)
    187182{
    188 #if defined HAVE_BSD_STDIO
    189     return (int)((uint8_t *)stream->FILE_PTR - (uint8_t *)stream->FILE_BASE);
     183#if defined HAVE_GLIBC_FILE
     184    return (int)((uint8_t *)stream->_IO_read_ptr
     185                  - (uint8_t *)stream->_IO_read_base);
     186#elif defined HAVE_FREEBSD_FILE
     187    return (int)((uint8_t *)stream->_p - (uint8_t *)stream->_bf._base);
    190188#else
    191189    (void)stream;
     
    196194static inline int get_stream_cnt(FILE *stream)
    197195{
    198 #if defined HAVE_GLIBC_FP
    199     return (int)((uint8_t *)stream->FILE_CNT - (uint8_t *)stream->FILE_PTR);
    200 #elif defined HAVE_BSD_STDIO
    201     return stream->FILE_CNT;
     196#if defined HAVE_GLIBC_FILE
     197    return (int)((uint8_t *)stream->_IO_read_end
     198                  - (uint8_t *)stream->_IO_read_ptr);
     199#elif defined HAVE_FREEBSD_FILE
     200    return stream->_r;
    202201#else
    203202    (void)stream;
Note: See TracChangeset for help on using the changeset viewer.