regtest: broaden none/tests/linux/bug498317 suppression for PPC
[valgrind.git] / memcheck / tests / freebsd / aio_read.c
blob5cc684f5977c001957882c52ecd827dc7f10225a
1 // my_aio_read.c
2 // from https://github.com/imyjf/apue/blob/master/my_aio_read.c
3 // and I guess originally from APUE but it isn't in my second
4 // edition (and I didn't keep the first edition)
5 #include <unistd.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <aio.h>
12 #include <strings.h>
13 #include <errno.h>
15 #define ERR_EXIT(msg) do { perror(msg); exit(1); } while(0)
17 int main() {
18 int ret;
19 char buf[64];
20 struct aiocb my_aiocb;
22 bzero((char*)&my_aiocb, sizeof(struct aiocb));
24 my_aiocb.aio_buf = buf;
25 my_aiocb.aio_fildes = STDIN_FILENO;
26 my_aiocb.aio_nbytes = 64;
27 my_aiocb.aio_offset = 0;
29 ret = aio_read(&my_aiocb);
30 if (ret < 0) {
31 ERR_EXIT("aio_read");
34 while (aio_error(&my_aiocb) == EINPROGRESS) {
35 //write(STDOUT_FILENO, ".", 1);
36 sleep(1);
39 ret = aio_return(&my_aiocb);
40 if (ret < 0) {
41 ERR_EXIT("aio_return");
44 buf[ret] = '\0';
45 printf("content: %s\n", buf);
47 return 0;