First Commit
This commit is contained in:
214
externals/cryptopp/TestPrograms/dump2def.cpp
vendored
Normal file
214
externals/cryptopp/TestPrograms/dump2def.cpp
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
// dump2def.cpp - Written and placed in public domain by Jeffrey Walton
|
||||
// Create a module definitions file from a dumpbin file.
|
||||
// dump2def can be used to create a list of exports from
|
||||
// a static library. Then, the exports can used to build
|
||||
// a dynamic link library with the same exports.
|
||||
//
|
||||
// If you wish to compile this source file using cl.exe, then:
|
||||
// cl.exe /DNDEBUG /Oi /Oy /O2 /Zi /TP /GR /EHsc /MT dump2def.cpp
|
||||
//
|
||||
// The intended workflow in Crypto++ is:
|
||||
//
|
||||
// 1. Open a Developer Prompt
|
||||
// 2. CD to cryptopp/ directory
|
||||
// 3. nmake /f cryptest.nmake cryptopp.dll
|
||||
//
|
||||
// The cryptopp.dll recipe first builds cryptlib.lib. Then it calls
|
||||
// dumpbin.exe to export all symbols from cryptlib.lib and writes them
|
||||
// to cryptopp.dump. The recipe then calls dump2def.exe to create a
|
||||
// module definition file. Finally, the recipe builds cryptopp.dll
|
||||
// using the module definition file cryptopp.def. The linker creates
|
||||
// the import lib cryptopp.lib and export cryptopp.exp automatically.
|
||||
//
|
||||
// This is only "half the problem solved" for those who wish to use
|
||||
// a DLL. The program must import the import lib cryptopp.lib. Then
|
||||
// the program must ensure the library headers export the symbol or
|
||||
// class with CRYPTOPP_DLL. CRYPTOPP_DLL is only present on some classes
|
||||
// because the FIPS module only allowed approved algorithms like AES and
|
||||
// SHA. Other classes like Base64Encoder and HexEncoder lack CRYPTOPP_DLL.
|
||||
//
|
||||
// CRYPTOPP_DLL simply adds declspec(dllimport) when CRYPTOPP_IMPORTS is
|
||||
// defined. The limitation of requiring declspec(dllimport) is imposed by
|
||||
// Microsoft. Microsoft does not allow a program to "import everything".
|
||||
//
|
||||
// If you would like to read more about the FIPS module and the pain it
|
||||
// causes then see https://www.cryptopp.com/wiki/FIPS_DLL. In fact we
|
||||
// recommend you delete the CryptDll and DllTest projects from the
|
||||
// Visual Studio solution file.
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
// Friendly name
|
||||
#define LIBRARY_DESC "Crypto++ Library"
|
||||
typedef std::set<std::string> SymbolMap;
|
||||
|
||||
const int ErrorSuccess = 0;
|
||||
const int ErrorDumpExtension = 1;
|
||||
const int ErrorTooFewOpts = 2;
|
||||
const int ErrorTooManyOpts = 3;
|
||||
const int ErrorOpenInputFailed = 4;
|
||||
const int ErrorOpenOutputFailed = 5;
|
||||
const int ErrorReadException = 6;
|
||||
const int ErrorWriteException = 7;
|
||||
|
||||
void PrintHelpAndExit(int code)
|
||||
{
|
||||
std::cout << "dump2def - create a module definitions file from a dumpbin file" << std::endl;
|
||||
std::cout << " Written and placed in public domain by Jeffrey Walton" << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case ErrorDumpExtension:
|
||||
std::cout << "Error: input file is missing \".dump\" extension.\n" << std::endl;
|
||||
break;
|
||||
case ErrorTooFewOpts:
|
||||
std::cout << "Error: Too few options were supplied.\n" << std::endl;
|
||||
break;
|
||||
case ErrorTooManyOpts:
|
||||
std::cout << "Error: Too many options were supplied.\n" << std::endl;
|
||||
break;
|
||||
case ErrorOpenInputFailed:
|
||||
std::cout << "Error: Failed to open input file.\n" << std::endl;
|
||||
break;
|
||||
case ErrorOpenOutputFailed:
|
||||
std::cout << "Error: Failed to open output file.\n" << std::endl;
|
||||
break;
|
||||
default:
|
||||
;;
|
||||
}
|
||||
|
||||
std::cout << "Usage: " << std::endl;
|
||||
|
||||
std::cout << " dump2def <infile>" << std::endl;
|
||||
std::cout << " - Create a def file from <infile> and write it to a file with" << std::endl;
|
||||
std::cout << " the same name as <infile> but using the .def extension" << std::endl;
|
||||
|
||||
std::cout << " dump2def <infile> <outfile>" << std::endl;
|
||||
std::cout << " - Create a def file from <infile> and write it to <outfile>" << std::endl;
|
||||
|
||||
std::exit((code == ErrorSuccess ? 0 : 1));
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// ******************** Handle Options ******************** //
|
||||
|
||||
// Convenience item
|
||||
std::vector<std::string> opts;
|
||||
for (size_t i=0; i<argc; ++i)
|
||||
opts.push_back(argv[i]);
|
||||
|
||||
// Look for help
|
||||
std::string opt = (opts.size() > 1 ? opts[1].substr(0,2) : "");
|
||||
if (opt == "/h" || opt == "-h" || opt == "/?" || opt == "-?")
|
||||
PrintHelpAndExit(ErrorSuccess);
|
||||
|
||||
// Add <outfile> as needed
|
||||
if (opts.size() == 2)
|
||||
{
|
||||
std::string outfile = opts[1];
|
||||
std::string::size_type pos = outfile.length() < 5 ? std::string::npos : outfile.length() - 5;
|
||||
if (pos == std::string::npos || outfile.substr(pos) != ".dump")
|
||||
PrintHelpAndExit(ErrorDumpExtension);
|
||||
|
||||
outfile.replace(pos, 5, ".def");
|
||||
opts.push_back(outfile);
|
||||
}
|
||||
|
||||
// Check or exit
|
||||
if (opts.size() < 2)
|
||||
PrintHelpAndExit(ErrorTooFewOpts);
|
||||
if (opts.size() > 3)
|
||||
PrintHelpAndExit(ErrorTooManyOpts);
|
||||
|
||||
// ******************** Read MAP file ******************** //
|
||||
|
||||
SymbolMap symbols;
|
||||
|
||||
try
|
||||
{
|
||||
std::ifstream infile(opts[1].c_str());
|
||||
|
||||
if (infile.is_open() == false)
|
||||
PrintHelpAndExit(ErrorOpenInputFailed);
|
||||
|
||||
std::string::size_type pos;
|
||||
std::string line;
|
||||
|
||||
// Find start of the symbol table
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
pos = line.find("public symbols");
|
||||
if (pos == std::string::npos) { continue; }
|
||||
|
||||
// Eat the whitespace after the table heading
|
||||
infile >> std::ws;
|
||||
break;
|
||||
}
|
||||
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
// End of table
|
||||
if (line.empty()) { break; }
|
||||
|
||||
std::istringstream iss(line);
|
||||
std::string address, symbol;
|
||||
iss >> address >> symbol;
|
||||
|
||||
symbols.insert(symbol);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
std::cerr << "Unexpected exception:" << std::endl;
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
PrintHelpAndExit(ErrorReadException);
|
||||
}
|
||||
|
||||
// ******************** Write DEF file ******************** //
|
||||
|
||||
try
|
||||
{
|
||||
std::ofstream outfile(opts[2].c_str());
|
||||
|
||||
if (outfile.is_open() == false)
|
||||
PrintHelpAndExit(ErrorOpenOutputFailed);
|
||||
|
||||
// Library name, cryptopp.dll
|
||||
std::string name = opts[2];
|
||||
std::string::size_type pos = name.find_last_of(".");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
name.erase(pos);
|
||||
|
||||
outfile << "LIBRARY " << name << std::endl;
|
||||
outfile << "DESCRIPTION \"" << LIBRARY_DESC << "\"" << std::endl;
|
||||
outfile << "EXPORTS" << std::endl;
|
||||
outfile << std::endl;
|
||||
|
||||
outfile << "\t;; " << symbols.size() << " symbols" << std::endl;
|
||||
|
||||
// Symbols from our object files
|
||||
SymbolMap::const_iterator it = symbols.begin();
|
||||
for ( ; it != symbols.end(); ++it)
|
||||
outfile << "\t" << *it << std::endl;
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
std::cerr << "Unexpected exception:" << std::endl;
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
PrintHelpAndExit(ErrorWriteException);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_32bit.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_32bit.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <cstddef>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
enum {N = (sizeof(std::size_t) == 4 ? 4 : -1)};
|
||||
int x[N];
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_64bit.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_64bit.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <cstddef>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
enum {N = (sizeof(std::size_t) == 8 ? 8 : -1)};
|
||||
int x[N];
|
||||
return 0;
|
||||
}
|
||||
6
externals/cryptopp/TestPrograms/test_arm_acle_header.cpp
vendored
Normal file
6
externals/cryptopp/TestPrograms/test_arm_acle_header.cpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <arm_acle.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
14
externals/cryptopp/TestPrograms/test_arm_aes.cpp
vendored
Normal file
14
externals/cryptopp/TestPrograms/test_arm_aes.cpp
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint8x16_t x={0};
|
||||
x=vaeseq_u8(x,x);
|
||||
x=vaesmcq_u8(x);
|
||||
x=vaesdq_u8(x,x);
|
||||
x=vaesimcq_u8(x);
|
||||
return 0;
|
||||
}
|
||||
13
externals/cryptopp/TestPrograms/test_arm_armv7.cpp
vendored
Normal file
13
externals/cryptopp/TestPrograms/test_arm_armv7.cpp
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdint.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __ARM_ARCH >= 7
|
||||
// Do nothing
|
||||
#elif __ARM_ARCH_7A__
|
||||
// Do nothing
|
||||
#else
|
||||
int n[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
11
externals/cryptopp/TestPrograms/test_arm_asimd.cpp
vendored
Normal file
11
externals/cryptopp/TestPrograms/test_arm_asimd.cpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t x={0};
|
||||
x=veorq_u32(x,x);
|
||||
return 0;
|
||||
}
|
||||
23
externals/cryptopp/TestPrograms/test_arm_crc.cpp
vendored
Normal file
23
externals/cryptopp/TestPrograms/test_arm_crc.cpp
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#if (CRYPTOPP_ARM_ACLE_HEADER)
|
||||
# include <stdint.h>
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
// Keep sync'd with arm_simd.h
|
||||
#include "arm_simd.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32_t w=0xffffffff;
|
||||
|
||||
w = CRC32B(w,w);
|
||||
w = CRC32W(w,w);
|
||||
w = CRC32CB(w,w);
|
||||
w = CRC32CW(w,w);
|
||||
|
||||
return 0;
|
||||
}
|
||||
11
externals/cryptopp/TestPrograms/test_arm_neon.cpp
vendored
Normal file
11
externals/cryptopp/TestPrograms/test_arm_neon.cpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t x={0};
|
||||
x=veorq_u32(x,x);
|
||||
return 0;
|
||||
}
|
||||
6
externals/cryptopp/TestPrograms/test_arm_neon_header.cpp
vendored
Normal file
6
externals/cryptopp/TestPrograms/test_arm_neon_header.cpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <arm_neon.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
26
externals/cryptopp/TestPrograms/test_arm_pmull.cpp
vendored
Normal file
26
externals/cryptopp/TestPrograms/test_arm_pmull.cpp
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
// Keep sync'd with arm_simd.h
|
||||
#include "arm_simd.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Linaro is missing a lot of pmull gear. Also see http://github.com/weidai11/cryptopp/issues/233.
|
||||
const uint64_t wa1[]={0,0x9090909090909090}, wb1[]={0,0xb0b0b0b0b0b0b0b0};
|
||||
const uint64x2_t a1=vld1q_u64(wa1), b1=vld1q_u64(wb1);
|
||||
|
||||
const uint8_t wa2[]={0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0},
|
||||
wb2[]={0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
|
||||
0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0};
|
||||
const uint8x16_t a2=vld1q_u8(wa2), b2=vld1q_u8(wb2);
|
||||
|
||||
const uint64x2_t r1 = PMULL_00(a1, b1);
|
||||
const uint64x2_t r2 = PMULL_11(vreinterpretq_u64_u8(a2),
|
||||
vreinterpretq_u64_u8(b2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
13
externals/cryptopp/TestPrograms/test_arm_sha1.cpp
vendored
Normal file
13
externals/cryptopp/TestPrograms/test_arm_sha1.cpp
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t y = {0};
|
||||
y=vsha1cq_u32(y,0,y);
|
||||
y=vsha1mq_u32(y,1,y);
|
||||
y=vsha1pq_u32(y,2,y);
|
||||
return 0;
|
||||
}
|
||||
13
externals/cryptopp/TestPrograms/test_arm_sha256.cpp
vendored
Normal file
13
externals/cryptopp/TestPrograms/test_arm_sha256.cpp
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t y = {0};
|
||||
y=vsha256hq_u32(y, y, y);
|
||||
y=vsha256h2q_u32(y, y, y);
|
||||
y=vsha256su1q_u32(y, y, y);
|
||||
return 0;
|
||||
}
|
||||
19
externals/cryptopp/TestPrograms/test_arm_sha3.cpp
vendored
Normal file
19
externals/cryptopp/TestPrograms/test_arm_sha3.cpp
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
// Keep sync'd with arm_simd.h
|
||||
#include "arm_simd.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SHA3 intrinsics are merely ARMv8.2 instructions.
|
||||
// https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics
|
||||
uint32x4_t x={0}, y={1}, z={2};
|
||||
x=VEOR3(x,y,z);
|
||||
x=VXAR(y,z,6);
|
||||
x=VRAX1(y,z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
externals/cryptopp/TestPrograms/test_arm_sha512.cpp
vendored
Normal file
17
externals/cryptopp/TestPrograms/test_arm_sha512.cpp
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SHA512 hash
|
||||
// https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics?search=SHA512
|
||||
uint32x4_t w={0}, x={0}, y={0}, z={0};
|
||||
w=vsha512hq_u64(x,y,z);
|
||||
w=vsha512h2q_u64(x,y);
|
||||
w=vsha512su0q_u64(x,y);
|
||||
w=vsha512su1q_u64 (x,y,z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
19
externals/cryptopp/TestPrograms/test_arm_sm3.cpp
vendored
Normal file
19
externals/cryptopp/TestPrograms/test_arm_sm3.cpp
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SM3 hash
|
||||
// https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics?search=SM3
|
||||
uint32x4_t x={1}, y={2}, z={3};
|
||||
y=vsm3ss1q_u32(x,y,z);
|
||||
y=vsm3tt1aq_u32(x,y,z,3);
|
||||
y=vsm3tt1bq_u32(x,y,z,1);
|
||||
y=vsm3tt2aq_u32(x,y,z,2);
|
||||
y=vsm3tt2bq_u32(x,y,z,3);
|
||||
y=vsm3partw1q_u32(x,y,z);
|
||||
y=vsm3partw2q_u32(x,y,z);
|
||||
return 0;
|
||||
}
|
||||
15
externals/cryptopp/TestPrograms/test_arm_sm4.cpp
vendored
Normal file
15
externals/cryptopp/TestPrograms/test_arm_sm4.cpp
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdint.h>
|
||||
#if (CRYPTOPP_ARM_NEON_HEADER)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SM4 block cipher
|
||||
// https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics?search=SM4
|
||||
uint32x4_t x={0}, y={1}, z={2};
|
||||
x=vsm4ekeyq_u32(y,z);
|
||||
x=vsm4eq_u32(y,z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
31
externals/cryptopp/TestPrograms/test_asm_mixed.cpp
vendored
Normal file
31
externals/cryptopp/TestPrograms/test_asm_mixed.cpp
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Most Clang cannot handle mixed asm with positional arguments, where the
|
||||
// body is Intel style with no prefix and the templates are AT&T style.
|
||||
// Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
|
||||
#include <cstddef>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
size_t ret = 1, N = 1;
|
||||
asm __volatile__
|
||||
(
|
||||
#if defined(__amd64__) || defined(__x86_64__)
|
||||
".intel_syntax noprefix ;\n"
|
||||
"xor rsi, rsi ;\n"
|
||||
"neg %1 ;\n"
|
||||
"inc %1 ;\n"
|
||||
"push %1 ;\n"
|
||||
"pop rax ;\n"
|
||||
".att_syntax prefix ;\n"
|
||||
: "=a" (ret) : "c" (N) : "%rsi"
|
||||
#else
|
||||
".intel_syntax noprefix ;\n"
|
||||
"xor esi, esi ;\n"
|
||||
"neg %1 ;\n"
|
||||
"inc %1 ;\n"
|
||||
"push %1 ;\n"
|
||||
"pop eax ;\n"
|
||||
".att_syntax prefix ;\n"
|
||||
: "=a" (ret) : "c" (N) : "%esi"
|
||||
#endif
|
||||
);
|
||||
return (int)ret;
|
||||
}
|
||||
6
externals/cryptopp/TestPrograms/test_cxx.cpp
vendored
Normal file
6
externals/cryptopp/TestPrograms/test_cxx.cpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <string>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int x=0;
|
||||
return x;
|
||||
}
|
||||
11
externals/cryptopp/TestPrograms/test_cxx11.cpp
vendored
Normal file
11
externals/cryptopp/TestPrograms/test_cxx11.cpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Real C++11 libraries provide <forward_list>
|
||||
#include <forward_list>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
std::forward_list<int> x;
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
5
externals/cryptopp/TestPrograms/test_cxx11_alignas.cpp
vendored
Normal file
5
externals/cryptopp/TestPrograms/test_cxx11_alignas.cpp
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
alignas(8) unsigned char x[16];
|
||||
return 0;
|
||||
}
|
||||
6
externals/cryptopp/TestPrograms/test_cxx11_alignof.cpp
vendored
Normal file
6
externals/cryptopp/TestPrograms/test_cxx11_alignof.cpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <cstddef>
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
std::size_t n = alignof(int);
|
||||
return 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_cxx11_assert.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_cxx11_assert.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// https://en.cppreference.com/w/cpp/feature_test
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cpp_static_assert >= 200410L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_cxx11_atomic.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_cxx11_atomic.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <atomic>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||
std::atomic<bool> g (false);
|
||||
return 0;
|
||||
}
|
||||
5
externals/cryptopp/TestPrograms/test_cxx11_auto.cpp
vendored
Normal file
5
externals/cryptopp/TestPrograms/test_cxx11_auto.cpp
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
auto a = 1 + 2;
|
||||
return 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_cxx11_constexpr.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_cxx11_constexpr.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
constexpr int fact(int n)
|
||||
{
|
||||
return n <= 1 ? 1 : (n * fact(n - 1));
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
fact(4);
|
||||
return 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_cxx11_deletefn.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_cxx11_deletefn.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
struct S {
|
||||
S() = delete;
|
||||
explicit S(int n) { }
|
||||
};
|
||||
|
||||
int main (int argc, char* rgv[])
|
||||
{
|
||||
S s(1);
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_cxx11_enumtype.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_cxx11_enumtype.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <cstddef>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
enum Size : std::size_t { Zero=0, One=1, Two=2 };
|
||||
Size s(Size::Zero);
|
||||
return 0;
|
||||
}
|
||||
6
externals/cryptopp/TestPrograms/test_cxx11_initializer.cpp
vendored
Normal file
6
externals/cryptopp/TestPrograms/test_cxx11_initializer.cpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <vector>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::vector<int> v{0,1,2,3,4};
|
||||
return 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_cxx11_lambda.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_cxx11_lambda.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// https://en.cppreference.com/w/cpp/feature_test
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cpp_lambdas >= 200907L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
29
externals/cryptopp/TestPrograms/test_cxx11_noexcept.cpp
vendored
Normal file
29
externals/cryptopp/TestPrograms/test_cxx11_noexcept.cpp
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#if defined(__GNUC__)
|
||||
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__apple_build_version__)
|
||||
# undef GNUC_VERSION
|
||||
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#elif defined(__clang__)
|
||||
# undef GNUC_VERSION
|
||||
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#endif
|
||||
|
||||
#if (GNUC_VERSION >= 7030)
|
||||
# pragma GCC diagnostic ignored "-Wterminate"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
void f(int n) noexcept(false)
|
||||
{
|
||||
if (n > 2)
|
||||
throw std::runtime_error("Oops");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
f(argc);
|
||||
return 0;
|
||||
}
|
||||
6
externals/cryptopp/TestPrograms/test_cxx11_nullptr.cpp
vendored
Normal file
6
externals/cryptopp/TestPrograms/test_cxx11_nullptr.cpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <cstddef>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int* p = nullptr;
|
||||
return 0;
|
||||
}
|
||||
11
externals/cryptopp/TestPrograms/test_cxx11_staticinit.cpp
vendored
Normal file
11
externals/cryptopp/TestPrograms/test_cxx11_staticinit.cpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// https://en.cppreference.com/w/cpp/feature_test
|
||||
// Apple bug https://bugs.llvm.org/show_bug.cgi?id=47012.
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cpp_threadsafe_static_init >= 200806L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_cxx11_sync.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_cxx11_sync.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <mutex>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::mutex m;
|
||||
std::lock_guard<std::mutex> l(m);
|
||||
return 0;
|
||||
}
|
||||
9
externals/cryptopp/TestPrograms/test_cxx11_vartemplates.cpp
vendored
Normal file
9
externals/cryptopp/TestPrograms/test_cxx11_vartemplates.cpp
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cpp_variadic_templates >= 200704L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
9
externals/cryptopp/TestPrograms/test_cxx14.cpp
vendored
Normal file
9
externals/cryptopp/TestPrograms/test_cxx14.cpp
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cplusplus >= 201402L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
9
externals/cryptopp/TestPrograms/test_cxx17.cpp
vendored
Normal file
9
externals/cryptopp/TestPrograms/test_cxx17.cpp
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cplusplus >= 201703L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_cxx17_assert.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_cxx17_assert.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// https://en.cppreference.com/w/cpp/feature_test
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cpp_static_assert >= 201411L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
11
externals/cryptopp/TestPrograms/test_cxx17_exceptions.cpp
vendored
Normal file
11
externals/cryptopp/TestPrograms/test_cxx17_exceptions.cpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// https://en.cppreference.com/w/cpp/feature_test
|
||||
#include <exception>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cpp_lib_uncaught_exceptions >= 201411L
|
||||
int x = std::uncaught_exceptions();
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
12
externals/cryptopp/TestPrograms/test_cxx98_exception.cpp
vendored
Normal file
12
externals/cryptopp/TestPrograms/test_cxx98_exception.cpp
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <exception>
|
||||
struct S {
|
||||
S() {}
|
||||
virtual ~S() {
|
||||
bool b = std::uncaught_exception();
|
||||
}
|
||||
};
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
S s;
|
||||
return 0;
|
||||
}
|
||||
8
externals/cryptopp/TestPrograms/test_glibc.cpp
vendored
Normal file
8
externals/cryptopp/TestPrograms/test_glibc.cpp
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <string>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifndef __GLIBCXX__
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
8
externals/cryptopp/TestPrograms/test_newlib.cpp
vendored
Normal file
8
externals/cryptopp/TestPrograms/test_newlib.cpp
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <string>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifndef __NEWLIB__
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
19
externals/cryptopp/TestPrograms/test_nodevirtualize.cpp
vendored
Normal file
19
externals/cryptopp/TestPrograms/test_nodevirtualize.cpp
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <string>
|
||||
|
||||
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
|
||||
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// GCC 12 is removing live code. We don't know why.
|
||||
// https://github.com/weidai11/cryptopp/issues/1134 and
|
||||
// https://github.com/weidai11/cryptopp/issues/1141
|
||||
#if defined(__linux__) && (GCC_VERSION >= 120000)
|
||||
// On successful compile -fno-devirtualize will be used
|
||||
// to work around the problem.
|
||||
;;
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
26
externals/cryptopp/TestPrograms/test_ppc_aes.cpp
vendored
Normal file
26
externals/cryptopp/TestPrograms/test_ppc_aes.cpp
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <altivec.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__))
|
||||
__vector unsigned char x = {1,2,3,4,5,6,7,8};
|
||||
x=__vcipher(x,x);
|
||||
x=__vcipherlast(x,x);
|
||||
x=__vncipher(x,x);
|
||||
x=__vncipherlast(x,x);
|
||||
#elif defined(__clang__)
|
||||
__vector unsigned long long x = {1,2};
|
||||
x=__builtin_altivec_crypto_vcipher(x,x);
|
||||
x=__builtin_altivec_crypto_vcipherlast(x,x);
|
||||
x=__builtin_altivec_crypto_vncipher(x,x);
|
||||
x=__builtin_altivec_crypto_vncipherlast(x,x);
|
||||
#elif defined(__GNUC__)
|
||||
__vector unsigned long long x = {1,2};
|
||||
x=__builtin_crypto_vcipher(x,x);
|
||||
x=__builtin_crypto_vcipherlast(x,x);
|
||||
x=__builtin_crypto_vncipher(x,x);
|
||||
x=__builtin_crypto_vncipherlast(x,x);
|
||||
#else
|
||||
int XXX[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
13
externals/cryptopp/TestPrograms/test_ppc_altivec.cpp
vendored
Normal file
13
externals/cryptopp/TestPrograms/test_ppc_altivec.cpp
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#define GNUC_VERSION (__GNUC__*1000 + __GNUC_MAJOR__*10)
|
||||
#if (GNUC_VERSION >= 4060) || defined(__clang__)
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated"
|
||||
#endif
|
||||
|
||||
#include <altivec.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__vector unsigned char x;
|
||||
x=vec_ld(0, (unsigned char*)argv[0]);
|
||||
x=vec_add(x,x);
|
||||
return 0;
|
||||
}
|
||||
44
externals/cryptopp/TestPrograms/test_ppc_power7.cpp
vendored
Normal file
44
externals/cryptopp/TestPrograms/test_ppc_power7.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
#if defined(__GNUC__)
|
||||
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__apple_build_version__)
|
||||
# undef GNUC_VERSION
|
||||
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#elif defined(__clang__)
|
||||
# undef GNUC_VERSION
|
||||
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#endif
|
||||
|
||||
#if (GNUC_VERSION >= 4060) || (LLVM_VERSION >= 1070) || (APPLE_VERSION >= 2000)
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated"
|
||||
#endif
|
||||
|
||||
// XL C++ on AIX does not define VSX and does not
|
||||
// provide an option to set it. We have to set it
|
||||
// for the code below. This define must stay in
|
||||
// sync with the define in test_ppc_power7.cpp.
|
||||
#if defined(_AIX) && defined(_ARCH_PWR7) && defined(__xlC__)
|
||||
# define __VSX__ 1
|
||||
#endif
|
||||
|
||||
#include <altivec.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if defined(_ARCH_PWR7) && defined(__VSX__)
|
||||
// PWR7
|
||||
__vector unsigned int a = {1,2,3,4};
|
||||
__vector unsigned int b = vec_ld(0, (unsigned int*)argv[0]);
|
||||
__vector unsigned int c = vec_xor(a, b);
|
||||
|
||||
// VSX
|
||||
__vector unsigned int x = {5,6,7,8};
|
||||
__vector unsigned int y = vec_xl(0, (unsigned int*)argv[0]);
|
||||
__vector unsigned int z = vec_xor(x, y);
|
||||
__vector unsigned long long xx = {1,2};
|
||||
__vector unsigned long long yy = (__vector unsigned long long)y;
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
46
externals/cryptopp/TestPrograms/test_ppc_power8.cpp
vendored
Normal file
46
externals/cryptopp/TestPrograms/test_ppc_power8.cpp
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#if defined(__GNUC__)
|
||||
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__apple_build_version__)
|
||||
# undef GNUC_VERSION
|
||||
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#elif defined(__clang__)
|
||||
# undef GNUC_VERSION
|
||||
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#endif
|
||||
|
||||
#if (GNUC_VERSION >= 4060) || (LLVM_VERSION >= 1070) || (APPLE_VERSION >= 2000)
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated"
|
||||
#endif
|
||||
|
||||
// XL C++ on AIX does not define CRYPTO and does not
|
||||
// provide an option to set it. We have to set it
|
||||
// for the code below. This define must stay in
|
||||
// sync with the define in test_ppc_power8.cpp
|
||||
#if defined(_AIX) && defined(_ARCH_PWR8) && defined(__xlC__)
|
||||
# define __CRYPTO__ 1
|
||||
#endif
|
||||
|
||||
#include <altivec.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if defined(_ARCH_PWR8)
|
||||
__vector unsigned long long r = {1, 2};
|
||||
__vector unsigned int s = vec_xl(0, (unsigned int*)argv[0]); // Power7
|
||||
__vector unsigned long long w = (__vector unsigned long long)r;
|
||||
__vector unsigned long long x = (__vector unsigned long long)s;
|
||||
__vector unsigned long long y = vec_xor(w, x);
|
||||
__vector unsigned long long z = vec_add(y, vec_add(w, x));
|
||||
# if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__))
|
||||
__vector unsigned long long u = __vpmsumd (y, z);
|
||||
# elif defined(__clang__)
|
||||
__vector unsigned long long u = __builtin_altivec_crypto_vpmsumd (y, z);
|
||||
# else
|
||||
__vector unsigned long long u = __builtin_crypto_vpmsumd (y, z);
|
||||
# endif
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
33
externals/cryptopp/TestPrograms/test_ppc_power9.cpp
vendored
Normal file
33
externals/cryptopp/TestPrograms/test_ppc_power9.cpp
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#if defined(__GNUC__)
|
||||
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__apple_build_version__)
|
||||
# undef GNUC_VERSION
|
||||
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#elif defined(__clang__)
|
||||
# undef GNUC_VERSION
|
||||
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
|
||||
#endif
|
||||
|
||||
#if (GNUC_VERSION >= 4060) || (LLVM_VERSION >= 1070) || (APPLE_VERSION >= 2000)
|
||||
# pragma GCC diagnostic ignored "-Wdeprecated"
|
||||
#endif
|
||||
|
||||
#include <altivec.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if defined(_ARCH_PWR9)
|
||||
__vector unsigned int v = vec_xl_be(0, (unsigned int*)argv[0]);
|
||||
#else
|
||||
int XXX[-1];
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__IBM_GCC_ASM)
|
||||
unsigned int y = __builtin_darn_32();
|
||||
#else
|
||||
int XXX[-1];
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
externals/cryptopp/TestPrograms/test_ppc_sha.cpp
vendored
Normal file
23
externals/cryptopp/TestPrograms/test_ppc_sha.cpp
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <altivec.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__))
|
||||
__vector unsigned int x = {1,2,3,4};
|
||||
x=__vshasigmaw(x, 0, 0);
|
||||
__vector unsigned long long y = {1,2};
|
||||
y=__vshasigmad(y, 0, 0);
|
||||
#elif defined(__clang__)
|
||||
__vector unsigned int x = {1,2,3,4};
|
||||
x=__builtin_altivec_crypto_vshasigmaw(x, 0, 0);
|
||||
__vector unsigned long long y = {1,2};
|
||||
y=__builtin_altivec_crypto_vshasigmad(y, 0, 0);
|
||||
#elif defined(__GNUC__)
|
||||
__vector unsigned int x = {1,2,3,4};
|
||||
x=__builtin_crypto_vshasigmaw(x, 0, 0);
|
||||
__vector unsigned long long y = {1,2};
|
||||
y=__builtin_crypto_vshasigmad(y, 0, 0);
|
||||
#else
|
||||
int XXX[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
17
externals/cryptopp/TestPrograms/test_ppc_vmull.cpp
vendored
Normal file
17
externals/cryptopp/TestPrograms/test_ppc_vmull.cpp
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <altivec.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__vector unsigned long long x = {1,2};
|
||||
__vector unsigned long long y = {3,4};
|
||||
|
||||
#if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__))
|
||||
__vector unsigned long long z=__vpmsumd(x,y);
|
||||
#elif defined(__clang__)
|
||||
__vector unsigned long long z=__builtin_altivec_crypto_vpmsumd(x,y);
|
||||
#elif defined(__GNUC__)
|
||||
__vector unsigned long long z=__builtin_crypto_vpmsumd(x,y);
|
||||
#else
|
||||
int XXX[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
15
externals/cryptopp/TestPrograms/test_pthreads.cpp
vendored
Normal file
15
externals/cryptopp/TestPrograms/test_pthreads.cpp
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <string>
|
||||
#include <pthread.h>
|
||||
|
||||
void* function(void *ptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
pthread_t thread;
|
||||
int ret = pthread_create(&thread, NULL, function, (void*)0);
|
||||
pthread_join(thread, NULL);
|
||||
return 0;
|
||||
}
|
||||
11
externals/cryptopp/TestPrograms/test_x86_aes.cpp
vendored
Normal file
11
externals/cryptopp/TestPrograms/test_x86_aes.cpp
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <emmintrin.h>
|
||||
#include <wmmintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m128i x = _mm_setzero_si128();
|
||||
x=_mm_aesenc_si128(x,x);
|
||||
x=_mm_aesenclast_si128(x,x);
|
||||
x=_mm_aesdec_si128(x,x);
|
||||
x=_mm_aesdeclast_si128(x,x);
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_x86_avx.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_x86_avx.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <immintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m256d x = _mm256_setzero_pd();
|
||||
x=_mm256_addsub_pd(x,x);
|
||||
return 0;
|
||||
}
|
||||
9
externals/cryptopp/TestPrograms/test_x86_avx2.cpp
vendored
Normal file
9
externals/cryptopp/TestPrograms/test_x86_avx2.cpp
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <immintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// _mm256_broadcastsi128_si256 due to Clang
|
||||
__m128i x = _mm_setzero_si128 ();
|
||||
__m256i y = _mm256_broadcastsi128_si256 (x);
|
||||
y = _mm256_add_epi64 (y,y);
|
||||
return 0;
|
||||
}
|
||||
8
externals/cryptopp/TestPrograms/test_x86_avx512.cpp
vendored
Normal file
8
externals/cryptopp/TestPrograms/test_x86_avx512.cpp
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdint.h>
|
||||
#include <immintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint64_t x[8] = {0};
|
||||
__m512i y = _mm512_loadu_si512((__m512i*)x);
|
||||
return 0;
|
||||
}
|
||||
8
externals/cryptopp/TestPrograms/test_x86_clmul.cpp
vendored
Normal file
8
externals/cryptopp/TestPrograms/test_x86_clmul.cpp
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <emmintrin.h>
|
||||
#include <wmmintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m128i x = _mm_setzero_si128();
|
||||
x=_mm_clmulepi64_si128(x,x,0x11);
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_x86_cpuid.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_x86_cpuid.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int a, b, c, d;
|
||||
asm volatile ( "cpuid" : "+a"(a), "=b"(b), "+c"(c), "=d"(d) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_x86_rdrand.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_x86_rdrand.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <immintrin.h>
|
||||
#if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
|
||||
# include <x86intrin.h>
|
||||
#endif
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int x=0;
|
||||
(void)_rdrand32_step (&x);
|
||||
return x == 0 ? 0 : 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_x86_rdseed.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_x86_rdseed.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <immintrin.h>
|
||||
#if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
|
||||
# include <x86intrin.h>
|
||||
#endif
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int x=0;
|
||||
(void)_rdseed32_step (&x);
|
||||
return x == 0 ? 0 : 0;
|
||||
}
|
||||
14
externals/cryptopp/TestPrograms/test_x86_sha.cpp
vendored
Normal file
14
externals/cryptopp/TestPrograms/test_x86_sha.cpp
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <emmintrin.h>
|
||||
#include <immintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m128i x = _mm_setzero_si128();
|
||||
x=_mm_sha1msg1_epu32(x,x);
|
||||
x=_mm_sha1msg2_epu32(x,x);
|
||||
x=_mm_sha1nexte_epu32(x,x);
|
||||
x=_mm_sha1rnds4_epu32(x,x,0);
|
||||
x=_mm_sha256msg1_epu32(x,x);
|
||||
x=_mm_sha256msg2_epu32(x,x);
|
||||
x=_mm_sha256rnds2_epu32(x,x,x);
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_x86_sse2.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_x86_sse2.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <emmintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m128i x = _mm_setzero_si128();
|
||||
x=_mm_add_epi64(x,x);
|
||||
return 0;
|
||||
}
|
||||
8
externals/cryptopp/TestPrograms/test_x86_sse3.cpp
vendored
Normal file
8
externals/cryptopp/TestPrograms/test_x86_sse3.cpp
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <emmintrin.h>
|
||||
#include <pmmintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m128d x = _mm_setzero_pd();
|
||||
x=_mm_addsub_pd(x,x);
|
||||
return 0;
|
||||
}
|
||||
10
externals/cryptopp/TestPrograms/test_x86_sse41.cpp
vendored
Normal file
10
externals/cryptopp/TestPrograms/test_x86_sse41.cpp
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <emmintrin.h>
|
||||
#include <smmintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m128i x = _mm_setzero_si128();
|
||||
__m128i a = _mm_setzero_si128();
|
||||
__m128i b = _mm_setzero_si128();
|
||||
x=_mm_blend_epi16(a,b,4);
|
||||
return 0;
|
||||
}
|
||||
7
externals/cryptopp/TestPrograms/test_x86_sse42.cpp
vendored
Normal file
7
externals/cryptopp/TestPrograms/test_x86_sse42.cpp
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <nmmintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int x=32;
|
||||
x=_mm_crc32_u8(x,4);
|
||||
return 0;
|
||||
}
|
||||
8
externals/cryptopp/TestPrograms/test_x86_ssse3.cpp
vendored
Normal file
8
externals/cryptopp/TestPrograms/test_x86_ssse3.cpp
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <emmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
__m128i x = _mm_setzero_si128();
|
||||
x=_mm_alignr_epi8(x,x,2);
|
||||
return 0;
|
||||
}
|
||||
39
externals/cryptopp/TestPrograms/test_x86_via_aes.cpp
vendored
Normal file
39
externals/cryptopp/TestPrograms/test_x86_via_aes.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// TODO: cut-in xcrypt-ecb
|
||||
#include <cstdlib>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int msr=0;
|
||||
unsigned int divisor=2;
|
||||
unsigned int buffer;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
"mov %1, %%rdi ;\n"
|
||||
"movl %2, %%edx ;\n"
|
||||
#else
|
||||
"mov %1, %%edi ;\n"
|
||||
"movl %2, %%edx ;\n"
|
||||
#endif
|
||||
|
||||
// xstore-rng
|
||||
".byte 0x0f, 0xa7, 0xc0 ;\n"
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
"andq %%rax, 0x1f ;\n"
|
||||
"movl %%eax, %0 ;\n"
|
||||
#else
|
||||
"andl %%eax, 0x1f ;\n"
|
||||
"movl %%eax, %0 ;\n"
|
||||
#endif
|
||||
|
||||
: "=g" (msr) : "g" (buffer), "g" (divisor)
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
: "rax", "rdx", "rdi", "cc"
|
||||
#else
|
||||
: "eax", "edx", "edi", "cc"
|
||||
#endif
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
38
externals/cryptopp/TestPrograms/test_x86_via_rng.cpp
vendored
Normal file
38
externals/cryptopp/TestPrograms/test_x86_via_rng.cpp
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <cstdlib>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int msr=0;
|
||||
unsigned int divisor=2;
|
||||
unsigned int buffer;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
"mov %1, %%rdi ;\n"
|
||||
"movl %2, %%edx ;\n"
|
||||
#else
|
||||
"mov %1, %%edi ;\n"
|
||||
"movl %2, %%edx ;\n"
|
||||
#endif
|
||||
|
||||
// xstore-rng
|
||||
".byte 0x0f, 0xa7, 0xc0 ;\n"
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
"andq %%rax, 0x1f ;\n"
|
||||
"movl %%eax, %0 ;\n"
|
||||
#else
|
||||
"andl %%eax, 0x1f ;\n"
|
||||
"movl %%eax, %0 ;\n"
|
||||
#endif
|
||||
|
||||
: "=g" (msr) : "g" (buffer), "g" (divisor)
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
: "rax", "rdx", "rdi", "cc"
|
||||
#else
|
||||
: "eax", "edx", "edi", "cc"
|
||||
#endif
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
externals/cryptopp/TestPrograms/test_x86_via_sha.cpp
vendored
Normal file
39
externals/cryptopp/TestPrograms/test_x86_via_sha.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// TODO: cut-in xsha1
|
||||
#include <cstdlib>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int msr=0;
|
||||
unsigned int divisor=2;
|
||||
unsigned int buffer;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
"mov %1, %%rdi ;\n"
|
||||
"movl %2, %%edx ;\n"
|
||||
#else
|
||||
"mov %1, %%edi ;\n"
|
||||
"movl %2, %%edx ;\n"
|
||||
#endif
|
||||
|
||||
// xstore-rng
|
||||
".byte 0x0f, 0xa7, 0xc0 ;\n"
|
||||
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
"andq %%rax, 0x1f ;\n"
|
||||
"movl %%eax, %0 ;\n"
|
||||
#else
|
||||
"andl %%eax, 0x1f ;\n"
|
||||
"movl %%eax, %0 ;\n"
|
||||
#endif
|
||||
|
||||
: "=g" (msr) : "g" (buffer), "g" (divisor)
|
||||
#if defined(__x86_64__) || defined(__amd64__)
|
||||
: "rax", "rdx", "rdi", "cc"
|
||||
#else
|
||||
: "eax", "edx", "edi", "cc"
|
||||
#endif
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user