From bc2b7d1895f56c83e21f68408734dd34069dbee6 Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 26 May 2017 23:17:12 +0300 Subject: [PATCH] Initial OS X support. --- CMakeLists.txt | 3 +- .../cryptonight-lite/cryptonight_lite_aesni.h | 18 ++-- .../cryptonight_lite_softaes.h | 12 +-- algo/cryptonight/cryptonight_aesni.h | 18 ++-- algo/cryptonight/cryptonight_softaes.h | 10 +- mac/cpu_mac.c | 47 ++++++++++ mac/memory_mac.c | 47 ++++++++++ mac/xmrig_mac.c | 91 +++++++++++++++++++ memory.c | 6 +- stratum.c | 37 +++++--- version.h | 4 +- 11 files changed, 244 insertions(+), 49 deletions(-) create mode 100644 mac/cpu_mac.c create mode 100644 mac/memory_mac.c create mode 100644 mac/xmrig_mac.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 12696ae76..39465124c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,8 @@ if (WIN32) set(SOURCES_OS win/cpu_win.c win/memory_win.c win/xmrig_win.c win/app.rc compat/winansi.c) set(EXTRA_LIBS ws2_32) add_definitions(/D_WIN32_WINNT=0x600) +elseif (APPLE) + set(SOURCES_OS mac/cpu_mac.c mac/memory_mac.c mac/xmrig_mac.c) else() set(SOURCES_OS unix/cpu_unix.c unix/memory_unix.c unix/xmrig_unix.c) set(EXTRA_LIBS pthread) @@ -136,4 +138,3 @@ else() target_link_libraries(xmrig32 jansson curl ${CPUID_LIB} ${EXTRA_LIBS}) endif() -source_group("HEADERS" FILES ${HEADERS}) diff --git a/algo/cryptonight-lite/cryptonight_lite_aesni.h b/algo/cryptonight-lite/cryptonight_lite_aesni.h index e69c79b26..bb528cfb4 100644 --- a/algo/cryptonight-lite/cryptonight_lite_aesni.h +++ b/algo/cryptonight-lite/cryptonight_lite_aesni.h @@ -41,7 +41,7 @@ // This will shift and xor tmp1 into itself as 4 32-bit vals such as // sl_xor(a1 a2 a3 a4) = a1 (a2^a1) (a3^a2^a1) (a4^a3^a2^a1) -inline __m128i sl_xor(__m128i tmp1) +static inline __m128i sl_xor(__m128i tmp1) { __m128i tmp4; tmp4 = _mm_slli_si128(tmp1, 0x04); @@ -54,31 +54,31 @@ inline __m128i sl_xor(__m128i tmp1) } -inline void aes_genkey_sub1(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub1(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x1) } -inline void aes_genkey_sub2(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub2(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x2) } -inline void aes_genkey_sub4(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub4(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x4) } -inline void aes_genkey_sub8(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub8(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x8) } -inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) +static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) { *x0 = _mm_aesenc_si128(*x0, key); *x1 = _mm_aesenc_si128(*x1, key); @@ -91,7 +91,7 @@ inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128 } -inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) +static inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) { __m128i xout0 = _mm_load_si128(memory); __m128i xout2 = _mm_load_si128(memory + 1); @@ -211,7 +211,7 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output) #if defined(__x86_64__) # define EXTRACT64(X) _mm_cvtsi128_si64(X) -inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) +static inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) { unsigned __int128 r = (unsigned __int128) a * (unsigned __int128) b; *hi = r >> 64; @@ -226,7 +226,7 @@ inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) ((uint64_t)(uint32_t)_mm_cvtsi128_si32(X) | \ ((uint64_t)(uint32_t)_mm_cvtsi128_si32(HI32(X)) << 32)) -inline uint64_t _umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { +static inline uint64_t _umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { // multiplier = ab = a * 2^32 + b // multiplicand = cd = c * 2^32 + d // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d diff --git a/algo/cryptonight-lite/cryptonight_lite_softaes.h b/algo/cryptonight-lite/cryptonight_lite_softaes.h index 3b28d3223..bab3dcafe 100644 --- a/algo/cryptonight-lite/cryptonight_lite_softaes.h +++ b/algo/cryptonight-lite/cryptonight_lite_softaes.h @@ -33,7 +33,7 @@ extern __m128i soft_aeskeygenassist(__m128i key, uint8_t rcon); // This will shift and xor tmp1 into itself as 4 32-bit vals such as // sl_xor(a1 a2 a3 a4) = a1 (a2^a1) (a3^a2^a1) (a4^a3^a2^a1) -inline __m128i sl_xor(__m128i tmp1) +static inline __m128i sl_xor(__m128i tmp1) { __m128i tmp4; tmp4 = _mm_slli_si128(tmp1, 0x04); @@ -46,7 +46,7 @@ inline __m128i sl_xor(__m128i tmp1) } -inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2, uint8_t rcon) +static inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2, uint8_t rcon) { __m128i xout1 = soft_aeskeygenassist(*xout2, rcon); xout1 = _mm_shuffle_epi32(xout1, 0xFF); // see PSHUFD, set all elems to 4th elem @@ -59,7 +59,7 @@ inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2, uint8_t rcon) } -inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) +static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) { *x0 = soft_aesenc(*x0, key); *x1 = soft_aesenc(*x1, key); @@ -72,7 +72,7 @@ inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128 } -inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) +static inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) { __m128i xout0 = _mm_load_si128(memory); __m128i xout2 = _mm_load_si128(memory + 1); @@ -192,7 +192,7 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output) #if defined(__x86_64__) # define EXTRACT64(X) _mm_cvtsi128_si64(X) -inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) +static inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) { unsigned __int128 r = (unsigned __int128) a * (unsigned __int128) b; *hi = r >> 64; @@ -207,7 +207,7 @@ inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) ((uint64_t)(uint32_t)_mm_cvtsi128_si32(X) | \ ((uint64_t)(uint32_t)_mm_cvtsi128_si32(HI32(X)) << 32)) -inline uint64_t _umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { +static inline uint64_t _umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { // multiplier = ab = a * 2^32 + b // multiplicand = cd = c * 2^32 + d // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d diff --git a/algo/cryptonight/cryptonight_aesni.h b/algo/cryptonight/cryptonight_aesni.h index dcbc740dd..e4d6d42f1 100644 --- a/algo/cryptonight/cryptonight_aesni.h +++ b/algo/cryptonight/cryptonight_aesni.h @@ -41,7 +41,7 @@ // This will shift and xor tmp1 into itself as 4 32-bit vals such as // sl_xor(a1 a2 a3 a4) = a1 (a2^a1) (a3^a2^a1) (a4^a3^a2^a1) -inline __m128i sl_xor(__m128i tmp1) +static inline __m128i sl_xor(__m128i tmp1) { __m128i tmp4; tmp4 = _mm_slli_si128(tmp1, 0x04); @@ -54,31 +54,31 @@ inline __m128i sl_xor(__m128i tmp1) } -inline void aes_genkey_sub1(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub1(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x1) } -inline void aes_genkey_sub2(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub2(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x2) } -inline void aes_genkey_sub4(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub4(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x4) } -inline void aes_genkey_sub8(__m128i* xout0, __m128i* xout2) +static inline void aes_genkey_sub8(__m128i* xout0, __m128i* xout2) { aes_genkey_sub(0x8) } -inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) +static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) { *x0 = _mm_aesenc_si128(*x0, key); *x1 = _mm_aesenc_si128(*x1, key); @@ -91,7 +91,7 @@ inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128 } -inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) +static inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) { __m128i xout0 = _mm_load_si128(memory); __m128i xout2 = _mm_load_si128(memory + 1); @@ -211,7 +211,7 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output) #if defined(__x86_64__) # define EXTRACT64(X) _mm_cvtsi128_si64(X) -inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) +static inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) { unsigned __int128 r = (unsigned __int128) a * (unsigned __int128) b; *hi = r >> 64; @@ -226,7 +226,7 @@ inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) ((uint64_t)(uint32_t)_mm_cvtsi128_si32(X) | \ ((uint64_t)(uint32_t)_mm_cvtsi128_si32(HI32(X)) << 32)) -inline uint64_t _umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { +static inline uint64_t _umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { // multiplier = ab = a * 2^32 + b // multiplicand = cd = c * 2^32 + d // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d diff --git a/algo/cryptonight/cryptonight_softaes.h b/algo/cryptonight/cryptonight_softaes.h index 0d70f8ca5..f12ab8c67 100644 --- a/algo/cryptonight/cryptonight_softaes.h +++ b/algo/cryptonight/cryptonight_softaes.h @@ -33,7 +33,7 @@ extern __m128i soft_aeskeygenassist(__m128i key, uint8_t rcon); // This will shift and xor tmp1 into itself as 4 32-bit vals such as // sl_xor(a1 a2 a3 a4) = a1 (a2^a1) (a3^a2^a1) (a4^a3^a2^a1) -inline __m128i sl_xor(__m128i tmp1) +static inline __m128i sl_xor(__m128i tmp1) { __m128i tmp4; tmp4 = _mm_slli_si128(tmp1, 0x04); @@ -46,7 +46,7 @@ inline __m128i sl_xor(__m128i tmp1) } -inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2, uint8_t rcon) +static inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2, uint8_t rcon) { __m128i xout1 = soft_aeskeygenassist(*xout2, rcon); xout1 = _mm_shuffle_epi32(xout1, 0xFF); // see PSHUFD, set all elems to 4th elem @@ -59,7 +59,7 @@ inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2, uint8_t rcon) } -inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) +static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) { *x0 = soft_aesenc(*x0, key); *x1 = soft_aesenc(*x1, key); @@ -72,7 +72,7 @@ inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128 } -inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) +static inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) { __m128i xout0 = _mm_load_si128(memory); __m128i xout2 = _mm_load_si128(memory + 1); @@ -192,7 +192,7 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output) #if defined(__x86_64__) # define EXTRACT64(X) _mm_cvtsi128_si64(X) -inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) +static inline uint64_t _umul128(uint64_t a, uint64_t b, uint64_t* hi) { unsigned __int128 r = (unsigned __int128) a * (unsigned __int128) b; *hi = r >> 64; diff --git a/mac/cpu_mac.c b/mac/cpu_mac.c new file mode 100644 index 000000000..88bda5419 --- /dev/null +++ b/mac/cpu_mac.c @@ -0,0 +1,47 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2016-2017 XMRig + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "cpu.h" + + +struct cpu_info cpu_info = { 0 }; +void cpu_init_common(); + + +void cpu_init() { +# ifdef XMRIG_NO_LIBCPUID + cpu_info.total_logical_cpus = sysconf(_SC_NPROCESSORS_CONF); +# endif + + cpu_init_common(); +} + + +int affine_to_cpu_mask(int id, unsigned long mask) +{ + return 0; +} diff --git a/mac/memory_mac.c b/mac/memory_mac.c new file mode 100644 index 000000000..868ffb146 --- /dev/null +++ b/mac/memory_mac.c @@ -0,0 +1,47 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2016-2017 XMRig + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "persistent_memory.h" +#include "options.h" +#include "utils/applog.h" + +char *persistent_memory; +int persistent_memory_flags = 0; + + +const char * persistent_memory_allocate() { + const int ratio = (opt_double_hash && opt_algo != ALGO_CRYPTONIGHT_LITE) ? 2 : 1; + const int size = MEMORY * (opt_n_threads * ratio + 1); + + persistent_memory = _mm_malloc(size, 16); + return persistent_memory; +} + + +void persistent_memory_free() { + _mm_free(persistent_memory); +} diff --git a/mac/xmrig_mac.c b/mac/xmrig_mac.c new file mode 100644 index 000000000..f7278c6db --- /dev/null +++ b/mac/xmrig_mac.c @@ -0,0 +1,91 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2016-2017 XMRig + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include "options.h" +#include "cpu.h" +#include "utils/applog.h" + + +static void signal_handler(int sig) +{ + switch (sig) { + case SIGHUP: + applog(LOG_WARNING, "SIGHUP received"); + break; + + case SIGINT: + applog(LOG_WARNING, "SIGINT received, exiting"); + proper_exit(0); + break; + + case SIGTERM: + applog(LOG_WARNING, "SIGTERM received, exiting"); + proper_exit(0); + break; + } +} + + +void proper_exit(int reason) { + exit(reason); +} + + +void os_specific_init() +{ + if (opt_affinity != -1) { + affine_to_cpu_mask(-1, opt_affinity); + } + + if (opt_background) { + int i = fork(); + if (i < 0) { + exit(1); + } + + if (i > 0) { + exit(0); + } + + i = setsid(); + + if (i < 0) { + applog(LOG_ERR, "setsid() failed (errno = %d)", errno); + } + + i = chdir("/"); + if (i < 0) { + applog(LOG_ERR, "chdir() failed (errno = %d)", errno); + } + + signal(SIGHUP, signal_handler); + signal(SIGTERM, signal_handler); + } + + signal(SIGINT, signal_handler); +} diff --git a/memory.c b/memory.c index 2032a2548..112f11153 100644 --- a/memory.c +++ b/memory.c @@ -38,12 +38,12 @@ static void * create_persistent_ctx_lite(int thr_id) { const size_t offset = MEMORY * (thr_id + 1); ctx = (struct cryptonight_ctx *) &persistent_memory[offset + MEMORY_LITE]; - ctx->memory = &persistent_memory[offset]; + ctx->memory = (uint8_t*) &persistent_memory[offset]; return ctx; } ctx = (struct cryptonight_ctx *) &persistent_memory[MEMORY - sizeof(struct cryptonight_ctx) * (thr_id + 1)]; - ctx->memory = &persistent_memory[MEMORY * (thr_id + 1)]; + ctx->memory = (uint8_t*) &persistent_memory[MEMORY * (thr_id + 1)]; return ctx; } @@ -70,7 +70,7 @@ void * create_persistent_ctx(int thr_id) { struct cryptonight_ctx *ctx = (struct cryptonight_ctx *) &persistent_memory[MEMORY - sizeof(struct cryptonight_ctx) * (thr_id + 1)]; const int ratio = opt_double_hash ? 2 : 1; - ctx->memory = &persistent_memory[MEMORY * (thr_id * ratio + 1)]; + ctx->memory = (uint8_t*) &persistent_memory[MEMORY * (thr_id * ratio + 1)]; return ctx; } diff --git a/stratum.c b/stratum.c index 1f2a4b8e6..4e9372519 100644 --- a/stratum.c +++ b/stratum.c @@ -36,6 +36,10 @@ # include #endif +#ifdef __APPLE_CC__ +# include +#endif + #include "stratum.h" #include "version.h" #include "stats.h" @@ -537,31 +541,36 @@ static int sockopt_keepalive_cb(void *userdata, curl_socket_t fd, curlsocktype p int tcp_keepintvl = 50; #ifndef WIN32 - if (unlikely(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, - sizeof(keepalive)))) + if (unlikely(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)))) { return 1; -#ifdef __linux - if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPCNT, - &tcp_keepcnt, sizeof(tcp_keepcnt)))) + } + +# ifdef __linux + if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_keepcnt, sizeof(tcp_keepcnt)))) { return 1; - if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, - &tcp_keepidle, sizeof(tcp_keepidle)))) + } + + if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle)))) { return 1; - if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, - &tcp_keepintvl, sizeof(tcp_keepintvl)))) + } + + if (unlikely(setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof(tcp_keepintvl)))) { return 1; -#endif /* __linux */ -#ifdef __APPLE_CC__ - if (unlikely(setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, - &tcp_keepintvl, sizeof(tcp_keepintvl)))) + } +# endif /* __linux */ + +# ifdef __APPLE_CC__ + if (unlikely(setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &tcp_keepintvl, sizeof(tcp_keepintvl)))) { return 1; -#endif /* __APPLE_CC__ */ + } +# endif /* __APPLE_CC__ */ #else /* WIN32 */ struct tcp_keepalive vals; vals.onoff = 1; vals.keepalivetime = tcp_keepidle * 1000; vals.keepaliveinterval = tcp_keepintvl * 1000; DWORD outputBytes; + if (unlikely(WSAIoctl(fd, SIO_KEEPALIVE_VALS, &vals, sizeof(vals), NULL, 0, &outputBytes, NULL, NULL))) { return 1; } diff --git a/version.h b/version.h index 6b453bdbe..330d96975 100644 --- a/version.h +++ b/version.h @@ -27,14 +27,14 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "Monero (XMR) CPU miner" -#define APP_VERSION "0.8.2" +#define APP_VERSION "0.8.3" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com" #define APP_VER_MAJOR 0 #define APP_VER_MINOR 8 -#define APP_VER_BUILD 2 +#define APP_VER_BUILD 3 #define APP_VER_REV 0 #endif /* __VERSION_H__ */