Skip to content

Commit

Permalink
small changes in --version output
Browse files Browse the repository at this point in the history
+ add sph haval which was half there in the vstudio project
  • Loading branch information
tpruvot committed May 22, 2016
1 parent 9180670 commit b971285
Show file tree
Hide file tree
Showing 10 changed files with 2,201 additions and 14 deletions.
11 changes: 11 additions & 0 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ static __inline int setpriority(int which, int who, int prio)
#define _ALIGN(x) __declspec(align(x))
typedef int ssize_t;

__inline int msver(void) {
switch (_MSC_VER) {
case 1500: return 2008;
case 1600: return 2010;
case 1700: return 2012;
case 1800: return 2013;
case 1900: return 2015;
default: return (_MSC_VER/100);
}
}

#include <stdlib.h>
// This static var is made to be compatible with linux/mingw (no free on string result)
// This is not thread safe but we only use that once on process start
Expand Down
6 changes: 3 additions & 3 deletions compat/cpuminer-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#define PACKAGE_NAME "cpuminer-multi"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "cpuminer-multi 1.2"
#define PACKAGE_STRING "cpuminer-multi 1.3"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "cpuminer-multi"
Expand All @@ -103,7 +103,7 @@
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "1.2"
#define PACKAGE_VERSION "1.3"

/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
Expand Down Expand Up @@ -132,7 +132,7 @@
#define USE_XOP 1

/* Version number of package */
#define VERSION "1.2"
#define VERSION "1.3"

/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
43 changes: 33 additions & 10 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -2575,15 +2575,38 @@ static void *stratum_thread(void *userdata)

