Permalink
Browse files

fix for x86 and arm (bionic) builds

to do later... arm static builds, more portable

to recheck with a compatible system... FreeBSD stuff
  • Loading branch information...
1 parent f9bae6b commit 4f99e0e23073ddb6b53cdb3995f068cbe5479b66 @tpruvot committed Aug 1, 2015
Showing with 272 additions and 29 deletions.
  1. +77 −0 Android.mk
  2. +1 −1 algo/cryptonight.c
  3. +5 −6 algo/neoscrypt.c
  4. +1 −1 asm/neoscrypt_asm.S
  5. +128 −0 compat/bionic/cpuminer-config.h
  6. +4 −10 cpu-miner.c
  7. +10 −7 crypto/int-util.h
  8. +46 −4 crypto/oaes_lib.c
View
@@ -0,0 +1,77 @@
+################################################################
+# Sample Android repo Makefile, used to test arm on the Tegra K1
+################################################################
+
+cpuminer-src := $(call my-dir)
+
+LOCAL_PATH := $(cpuminer-src)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE=cpuminer-jansson
+LOCAL_MODULE_TAGS=optional
+
+define all-c-files-under
+$(patsubst ./%,%, \
+ $(shell cd $(LOCAL_PATH) ; \
+ find -L $(1) -name "*.c" -and -not -name ".*") \
+ )
+endef
+
+LOCAL_SRC_FILES := $(call all-c-files-under,compat/jansson)
+LOCAL_C_INCLUDES := $(cpuminer-src)/compat/jansson
+
+include $(BUILD_STATIC_LIBRARY)
+
+################################################################
+
+
+LOCAL_PATH := $(cpuminer-src)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE=cpuminer
+LOCAL_MODULE_TAGS=optional
+LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
+LOCAL_MODULE_STEM := $(LOCAL_MODULE)
+
+LOCAL_C_INCLUDES := $(cpuminer-src)/compat/bionic \
+ $(cpuminer-src)/compat/jansson \
+ $(TARGET_OUT_INTERMEDIATES)/include/libcurl \
+ external/openssl/include \
+
+LOCAL_CFLAGS := -std=c99 -Wno-pointer-sign -Wno-missing-field-initializers \
+ -Wno-unused-parameter #-DNOASM
+LOCAL_CFLAGS += -DVERSION=\"1.2\"
+
+sph_files:=$(call all-c-files-under,sha3)
+
+LOCAL_SRC_FILES=\
+ cpu-miner.c util.c \
+ api.c sysinfos.c \
+ $(call all-c-files-under,algo) \
+ $(filter-out sha3/md_helper.c,$(sph_files)) \
+ $(call all-c-files-under,crypto) \
+ $(call all-c-files-under,lyra2) \
+ asm/sha2-$(TARGET_ARCH).S \
+ asm/scrypt-$(TARGET_ARCH).S \
+ asm/neoscrypt_asm.S
+
+LOCAL_STATIC_LIBRARIES := libm cpuminer-jansson
+LOCAL_STATIC_LIBRARIES += libz libcrypto_static
+LOCAL_STATIC_LIBRARIES += libssl_static
+
+# Require curl config changes and an addional
+# module definition in external/curl(_static?)
+#LOCAL_FORCE_STATIC_EXECUTABLE := true
+
+ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+LOCAL_CFLAGS += -DCURL_STATICLIB # -DHTTP_ONLY
+LOCAL_STATIC_LIBRARIES += libcurl_static libc
+else
+LOCAL_SHARED_LIBRARIES := libssl libcrypto
+LOCAL_SHARED_LIBRARIES += libcurl
+#LOCAL_STATIC_LIBRARIES += libcurl_static
+endif
+
+include $(BUILD_EXECUTABLE)
+
View
@@ -85,7 +85,7 @@ extern int fast_aesb_pseudo_round_mut(uint8_t *val, uint8_t *expandedKey);
#define fast_aesb_pseudo_round_mut aesb_pseudo_round_mut
#endif
-#ifdef NOASM
+#if defined(NOASM) || !defined(__x86_64__)
static uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi) {
// multiplier = ab = a * 2^32 + b
// multiplicand = cd = c * 2^32 + d
View
@@ -45,7 +45,7 @@
#endif
#ifdef __GNUC__
-#ifdef NOASM
+#if defined(NOASM) || defined(__arm__)
#define ASM 0
#else
#define ASM 1
@@ -1005,16 +1005,15 @@ void neoscrypt(uchar *output, const uchar *password, uint32_t profile)
static bool fulltest_le(const uint *hash, const uint *target)
{
- uint i;
- bool rc;
+ bool rc = false;
- for (i = 7; i >= 0; i--) {
+ for (int i = 7; i >= 0; i--) {
if (hash[i] > target[i]) {
- rc = 0;
+ rc = false;
break;
}
if(hash[i] < target[i]) {
- rc = 1;
+ rc = true;
break;
}
}
View
@@ -29,7 +29,7 @@
#include "miner.h"
#endif
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__arm__)
#define ASM 1
/* #define WIN64 0 */
#endif
@@ -0,0 +1,128 @@
+/* cpuminer-config.h.in. Adapted for arm bionic (Android 5.1.1 Tegra K1) */
+
+/* Define to 1 if using `alloca.c'. */
+/* #undef C_ALLOCA */
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+#define HAVE_ALLOCA_H 1
+
+/* Define to 1 if you have the declaration of `be32dec', and to 0 if you
+ don't. */
+#define HAVE_DECL_BE32DEC 0
+
+/* Define to 1 if you have the declaration of `be32enc', and to 0 if you
+ don't. */
+#define HAVE_DECL_BE32ENC 0
+
+/* Define to 1 if you have the declaration of `le16dec', and to 0 if you
+ don't. */
+#define HAVE_DECL_LE16DEC 0
+
+/* Define to 1 if you have the declaration of `le16enc', and to 0 if you
+ don't. */
+#define HAVE_DECL_LE16ENC 0
+
+/* Define to 1 if you have the declaration of `le32dec', and to 0 if you
+ don't. */
+#define HAVE_DECL_LE32DEC 0
+
+/* Define to 1 if you have the declaration of `le32enc', and to 0 if you
+ don't. */
+#define HAVE_DECL_LE32ENC 0
+
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#define HAVE_SYSLOG_H 1
+
+/* Define to 1 if you have the <sys/endian.h> header file. */
+/* #undef HAVE_SYS_ENDIAN_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/sysctl.h> header file. */
+#undef HAVE_SYS_SYSCTL_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Name of package */
+#define PACKAGE "cpuminer-multi"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "cpuminer-multi"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "cpuminer-multi " VERSION
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "cpuminer-multi"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "http://github.com/tpruvot/cpuminer-multi"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION VERSION
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at runtime.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if assembly routines are wanted. */
+#define USE_ASM 1
+
+/* Define to 1 if AVX assembly is available. */
+#define USE_AVX 1
+
+/* Define to 1 if AVX2 assembly is available. */
+#define USE_AVX2 1
+
+/* Define if __uint128_t is available */
+#undef USE_INT128
+
+/* Define to 1 if XOP assembly is available. */
+#define USE_XOP 1
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
View
@@ -411,6 +411,10 @@ static inline void drop_policy(void)
#endif
}
+#ifdef __BIONIC__
+#define pthread_setaffinity_np(tid,sz,s) {} /* only do process affinity */
+#endif
+
static void affine_to_cpu_mask(int id, uint8_t mask) {
cpu_set_t set;
CPU_ZERO(&set);
@@ -426,17 +430,7 @@ static void affine_to_cpu_mask(int id, uint8_t mask) {
pthread_setaffinity_np(thr_info[id].pth, sizeof(&set), &set);
}
}
-#elif defined(__FreeBSD__) /* FreeBSD specific policy and affinity management */
-#include <sys/cpuset.h>
-static inline void drop_policy(void) { }
-static inline void affine_to_cpu(int id, int cpu)
-{
- cpuset_t set;
- CPU_ZERO(&set);
- CPU_SET(cpu, &set);
- cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(cpuset_t), &set);
-}
#elif defined(WIN32) /* Windows */
static inline void drop_policy(void) { }
static void affine_to_cpu_mask(int id, uint8_t mask) {
View
@@ -16,12 +16,17 @@
#define inline __inline
#endif
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 0x1234
+#define BIG_ENDIAN 0x4321
+#endif
+
+#if !defined(BYTE_ORDER) && (defined(__LITTLE_ENDIAN__) || defined(__arm__) || defined(WIN32))
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
#if defined(WIN32)
#include <stdlib.h>
-//#define IS_LITTLE_ENDIAN (1 == *(unsigned char *)&(const int){1})
-#define LITTLE_ENDIAN 1234
-#define BIG_ENDIAN 4321
-#define BYTE_ORDER LITTLE_ENDIAN
static inline uint32_t rol32(uint32_t x, int r) {
return _rotl(x, r);
@@ -51,8 +56,6 @@ static inline uint64_t lo_dword(uint64_t val) {
return val & 0xFFFFFFFF;
}
-extern uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t* product_hi);
-
static inline uint64_t div_with_reminder(uint64_t dividend, uint32_t divisor, uint32_t* remainder) {
dividend |= ((uint64_t)*remainder) << 32;
*remainder = dividend % divisor;
@@ -189,4 +192,4 @@ static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not e
#define memcpy_swap64le memcpy_swap64
#endif
-#endif /* INT_UTILS_H_ */
+#endif /* INT_UTILS_H_ */
View
@@ -28,14 +28,56 @@
* ---------------------------------------------------------------------------
*/
static const char _NR[] = {
- 0x4e,0x61,0x62,0x69,0x6c,0x20,0x53,0x2e,0x20,
- 0x41,0x6c,0x20,0x52,0x61,0x6d,0x6c,0x69,0x00 };
+ 0x4e,0x61,0x62,0x69,0x6c,0x20,0x53,0x2e,0x20,
+ 0x41,0x6c,0x20,0x52,0x61,0x6d,0x6c,0x69,0x00
+};
+
+#include <sys/types.h>
+#define NO_OLDNAMES /* timeb is still defined in mingw */
#include "miner.h"
#include <stddef.h>
-#include <time.h>
-#include <sys/timeb.h>
+#include <time.h>
+
+// Only used by ftime, which was removed from POSIX 2008.
+struct timeb {
+ time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
+
+#ifdef _MSC_VER
+struct timezone {
+ int tz_minuteswest; /* minutes W of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+#endif
+
+// This was removed from POSIX 2008.
+static int ftime(struct timeb* tb) {
+ struct timeval tv;
+ struct timezone tz;
+
+ if (gettimeofday(&tv, &tz) < 0)
+ return -1;
+
+ tb->time = tv.tv_sec;
+ tb->millitm = (tv.tv_usec + 500) / 1000;
+
+ if (tb->millitm == 1000) {
+ ++tb->time;
+ tb->millitm = 0;
+ }
+
+ tb->timezone = tz.tz_minuteswest;
+ tb->dstflag = tz.tz_dsttime;
+
+ return 0;
+}
+
+
#if !((defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__APPLE__))
#include <malloc.h>
#endif

0 comments on commit 4f99e0e

Please sign in to comment.