summaryrefslogtreecommitdiff
path: root/TestPrograms
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2020-08-05 22:10:31 -0400
committerJeffrey Walton <noloader@gmail.com>2020-08-05 22:10:31 -0400
commit1b765d8bd3327067098ab180d0a6161dab8356c3 (patch)
treeac0fecceb5f99b1ff954885e6d0976dfe934d67a /TestPrograms
parent67ad4256e91b2676a777ed04453e7f6607fffd3b (diff)
downloadcryptopp-git-1b765d8bd3327067098ab180d0a6161dab8356c3.tar.gz
Add C++11 test programs
Diffstat (limited to 'TestPrograms')
-rw-r--r--TestPrograms/dump2def.cxx298
-rw-r--r--TestPrograms/test_asm_mixed.cxx32
-rw-r--r--TestPrograms/test_cxx11_alignas.cxx5
-rw-r--r--TestPrograms/test_cxx11_alignof.cxx6
-rw-r--r--TestPrograms/test_cxx11_atomic.cxx7
-rw-r--r--TestPrograms/test_cxx11_deletefn.cxx10
-rw-r--r--TestPrograms/test_cxx11_dyninit.cxx10
-rw-r--r--TestPrograms/test_cxx11_lambda.cxx10
-rw-r--r--TestPrograms/test_cxx11_sync.cxx7
-rw-r--r--TestPrograms/test_cxx17.cxx2
-rw-r--r--TestPrograms/test_x86_via_aes.cxx26
-rw-r--r--TestPrograms/test_x86_via_rng.cxx26
-rw-r--r--TestPrograms/test_x86_via_sha.cxx26
13 files changed, 260 insertions, 205 deletions
diff --git a/TestPrograms/dump2def.cxx b/TestPrograms/dump2def.cxx
index 97bc7580..3e41f6e6 100644
--- a/TestPrograms/dump2def.cxx
+++ b/TestPrograms/dump2def.cxx
@@ -58,157 +58,157 @@ 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));
+ 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;
+ // ******************** 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;
}
diff --git a/TestPrograms/test_asm_mixed.cxx b/TestPrograms/test_asm_mixed.cxx
index c276e3ca..03ed5795 100644
--- a/TestPrograms/test_asm_mixed.cxx
+++ b/TestPrograms/test_asm_mixed.cxx
@@ -8,23 +8,23 @@ int main(int argc, char* argv[])
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"
+ ".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"
+ ".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;
diff --git a/TestPrograms/test_cxx11_alignas.cxx b/TestPrograms/test_cxx11_alignas.cxx
new file mode 100644
index 00000000..3debcba9
--- /dev/null
+++ b/TestPrograms/test_cxx11_alignas.cxx
@@ -0,0 +1,5 @@
+int main(int argc, char* argv[])
+{
+ alignas(16) unsigned char x[16];
+ return 0;
+}
diff --git a/TestPrograms/test_cxx11_alignof.cxx b/TestPrograms/test_cxx11_alignof.cxx
new file mode 100644
index 00000000..a5b72fff
--- /dev/null
+++ b/TestPrograms/test_cxx11_alignof.cxx
@@ -0,0 +1,6 @@
+#include <cstddef>
+int main (int argc, char* argv[])
+{
+ std::size_t n = alignof(int);
+ return 0;
+}
diff --git a/TestPrograms/test_cxx11_atomic.cxx b/TestPrograms/test_cxx11_atomic.cxx
new file mode 100644
index 00000000..63d16489
--- /dev/null
+++ b/TestPrograms/test_cxx11_atomic.cxx
@@ -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;
+}
diff --git a/TestPrograms/test_cxx11_deletefn.cxx b/TestPrograms/test_cxx11_deletefn.cxx
new file mode 100644
index 00000000..d1e3a78b
--- /dev/null
+++ b/TestPrograms/test_cxx11_deletefn.cxx
@@ -0,0 +1,10 @@
+struct S {
+ S() = delete;
+ explicit S(int n) { }
+};
+
+int main (int argc, char* rgv[])
+{
+ S s(1);
+ return 0;
+}
diff --git a/TestPrograms/test_cxx11_dyninit.cxx b/TestPrograms/test_cxx11_dyninit.cxx
new file mode 100644
index 00000000..c826fa3f
--- /dev/null
+++ b/TestPrograms/test_cxx11_dyninit.cxx
@@ -0,0 +1,10 @@
+// https://en.cppreference.com/w/cpp/feature_test
+int main(int argc, char* argv[])
+{
+#if __cpp_threadsafe_static_init >= 200806L
+ int x[1];
+#else
+ int x[-1];
+#endif
+ return 0;
+}
diff --git a/TestPrograms/test_cxx11_lambda.cxx b/TestPrograms/test_cxx11_lambda.cxx
new file mode 100644
index 00000000..7e28ecb8
--- /dev/null
+++ b/TestPrograms/test_cxx11_lambda.cxx
@@ -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;
+}
diff --git a/TestPrograms/test_cxx11_sync.cxx b/TestPrograms/test_cxx11_sync.cxx
new file mode 100644
index 00000000..56076924
--- /dev/null
+++ b/TestPrograms/test_cxx11_sync.cxx
@@ -0,0 +1,7 @@
+#include <mutex>
+int main(int argc, char* argv[])
+{
+ static std::mutex m;
+ std::lock_guard<std::mutex> l(m);
+ return 0;
+}
diff --git a/TestPrograms/test_cxx17.cxx b/TestPrograms/test_cxx17.cxx
index 665cdbc2..32dd43d2 100644
--- a/TestPrograms/test_cxx17.cxx
+++ b/TestPrograms/test_cxx17.cxx
@@ -2,4 +2,4 @@
int main(int argc, char* argv[])
{
return 0 == std::uncaught_exceptions() ? 0 : 1;
-} \ No newline at end of file
+}
diff --git a/TestPrograms/test_x86_via_aes.cxx b/TestPrograms/test_x86_via_aes.cxx
index 319ca30e..7b14958c 100644
--- a/TestPrograms/test_x86_via_aes.cxx
+++ b/TestPrograms/test_x86_via_aes.cxx
@@ -9,29 +9,29 @@ int main(int argc, char* argv[])
__asm__ __volatile__
(
#if defined(__x86_64__) || defined(__amd64__)
- "mov %1, %%rdi ;\n"
- "movl %2, %%edx ;\n"
+ "mov %1, %%rdi ;\n"
+ "movl %2, %%edx ;\n"
#else
- "mov %1, %%edi ;\n"
- "movl %2, %%edx ;\n"
+ "mov %1, %%edi ;\n"
+ "movl %2, %%edx ;\n"
#endif
- // xstore-rng
- ".byte 0x0f, 0xa7, 0xc0 ;\n"
+ // xstore-rng
+ ".byte 0x0f, 0xa7, 0xc0 ;\n"
#if defined(__x86_64__) || defined(__amd64__)
- "andq %%rax, 0x1f ;\n"
- "movl %%eax, %0 ;\n"
+ "andq %%rax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
#else
- "andl %%eax, 0x1f ;\n"
- "movl %%eax, %0 ;\n"
+ "andl %%eax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
#endif
- : "=g" (msr) : "g" (buffer), "g" (divisor)
+ : "=g" (msr) : "g" (buffer), "g" (divisor)
#if defined(__x86_64__) || defined(__amd64__)
- : "rax", "rdx", "rdi", "cc"
+ : "rax", "rdx", "rdi", "cc"
#else
- : "eax", "edx", "edi", "cc"
+ : "eax", "edx", "edi", "cc"
#endif
);
diff --git a/TestPrograms/test_x86_via_rng.cxx b/TestPrograms/test_x86_via_rng.cxx
index 7e7380e7..1ecd8f53 100644
--- a/TestPrograms/test_x86_via_rng.cxx
+++ b/TestPrograms/test_x86_via_rng.cxx
@@ -8,29 +8,29 @@ int main(int argc, char* argv[])
__asm__ __volatile__
(
#if defined(__x86_64__) || defined(__amd64__)
- "mov %1, %%rdi ;\n"
- "movl %2, %%edx ;\n"
+ "mov %1, %%rdi ;\n"
+ "movl %2, %%edx ;\n"
#else
- "mov %1, %%edi ;\n"
- "movl %2, %%edx ;\n"
+ "mov %1, %%edi ;\n"
+ "movl %2, %%edx ;\n"
#endif
- // xstore-rng
- ".byte 0x0f, 0xa7, 0xc0 ;\n"
+ // xstore-rng
+ ".byte 0x0f, 0xa7, 0xc0 ;\n"
#if defined(__x86_64__) || defined(__amd64__)
- "andq %%rax, 0x1f ;\n"
- "movl %%eax, %0 ;\n"
+ "andq %%rax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
#else
- "andl %%eax, 0x1f ;\n"
- "movl %%eax, %0 ;\n"
+ "andl %%eax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
#endif
- : "=g" (msr) : "g" (buffer), "g" (divisor)
+ : "=g" (msr) : "g" (buffer), "g" (divisor)
#if defined(__x86_64__) || defined(__amd64__)
- : "rax", "rdx", "rdi", "cc"
+ : "rax", "rdx", "rdi", "cc"
#else
- : "eax", "edx", "edi", "cc"
+ : "eax", "edx", "edi", "cc"
#endif
);
diff --git a/TestPrograms/test_x86_via_sha.cxx b/TestPrograms/test_x86_via_sha.cxx
index a8632081..bb8be1cd 100644
--- a/TestPrograms/test_x86_via_sha.cxx
+++ b/TestPrograms/test_x86_via_sha.cxx
@@ -9,29 +9,29 @@ int main(int argc, char* argv[])
__asm__ __volatile__
(
#if defined(__x86_64__) || defined(__amd64__)
- "mov %1, %%rdi ;\n"
- "movl %2, %%edx ;\n"
+ "mov %1, %%rdi ;\n"
+ "movl %2, %%edx ;\n"
#else
- "mov %1, %%edi ;\n"
- "movl %2, %%edx ;\n"
+ "mov %1, %%edi ;\n"
+ "movl %2, %%edx ;\n"
#endif
- // xstore-rng
- ".byte 0x0f, 0xa7, 0xc0 ;\n"
+ // xstore-rng
+ ".byte 0x0f, 0xa7, 0xc0 ;\n"
#if defined(__x86_64__) || defined(__amd64__)
- "andq %%rax, 0x1f ;\n"
- "movl %%eax, %0 ;\n"
+ "andq %%rax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
#else
- "andl %%eax, 0x1f ;\n"
- "movl %%eax, %0 ;\n"
+ "andl %%eax, 0x1f ;\n"
+ "movl %%eax, %0 ;\n"
#endif
- : "=g" (msr) : "g" (buffer), "g" (divisor)
+ : "=g" (msr) : "g" (buffer), "g" (divisor)
#if defined(__x86_64__) || defined(__amd64__)
- : "rax", "rdx", "rdi", "cc"
+ : "rax", "rdx", "rdi", "cc"
#else
- : "eax", "edx", "edi", "cc"
+ : "eax", "edx", "edi", "cc"
#endif
);