diff --git a/main.c b/main.c index fb072fe8..78e53722 100644 --- a/main.c +++ b/main.c @@ -36,8 +36,10 @@ #include "findnonce.h" #include "ocl.h" -#if defined(__linux) - #include +#if defined(unix) + #include + #include + #include #include #include #endif @@ -449,6 +451,31 @@ static double bench_algo_stage3( return rate; } +#if defined(unix) + + // Change non-blocking status on a file descriptor + static void set_non_blocking( + int fd, + int yes + ) + { + int flags = fcntl(fd, F_GETFL, 0); + if (flags<0) { + perror("fcntl(GET) failed"); + exit(1); + } + flags = yes ? (flags|O_NONBLOCK) : (flags&~O_NONBLOCK); + + int r = fcntl(fd, F_SETFL, flags); + if (r<0) { + perror("fcntl(SET) failed"); + exit(1); + } + } + +#endif // defined(unix) + +// Algo benchmark, crash-safe, system-dependent stage static double bench_algo_stage2( enum sha256_algos algo )