Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif

EXTRA_DIST = example-cfg.json nomacro.pl

SUBDIRS = compat
SUBDIRS = compat algorithms

INCLUDES = $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES)

Expand All @@ -16,20 +16,9 @@ bin_PROGRAMS = minerd
dist_man_MANS = minerd.1

minerd_SOURCES = elist.h miner.h compat.h \
cpu-miner.c util.c \
sha2.c scrypt.c
if USE_ASM
if ARCH_x86
minerd_SOURCES += sha2-x86.S scrypt-x86.S
endif
if ARCH_x86_64
minerd_SOURCES += sha2-x64.S scrypt-x64.S
endif
if ARCH_ARM
minerd_SOURCES += sha2-arm.S scrypt-arm.S
endif
endif
cpu-miner.c util.c

minerd_LDFLAGS = $(PTHREAD_FLAGS)
minerd_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@
minerd_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@ @ALGO_LIBS@
minerd_CPPFLAGS = @LIBCURL_CPPFLAGS@

5 changes: 5 additions & 0 deletions algorithms/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

SUBDIRS = @ALGOS@

all-local:
sh ./genheader.sh @ALGOS@
5 changes: 5 additions & 0 deletions algorithms/example/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
noinst_LIBRARIES= libexample.a


libexample_a_SOURCES = plugin.c

67 changes: 67 additions & 0 deletions algorithms/example/plugin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <string.h>

#include "miner.h"

typedef struct {
int N;
double x;
} example_param_t;

static example_param_t default_param;

int init_EXAMPLE() {
default_param.N = 1023;
default_param.x = 12.1;

return 0; // 0 == success
}

void* thread_init_EXAMPLE(int* error, void *extra_param) {
example_param_t *p = (example_param_t*) extra_param;

void *buff = malloc((size_t)p->N * 1234);
*error = (buff == NULL);
return buff;
}


int scanhash_EXAMPLE(int thr_id, uint32_t *pdata,
unsigned char *scratchbuf, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, void *extra_param) {

example_param_t *p = (example_param_t*) extra_param;

// c.f. scrypt or sha256d code for usage of other parameters
return 0;
}

void *param_default_EXAMPLE() {
return (void*) &default_param;
}

void *param_parse_EXAMPLE(const char *str, int *error) {
static example_param_t p;
const char *delim = ",";
char *pch = strtok (str, delim);
int i = 0;

while( pch ) {
switch(i) {
case 0:
p.N = strtol(pch, NULL, 10);
applog(LOG_INFO, "example: Setting parameter N to %i", p.N);
break;
case 1:
p.x = strtod(pch, NULL);
applog(LOG_INFO, "example: Setting parameter x to %f", p.x);
break;
default:
applog(LOG_ERR, "Too many parameters specified to example algorithm: %s", str);
*error = 1;
return NULL;
}
i++;
pch = strtok (NULL, delim);
}
return (void*) &p;
}
18 changes: 18 additions & 0 deletions algorithms/example/plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef EXAMPLE_PLUGIN_H
#define EXAMPLE_PLUGIN_H

#define PLUGIN_NAME_EXAMPLE "example"
#define PLUGIN_DESC_EXAMPLE "example(N, x), default: N=1024, x=12.1"

int init_EXAMPLE();
void* thread_init_EXAMPLE(int* error, void *extra_param);

int scanhash_EXAMPLE(int thr_id, uint32_t *pdata,
void *thread_local_data, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, void* extra_param);

void *param_default_EXAMPLE();

void *param_parse_EXAMPLE( const char *str, int *error);

#endif // EXAMPLE_PLUGIN_H
13 changes: 13 additions & 0 deletions algorithms/genheader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

cat << EOF > all.h
/* This file is automatically generated. Do not edit. */
EOF

for i in $*; do
echo -e "#include \"$i/plugin.h\"" >> all.h
ALGORITHMS="${ALGORITHMS}(`echo $i | tr '[:lower:]' '[:upper:]'`)"
done

echo "#define ALGOS $ALGORITHMS" >> all.h

Empty file added algorithms/nist5/.dirstamp
Empty file.
6 changes: 6 additions & 0 deletions algorithms/nist5/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AUTOMAKE_OPTIONS = subdir-objects

noinst_LIBRARIES= libnist5.a

libnist5_a_CFLAGS = ${CFLAGS} -I../x11/ -I../x11/x5 -I../x11/x6 -DALGO_NAME=_NIST5
libnist5_a_SOURCES = xcoin.c
18 changes: 18 additions & 0 deletions algorithms/nist5/plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef NIST5_PLUGIN_H
#define NIST5_PLUGIN_H

#define PLUGIN_NAME_NIST5 "NIST5"
#define PLUGIN_DESC_NIST5 "\tNIST5 algorithm"

int init_NIST5();
void* thread_init_NIST5(int* error, void* extra_param);

int scanhash_NIST5(int thr_id, uint32_t *pdata,
void *thread_local_data, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, void* extra_param);

void *param_default_NIST5();

void *param_parse_NIST5( const char *str, int *error);

#endif // NIST5_PLUGIN_H
Loading