mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-05 11:34:16 +00:00
Add set_non_blocking routing
In preparation for upcoming generic unix automated algorithm benchmark method (as opposed to linux specific), add a utility method.
This commit is contained in:
parent
29f0f9bc18
commit
01886493cf
31
main.c
31
main.c
@ -36,8 +36,10 @@
|
|||||||
#include "findnonce.h"
|
#include "findnonce.h"
|
||||||
#include "ocl.h"
|
#include "ocl.h"
|
||||||
|
|
||||||
#if defined(__linux)
|
#if defined(unix)
|
||||||
#include <sys/mman.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@ -449,6 +451,31 @@ static double bench_algo_stage3(
|
|||||||
return rate;
|
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(
|
static double bench_algo_stage2(
|
||||||
enum sha256_algos algo
|
enum sha256_algos algo
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user