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"