types.h

Go to the documentation of this file.
00001 /*
00002     $Id: types_8h-source.html,v 1.19 2006/10/27 11:16:42 rocky Exp $
00003 
00004     Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
00005     Copyright (C) 2002, 2003, 2004, 2005, 2006
00006     Rocky Bernstein <rocky@panix.com>
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00027 
00028 #ifndef __CDIO_TYPES_H__
00029 #define __CDIO_TYPES_H__
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif /* __cplusplus */
00034 
00035 #ifndef EXTERNAL_LIBCDIO_CONFIG_H
00036 #define EXTERNAL_LIBCDIO_CONFIG_H
00037 #include <cdio/cdio_config.h>
00038 #endif
00039 
00040 #ifdef HAVE_SYS_TYPES_H
00041 #include <sys/types.h>
00042 #endif
00043 
00044   /* provide some C99 definitions */
00045 
00046 #if defined(HAVE_SYS_TYPES_H) 
00047 #include <sys/types.h>
00048 #endif 
00049 
00050 #if defined(HAVE_STDINT_H)
00051 # include <stdint.h>
00052 #elif defined(HAVE_INTTYPES_H)
00053 # include <inttypes.h>
00054 #elif defined(AMIGA) || defined(__linux__)
00055   typedef u_int8_t uint8_t;
00056   typedef u_int16_t uint16_t;
00057   typedef u_int32_t uint32_t;
00058   typedef u_int64_t uint64_t;
00059 #else
00060   /* warning ISO/IEC 9899:1999 <stdint.h> was missing and even <inttypes.h> */
00061   /* fixme */
00062 #endif /* HAVE_STDINT_H */
00063   
00064 typedef uint8_t ubyte;
00065 
00066   /* default HP/UX macros are broken */
00067 #if defined(__hpux__)
00068 # undef UINT16_C
00069 # undef UINT32_C
00070 # undef UINT64_C
00071 # undef INT64_C
00072 #endif
00073 
00074   /* if it's still not defined, take a good guess... should work for
00075      most 32bit and 64bit archs */
00076   
00077 #ifndef UINT16_C
00078 # define UINT16_C(c) c ## U
00079 #endif
00080   
00081 #ifndef UINT32_C
00082 # if defined (SIZEOF_INT) && SIZEOF_INT == 4
00083 #  define UINT32_C(c) c ## U
00084 # elif defined (SIZEOF_LONG) && SIZEOF_LONG == 4
00085 #  define UINT32_C(c) c ## UL
00086 # else
00087 #  define UINT32_C(c) c ## U
00088 # endif
00089 #endif
00090   
00091 #ifndef UINT64_C
00092 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
00093 #  define UINT64_C(c) c ## UL
00094 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
00095 #  define UINT64_C(c) c ## U
00096 # else
00097 #  define UINT64_C(c) c ## ULL
00098 # endif
00099 #endif
00100   
00101 #ifndef INT64_C
00102 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
00103 #  define INT64_C(c) c ## L
00104 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
00105 #  define INT64_C(c) c 
00106 # else
00107 #  define INT64_C(c) c ## LL
00108 # endif
00109 #endif
00110   
00111 #ifndef __cplusplus
00112 # if defined(HAVE_STDBOOL_H)
00113 #  include <stdbool.h>
00114 # else
00115    /* ISO/IEC 9899:1999 <stdbool.h> missing -- enabling workaround */
00116   
00117 #   define false   0
00118 #   define true    1
00119 #   define bool uint8_t
00120 # endif /*HAVE_STDBOOL_H*/
00121 #endif /*C++*/
00122   
00123   /* some GCC optimizations -- gcc 2.5+ */
00124   
00125 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00126 #define GNUC_PRINTF( format_idx, arg_idx )              \
00127   __attribute__((format (printf, format_idx, arg_idx)))
00128 #define GNUC_SCANF( format_idx, arg_idx )               \
00129   __attribute__((format (scanf, format_idx, arg_idx)))
00130 #define GNUC_FORMAT( arg_idx )                  \
00131   __attribute__((format_arg (arg_idx)))
00132 #define GNUC_NORETURN                           \
00133   __attribute__((noreturn))
00134 #define GNUC_CONST                              \
00135   __attribute__((const))
00136 #define GNUC_UNUSED                             \
00137   __attribute__((unused))
00138 #define GNUC_PACKED                             \
00139   __attribute__((packed))
00140 #else   /* !__GNUC__ */
00141 #define GNUC_PRINTF( format_idx, arg_idx )
00142 #define GNUC_SCANF( format_idx, arg_idx )
00143 #define GNUC_FORMAT( arg_idx )
00144 #define GNUC_NORETURN
00145 #define GNUC_CONST
00146 #define GNUC_UNUSED
00147 #define GNUC_PACKED
00148 #endif  /* !__GNUC__ */
00149   
00150 #if defined(__GNUC__)
00151   /* for GCC we try to use GNUC_PACKED */
00152 # define PRAGMA_BEGIN_PACKED
00153 # define PRAGMA_END_PACKED
00154 #elif defined(HAVE_ISOC99_PRAGMA)
00155   /* should work with most EDG-frontend based compilers */
00156 # define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
00157 # define PRAGMA_END_PACKED   _Pragma("pack()")
00158 #else /* neither gcc nor _Pragma() available... */
00159   /* ...so let's be naive and hope the regression testsuite is run... */
00160 # define PRAGMA_BEGIN_PACKED
00161 # define PRAGMA_END_PACKED
00162 #endif
00163   
00164   /*
00165    * user directed static branch prediction gcc 2.96+
00166    */
00167 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
00168 # define GNUC_LIKELY(x)   __builtin_expect((x),true)
00169 # define GNUC_UNLIKELY(x) __builtin_expect((x),false)
00170 #else 
00171 # define GNUC_LIKELY(x)   (x) 
00172 # define GNUC_UNLIKELY(x) (x)
00173 #endif
00174   
00175 #ifndef NULL
00176 # define NULL ((void*) 0)
00177 #endif
00178   
00179   /* our own offsetof()-like macro */
00180 #define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
00181   
00196   PRAGMA_BEGIN_PACKED
00197   struct msf_s {
00198     uint8_t m, s, f; /* BCD encoded! */
00199   } GNUC_PACKED;
00200   PRAGMA_END_PACKED
00201   
00202   typedef struct msf_s msf_t;
00203 
00204 #define msf_t_SIZEOF 3
00205 
00212   typedef char cdio_utf8_t;
00213 
00214   typedef enum  {
00215     nope  = 0,
00216     yep   = 1,
00217     dunno = 2
00218   } bool_3way_t;
00219   
00220   /* type used for bit-fields in structs (1 <= bits <= 8) */
00221 #if defined(__GNUC__)
00222   /* this is strict ISO C99 which allows only 'unsigned int', 'signed
00223      int' and '_Bool' explicitly as bit-field type */
00224   typedef unsigned int bitfield_t;
00225 #else
00226   /* other compilers might increase alignment requirements to match the
00227      'unsigned int' type -- fixme: find out how unalignment accesses can
00228      be pragma'ed on non-gcc compilers */
00229   typedef uint8_t bitfield_t;
00230 #endif
00231   
00237   typedef int32_t lba_t;
00238   
00244   typedef int32_t lsn_t;
00245   
00246   /* Address in either MSF or logical format */
00247   union cdio_cdrom_addr         
00248   {
00249     msf_t       msf;
00250     lba_t       lba;
00251   };
00252 
00254   typedef uint8_t track_t;
00255   
00257   typedef uint8_t session_t;
00258   
00262 #define CDIO_INVALID_SESSION   0xFF
00263   
00269 #define CDIO_INVALID_LBA    -45301
00270   
00274 #define CDIO_INVALID_LSN    CDIO_INVALID_LBA
00275 
00279 #define CDIO_MCN_SIZE       13
00280 
00285   typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
00286   
00287 
00291 #define CDIO_ISRC_SIZE       12
00292 
00297   typedef char cdio_isrc_t[CDIO_ISRC_SIZE+1];
00298 
00299   typedef int cdio_fs_anal_t;
00300 
00305   typedef enum {
00306     CDIO_TRACK_FLAG_NONE =               0x00,  
00307     CDIO_TRACK_FLAG_PRE_EMPHASIS =       0x01,  
00309     CDIO_TRACK_FLAG_COPY_PERMITTED =     0x02,  
00310     CDIO_TRACK_FLAG_DATA =               0x04,  
00311     CDIO_TRACK_FLAG_FOUR_CHANNEL_AUDIO = 0x08,  
00312   CDIO_TRACK_FLAG_SCMS =                 0x10   
00313 } cdio_track_flag;
00314 
00315 #ifdef __cplusplus
00316 }
00317 #endif /* __cplusplus */
00318 
00319 #endif /* __CDIO_TYPES_H__ */
00320 
00321 
00322 /* 
00323  * Local variables:
00324  *  c-file-style: "gnu"
00325  *  tab-width: 8
00326  *  indent-tabs-mode: nil
00327  * End:
00328  */

Generated on Fri Oct 27 06:38:08 2006 for libcdio by  doxygen 1.4.6