Reduce differences in pbatard branch for headers. (Still need to add empty array/union differences).

This commit is contained in:
R. Bernstein
2012-03-03 08:48:43 -05:00
parent 730b58a86e
commit 316fb2408f
8 changed files with 213 additions and 117 deletions

View File

@@ -29,7 +29,7 @@
#define __CDIO_BYTESEX_H__
#include <cdio/types.h>
#include <cdio/bytesex_asm.h>
#include <cdio/bytesex_asm.h> /* also defines CDIO_INLINE */
#include <cdio/logging.h>
/** 16-bit big-endian to little-endian */
@@ -67,19 +67,19 @@
# define UINT64_SWAP_LE_BE UINT64_SWAP_LE_BE_C
#endif
inline static
static CDIO_INLINE
uint16_t uint16_swap_le_be (const uint16_t val)
{
return UINT16_SWAP_LE_BE (val);
}
inline static
static CDIO_INLINE
uint32_t uint32_swap_le_be (const uint32_t val)
{
return UINT32_SWAP_LE_BE (val);
}
inline static
static CDIO_INLINE
uint64_t uint64_swap_le_be (const uint64_t val)
{
return UINT64_SWAP_LE_BE (val);
@@ -119,10 +119,10 @@ uint64_t uint64_swap_le_be (const uint64_t val)
/** converter function template */
#define CVT_TO_FUNC(bits) \
static inline uint ## bits ## _t \
static CDIO_INLINE uint ## bits ## _t \
uint ## bits ## _to_be (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_BE (val); } \
static inline uint ## bits ## _t \
static CDIO_INLINE uint ## bits ## _t \
uint ## bits ## _to_le (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_LE (val); } \
@@ -163,14 +163,14 @@ CVT_TO_FUNC(64)
#define from_722(i) uint16_from_be(i)
/** Convert from uint16_t to ISO 9669 7.2.3 format */
static inline uint32_t
static CDIO_INLINE uint32_t
to_723(uint16_t i)
{
return uint32_swap_le_be(i) | i;
}
/** Convert from ISO 9660 7.2.3 format to uint16_t */
static inline uint16_t
static CDIO_INLINE uint16_t
from_723 (uint32_t p)
{
if (uint32_swap_le_be (p) != p)
@@ -192,14 +192,14 @@ from_723 (uint32_t p)
#define from_732(i) uint32_from_be(i)
/** Convert from uint16_t to ISO 9669 7.3.3 format */
static inline uint64_t
static CDIO_INLINE uint64_t
to_733(uint32_t i)
{
return uint64_swap_le_be(i) | i;
}
/** Convert from ISO 9660 7.3.3 format to uint32_t */
static inline uint32_t
static CDIO_INLINE uint32_t
from_733 (uint64_t p)
{
if (uint64_swap_le_be (p) != p)

View File

@@ -1,7 +1,5 @@
/*
$Id: bytesex_asm.h,v 1.3 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2008, 2012 Rocky Bernstein <rocky@gnu.org>
2001, 2004, 2005 Herbert Valerio Riedel <hvr@gnu.org>
2001 Sven Ottemann <ac-logic@freenet.de>
@@ -32,9 +30,21 @@
#include <cdio/types.h>
#if !defined CDIO_INLINE
#if defined(__cplusplus) || defined(inline)
#define CDIO_INLINE inline
#elif defined(__GNUC__)
#define CDIO_INLINE __inline__
#elif defined(_MSC_VER)
#define CDIO_INLINE __inline
#else
#define CDIO_INLINE
#endif
#endif /* CDIO_INLINE */
#if defined(__powerpc__) && defined(__GNUC__)
inline static
static CDIO_INLINE
uint32_t uint32_swap_le_be_asm(const uint32_t a)
{
uint32_t b;
@@ -46,7 +56,7 @@ uint32_t uint32_swap_le_be_asm(const uint32_t a)
return b;
}
inline static
static CDIO_INLINE
uint16_t uint16_swap_le_be_asm(const uint16_t a)
{
uint32_t b;
@@ -63,7 +73,7 @@ uint16_t uint16_swap_le_be_asm(const uint16_t a)
#elif defined(__mc68000__) && defined(__STORMGCC__)
inline static
static CDIO_INLINE
uint32_t uint32_swap_le_be_asm(uint32_t a __asm__("d0"))
{
/* __asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val)); */
@@ -75,7 +85,7 @@ uint32_t uint32_swap_le_be_asm(uint32_t a __asm__("d0"))
return(a);
}
inline static
static CDIO_INLINE
uint16_t uint16_swap_le_be_asm(uint16_t a __asm__("d0"))
{
__asm__("move.l %1,d0;rol.w #8,d0;move.l d0,%0"
@@ -90,7 +100,7 @@ uint16_t uint16_swap_le_be_asm(uint16_t a __asm__("d0"))
#elif 0 && defined(__i386__) && defined(__GNUC__)
inline static
static CDIO_INLINE
uint32_t uint32_swap_le_be_asm(uint32_t a)
{
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
@@ -102,7 +112,7 @@ uint32_t uint32_swap_le_be_asm(uint32_t a)
return(a);
}
inline static
static CDIO_INLINE
uint16_t uint16_swap_le_be_asm(uint16_t a)
{
__asm__("xchgb %b0,%h0" /* swap bytes */

View File

@@ -29,17 +29,10 @@
/** Application Interface or Protocol version number. If the public
* interface changes, we increase this number.
*/
#define CDIO_API_VERSION 5
#define CDIO_API_VERSION 6
#include <cdio/version.h>
#include <cdio/types.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <cdio/sector.h>
#ifdef __cplusplus

View File

@@ -26,16 +26,7 @@
#ifndef __CDIO_READ_H__
#define __CDIO_READ_H__
#ifndef EXTERNAL_LIBCDIO_CONFIG_H
#define EXTERNAL_LIBCDIO_CONFIG_H
/* Need for HAVE_SYS_TYPES_H */
#include <cdio/cdio_config.h>
#endif
#ifdef HAVE_SYS_TYPES_H
/* Some systems need this for off_t and ssize. */
#include <sys/types.h>
#endif
#include <cdio/types.h>
#ifdef __cplusplus
extern "C" {

View File

@@ -35,16 +35,6 @@
extern "C" {
#endif /* __cplusplus */
/* MSYS 1.0.10 with MinGW 3.4.2 (and perhaps others) don't have
S_ISSOCK() or S_ISLNK() macros, so we'll roll our own. */
#if !defined(HAVE_S_ISSOCK) && !defined(S_ISSOCK)
#define S_ISSOCK(st_mode) ((((st_mode)) & 0170000) == (0140000))
#endif
#if !defined(HAVE_S_ISLNK) && !defined(S_ISLNK)
#define S_ISLNK(st_mode) ((((st_mode)) & 0170000) == (0010000))
#endif
/*! An enumeration for some of the ISO_ROCK_* \#defines below. This isn't
really an enumeration one would really use in a program it is to
be helpful in debuggers where wants just to refer to the ISO_ROCK_*

View File

@@ -29,37 +29,35 @@
extern "C" {
#endif /* __cplusplus */
#ifndef EXTERNAL_LIBCDIO_CONFIG_H
#define EXTERNAL_LIBCDIO_CONFIG_H
#include <cdio/cdio_config.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
/* provide some C99 definitions */
#if defined(HAVE_SYS_TYPES_H)
/* If <sys/types.h> is not available on your platform please
contact the libcdio mailing list so that we can fix it! */
#if !defined(ARE_THERE_STILL_ENVS_WITHOUT_SYS_TYPES)
#include <sys/types.h>
#endif
#if defined(HAVE_STDINT_H)
# include <stdint.h>
#elif defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#elif defined(AMIGA) || defined(__linux__)
typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t;
typedef u_int32_t uint32_t;
typedef u_int64_t uint64_t;
#if defined(AMIGA)
typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t;
typedef u_int32_t uint32_t;
typedef u_int64_t uint64_t;
#else
/* warning ISO/IEC 9899:1999 <stdint.h> was missing and even <inttypes.h> */
/* fixme */
#endif /* HAVE_STDINT_H */
/* If <stdint.h> is not available on your platform please
contact the libcdio mailing list so that we can fix it!
For MSVC, you can find both a public domain stdint.h and
inttypes.h in the MSVC/missing directory of libcdio. */
#include <stdint.h>
#endif
typedef uint8_t ubyte;
/* MSVC does not define mode_t and ssize_t by default. The way
to compensate for missing UNIX types is to include a custom
unistd.h that defines them. Such a file is provided with
the libcdio source, in the MSVC/missing directory */
#if defined(_MSC_VER)
#include <unistd.h>
#endif
/* default HP/UX macros are broken */
#if defined(__hpux__)
# undef UINT16_C
@@ -106,15 +104,24 @@ typedef uint8_t ubyte;
#endif
#ifndef __cplusplus
# if defined(HAVE_STDBOOL_H)
# include <stdbool.h>
# else
/* ISO/IEC 9899:1999 <stdbool.h> missing -- enabling workaround */
# define false 0
# define true 1
# define bool uint8_t
# endif /*HAVE_STDBOOL_H*/
/* All the stdbool.h seem to define those */
#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#undef bool
#undef true
#undef false
#ifdef _Bool
#define bool _Bool
#else
#define bool int
#endif
#define true 1
#define false 0
#endif /* __bool_true_false_are_defined */
#endif /*C++*/
/* some GCC optimizations -- gcc 2.5+ */
@@ -148,18 +155,21 @@ typedef uint8_t ubyte;
/* for GCC we try to use GNUC_PACKED */
# define PRAGMA_BEGIN_PACKED
# define PRAGMA_END_PACKED
#elif defined(HAVE_ISOC99_PRAGMA)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
/* should work with most EDG-frontend based compilers */
# define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
# define PRAGMA_END_PACKED _Pragma("pack()")
#elif defined(_MSC_VER)
# define PRAGMA_BEGIN_PACKED __pragma(pack(push, 1))
# define PRAGMA_END_PACKED __pragma(pack(pop))
#else /* neither gcc nor _Pragma() available... */
/* ...so let's be naive and hope the regression testsuite is run... */
# define PRAGMA_BEGIN_PACKED
# define PRAGMA_END_PACKED
#endif
/**
* user-directed static branch prediction gcc 2.96+
/*
* user directed static branch prediction gcc 2.96+
*/
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
# define GNUC_LIKELY(x) __builtin_expect((x),true)