Merge pull request #253 from crawfxrd/windows-fixes
Fix compilation with VS2017
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
/* This is the host/port we connect to.*/
|
/* This is the host/port we connect to.*/
|
||||||
#define TARGET "127.0.0.1:3260"
|
#define TARGET "127.0.0.1:3260"
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
@@ -625,7 +625,7 @@ int main(int argc _U_, char *argv[] _U_)
|
|||||||
struct client_state clnt;
|
struct client_state clnt;
|
||||||
|
|
||||||
printf("iscsi client\n");
|
printf("iscsi client\n");
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
|
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
|
||||||
printf("Failed to start Winsock2\n");
|
printf("Failed to start Winsock2\n");
|
||||||
exit(10);
|
exit(10);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <basetsd.h>
|
#include <basetsd.h>
|
||||||
#define ssize_t SSIZE_T
|
#define ssize_t SSIZE_T
|
||||||
#endif
|
#endif
|
||||||
@@ -324,7 +324,7 @@ int iscsi_process_reject(struct iscsi_context *iscsi,
|
|||||||
struct iscsi_in_pdu *in);
|
struct iscsi_in_pdu *in);
|
||||||
int iscsi_send_target_nop_out(struct iscsi_context *iscsi, uint32_t ttt, uint32_t lun);
|
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,
|
void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string,
|
||||||
...);
|
...);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#define EXTERN __declspec( dllexport )
|
#define EXTERN __declspec( dllexport )
|
||||||
#else
|
#else
|
||||||
#define EXTERN
|
#define EXTERN
|
||||||
@@ -166,7 +166,7 @@ enum iscsi_immediate_data {
|
|||||||
ISCSI_IMMEDIATE_DATA_NO = 0,
|
ISCSI_IMMEDIATE_DATA_NO = 0,
|
||||||
ISCSI_IMMEDIATE_DATA_YES = 1
|
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
|
* 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_NO = 0,
|
||||||
ISCSI_INITIAL_R2T_YES = 1
|
ISCSI_INITIAL_R2T_YES = 1
|
||||||
};
|
};
|
||||||
int
|
EXTERN int
|
||||||
iscsi_set_initial_r2t(struct iscsi_context *iscsi, enum iscsi_initial_r2t initial_r2t);
|
iscsi_set_initial_r2t(struct iscsi_context *iscsi, enum iscsi_initial_r2t initial_r2t);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#ifndef MD5_H
|
#ifndef MD5_H
|
||||||
#define MD5_H
|
#define MD5_H
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#else
|
#else
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
#ifndef __scsi_lowlevel_h__
|
#ifndef __scsi_lowlevel_h__
|
||||||
#define __scsi_lowlevel_h__
|
#define __scsi_lowlevel_h__
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#define EXTERN __declspec( dllexport )
|
#define EXTERN __declspec( dllexport )
|
||||||
#else
|
#else
|
||||||
#define EXTERN
|
#define EXTERN
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
You should have received a copy of the GNU Lesser General Public License
|
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/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
You should have received a copy of the GNU Lesser General Public License
|
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/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
|
#include "win32/win32_compat.h"
|
||||||
#else
|
#else
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#define PRIx32 "x"
|
#define PRIx32 "x"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#include "aros/aros_compat.h"
|
#include "aros/aros_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
@@ -139,7 +139,7 @@ void iscsi_decrement_iface_rr() {
|
|||||||
|
|
||||||
static int set_nonblocking(int fd)
|
static int set_nonblocking(int fd)
|
||||||
{
|
{
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
unsigned long opt = 1;
|
unsigned long opt = 1;
|
||||||
return ioctlsocket(fd, FIONBIO, &opt);
|
return ioctlsocket(fd, FIONBIO, &opt);
|
||||||
#else
|
#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 (connect(iscsi->fd, &sa->sa, socksize) != 0
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
&& WSAGetLastError() != WSAEWOULDBLOCK
|
&& WSAGetLastError() != WSAEWOULDBLOCK
|
||||||
#endif
|
#endif
|
||||||
&& errno != EINPROGRESS) {
|
&& errno != EINPROGRESS) {
|
||||||
@@ -1102,7 +1102,7 @@ void iscsi_set_bind_interfaces(struct iscsi_context *iscsi, char * interfaces _U
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
static iscsi_transport iscsi_transport_tcp = {
|
static iscsi_transport iscsi_transport_tcp = {
|
||||||
iscsi_tcp_connect,
|
iscsi_tcp_connect,
|
||||||
iscsi_tcp_queue_pdu,
|
iscsi_tcp_queue_pdu,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "aros/aros_compat.h"
|
#include "aros/aros_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "win32_compat.h"
|
#include "win32_compat.h"
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
@@ -354,7 +354,7 @@ int main(int argc, char *argv[])
|
|||||||
int i;
|
int i;
|
||||||
static int show_help = 0, show_usage = 0, debug = 0;
|
static int show_help = 0, show_usage = 0, debug = 0;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef _WIN32
|
||||||
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
|
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
|
||||||
printf("Failed to start Winsock2\n");
|
printf("Failed to start Winsock2\n");
|
||||||
exit(10);
|
exit(10);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
static int dummy ATTRIBUTE((unused));
|
static int dummy ATTRIBUTE((unused));
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,10 @@ THE SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
/*Adaptions by memphiz@xbmc.org*/
|
/*Adaptions by memphiz@xbmc.org*/
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#ifndef win32_COMPAT_H_
|
#ifndef win32_COMPAT_H_
|
||||||
#define win32_COMPAT_H_
|
#define win32_COMPAT_H_
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
#define NO_IPv6 1
|
#define NO_IPv6 1
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
@@ -65,16 +66,22 @@ typedef int socklen_t;
|
|||||||
#define writev win32_writev
|
#define writev win32_writev
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strdup _strdup
|
#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 poll(x, y, z) win32_poll(x, y, z)
|
||||||
#define inet_pton(x,y,z) win32_inet_pton(x,y,z)
|
#define inet_pton(x,y,z) win32_inet_pton(x,y,z)
|
||||||
#define sleep(x) Sleep(x * 1000)
|
#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__)
|
#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_inet_pton(int af, const char * src, void * dst);
|
||||||
int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout);
|
int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout);
|
||||||
int win32_gettimeofday(struct timeval *tv, struct timezone *tz);
|
int win32_gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||||
ssize_t win32_writev(int fd, const struct iovec *iov, int iovcnt);
|
ssize_t win32_writev(int fd, const struct iovec *iov, int iovcnt);
|
||||||
ssize_t win32_readv(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 {
|
struct iovec {
|
||||||
void *iov_base;
|
void *iov_base;
|
||||||
@@ -83,5 +90,5 @@ struct iovec {
|
|||||||
|
|
||||||
#define inline
|
#define inline
|
||||||
|
|
||||||
|
#endif // _WIN32
|
||||||
#endif // win32_COMPAT_H_
|
#endif // win32_COMPAT_H_
|
||||||
#endif//WIN32
|
|
||||||
|
|||||||
Reference in New Issue
Block a user