Better fix for MSVC.

This commit is contained in:
XMRig 2017-08-17 07:33:21 +03:00
parent e3dd4a6581
commit fc1d6c7e84
7 changed files with 50 additions and 20 deletions

View file

@ -20,13 +20,10 @@
#include <string.h>
#include <assert.h>
#if defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
#include <unistd.h>
#endif
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#elif defined(_MSC_VER)
# include <io.h>
#endif
#include "jansson.h"
@ -72,10 +69,13 @@ static int dump_to_file(const char *buffer, size_t size, void *data)
static int dump_to_fd(const char *buffer, size_t size, void *data)
{
int *dest = (int *)data;
#ifdef HAVE_UNISTD_H
# if defined(HAVE_UNISTD_H)
if(write(*dest, buffer, size) == (ssize_t)size)
return 0;
#endif
# elif (defined(_MSC_VER))
if (write(*dest, buffer, (unsigned int) size) == (int) size)
return 0;
# endif
return -1;
}

View file

@ -21,7 +21,7 @@
#include <sched.h>
#endif
#if defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

View file

@ -92,7 +92,9 @@
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
#ifndef _MSC_VER
# define HAVE_UNISTD_H 1
#endif
/* Define to 1 if the system has the type 'unsigned long long int'. */
#define HAVE_UNSIGNED_LONG_LONG_INT 1

View file

@ -18,12 +18,12 @@
#include <string.h>
#include <assert.h>
#if defined(HAVE_UNISTD_H) && !defined(_MSC_VER)
#include <unistd.h>
#endif
#ifdef _MSC_VER
#define STDIN_FILENO 0
#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#elif defined(_MSC_VER)
# include <io.h>
# define HAVE_UNISTD_H
# define STDIN_FILENO 0
#endif
#include "jansson.h"

View file

@ -30,13 +30,23 @@
#include "Platform.h"
#include "version.h"
#ifdef XMRIG_NVIDIA_PROJECT
# include "nvidia/cryptonight.h"
#endif
static inline char *createUserAgent()
{
const size_t max = 128;
const size_t max = 160;
char *buf = new char[max];
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__);
# ifdef XMRIG_NVIDIA_PROJECT
const int cudaVersion = cuda_get_runtime_version();
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__);
# else
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__);
# endif
return buf;
}

View file

@ -32,10 +32,14 @@
#include "Platform.h"
#include "version.h"
#ifdef XMRIG_NVIDIA_PROJECT
# include "nvidia/cryptonight.h"
#endif
static inline char *createUserAgent()
{
const size_t max = 128;
const size_t max = 160;
char *buf = new char[max];
int length = snprintf(buf, max, "%s/%s (Linux ", APP_NAME, APP_VERSION);
@ -46,6 +50,11 @@ static inline char *createUserAgent()
length += snprintf(buf + length, max - length, "i686) libuv/%s", uv_version_string());
# endif
# ifdef XMRIG_NVIDIA_PROJECT
const int cudaVersion = cuda_get_runtime_version();
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
# endif
# ifdef __GNUC__
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# endif

View file

@ -30,6 +30,10 @@
#include "Platform.h"
#include "version.h"
#ifdef XMRIG_NVIDIA_PROJECT
# include "nvidia/cryptonight.h"
#endif
static inline OSVERSIONINFOEX winOsVersion()
{
@ -63,6 +67,11 @@ static inline char *createUserAgent()
length += snprintf(buf + length, max - length, ") libuv/%s", uv_version_string());
# endif
# ifdef XMRIG_NVIDIA_PROJECT
const int cudaVersion = cuda_get_runtime_version();
length += snprintf(buf + length, max - length, " CUDA/%d.%d", cudaVersion / 1000, cudaVersion % 100);
# endif
# ifdef __GNUC__
length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
# elif _MSC_VER