1570af302Sopenharmony_ci#include "util.h" 2570af302Sopenharmony_ci#include <poll.h> 3570af302Sopenharmony_ci#include <unistd.h> 4570af302Sopenharmony_ci#include <fcntl.h> 5570af302Sopenharmony_ci 6570af302Sopenharmony_cistatic void Bm_function_Poll(benchmark::State &state) 7570af302Sopenharmony_ci{ 8570af302Sopenharmony_ci struct pollfd pfd; 9570af302Sopenharmony_ci int fd = open("/dev/zero", O_RDONLY, OPEN_MODE); 10570af302Sopenharmony_ci if (fd == -1) { 11570af302Sopenharmony_ci perror("open poll"); 12570af302Sopenharmony_ci exit(-1); 13570af302Sopenharmony_ci } 14570af302Sopenharmony_ci 15570af302Sopenharmony_ci pfd.fd = fd; 16570af302Sopenharmony_ci pfd.events = POLLIN; 17570af302Sopenharmony_ci 18570af302Sopenharmony_ci for (auto _ : state) { 19570af302Sopenharmony_ci benchmark::DoNotOptimize(poll(&pfd, 1, 0)); 20570af302Sopenharmony_ci } 21570af302Sopenharmony_ci 22570af302Sopenharmony_ci close(fd); 23570af302Sopenharmony_ci state.SetBytesProcessed(state.iterations()); 24570af302Sopenharmony_ci} 25570af302Sopenharmony_ci 26570af302Sopenharmony_ciMUSL_BENCHMARK(Bm_function_Poll);