summaryrefslogtreecommitdiff
path: root/extra/yassl/taocrypt/include/misc.hpp
diff options
context:
space:
mode:
authorunknown <svoj@mysql.com>2005-05-31 20:56:32 +0500
committerunknown <svoj@mysql.com>2005-05-31 20:56:32 +0500
commitb3d646e6f8b3b53f43ecb4f1cfefd2863d689390 (patch)
tree039a0d9d6e565ecbf39c2c04fed0bdf039351125 /extra/yassl/taocrypt/include/misc.hpp
parent1c7b61e3aef5227165a9957ead000e67935708b2 (diff)
downloadmariadb-git-b3d646e6f8b3b53f43ecb4f1cfefd2863d689390.tar.gz
WL#2286 - Compile MySQL w/YASSL support
merge with latest yaSSL, move templates instantiation into separate file where it is possible extra/yassl/include/buffer.hpp: merge with latest yaSSL extra/yassl/include/crypto_wrapper.hpp: merge with latest yaSSL extra/yassl/include/socket_wrapper.hpp: merge with latest yaSSL extra/yassl/include/yassl_imp.hpp: merge with latest yaSSL extra/yassl/include/yassl_types.hpp: merge with latest yaSSL extra/yassl/mySTL/helpers.hpp: merge with latest yaSSL extra/yassl/mySTL/list.hpp: merge with latest yaSSL extra/yassl/mySTL/memory.hpp: merge with latest yaSSL extra/yassl/mySTL/vector.hpp: merge with latest yaSSL extra/yassl/src/Makefile.am: Include template_instnt.cpp into libyassl_a_SOURCES. extra/yassl/src/buffer.cpp: merge with latest yaSSL extra/yassl/src/cert_wrapper.cpp: merge with latest yaSSL extra/yassl/src/crypto_wrapper.cpp: merge with latest yaSSL extra/yassl/src/handshake.cpp: merge with latest yaSSL extra/yassl/src/lock.cpp: merge with latest yaSSL extra/yassl/src/log.cpp: merge with latest yaSSL extra/yassl/src/socket_wrapper.cpp: merge with latest yaSSL extra/yassl/src/ssl.cpp: merge with latest yaSSL extra/yassl/src/timer.cpp: merge with latest yaSSL extra/yassl/src/yassl_error.cpp: merge with latest yaSSL extra/yassl/src/yassl_imp.cpp: merge with latest yaSSL extra/yassl/src/yassl_int.cpp: merge with latest yaSSL extra/yassl/taocrypt/include/algebra.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/asn.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/block.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/hash.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/integer.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/misc.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/modes.hpp: merge with latest yaSSL extra/yassl/taocrypt/include/runtime.hpp: merge with latest yaSSL extra/yassl/taocrypt/src/Makefile.am: Include template_instnt.cpp into libtaocrypt_a_SOURCES. extra/yassl/taocrypt/src/aestables.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/algebra.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/arc4.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/asn.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/coding.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/dh.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/dsa.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/file.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/integer.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/misc.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/random.cpp: merge with latest yaSSL extra/yassl/taocrypt/src/rsa.cpp: merge with latest yaSSL
Diffstat (limited to 'extra/yassl/taocrypt/include/misc.hpp')
-rw-r--r--extra/yassl/taocrypt/include/misc.hpp100
1 files changed, 42 insertions, 58 deletions
diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp
index de8cbb30fcb..812cdd93879 100644
--- a/extra/yassl/taocrypt/include/misc.hpp
+++ b/extra/yassl/taocrypt/include/misc.hpp
@@ -27,75 +27,59 @@
#include <stdlib.h>
#include <assert.h>
#include <string.h>
+#include "types.hpp"
+#include "type_traits.hpp"
+/*
+namespace GCC_ABI {
+ extern "C" int __cxa_pure_virtual();
+} */
namespace TaoCrypt {
+// using GCC_ABI::__cxa_pure_virtual;
-// define this if running on a big-endian CPU
-#if !defined(LITTLE_ENDIAN_ORDER) && (defined(__BIG_ENDIAN__) || \
- defined(__sparc) || defined(__sparc__) || defined(__hppa__) || \
- defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__)))
- #define BIG_ENDIAN_ORDER
-#endif
+// library allocation
+struct new_t {}; // TaoCrypt New type
+extern new_t tc; // pass in parameter
-#ifndef BIG_ENDIAN_ORDER
- #define LITTLE_ENDIAN_ORDER
-#endif
+} // namespace TaoCrypt
+void* operator new (size_t, TaoCrypt::new_t);
+void* operator new[](size_t, TaoCrypt::new_t);
-typedef unsigned char byte;
-typedef unsigned short word16;
-typedef unsigned int word32;
-
-#if defined(__GNUC__) || defined(__MWERKS__) || defined(_LONGLONG_TYPE)
- #define WORD64_AVAILABLE
- typedef unsigned long long word64;
- #define W64LIT(x) x##LL
-#elif defined(_MSC_VER) || defined(__BCPLUSPLUS__)
- #define WORD64_AVAILABLE
- typedef unsigned __int64 word64;
- #define W64LIT(x) x##ui64
-#elif defined(__DECCXX)
- #define WORD64_AVAILABLE
- typedef unsigned long word64;
-#endif
+void operator delete (void*, TaoCrypt::new_t);
+void operator delete[](void*, TaoCrypt::new_t);
-// define largest word type
-#ifdef WORD64_AVAILABLE
- typedef word64 lword;
-#else
- typedef word32 lword;
-#endif
-// FIXME the !defined(__sun) is a temporarely solution until asm for
-// __x86_64__ and Solaris is written
-#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
- defined(__mips64) || (defined(__x86_64__) && !defined(__sun))
-// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers
-// don't allow any way to access the 64-bit by 64-bit multiply instruction
-// without using assembly, so in order to use word64 as word, the assembly
-// instruction must be defined in Dword::Multiply().
- typedef word32 hword;
- typedef word64 word;
-#else
- #define TAOCRYPT_NATIVE_DWORD_AVAILABLE
- #ifdef WORD64_AVAILABLE
- #define TAOCRYPT_SLOW_WORD64
- // define this if your CPU is not64-bit to use alternative code
- // that avoids word64
- typedef word16 hword;
- typedef word32 word;
- typedef word64 dword;
- #else
- typedef byte hword;
- typedef word16 word;
- typedef word32 dword;
- #endif
-#endif
+namespace TaoCrypt {
-const word32 WORD_SIZE = sizeof(word);
-const word32 WORD_BITS = WORD_SIZE * 8;
+template<typename T>
+void tcDelete(T* ptr)
+{
+ if (ptr) ptr->~T();
+ ::operator delete(ptr, TaoCrypt::tc);
+}
+
+template<typename T>
+void tcArrayDelete(T* ptr)
+{
+ // can't do array placement destruction since not tracking size in
+ // allocation, only allow builtins to use array placement since they
+ // don't need destructors called
+ typedef char builtin[IsFundamentalType<T>::Yes ? 1 : -1];
+ (void)sizeof(builtin);
+
+ ::operator delete[](ptr, TaoCrypt::tc);
+}
+
+
+// to resolve compiler generated operator delete on base classes with
+// virtual destructors, make sure doesn't get called
+class virtual_base {
+public:
+ static void operator delete(void*) { assert(0); }
+};
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)