From fc51d1696b5590921f008108cd393883e5bee5ff Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 8 Feb 2014 18:40:37 +0100 Subject: [PATCH] VS2010 build: config.h cleanup and offload. Added git versioning. --- winbuild/dist/include/config.h | 195 ++++------------------------- winbuild/dist/include/gitversion.h | 0 winbuild/dist/include/winbuild.h | 140 +++++++++++++++++++++ winbuild/sgminer.vcxproj | 25 +++- winbuild/sgminer.vcxproj.filters | 3 + 5 files changed, 190 insertions(+), 173 deletions(-) create mode 100644 winbuild/dist/include/gitversion.h create mode 100644 winbuild/dist/include/winbuild.h diff --git a/winbuild/dist/include/config.h b/winbuild/dist/include/config.h index 45e28756..561b67d2 100644 --- a/winbuild/dist/include/config.h +++ b/winbuild/dist/include/config.h @@ -11,18 +11,22 @@ #if defined(_MSC_VER) +#define HAVE_LIBCURL 1 +#define CURL_HAS_KEEPALIVE 1 +#define HAVE_CURSES 1 +#define USE_SCRYPT 1 +#define HAVE_OPENCL 1 +#define HAVE_ADL 1 + #define WIN32 1 +#define _CRT_SECURE_NO_WARNINGS +#define WIN32_LEAN_AND_MEAN + +#define WANT_X8664_SSE4 + #define STDC_HEADERS 1 #define EXECV_2ND_ARG_TYPE char* const* -#define GNULIB_TEST_MEMCHR 1 -#define GNULIB_TEST_MEMMEM 1 -#define GNULIB_TEST_SIGACTION 1 -#define GNULIB_TEST_SIGPROCMASK 1 - -#define HAVE_LIBCURL 1 -#define CURL_HAS_KEEPALIVE 1 -#define HAVE_CURSES 1 #define HAVE_ALLOCA 1 #define HAVE_ATTRIBUTE_COLD 1 @@ -53,20 +57,6 @@ #define HAVE_WCHAR_H 1 #define HAVE_WCHAR_T 1 -#define _CRT_SECURE_NO_WARNINGS -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include - -#include -#pragma comment(lib, "winmm.lib") - -#define WANT_X8664_SSE4 - -#define USE_SCRYPT -#define HAVE_OPENCL -#define HAVE_ADL - #define PRIi64 "I64d" #define PRIi32 "I32d" #define PRIu32 "I32u" @@ -76,166 +66,33 @@ #define R_OK 0 -#define snprintf _snprintf -#define strdup _strdup - -#include -#include +// Libraries to include +#pragma comment(lib, "winmm.lib") +#pragma comment(lib, "wsock32.lib") +#pragma comment(lib, "pthreadVC2.lib") +#pragma comment(lib, "OpenCL.lib") -#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) - -//#define USE_AVX2 1 - -#define inline __inline - -#include -#include -#include - -typedef intptr_t ssize_t; - - -struct timezone2 -{ - __int32 tz_minuteswest; /* minutes W of Greenwich */ - __int32 tz_dsttime; /* type of dst correction */ -}; - - -#include -#include - -const __int64 DELTA_EPOCH_IN_MICROSECS= 11644473600000000; - -/* IN UNIX the use of the timezone struct is obsolete; -I don't know why you use it. See http://linux.about.com/od/commands/l/blcmdl2_gettime.htm -But if you want to use this structure to know about GMT(UTC) diffrence from your local time -it will be next: tz_minuteswest is the real diffrence in minutes from GMT(UTC) and a tz_dsttime is a flag -indicates whether daylight is now in use -*/ - -inline int gettimeofday(struct timeval *tv/*in*/, struct timezone2 *tz/*in*/) -{ - FILETIME ft; - __int64 tmpres = 0; - TIME_ZONE_INFORMATION tz_winapi; - int rez=0; - - ZeroMemory(&ft,sizeof(ft)); - ZeroMemory(&tz_winapi,sizeof(tz_winapi)); - - GetSystemTimeAsFileTime(&ft); - - tmpres = ft.dwHighDateTime; - tmpres <<= 32; - tmpres |= ft.dwLowDateTime; - - /*converting file time to unix epoch*/ - tmpres /= 10; /*convert into microseconds*/ - tmpres -= DELTA_EPOCH_IN_MICROSECS; - tv->tv_sec = (__int32)(tmpres*0.000001); - tv->tv_usec =(tmpres%1000000); - - if( tz ) - { - //_tzset(),don't work properly, so we use GetTimeZoneInformation - rez=GetTimeZoneInformation(&tz_winapi); - tz->tz_dsttime=(rez==2)?true:false; - tz->tz_minuteswest = tz_winapi.Bias + ((rez==2)?tz_winapi.DaylightBias:0); - } - - return 0; -} - -inline int strcasecmp(const char *s1, const char *s2) -{ - unsigned char c1,c2; - do { - c1 = *s1++; - c2 = *s2++; - c1 = (unsigned char) tolower( (unsigned char) c1); - c2 = (unsigned char) tolower( (unsigned char) c2); - } - while((c1 == c2) && (c1 != '\0')); - return (int) c1-c2; -} - -inline int strncasecmp(const char *s1, const char *s2, size_t n) -{ - if (n == 0) - return 0; - - while (n-- != 0 && tolower(*s1) == tolower(*s2)) - { - if (n == 0 || *s1 == '\0' || *s2 == '\0') - break; - s1++; - s2++; - } - - return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); -} - -#include -inline long double roundl(long double r) -{ - return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5); -} - -#if (_MSC_VER < 1800) -#define round (int)roundl -inline long long int lround(double r) -{ - return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5); -} +#ifdef HAVE_LIBCURL +#define CURL_STATICLIB 1 +#pragma comment(lib, "libcurl_a.lib") #endif -inline void* memmem (void* buf, size_t buflen, void* pat, size_t patlen) -{ - void* end = (char *) buf+buflen-patlen; - while (buf=memchr (buf, ((char *) pat) [0], buflen)) - { - if (buf> end) - return 0; - if (memcmp (buf, pat, patlen) == 0) - return buf; - buf = (char *) buf+1; - } - return 0; -} - -#define usleep(x) Sleep((x)/1000) -#define sleep(x) Sleep((x)*1000) +#ifdef HAVE_CURSES +#pragma comment(lib, "pdcurses.lib") +#endif #endif #define VERSION "v4.1.0" - #define PACKAGE_NAME "sgminer" #define PACKAGE_TARNAME "sgminer" #define PACKAGE_VERSION "4.1.0" #define PACKAGE_STRING "sgminer 4.1.0" #define PACKAGE "sgminer" -#define SGMINER_PREFIX "" - - -#if defined (WIN32) -#define __func__ __FUNCTION__ -#define __attribute__(x) -#endif - -// Libraries to include -#pragma comment(lib, "wsock32.lib") -#pragma comment(lib, "pthreadVC2.lib") -#pragma comment(lib, "OpenCL.lib") -#ifdef HAVE_LIBCURL -#define CURL_STATICLIB 1 -#pragma comment(lib, "libcurl_a.lib") -#endif +#define SGMINER_PREFIX "" -#ifdef HAVE_CURSES -#pragma comment(lib, "pdcurses.lib") -#endif +#include "gitversion.h" +#include "winbuild.h" #endif \ No newline at end of file diff --git a/winbuild/dist/include/gitversion.h b/winbuild/dist/include/gitversion.h new file mode 100644 index 00000000..e69de29b diff --git a/winbuild/dist/include/winbuild.h b/winbuild/dist/include/winbuild.h new file mode 100644 index 00000000..b8127277 --- /dev/null +++ b/winbuild/dist/include/winbuild.h @@ -0,0 +1,140 @@ +#ifndef __WINBUILD_H__ +#define __WINBUILD_H__ +#endif + +#if defined(_MSC_VER) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef intptr_t ssize_t; + +#define snprintf _snprintf +#define strdup _strdup + +#define inline __inline + +struct timezone2 +{ + __int32 tz_minuteswest; /* minutes W of Greenwich */ + __int32 tz_dsttime; /* type of dst correction */ +}; + + +const __int64 DELTA_EPOCH_IN_MICROSECS= 11644473600000000; + +/* IN UNIX the use of the timezone struct is obsolete; +I don't know why you use it. See http://linux.about.com/od/commands/l/blcmdl2_gettime.htm +But if you want to use this structure to know about GMT(UTC) diffrence from your local time +it will be next: tz_minuteswest is the real diffrence in minutes from GMT(UTC) and a tz_dsttime is a flag +indicates whether daylight is now in use +*/ + +inline int gettimeofday(struct timeval *tv/*in*/, struct timezone2 *tz/*in*/) +{ + FILETIME ft; + __int64 tmpres = 0; + TIME_ZONE_INFORMATION tz_winapi; + int rez=0; + + ZeroMemory(&ft,sizeof(ft)); + ZeroMemory(&tz_winapi,sizeof(tz_winapi)); + + GetSystemTimeAsFileTime(&ft); + + tmpres = ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + + /*converting file time to unix epoch*/ + tmpres /= 10; /*convert into microseconds*/ + tmpres -= DELTA_EPOCH_IN_MICROSECS; + tv->tv_sec = (__int32)(tmpres*0.000001); + tv->tv_usec =(tmpres%1000000); + + if( tz ) + { + //_tzset(),don't work properly, so we use GetTimeZoneInformation + rez=GetTimeZoneInformation(&tz_winapi); + tz->tz_dsttime=(rez==2)?true:false; + tz->tz_minuteswest = tz_winapi.Bias + ((rez==2)?tz_winapi.DaylightBias:0); + } + + return 0; +} + +inline int strcasecmp(const char *s1, const char *s2) +{ + unsigned char c1,c2; + do { + c1 = *s1++; + c2 = *s2++; + c1 = (unsigned char) tolower( (unsigned char) c1); + c2 = (unsigned char) tolower( (unsigned char) c2); + } + while((c1 == c2) && (c1 != '\0')); + return (int) c1-c2; +} + +inline int strncasecmp(const char *s1, const char *s2, size_t n) +{ + if (n == 0) + return 0; + + while (n-- != 0 && tolower(*s1) == tolower(*s2)) + { + if (n == 0 || *s1 == '\0' || *s2 == '\0') + break; + s1++; + s2++; + } + + return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); +} + +inline long double roundl(long double r) +{ + return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5); +} + +#if (_MSC_VER < 1800) +#define round (int)roundl +inline long long int lround(double r) +{ + return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5); +} +#endif + +inline void* memmem (void* buf, size_t buflen, void* pat, size_t patlen) +{ + void* end = (char *) buf+buflen-patlen; + while (buf=memchr (buf, ((char *) pat) [0], buflen)) + { + if (buf> end) + return 0; + if (memcmp (buf, pat, patlen) == 0) + return buf; + buf = (char *) buf+1; + } + return 0; +} + +#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) + +#define usleep(x) Sleep((x)/1000) +#define sleep(x) Sleep((x)*1000) + +#define __func__ __FUNCTION__ +#define __attribute__(x) + + +#endif \ No newline at end of file diff --git a/winbuild/sgminer.vcxproj b/winbuild/sgminer.vcxproj index 42f2351a..36789598 100644 --- a/winbuild/sgminer.vcxproj +++ b/winbuild/sgminer.vcxproj @@ -110,7 +110,11 @@ del /f "$(OutDir)*.exe" -del /f "$(OutDir)*.dll" +del /f "$(OutDir)*.dll" + +type nul > "$(ProjectDir)dist\include\gitversion.h" +FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" > "$(ProjectDir)dist\include\gitversion.h" +exit 0 @@ -141,7 +145,11 @@ del /f "$(OutDir)*.dll" del /f "$(OutDir)*.exe" -del /f "$(OutDir)*.dll" +del /f "$(OutDir)*.dll" + +type nul > "$(ProjectDir)dist\include\gitversion.h" +FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" > "$(ProjectDir)dist\include\gitversion.h" +exit 0 @@ -175,7 +183,11 @@ del /f "$(OutDir)*.dll" del /f "$(OutDir)*.exe" -del /f "$(OutDir)*.dll" +del /f "$(OutDir)*.dll" + +type nul > "$(ProjectDir)dist\include\gitversion.h" +FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" > "$(ProjectDir)dist\include\gitversion.h" +exit 0 @@ -212,7 +224,11 @@ del /f "$(OutDir)*.dll" del /f "$(OutDir)*.exe" -del /f "$(OutDir)*.dll" +del /f "$(OutDir)*.dll" + +type nul > "$(ProjectDir)dist\include\gitversion.h" +FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" > "$(ProjectDir)dist\include\gitversion.h" +exit 0 @@ -267,6 +283,7 @@ del /f "$(OutDir)*.dll" + diff --git a/winbuild/sgminer.vcxproj.filters b/winbuild/sgminer.vcxproj.filters index 933e3f12..0ed5cb60 100644 --- a/winbuild/sgminer.vcxproj.filters +++ b/winbuild/sgminer.vcxproj.filters @@ -160,6 +160,9 @@ Libraries\jansson + + Header Files +