Commit 89fb7ea3 authored by David McGrew's avatar David McGrew

Fixed bswap_32, bswap_64 (#defines were a little off)

parent fec49ddc
......@@ -15,6 +15,10 @@
#define WORDS_BIGENDIAN 0
/* if we're on an intel x86, define this to use inlined asm */
#define HAVE_X86 0
/* check for <stdint.h> or <machine/types.h> */
#define HAVE_STDINT_H 0
......
......@@ -5296,8 +5296,10 @@ host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "host_cpu: $host_cpu"
if test $host_cpu = x86; then
echo "x86 cpu found" # should use inline assembly
echo "x86 cpu found"
fi
case $host_cpu in
......@@ -5305,7 +5307,11 @@ case $host_cpu in
cat >>confdefs.h <<\_ACEOF
#define CPU_CISC 1
_ACEOF
;;
cat >>confdefs.h <<\_ACEOF
#define HAVE_X86 1
_ACEOF
;; # use x86 inline assembly
* )
cat >>confdefs.h <<\_ACEOF
#define CPU_RISC 1
......
......@@ -52,14 +52,17 @@ AC_C_BIGENDIAN
AC_CANONICAL_HOST
echo "host_cpu: $host_cpu"
if test $host_cpu = x86; then
echo "x86 cpu found" # should use inline assembly
echo "x86 cpu found"
fi
dnl check host_cpu type, set defines appropriately
case $host_cpu in
i*86 )
AC_DEFINE(CPU_CISC);;
AC_DEFINE(CPU_CISC)
AC_DEFINE(HAVE_X86, 1);; # use x86 inline assembly
* )
AC_DEFINE(CPU_RISC);;
esac
......
......@@ -14,12 +14,16 @@
/* if we're on a big endian machine, we need to define this */
#define WORDS_BIGENDIAN 1
#define WORDS_BIGENDIAN 0
/* if we're on an intel x86, define this to use inlined asm */
#define HAVE_X86 1
/* check for <stdint.h> or <machine/types.h> */
#define HAVE_STDINT_H 1
#define HAVE_MACHINE_TYPES_H 1
#define HAVE_MACHINE_TYPES_H 0
#define HAVE_SYS_INT_TYPES_H 0
/* check if an unsigned 64-bit integer is supported natively */
......@@ -82,8 +86,8 @@
*
*/
#define CPU_RISC 1
#define CPU_CISC 0
#define CPU_RISC 0
#define CPU_CISC 1
#define CPU_ALTIVEC 0
/*
......
......@@ -181,7 +181,7 @@ typedef struct {
#define debug_print2(mod, format, arg1,arg2) \
if (mod.on) err_report(err_level_debug, ("%s: " format), mod.name, arg1,arg2)
#else
#else
/* define macros to do nothing */
#define debug_print(mod, format, arg)
......
......@@ -413,11 +413,10 @@ octet_string_set_to_zero(octet_t *s, int len) {
inline uint32_t
bswap_32(uint32_t v) {
#ifdef WORDS_BIGENDIAN
/* assume that we're on a big-endian machine */
/* htonl() does nothing */
#if WORDS_BIGENDIAN
/* we're on a big-endian machine, so we do nothing here */
#else
#if CPU_CISC
#if HAVE_X86
/* assume that we're on an Intel x86 with x > 3 */
asm("bswap %0" : "=r" (v) : "0" (v));
#else
......@@ -430,13 +429,14 @@ bswap_32(uint32_t v) {
inline uint64_t
bswap_64(uint64_t v) {
#ifdef WORDS_BIGENDIAN
/* assume that we're on a big-endian machine */
/* FIX? */
#if WORDS_BIGENDIAN
/* we're on a big-endian machine, so we do nothing here */
#else
#if CPU_CISC /* assume that we're on an Intel x86 with x > 3 */
#if HAVE_U_LONG_LONG
/* use the native 64-bit math */
v= (bswap_32(v >> 32)) | ((uint64_t)bswap_32((uint32_t)v)) << 32 ;
#else
/* use the make64 functions to do 64-bit math */
v = make64(htonl(low32(v)),htonl(high32(v)));
#endif
#endif
......
......@@ -53,7 +53,7 @@ main() {
#if WORDS_BIGENDIAN
printf("CPU set to big-endian\t\t\t(WORDS_BIGENDIAN == 1)\n");
#else
printf("CPU set to little-endian\t\t\t(WORDS_BIGENDIAN == 0)\n");
printf("CPU set to little-endian\t\t(WORDS_BIGENDIAN == 0)\n");
#endif
......
......@@ -782,6 +782,7 @@ srtp_stream_init(srtp_stream_ctx_t *srtp,
if (status) return status;
/* run auth func over ROC, put result into auth_tag */
debug_print(mod_srtp, "estimated packet index: %016llx", est);
status = auth_compute(stream->rtp_auth, (octet_t *)&est, 4, auth_tag);
debug_print(mod_srtp, "srtp auth tag: %s",
octet_string_hex_string(auth_tag, tag_len));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment