port to Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
change makefile to compile for both i386 and x86_64 on Darwin/Mac OS Xpull/2/head
parent
954fed3d5d
commit
1315a7bc9a
|
|
@ -31,7 +31,9 @@ GAS217_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler v
|
|||
ISMINGW = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "mingw")
|
||||
|
||||
ifneq ($(GCC42_OR_LATER),0)
|
||||
ifneq ($(UNAME),Darwin)
|
||||
ifeq ($(UNAME),Darwin)
|
||||
CXXFLAGS += -arch x86_64 -arch i386
|
||||
else
|
||||
CXXFLAGS += -march=native -mtune=native
|
||||
endif
|
||||
endif
|
||||
|
|
@ -86,6 +88,9 @@ LDLIBS += -lnsl -lsocket
|
|||
ifeq ($(CXX),CC) # override flags for CC (Solaris native C++ compiler)
|
||||
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef -m$(shell isainfo -b)
|
||||
LDFLAGS =
|
||||
AR = CC
|
||||
ARFLAGS = -xar -o
|
||||
RANLIB = true
|
||||
ifeq ($(ISX86),1)
|
||||
# SSE2 intrinsics should work in Sun Studio 12, but we're not using SSE2 intrinsics anymore
|
||||
# CXXFLAGS += -xarch=sse2 -D__SSE2__
|
||||
|
|
|
|||
2
idea.cpp
2
idea.cpp
|
|
@ -129,7 +129,7 @@ static inline IDEA::Word AddInv(IDEA::Word x)
|
|||
void IDEA::Base::DeKey()
|
||||
{
|
||||
FixedSizeSecBlock<IDEA::Word, 6*ROUNDS+4> tempkey;
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
for (i=0; i<ROUNDS; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ static word AtomicInverseModPower2(word A)
|
|||
#elif defined(__DECCXX)
|
||||
#define MultiplyWordsLoHi(p0, p1, a, b) p0 = a*b; p1 = asm("umulh %a0, %a1, %v0", a, b);
|
||||
#elif defined(__x86_64__)
|
||||
#ifdef __SUNPRO_CC
|
||||
#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5100
|
||||
// Sun Studio's gcc-style inline assembly is heavily bugged as of version 5.9 Patch 124864-09 2008/12/16, but this one works
|
||||
#define MultiplyWordsLoHi(p0, p1, a, b) asm ("mulq %3" : "=a"(p0), "=d"(p1) : "a"(a), "r"(b) : "cc");
|
||||
#else
|
||||
|
|
|
|||
5
stdcpp.h
5
stdcpp.h
|
|
@ -14,6 +14,11 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#ifdef __SUNPRO_CC
|
||||
// workaround needed on Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
|
||||
#include <vector.cc>
|
||||
#endif
|
||||
|
||||
// for alloca
|
||||
#ifdef __sun
|
||||
#include <alloca.h>
|
||||
|
|
|
|||
12
tea.cpp
12
tea.cpp
|
|
@ -62,8 +62,14 @@ void XTEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by
|
|||
word32 y, z;
|
||||
Block::Get(inBlock)(y)(z);
|
||||
|
||||
#ifdef __SUNPRO_CC
|
||||
// workaround needed on Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
|
||||
size_t sum = 0;
|
||||
while ((sum&0xffffffff) != m_limit)
|
||||
#else
|
||||
word32 sum = 0;
|
||||
while (sum != m_limit)
|
||||
#endif
|
||||
{
|
||||
y += (z<<4 ^ z>>5) + z ^ sum + m_k[sum&3];
|
||||
sum += DELTA;
|
||||
|
|
@ -78,8 +84,14 @@ void XTEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by
|
|||
word32 y, z;
|
||||
Block::Get(inBlock)(y)(z);
|
||||
|
||||
#ifdef __SUNPRO_CC
|
||||
// workaround needed on Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
|
||||
size_t sum = m_limit;
|
||||
while ((sum&0xffffffff) != 0)
|
||||
#else
|
||||
word32 sum = m_limit;
|
||||
while (sum != 0)
|
||||
#endif
|
||||
{
|
||||
z -= (y<<4 ^ y>>5) + y ^ sum + m_k[sum>>11 & 3];
|
||||
sum -= DELTA;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,10 @@ bool TestSettings()
|
|||
|
||||
cout << "\nTesting Settings...\n\n";
|
||||
|
||||
if (*(word32 *)"\x01\x02\x03\x04" == 0x04030201L)
|
||||
word32 w;
|
||||
memcpy_s(&w, sizeof(w), "\x01\x02\x03\x04", 4);
|
||||
|
||||
if (w == 0x04030201L)
|
||||
{
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
cout << "passed: ";
|
||||
|
|
@ -140,7 +143,7 @@ bool TestSettings()
|
|||
#endif
|
||||
cout << "Your machine is little endian.\n";
|
||||
}
|
||||
else if (*(word32 *)"\x01\x02\x03\x04" == 0x01020304L)
|
||||
else if (w == 0x01020304L)
|
||||
{
|
||||
#ifndef IS_LITTLE_ENDIAN
|
||||
cout << "passed: ";
|
||||
|
|
|
|||
36
wake.cpp
36
wake.cpp
|
|
@ -16,22 +16,24 @@ void WAKE_TestInstantiations()
|
|||
inline word32 WAKE_Base::M(word32 x, word32 y)
|
||||
{
|
||||
word32 w = x+y;
|
||||
return (w>>8) ^ t[(byte)w];
|
||||
return (w>>8) ^ t[w & 0xff];
|
||||
}
|
||||
|
||||
void WAKE_Base::GenKey(word32 k0, word32 k1, word32 k2, word32 k3)
|
||||
{
|
||||
long x, z;
|
||||
int p ;
|
||||
static long tt[10]= {
|
||||
0x726a8f3bL, // table
|
||||
0xe69a3b5cL,
|
||||
0xd3c71fe5L,
|
||||
0xab3c73d2L,
|
||||
0x4d3a8eb3L,
|
||||
0x0396d6e8L,
|
||||
0x3d4c2f7aL,
|
||||
0x9ee27cf3L, } ;
|
||||
// this code is mostly copied from David Wheeler's paper "A Bulk Data Encryption Algorithm"
|
||||
signed int x, z, p;
|
||||
// x and z were declared as "long" in Wheeler's paper, which is a signed type. I don't know if that was intentional, but it's too late to change it now. -- Wei 7/4/2010
|
||||
CRYPTOPP_COMPILE_ASSERT(sizeof(x) == 4);
|
||||
static int tt[10]= {
|
||||
0x726a8f3b, // table
|
||||
0xe69a3b5c,
|
||||
0xd3c71fe5,
|
||||
0xab3c73d2,
|
||||
0x4d3a8eb3,
|
||||
0x0396d6e8,
|
||||
0x3d4c2f7a,
|
||||
0x9ee27cf3, } ;
|
||||
t[0] = k0;
|
||||
t[1] = k1;
|
||||
t[2] = k2;
|
||||
|
|
@ -39,16 +41,16 @@ void WAKE_Base::GenKey(word32 k0, word32 k1, word32 k2, word32 k3)
|
|||
for (p=4 ; p<256 ; p++)
|
||||
{
|
||||
x=t[p-4]+t[p-1] ; // fill t
|
||||
t[p]= (x>>3) ^ tt[byte(x&7)] ;
|
||||
t[p]= (x>>3) ^ tt[x&7] ;
|
||||
}
|
||||
|
||||
for (p=0 ; p<23 ; p++)
|
||||
t[p]+=t[p+89] ; // mix first entries
|
||||
x=t[33] ; z=t[59] | 0x01000001L ;
|
||||
z=z&0xff7fffffL ;
|
||||
x=t[33] ; z=t[59] | 0x01000001 ;
|
||||
z=z&0xff7fffff ;
|
||||
for (p=0 ; p<256 ; p++) { //change top byte to
|
||||
x=(x&0xff7fffffL)+z ; // a permutation etc
|
||||
t[p]=(t[p] & 0x00ffffffL) ^ x ; }
|
||||
x=(x&0xff7fffff)+z ; // a permutation etc
|
||||
t[p]=(t[p] & 0x00ffffff) ^ x ; }
|
||||
|
||||
t[256]=t[0] ;
|
||||
byte y=byte(x);
|
||||
|
|
|
|||
Loading…
Reference in New Issue