Merge pull request #253 from crawfxrd/windows-fixes

Fix compilation with VS2017
This commit is contained in:
Ronnie Sahlberg
2017-11-30 09:52:40 +10:00
committed by GitHub
19 changed files with 38 additions and 30 deletions

View File

@@ -34,7 +34,7 @@
/* This is the host/port we connect to.*/
#define TARGET "127.0.0.1:3260"
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#include "win32/win32_compat.h"
#pragma comment(lib, "ws2_32.lib")
@@ -625,7 +625,7 @@ int main(int argc _U_, char *argv[] _U_)
struct client_state clnt;
printf("iscsi client\n");
#if defined(WIN32)
#if defined(_WIN32)
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
printf("Failed to start Winsock2\n");
exit(10);

View File

@@ -20,7 +20,7 @@
#include <stdint.h>
#include <time.h>
#if defined(WIN32)
#if defined(_WIN32)
#include <basetsd.h>
#define ssize_t SSIZE_T
#endif
@@ -324,7 +324,7 @@ int iscsi_process_reject(struct iscsi_context *iscsi,
struct iscsi_in_pdu *in);
int iscsi_send_target_nop_out(struct iscsi_context *iscsi, uint32_t ttt, uint32_t lun);
#if defined(WIN32)
#if defined(_WIN32)
void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string,
...);
#else

View File

@@ -20,7 +20,7 @@
#include <stdint.h>
#include <sys/types.h>
#if defined(WIN32)
#if defined(_WIN32)
#define EXTERN __declspec( dllexport )
#else
#define EXTERN
@@ -166,7 +166,7 @@ enum iscsi_immediate_data {
ISCSI_IMMEDIATE_DATA_NO = 0,
ISCSI_IMMEDIATE_DATA_YES = 1
};
int iscsi_set_immediate_data(struct iscsi_context *iscsi, enum iscsi_immediate_data immediate_data);
EXTERN int iscsi_set_immediate_data(struct iscsi_context *iscsi, enum iscsi_immediate_data immediate_data);
/*
* This function is used to set the desired mode for initial_r2t
@@ -179,7 +179,7 @@ enum iscsi_initial_r2t {
ISCSI_INITIAL_R2T_NO = 0,
ISCSI_INITIAL_R2T_YES = 1
};
int
EXTERN int
iscsi_set_initial_r2t(struct iscsi_context *iscsi, enum iscsi_initial_r2t initial_r2t);

View File

@@ -23,7 +23,7 @@
#ifndef MD5_H
#define MD5_H
#if defined(WIN32)
#if defined(_WIN32)
#else
#include <netinet/in.h>
#endif

View File

@@ -17,7 +17,7 @@
#ifndef __scsi_lowlevel_h__
#define __scsi_lowlevel_h__
#if defined(WIN32)
#if defined(_WIN32)
#define EXTERN __declspec( dllexport )
#else
#define EXTERN

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32)
#if defined(_WIN32)
#include "win32/win32_compat.h"
#else
#include <unistd.h>

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32)
#if defined(_WIN32)
#else
#include <unistd.h>
#endif

View File

@@ -21,7 +21,8 @@
#define _GNU_SOURCE
#if defined(WIN32)
#if defined(_WIN32)
#include "win32/win32_compat.h"
#else
#include <strings.h>
#include <unistd.h>

View File

@@ -27,7 +27,7 @@
#include <arpa/inet.h>
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#endif

View File

@@ -31,7 +31,7 @@
#include <unistd.h>
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include "win32/win32_compat.h"
#endif

View File

@@ -32,7 +32,7 @@
#include <arpa/inet.h>
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#include "win32/win32_compat.h"
#endif

View File

@@ -16,7 +16,7 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#if defined(WIN32)
#if defined(_WIN32)
#else
#include <unistd.h>
#endif

View File

@@ -34,7 +34,7 @@
#define PRIx32 "x"
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#include "win32/win32_compat.h"

View File

@@ -38,7 +38,7 @@
#include "aros/aros_compat.h"
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#include "win32/win32_compat.h"
#else

View File

@@ -43,7 +43,7 @@
#include <sys/socket.h>
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#include "win32/win32_compat.h"
@@ -139,7 +139,7 @@ void iscsi_decrement_iface_rr() {
static int set_nonblocking(int fd)
{
#if defined(WIN32)
#if defined(_WIN32)
unsigned long opt = 1;
return ioctlsocket(fd, FIONBIO, &opt);
#else
@@ -272,7 +272,7 @@ static int iscsi_tcp_connect(struct iscsi_context *iscsi, union socket_address *
}
if (connect(iscsi->fd, &sa->sa, socksize) != 0
#if defined(WIN32)
#if defined(_WIN32)
&& WSAGetLastError() != WSAEWOULDBLOCK
#endif
&& errno != EINPROGRESS) {
@@ -1102,7 +1102,7 @@ void iscsi_set_bind_interfaces(struct iscsi_context *iscsi, char * interfaces _U
#endif
}
#ifdef WIN32
#if defined(_MSC_VER) && _MSC_VER < 1900
static iscsi_transport iscsi_transport_tcp = {
iscsi_tcp_connect,
iscsi_tcp_queue_pdu,

View File

@@ -27,7 +27,7 @@
#include "aros/aros_compat.h"
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#include "win32/win32_compat.h"
#endif

View File

@@ -19,7 +19,7 @@
#include "config.h"
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <winsock2.h>
#include "win32_compat.h"
#pragma comment(lib, "ws2_32.lib")
@@ -354,7 +354,7 @@ int main(int argc, char *argv[])
int i;
static int show_help = 0, show_usage = 0, debug = 0;
#ifdef WIN32
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
printf("Failed to start Winsock2\n");
exit(10);

View File

@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef WIN32
#ifndef _WIN32
static int dummy ATTRIBUTE((unused));

View File

@@ -22,9 +22,10 @@ THE SOFTWARE.
*/
/*Adaptions by memphiz@xbmc.org*/
#ifdef WIN32
#ifndef win32_COMPAT_H_
#define win32_COMPAT_H_
#ifdef _WIN32
#define NO_IPv6 1
#include <winsock2.h>
@@ -65,16 +66,22 @@ typedef int socklen_t;
#define writev win32_writev
#define strncasecmp _strnicmp
#define strdup _strdup
#define dup2(x, y, z) win32_dup2(x, y)
#define dup2(x, y) win32_dup2(x, y)
#define poll(x, y, z) win32_poll(x, y, z)
#define inet_pton(x,y,z) win32_inet_pton(x,y,z)
#define sleep(x) Sleep(x * 1000)
#define getpid GetCurrentProcessId
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf(a, b, c, ...) _snprintf_s(a, b, b, c, ## __VA_ARGS__)
#endif
int win32_inet_pton(int af, const char * src, void * dst);
int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout);
int win32_gettimeofday(struct timeval *tv, struct timezone *tz);
ssize_t win32_writev(int fd, const struct iovec *iov, int iovcnt);
ssize_t win32_readv(int fd, const struct iovec *iov, int iovcnt);
int win32_dup2(int oldfd, int newfd);
struct iovec {
void *iov_base;
@@ -83,5 +90,5 @@ struct iovec {
#define inline
#endif//win32_COMPAT_H_
#endif//WIN32
#endif // _WIN32
#endif // win32_COMPAT_H_