mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-03 17:40:13 +00:00
Initial OS X support.
This commit is contained in:
parent
ebb0f81f2f
commit
bc2b7d1895
11 changed files with 244 additions and 49 deletions
|
@ -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})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
47
mac/cpu_mac.c
Normal file
47
mac/cpu_mac.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#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;
|
||||
}
|
47
mac/memory_mac.c
Normal file
47
mac/memory_mac.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <mm_malloc.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#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);
|
||||
}
|
91
mac/xmrig_mac.c
Normal file
91
mac/xmrig_mac.c
Normal file
|
@ -0,0 +1,91 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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);
|
||||
}
|
6
memory.c
6
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;
|
||||
}
|
||||
|
|
37
stratum.c
37
stratum.c
|
@ -36,6 +36,10 @@
|
|||
# include <poll.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE_CC__
|
||||
# include <netinet/in.h>
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
Loading…
Reference in a new issue