mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-08 17:59:37 +00:00
Add thirdparty libs
This commit is contained in:
+214
@@ -0,0 +1,214 @@
|
||||
// dump2def.cxx - 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.cxx
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <arm_acle.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.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;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32x4_t x={0};
|
||||
x=veorq_u32(x,x);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
uint32_t w=0xffffffff;
|
||||
|
||||
w = __crc32w(w,w);
|
||||
w = __crc32h(w,w);
|
||||
w = __crc32b(w,w);
|
||||
w = __crc32cw(w,w);
|
||||
w = __crc32ch(w,w);
|
||||
w = __crc32cb(w,w);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <stdint.h>
|
||||
#ifdef 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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <arm_neon.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const poly64_t a=0x60606060, b=0x90909090, c=0xb0b0b0b0;
|
||||
const poly64x2_t d={0x60606060,0x90909090};
|
||||
const poly8x16_t e={0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
|
||||
0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0};
|
||||
|
||||
const poly128_t r1 = vmull_p64(a, b);
|
||||
const poly128_t r2 = vmull_high_p64(d, d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.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;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.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;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SM4 block cipher
|
||||
uint32x4_t x;
|
||||
x=vsm4ekeyq_u32(x,x);
|
||||
x=vsm4eq_u32(x,x);
|
||||
|
||||
// SM3 hash
|
||||
uint32x4_t y;
|
||||
y=vsm3ss1q_u32(x,y,y);
|
||||
y=vsm3tt1aq_u32(x,y,y,3);
|
||||
y=vsm3tt1bq_u32(x,y,y,1);
|
||||
y=vsm3tt2aq_u32(x,y,y,2);
|
||||
y=vsm3tt2bq_u32(x,y,y,3);
|
||||
y=vsm3partw1q_u32(x,y,y);
|
||||
y=vsm3partw2q_u32(x,y,y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SM4 block cipher
|
||||
uint32x4_t x;
|
||||
x=vsm4ekeyq_u32(x,x);
|
||||
x=vsm4eq_u32(x,x);
|
||||
|
||||
// SM3 hash
|
||||
uint32x4_t y;
|
||||
y=vsm3ss1q_u32(x,y,y);
|
||||
y=vsm3tt1aq_u32(x,y,y,3);
|
||||
y=vsm3tt1bq_u32(x,y,y,1);
|
||||
y=vsm3tt2aq_u32(x,y,y,2);
|
||||
y=vsm3tt2bq_u32(x,y,y,3);
|
||||
y=vsm3partw1q_u32(x,y,y);
|
||||
y=vsm3partw2q_u32(x,y,y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SM3 hash
|
||||
uint32x4_t y;
|
||||
y=vsm3ss1q_u32(x,y,y);
|
||||
y=vsm3tt1aq_u32(x,y,y,3);
|
||||
y=vsm3tt1bq_u32(x,y,y,1);
|
||||
y=vsm3tt2aq_u32(x,y,y,2);
|
||||
y=vsm3tt2bq_u32(x,y,y,3);
|
||||
y=vsm3partw1q_u32(x,y,y);
|
||||
y=vsm3partw2q_u32(x,y,y);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdint.h>
|
||||
#ifdef CRYPTOPP_ARM_NEON_HEADER
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
#ifdef CRYPTOPP_ARM_ACLE_HEADER
|
||||
# include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// SM4 block cipher
|
||||
uint32x4_t x;
|
||||
x=vsm4ekeyq_u32(x,x);
|
||||
x=vsm4eq_u32(x,x);
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <string>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
unsigned int x=0;
|
||||
return x;
|
||||
}
|
||||
+11
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
alignas(8) unsigned char x[16];
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <cstddef>
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
std::size_t n = alignof(int);
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
auto a = 1 + 2;
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
struct S {
|
||||
S() = delete;
|
||||
explicit S(int n) { }
|
||||
};
|
||||
|
||||
int main (int argc, char* rgv[])
|
||||
{
|
||||
S s(1);
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <vector>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::vector<int> v{0,1,2,3,4};
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <cstddef>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int* p = nullptr;
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <mutex>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::mutex m;
|
||||
std::lock_guard<std::mutex> l(m);
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cplusplus >= 201402L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#if __cplusplus >= 201703L
|
||||
int x[1];
|
||||
#else
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <string>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifndef __GLIBCXX__
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <string>
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifndef __NEWLIB__
|
||||
int x[-1];
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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.cxx.
|
||||
#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;
|
||||
}
|
||||
@@ -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.cxx
|
||||
#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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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