[RISCV] Add RVVConstraint to SiFive custom matrix multiply instructions. (#124055)
[llvm-project.git] / compiler-rt / test / asan / TestCases / Windows / bind_io_completion_callback.cpp
blobef7e45867ede0dcc38ac029fe03bfc9cb6a80f09
1 // Make sure we can throw exceptions from work items executed via
2 // BindIoCompletionCallback.
3 //
4 // RUN: %clangxx_asan %s -o %t.exe
5 // RUN: %run %t.exe 2>&1 | FileCheck %s
7 #include <windows.h>
8 #include <stdio.h>
10 void ThrowAndCatch();
12 __declspec(noinline)
13 void Throw() {
14 fprintf(stderr, "Throw\n");
15 // CHECK: Throw
16 throw 1;
19 void ThrowAndCatch() {
20 int local;
21 try {
22 Throw();
23 } catch(...) {
24 fprintf(stderr, "Catch\n");
25 // CHECK: Catch
29 char buffer[65536];
30 HANDLE done;
31 OVERLAPPED ov;
33 void CALLBACK completion_callback(DWORD error, DWORD bytesRead,
34 LPOVERLAPPED pov) {
35 ThrowAndCatch();
36 SetEvent(done);
39 int main(int argc, char **argv) {
40 done = CreateEvent(0, false, false, "job is done");
41 if (!done)
42 return 1;
43 HANDLE file = CreateFile(
44 argv[0], GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
45 OPEN_EXISTING,
46 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED,
47 NULL);
48 if (!file)
49 return 2;
50 if (!BindIoCompletionCallback(file, completion_callback, 0))
51 return 3;
53 if (!ReadFile(file, buffer, sizeof(buffer), NULL, &ov) &&
54 GetLastError() != ERROR_IO_PENDING)
55 return 4;
57 if (WAIT_OBJECT_0 != WaitForSingleObject(done, 10 * 1000))
58 return 5;
59 fprintf(stderr, "Done!\n");
60 // CHECK: Done!