[Asterisk-cvs] asterisk/include/asterisk endian.h, NONE,
1.1 unaligned.h, NONE, 1.1 frame.h, 1.44, 1.45
markster at lists.digium.com
markster at lists.digium.com
Mon Mar 28 22:55:39 CST 2005
- Previous message: [Asterisk-cvs]
asterisk/channels chan_alsa.c, 1.38, 1.39 chan_oss.c,
1.45, 1.46 iax2-parser.c, 1.38, 1.39
- Next message: [Asterisk-cvs] asterisk/formats format_g726.c, 1.7,
1.8 format_g729.c, 1.16, 1.17 format_gsm.c, 1.21,
1.22 format_h263.c, 1.8, 1.9 format_ilbc.c, 1.9,
1.10 format_jpeg.c, 1.7, 1.8 format_pcm.c, 1.17,
1.18 format_pcm_alaw.c, 1.15, 1.16 format_sln.c, 1.4,
1.5 format_vox.c, 1.18, 1.19 format_wav.c, 1.21,
1.22 format_wav_gsm.c, 1.30, 1.31
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk/include/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv6904/include/asterisk
Modified Files:
frame.h
Added Files:
endian.h unaligned.h
Log Message:
Simplify endianness and fix for unaligned reads (bug #3867)
--- NEW FILE: endian.h ---
/*
* Asterisk -- A telephony toolkit for Linux.
*
* Asterisk internal frame definitions.
*
* Copyright (C) 1999 - 2005, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
* This program is free software, distributed under the terms of
* the GNU Lesser General Public License. Other components of
* Asterisk are distributed under The GNU General Public License
* only.
*/
#ifndef _ASTERISK_ENDIAN_H
#define _ASTERISK_ENDIAN_H
/*
* Autodetect system endianess
*/
#if defined( __OpenBSD__ )
# include <machine/types.h>
# include <sys/endian.h>
#elif defined( __FreeBSD__ ) || defined( __NetBSD__ )
# include <sys/types.h>
# include <sys/endian.h>
#elif defined( BSD ) && ( BSD >= 199103 ) || defined(__APPLE__)
# include <machine/endian.h>
#elif defined ( SOLARIS )
# include <solaris-compat/compat.h>
#elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
# include <endian.h>
#if !defined(__APPLE__)
# include <byteswap.h>
#endif
#elif defined( linux )
# include <endian.h>
#endif
#ifndef BYTE_ORDER
#define BYTE_ORDER __BYTE_ORDER
#endif
#ifndef __BYTE_ORDER
#error Endianess needs to be defined
#endif
#endif /* _ASTERISK_ENDIAN_H */
--- NEW FILE: unaligned.h ---
/*
* Asterisk -- A telephony toolkit for Linux.
*
* Asterisk internal frame definitions.
*
* Copyright (C) 1999 - 2005, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
* This program is free software, distributed under the terms of
* the GNU Lesser General Public License. Other components of
* Asterisk are distributed under The GNU General Public License
* only.
*/
#ifndef _ASTERISK_UNALIGNED_H
#define _ASTERISK_UNALIGNED_H
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#ifdef __GNUC__
/* If we just tell GCC what's going on, we can trust it to behave optimally */
static inline unsigned int get_unaligned_uint32(void *p)
{
struct { unsigned int d; } __attribute__((packed)) *pp = (void *)p;
return pp->d;
}
static inline unsigned short get_unaligned_uint16(void *p)
{
struct { unsigned short d; } __attribute__((packed)) *pp = (void *)p;
return pp->d;
}
static inline void put_unaligned_uint32(void *p, unsigned int datum)
{
struct { unsigned int d; } __attribute__((packed)) *pp = (void *)p;
pp->d = datum;
}
static inline void put_unaligned_uint16(void *p, unsigned short datum)
{
struct { unsigned short d; } __attribute__((packed)) *pp = (void *)p;
pp->d = datum;
}
#elif defined(SOLARIS) && defined(__sparc__)
static inline unsigned int get_unaligned_uint32(void *p)
{
unsigned char *cp = p;
return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3];
}
static inline unsigned short get_unaligned_uint16(void *p)
{
unsigned char *cp = p;
return (cp[0] << 8) | cp[1] ;
}
static inline void put_unaligned_uint32(void *p, unsigned int datum)
{
unsigned char *cp = p;
cp[0] = datum >> 24;
cp[1] = datum >> 16;
cp[2] = datum >> 8;
cp[3] = datum;
}
static inline void put_unaligned_uint16(void *p, unsigned int datum)
{
unsigned char *cp = p;
cp[0] = datum >> 8;
cp[1] = datum;
}
#else /* Not GCC, not Solaris/SPARC. Assume we can handle direct load/store. */
#define get_unaligned_uint32(p) (*((unsigned int *)(p)))
#define get_unaligned_uint16(p) (*((unsigned short *)(p)))
#define put_unaligned_uint32(p,d) do { unsigned int *__P = (p); *__P = d; } while(0)
#define put_unaligned_uint16(p,d) do { unsigned short *__P = (p); *__P = d; } while(0)
#endif
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif /* _ASTERISK_UNALIGNED_H */
Index: frame.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/frame.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- frame.h 21 Mar 2005 04:30:57 -0000 1.44
+++ frame.h 29 Mar 2005 04:49:24 -0000 1.45
@@ -22,45 +22,7 @@
#include <sys/types.h>
#include <sys/time.h>
-
-#ifdef SOLARIS
-#include "solaris-compat/compat.h"
-#endif
-
-/*
- * Autodetect system endianess
- */
-#ifndef __BYTE_ORDER
-#ifdef __linux__
-#include <endian.h>
-#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
-#if defined(__OpenBSD__)
-#include <machine/types.h>
-#endif /* __OpenBSD__ */
-#include <machine/endian.h>
-#define __BYTE_ORDER BYTE_ORDER
-#define __LITTLE_ENDIAN LITTLE_ENDIAN
-#define __BIG_ENDIAN BIG_ENDIAN
-#else
-#ifdef __LITTLE_ENDIAN__
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif /* __LITTLE_ENDIAN */
-
-#if defined(i386) || defined(__i386__)
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif /* defined i386 */
-
-#if defined(sun) && defined(unix) && defined(sparc)
-#define __BYTE_ORDER __BIG_ENDIAN
-#endif /* sun unix sparc */
-
-#endif /* linux */
-
-#endif /* __BYTE_ORDER */
-
-#ifndef __BYTE_ORDER
-#error Need to know endianess
-#endif /* __BYTE_ORDER */
+#include <asterisk/endian.h>
struct ast_codec_pref {
char order[32];
- Previous message: [Asterisk-cvs]
asterisk/channels chan_alsa.c, 1.38, 1.39 chan_oss.c,
1.45, 1.46 iax2-parser.c, 1.38, 1.39
- Next message: [Asterisk-cvs] asterisk/formats format_g726.c, 1.7,
1.8 format_g729.c, 1.16, 1.17 format_gsm.c, 1.21,
1.22 format_h263.c, 1.8, 1.9 format_ilbc.c, 1.9,
1.10 format_jpeg.c, 1.7, 1.8 format_pcm.c, 1.17,
1.18 format_pcm_alaw.c, 1.15, 1.16 format_sln.c, 1.4,
1.5 format_vox.c, 1.18, 1.19 format_wav.c, 1.21,
1.22 format_wav_gsm.c, 1.30, 1.31
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list