Main Page | Data Structures | Directories | File List | Data Fields | Globals

types.h

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

Generated on Mon Sep 26 08:17:38 2005 for libcdio by  doxygen 1.4.4