libcdio 0.83

types.h

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

Generated for libcdio by doxygen 1.7.3