From cf0360a14e3306f270870cf68e78eb3cbcbf4fa9 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Fri, 20 Jan 2012 10:08:14 +0000
Subject: [PATCH] - Fixed compiler error on 64-bit systems not using GCC -
t_udbl optimization now also works on platforms that did not define
POLARSSL_HAVE_LONGLONG
---
include/polarssl/bignum.h | 7 +++++--
library/bignum.c | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/polarssl/bignum.h b/include/polarssl/bignum.h
index f830c087f..9afc948d0 100644
--- a/include/polarssl/bignum.h
+++ b/include/polarssl/bignum.h
@@ -30,6 +30,8 @@
#include
#include
+#include "config.h"
+
#define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An error occurred while reading from or writing to a file. */
#define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Bad input parameters to function. */
#define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006 /**< There is an invalid character in the digit string. */
@@ -95,11 +97,12 @@ typedef unsigned long t_udbl;
#if defined(_MSC_VER) && defined(_M_IX86)
typedef unsigned __int64 t_udbl;
#else
- #if defined(__amd64__) || defined(__x86_64__) || \
+ #if defined(__GNUC__) && ( \
+ defined(__amd64__) || defined(__x86_64__) || \
defined(__ppc64__) || defined(__powerpc64__) || \
defined(__ia64__) || defined(__alpha__) || \
(defined(__sparc__) && defined(__arch64__)) || \
- defined(__s390x__)
+ defined(__s390x__) )
typedef unsigned int t_udbl __attribute__((mode(TI)));
#else
#if defined(POLARSSL_HAVE_LONGLONG)
diff --git a/library/bignum.c b/library/bignum.c
index 9dff9914d..162b3f0ab 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -1101,7 +1101,7 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B )
Z.p[i - t - 1] = ~0;
else
{
-#if defined(POLARSSL_HAVE_LONGLONG)
+#if defined(t_udbl)
t_udbl r;
r = (t_udbl) X.p[i] << biL;