Memalign/sysconf fixes for mingw/windows (thanks to @iceman1001)
This commit is contained in:
@ -39,7 +39,19 @@ inline uint64_t crack_states_bitsliced(uint32_t **task){
|
|||||||
bitslice_t * restrict bitsliced_even_states[(task[4]-task[3])/MAX_BITSLICES];
|
bitslice_t * restrict bitsliced_even_states[(task[4]-task[3])/MAX_BITSLICES];
|
||||||
size_t bitsliced_blocks = 0;
|
size_t bitsliced_blocks = 0;
|
||||||
for(uint32_t const * restrict p_even = task[3]; p_even < task[4]; p_even+=MAX_BITSLICES){
|
for(uint32_t const * restrict p_even = task[3]; p_even < task[4]; p_even+=MAX_BITSLICES){
|
||||||
bitslice_t * restrict lstate_p = memalign(sizeof(bitslice_t), (STATE_SIZE+ROLLBACK_SIZE)*sizeof(bitslice_t));
|
#ifdef __WIN32
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
bitslice_t * restrict lstate_p = __mingw_aligned_malloc((STATE_SIZE+ROLLBACK_SIZE) * sizeof(bitslice_t), sizeof(bitslice_t));
|
||||||
|
#else
|
||||||
|
bitslice_t * restrict lstate_p = _aligned_malloc((STATE_SIZE+ROLLBACK_SIZE) * sizeof(bitslice_t), sizeof(bitslice_t));
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef __APPLE__
|
||||||
|
bitslice_t * restrict lstate_p = malloc((STATE_SIZE+ROLLBACK_SIZE) * sizeof(bitslice_t));
|
||||||
|
#else
|
||||||
|
bitslice_t * restrict lstate_p = memalign(sizeof(bitslice_t), (STATE_SIZE+ROLLBACK_SIZE) * sizeof(bitslice_t));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
memset(lstate_p, 0x0, (STATE_SIZE)*sizeof(bitslice_t));
|
memset(lstate_p, 0x0, (STATE_SIZE)*sizeof(bitslice_t));
|
||||||
// bitslice even half-states
|
// bitslice even half-states
|
||||||
const size_t max_slices = (task[4]-p_even) < MAX_BITSLICES ? task[4]-p_even : MAX_BITSLICES;
|
const size_t max_slices = (task[4]-p_even) < MAX_BITSLICES ? task[4]-p_even : MAX_BITSLICES;
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#ifndef __WIN32
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
#endif
|
||||||
#include "craptev1.h"
|
#include "craptev1.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#define __STDC_FORMAT_MACROS
|
#define __STDC_FORMAT_MACROS
|
||||||
@ -43,7 +45,7 @@ uint64_t *readnonces(char* fname){
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t **space;
|
uint32_t **space;
|
||||||
size_t thread_count;
|
size_t thread_count = 1;
|
||||||
uint64_t states_tested = 0;
|
uint64_t states_tested = 0;
|
||||||
uint64_t total_states;
|
uint64_t total_states;
|
||||||
|
|
||||||
@ -71,7 +73,9 @@ int main(int argc, char* argv[]){
|
|||||||
space = craptev1_get_space(nonces, 95, uid);
|
space = craptev1_get_space(nonces, 95, uid);
|
||||||
total_states = craptev1_sizeof_space(space);
|
total_states = craptev1_sizeof_space(space);
|
||||||
|
|
||||||
|
#ifndef __WIN32
|
||||||
thread_count = get_nprocs_conf();
|
thread_count = get_nprocs_conf();
|
||||||
|
#endif
|
||||||
// append some zeroes to the end of the space to make sure threads don't go off into the wild
|
// append some zeroes to the end of the space to make sure threads don't go off into the wild
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for(j = 0; space[j]; j+=5){
|
for(j = 0; space[j]; j+=5){
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#ifndef __WIN32
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
#endif
|
||||||
#include "craptev1.h"
|
#include "craptev1.h"
|
||||||
#include "crypto1_bs.h"
|
#include "crypto1_bs.h"
|
||||||
#include "crypto1_bs_crack.h"
|
#include "crypto1_bs_crack.h"
|
||||||
@ -44,7 +46,7 @@ uint64_t *readnonces(char* fname){
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t **space;
|
uint32_t **space;
|
||||||
size_t thread_count;
|
size_t thread_count = 1;
|
||||||
|
|
||||||
void* crack_states_thread(void* x){
|
void* crack_states_thread(void* x){
|
||||||
const size_t thread_id = (size_t)x;
|
const size_t thread_id = (size_t)x;
|
||||||
@ -72,7 +74,10 @@ int main(int argc, char* argv[]){
|
|||||||
space = craptev1_get_space(nonces, 95, uid);
|
space = craptev1_get_space(nonces, 95, uid);
|
||||||
total_states = craptev1_sizeof_space(space);
|
total_states = craptev1_sizeof_space(space);
|
||||||
|
|
||||||
thread_count = get_nprocs_conf();
|
#ifndef __WIN32
|
||||||
|
thread_count = sysconf(_SC_NPROCESSORS_CONF);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
// append some zeroes to the end of the space to make sure threads don't go off into the wild
|
// append some zeroes to the end of the space to make sure threads don't go off into the wild
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for(j = 0; space[j]; j+=5){
|
for(j = 0; space[j]; j+=5){
|
||||||
|
Reference in New Issue
Block a user