1// RUN: %libomptarget-compile-run-and-check-generic
2
3// REQUIRES: libc
4
5#include <assert.h>
6#include <stdio.h>
7
8#pragma omp declare target to(stdout)
9
10int main() {
11 int r = 0;
12// CHECK: PASS
13#pragma omp target map(from : r)
14 { r = fwrite(ptr: "PASS\n", size: 1, n: sizeof("PASS\n") - 1, stdout); }
15 assert(r == sizeof("PASS\n") - 1 && "Incorrect number of bytes written");
16
17// CHECK: PASS
18#pragma omp target map(from : r) nowait
19 { r = fwrite(ptr: "PASS\n", size: 1, n: 5, stdout); }
20#pragma omp taskwait
21 assert(r == sizeof("PASS\n") - 1 && "Incorrect number of bytes written");
22}
23

source code of offload/test/libc/fwrite.c