[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / lldb / test / Shell / Register / Inputs / x86-multithread-write.cpp
blob320f9e938e5bf4b56c61a135895adbef8a31766b
1 #include <cinttypes>
2 #include <cstdint>
3 #include <cstdio>
4 #include <mutex>
5 #include <thread>
7 std::mutex t1_mutex, t2_mutex;
9 struct test_data {
10 uint32_t eax;
11 uint32_t ebx;
13 struct alignas(16) {
14 uint8_t data[10];
15 } st0;
18 constexpr test_data filler = {
19 .eax = 0xffffffff,
20 .ebx = 0xffffffff,
21 .st0 = {{0x1f, 0x2f, 0x3f, 0x4f, 0x5f, 0x6f, 0x7f, 0x8f, 0x80, 0x40}},
24 void t_func(std::mutex &t_mutex) {
25 std::lock_guard<std::mutex> t_lock(t_mutex);
26 test_data out = filler;
28 asm volatile(
29 "finit\t\n"
30 "fldt %2\t\n"
31 "int3\n\t"
32 "fstpt %2\t\n"
33 : "+a"(out.eax), "+b"(out.ebx)
34 : "m"(out.st0)
35 : "memory", "st"
38 printf("eax = 0x%08" PRIx32 "\n", out.eax);
39 printf("ebx = 0x%08" PRIx32 "\n", out.ebx);
40 printf("st0 = { ");
41 for (int i = 0; i < sizeof(out.st0.data); ++i)
42 printf("0x%02" PRIx8 " ", out.st0.data[i]);
43 printf("}\n");
46 int main() {
47 // block both threads from proceeding
48 std::unique_lock<std::mutex> m1_lock(t1_mutex);
49 std::unique_lock<std::mutex> m2_lock(t2_mutex);
51 // start both threads
52 std::thread t1(t_func, std::ref(t1_mutex));
53 std::thread t2(t_func, std::ref(t2_mutex));
55 // release lock on thread 1 to make it interrupt the program
56 m1_lock.unlock();
57 // wait for thread 1 to finish
58 t1.join();
60 // release lock on thread 2
61 m2_lock.unlock();
62 // wait for thread 2 to finish
63 t2.join();
65 return 0;