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

Generated for libcdio by doxygen 1.7.6.1