static void show_version_and_exit(void)
{
printf(" built on " __DATE__
printf(" built "
#ifdef _MSC_VER
" with VC++ 2013\n");
"with VC++ %d", msver());
#elif defined(__GNUC__)
" with GCC");
printf(" %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
"with GCC ");
printf("%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif
printf(" the " __DATE__ "\n");

printf(" features:"
// Note: if compiled with cpu opts (instruction sets),
// the binary is no more compatible with older ones!
printf(" compiled for"
#if defined(__ARM_NEON__)
" ARM NEON"
#elif defined(__AVX2__)
" AVX2"
#elif defined(__AVX__)
" AVX"
#elif defined(__XOP__)
" XOP"
#elif defined(__SSE4_1__)
" SSE4"
#elif defined(_M_X64) || defined(__x86_64__)
" x64"
#elif defined(_M_IX86) || defined(__x86__)
" x86"
#else
" general use"
#endif
"\n");

printf(" config features:"
#if defined(USE_ASM) && defined(__i386__)
" i386"
#endif
Expand All @@ -2593,15 +2616,15 @@ static void show_version_and_exit(void)
#if defined(USE_ASM) && (defined(__i386__) || defined(__x86_64__))
" SSE2"
#endif
#if defined(__x86_64__) && defined(USE_XOP)
" XOP"
#endif
#if defined(__x86_64__) && defined(USE_AVX)
" AVX"
#endif
#if defined(__x86_64__) && defined(USE_AVX2)
" AVX2"
#endif
#if defined(__x86_64__) && defined(USE_XOP)
" XOP"
#endif
#if defined(USE_ASM) && defined(__arm__) && defined(__APCS_32__)
" ARM"
#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \
Expand Down Expand Up @@ -3133,8 +3156,8 @@ static int thread_create(struct thr_info *thr, void* func)

static void show_credits()
{
printf("** " PACKAGE_NAME " " PACKAGE_VERSION " by Tanguy Pruvot (tpruvot@github) **\n");
printf("BTC donation address: 1FhDPLPpw18X4srecguG3MxJYe4a1JsZnd\n\n");
printf("** " PACKAGE_NAME " " PACKAGE_VERSION " by tpruvot@github **\n");
printf("BTC donation address: 1FhDPLPpw18X4srecguG3MxJYe4a1JsZnd (tpruvot)\n\n");
}

void get_defconfig_path(char *out, size_t bufsize, char *argv0);
Expand Down
1 change: 1 addition & 0 deletions cpuminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
<ClCompile Include="sha3\sph_hamsi_helper.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="sha3\sph_haval.c" />
<ClCompile Include="sha3\sph_whirlpool.c" />
<ClCompile Include="sha3\sph_gost.c" />
<ClCompile Include="sha3\md_helper.c">
Expand Down
3 changes: 3 additions & 0 deletions cpuminer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<ClCompile Include="sha3\sph_hamsi_helper.c">
<Filter>sph</Filter>
</ClCompile>
<ClCompile Include="sha3\sph_haval.c">
<Filter>sph</Filter>
</ClCompile>
<ClCompile Include="sha3\sph_hefty1.c">
<Filter>sph</Filter>
</ClCompile>
Expand Down
195 changes: 195 additions & 0 deletions sha3/haval_helper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/* $Id: haval_helper.c 218 2010-06-08 17:06:34Z tp $ */
/*
* Helper code, included (three times !) by HAVAL implementation.
*
* TODO: try to merge this with md_helper.c.
*
* ==========================(LICENSE BEGIN)============================
*
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* ===========================(LICENSE END)=============================
*
* @author Thomas Pornin <[email protected]>
*/

#undef SPH_XCAT
#define SPH_XCAT(a, b) SPH_XCAT_(a, b)
#undef SPH_XCAT_
#define SPH_XCAT_(a, b) a ## b

static void
#ifdef SPH_UPTR
SPH_XCAT(SPH_XCAT(haval, PASSES), _short)
#else
SPH_XCAT(haval, PASSES)
#endif
(sph_haval_context *sc, const void *data, size_t len)
{
unsigned current;

#if SPH_64
current = (unsigned)sc->count & 127U;
#else
current = (unsigned)sc->count_low & 127U;
#endif
while (len > 0) {
unsigned clen;
#if !SPH_64
sph_u32 clow, clow2;
#endif

clen = 128U - current;
if (clen > len)
clen = (unsigned) len;
memcpy(sc->buf + current, data, clen);
data = (const unsigned char *)data + clen;
current += clen;
len -= clen;
if (current == 128U) {
DSTATE;
IN_PREPARE(sc->buf);

RSTATE;
SPH_XCAT(CORE, PASSES)(INW);
WSTATE;
current = 0;
}
#if SPH_64
sc->count += clen;
#else
clow = sc->count_low;
clow2 = SPH_T32(clow + clen);
sc->count_low = clow2;
if (clow2 < clow)
sc->count_high ++;
#endif
}
}

#ifdef SPH_UPTR
static void
SPH_XCAT(haval, PASSES)(sph_haval_context *sc, const void *data, size_t len)
{
unsigned current;
size_t orig_len;
#if !SPH_64
sph_u32 clow, clow2;
#endif
DSTATE;

if (len < 256U) {
SPH_XCAT(SPH_XCAT(haval, PASSES), _short)(sc, data, len);
return;
}
#if SPH_64
current = (unsigned)sc->count & 127U;
#else
current = (unsigned)sc->count_low & 127U;
#endif
if (current > 0) {
unsigned clen;

clen = 128U - current;
SPH_XCAT(SPH_XCAT(haval, PASSES), _short)(sc, data, clen);
data = (const unsigned char *)data + clen;
len -= clen;
}
#if !SPH_UNALIGNED
if (((SPH_UPTR)data & 3U) != 0) {
SPH_XCAT(SPH_XCAT(haval, PASSES), _short)(sc, data, len);
return;
}
#endif
orig_len = len;
RSTATE;
while (len >= 128U) {
IN_PREPARE(data);

SPH_XCAT(CORE, PASSES)(INW);
data = (const unsigned char *)data + 128U;
len -= 128U;
}
WSTATE;
if (len > 0)
memcpy(sc->buf, data, len);
#if SPH_64
sc->count += (sph_u64)orig_len;
#else
clow = sc->count_low;
clow2 = SPH_T32(clow + orig_len);
sc->count_low = clow2;
if (clow2 < clow)
sc->count_high ++;
orig_len >>= 12;
orig_len >>= 10;
orig_len >>= 10;
sc->count_high += orig_len;
#endif
}
#endif

static void
SPH_XCAT(SPH_XCAT(haval, PASSES), _close)(sph_haval_context *sc,
unsigned ub, unsigned n, void *dst)
{
unsigned current;
DSTATE;

#if SPH_64
current = (unsigned)sc->count & 127U;
#else
current = (unsigned)sc->count_low & 127U;
#endif
sc->buf[current ++] = (0x01 << n) | ((ub & 0xFF) >> (8 - n));
RSTATE;
if (current > 118U) {
memset(sc->buf + current, 0, 128U - current);

do {
IN_PREPARE(sc->buf);

SPH_XCAT(CORE, PASSES)(INW);
} while (0);
current = 0;
}
memset(sc->buf + current, 0, 118U - current);
sc->buf[118] = 0x01 | (PASSES << 3);
sc->buf[119] = sc->olen << 3;
#if SPH_64
sph_enc64le_aligned(sc->buf + 120, SPH_T64(sc->count << 3));
#else
sph_enc32le_aligned(sc->buf + 120, SPH_T32(sc->count_low << 3));
sph_enc32le_aligned(sc->buf + 124,
SPH_T32((sc->count_high << 3) | (sc->count_low >> 29)));
#endif
do {
IN_PREPARE(sc->buf);

SPH_XCAT(CORE, PASSES)(INW);
} while (0);

WSTATE;
haval_out(sc, dst);
haval_init(sc, sc->olen, sc->passes);
}

Loading

0 comments on commit b971285

Please sign in to comment.