Changeset f3ed2af
- Timestamp:
- Jul 27, 2020, 1:43:16 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3a1cf0d
- Parents:
- a86b1b85
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/io_uring.c
ra86b1b85 rf3ed2af 1 #ifndef _GNU_SOURCE 1 2 #define _GNU_SOURCE 3 #endif 2 4 3 5 #include <fcntl.h> … … 8 10 9 11 struct io_uring ring; 12 13 __attribute__((aligned(1024))) char data[1024]; 10 14 11 15 int main(int argc, char * argv[]) { … … 22 26 23 27 /* prep the array */ 24 char data[512]; 25 struct iovec iov = { data, 512 }; 28 struct iovec iov = { data, 1024 }; 26 29 27 30 /* init liburing */ … … 35 38 sqe = io_uring_get_sqe(&ring); 36 39 io_uring_prep_readv(sqe, fd, &iov, 1, 0); 40 // io_uring_prep_read(sqe, fd, data, 1024, 0); 37 41 38 sqe->user_data = data;42 sqe->user_data = (uint64_t)(uintptr_t)data; 39 43 40 44 /* tell the kernel we have an sqe ready for consumption */ … … 46 50 /* read and process cqe event */ 47 51 if(ret == 0) { 48 char * out = cqe->user_data;52 char * out = (char *)(uintptr_t)cqe->user_data; 49 53 signed int len = cqe->res; 50 54 io_uring_cqe_seen(&ring, cqe); … … 54 58 } 55 59 else if( len < 0 ) { 56 fprintf(stderr, "readv returned error : %s\n", strerror(-len));60 fprintf(stderr, "readv/read returned error : %s\n", strerror(-len)); 57 61 } 58 62 }
Note: See TracChangeset
for help on using the changeset viewer.