libcdio  0.90
types.h
Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2012
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 /* If <sys/types.h> is not available on your platform please
00033    contact the libcdio mailing list so that we can fix it! */
00034 #if !defined(ARE_THERE_STILL_ENVS_WITHOUT_SYS_TYPES) 
00035 #include <sys/types.h>
00036 #endif 
00037 
00038 #if defined(AMIGA)
00039 typedef u_int8_t uint8_t;
00040 typedef u_int16_t uint16_t;
00041 typedef u_int32_t uint32_t;
00042 typedef u_int64_t uint64_t;
00043 #else
00044 /* If <stdint.h> is not available on your platform please
00045    contact the libcdio mailing list so that we can fix it!
00046    For MSVC, you can find both a public domain stdint.h and
00047    inttypes.h in the MSVC/missing directory of libcdio. */
00048 #include <stdint.h>
00049 #endif
00050 
00051 typedef uint8_t ubyte;
00052 
00053 /* MSVC does not define mode_t and ssize_t by default. The way
00054    to compensate for missing UNIX types is to include a custom
00055    unistd.h that defines them. Such a file is provided with
00056    the libcdio source, in the MSVC/missing directory */
00057 #if defined(_MSC_VER)
00058 #include <unistd.h>
00059 #endif
00060 
00061   /* default HP/UX macros are broken */
00062 #if defined(__hpux__)
00063 # undef UINT16_C
00064 # undef UINT32_C
00065 # undef UINT64_C
00066 # undef INT64_C
00067 #endif
00068 
00069   /* if it's still not defined, take a good guess... should work for
00070      most 32bit and 64bit archs */
00071   
00072 #ifndef UINT16_C
00073 # define UINT16_C(c) c ## U
00074 #endif
00075   
00076 #ifndef UINT32_C
00077 # if defined (SIZEOF_INT) && SIZEOF_INT == 4
00078 #  define UINT32_C(c) c ## U
00079 # elif defined (SIZEOF_LONG) && SIZEOF_LONG == 4
00080 #  define UINT32_C(c) c ## UL
00081 # else
00082 #  define UINT32_C(c) c ## U
00083 # endif
00084 #endif
00085   
00086 #ifndef UINT64_C
00087 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
00088 #  define UINT64_C(c) c ## UL
00089 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
00090 #  define UINT64_C(c) c ## U
00091 # else
00092 #  define UINT64_C(c) c ## ULL
00093 # endif
00094 #endif
00095   
00096 #ifndef INT64_C
00097 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
00098 #  define INT64_C(c) c ## L
00099 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
00100 #  define INT64_C(c) c 
00101 # else
00102 #  define INT64_C(c) c ## LL
00103 # endif
00104 #endif
00105   
00106 #ifndef __cplusplus
00107 
00108 /* All the stdbool.h seem to define those */
00109 #ifndef __bool_true_false_are_defined
00110 #define __bool_true_false_are_defined 1
00111 
00112 #undef bool
00113 #undef true
00114 #undef false
00115 
00116 #ifdef _Bool
00117 #define bool _Bool
00118 #else
00119 #define bool unsigned char
00120 #endif
00121 #define true 1
00122 #define false 0
00123 
00124 #endif /* __bool_true_false_are_defined */
00125 #endif /*C++*/
00126   
00127   /* some GCC optimizations -- gcc 2.5+ */
00128   
00129 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00130 #define GNUC_PRINTF( format_idx, arg_idx )              \
00131   __attribute__((format (printf, format_idx, arg_idx)))
00132 #define GNUC_SCANF( format_idx, arg_idx )               \
00133   __attribute__((format (scanf, format_idx, arg_idx)))
00134 #define GNUC_FORMAT( arg_idx )                  \
00135   __attribute__((format_arg (arg_idx)))
00136 #define GNUC_NORETURN                           \
00137   __attribute__((noreturn))
00138 #define GNUC_CONST                              \
00139   __attribute__((const))
00140 #define GNUC_UNUSED                             \
00141   __attribute__((unused))
00142 #define GNUC_PACKED                             \
00143   __attribute__((packed))
00144 #else   /* !__GNUC__ */
00145 #define GNUC_PRINTF( format_idx, arg_idx )
00146 #define GNUC_SCANF( format_idx, arg_idx )
00147 #define GNUC_FORMAT( arg_idx )
00148 #define GNUC_NORETURN
00149 #define GNUC_CONST
00150 #define GNUC_UNUSED
00151 #define GNUC_PACKED
00152 #endif  /* !__GNUC__ */
00153   
00154 #if defined(__MINGW32__)
00155 #  define PRAGMA_BEGIN_PACKED _Pragma("pack(push)") \
00156                               _Pragma("pack(1)")
00157 #  define PRAGMA_END_PACKED   _Pragma("pack(pop)")
00158 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
00159      /* should work with most EDG-frontend based compilers */
00160 #    define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
00161 #    define PRAGMA_END_PACKED   _Pragma("pack()")
00162 #elif defined(_MSC_VER)
00163 #  define PRAGMA_BEGIN_PACKED __pragma(pack(push, 1))
00164 #  define PRAGMA_END_PACKED   __pragma(pack(pop))
00165 #else /* neither gcc nor _Pragma() available... */
00166    /* ...so let's be naive and hope the regression testsuite is run... */
00167 #  define PRAGMA_BEGIN_PACKED
00168 #  define PRAGMA_END_PACKED
00169 #endif
00170   
00171   /*
00172    * user directed static branch prediction gcc 2.96+
00173    */
00174 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
00175 # define GNUC_LIKELY(x)   __builtin_expect((x),true)
00176 # define GNUC_UNLIKELY(x) __builtin_expect((x),false)
00177 #else 
00178 # define GNUC_LIKELY(x)   (x) 
00179 # define GNUC_UNLIKELY(x) (x)
00180 #endif
00181   
00182 #ifndef NULL
00183 # define NULL ((void*) 0)
00184 #endif
00185 
00188 #if defined(__GNUC__)
00189 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
00190 #   define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated(notice)))
00191 # else
00192 #   define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated))
00193 # endif
00194 #elif defined(_MSC_VER)
00195 #define LIBCDIO_DEPRECATED(object, notice) __declspec(deprecated(notice)) object
00196 #else
00197 #define LIBCDIO_DEPRECATED(object, notice)
00198 #endif
00199 
00201 #define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
00202   
00217   PRAGMA_BEGIN_PACKED
00218   struct msf_s {
00219     uint8_t m, s, f; /* BCD encoded! */
00220   } GNUC_PACKED;
00221   PRAGMA_END_PACKED
00222   
00223   typedef struct msf_s msf_t;
00224 
00225 #define msf_t_SIZEOF 3
00226 
00233   typedef char cdio_utf8_t;
00234 
00235   typedef enum  {
00236     nope  = 0,
00237     yep   = 1,
00238     dunno = 2
00239   } bool_3way_t;
00240   
00241   /* type used for bit-fields in structs (1 <= bits <= 8) */
00242 #if defined(__GNUC__)
00243   /* this is strict ISO C99 which allows only 'unsigned int', 'signed
00244      int' and '_Bool' explicitly as bit-field type */
00245   typedef unsigned int bitfield_t;
00246 #else
00247   /* other compilers might increase alignment requirements to match the
00248      'unsigned int' type -- fixme: find out how unalignment accesses can
00249      be pragma'ed on non-gcc compilers */
00250   typedef uint8_t bitfield_t;
00251 #endif
00252   
00258   typedef int32_t lba_t;
00259   
00265   typedef int32_t lsn_t;
00266   
00267   /* Address in either MSF or logical format */
00268   union cdio_cdrom_addr         
00269   {
00270     msf_t       msf;
00271     lba_t       lba;
00272   };
00273 
00275   typedef uint8_t track_t;
00276   
00278   typedef uint8_t session_t;
00279   
00283 #define CDIO_INVALID_SESSION   0xFF
00284   
00290 #define CDIO_INVALID_LBA    -45301
00291   
00295 #define CDIO_INVALID_LSN    CDIO_INVALID_LBA
00296 
00301 #define CDIO_MCN_SIZE       13
00302 
00307   typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
00308   
00309 
00313 #define CDIO_ISRC_SIZE       12
00314 
00319   typedef char cdio_isrc_t[CDIO_ISRC_SIZE+1];
00320 
00321   typedef int cdio_fs_anal_t;
00322 
00327   typedef enum {
00328     CDIO_TRACK_FLAG_NONE =               0x00,  
00329     CDIO_TRACK_FLAG_PRE_EMPHASIS =       0x01,  
00331     CDIO_TRACK_FLAG_COPY_PERMITTED =     0x02,  
00332     CDIO_TRACK_FLAG_DATA =               0x04,  
00333     CDIO_TRACK_FLAG_FOUR_CHANNEL_AUDIO = 0x08,  
00334   CDIO_TRACK_FLAG_SCMS =                 0x10   
00335 } cdio_track_flag;
00336 
00337 #ifdef __cplusplus
00338 }
00339 #endif /* __cplusplus */
00340 
00341 #endif /* CDIO_TYPES_H_ */
00342 
00343 
00344 /* 
00345  * Local variables:
00346  *  c-file-style: "gnu"
00347  *  tab-width: 8
00348  *  indent-tabs-mode: nil
00349  * End:
00350  */