Skip to content

Commit

Permalink
issue 2935075: Add preprocessor definition for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldar Shalev authored and EldarShalev committed Aug 22, 2022
1 parent bda8436 commit 7f6e22c
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 87 deletions.
14 changes: 7 additions & 7 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void printHistogram(uint32_t binSize, std::map<uint32_t, uint32_t> &activeBins,
std::map<uint32_t, uint32_t>::iterator itr;

// Scale to terminal
#ifndef WIN32
#ifndef __windows__
struct winsize size;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &size);
terminalWidth = size.ws_col;
Expand Down Expand Up @@ -824,7 +824,7 @@ static int _connect_check(int ifd) {

#define POLL_TIMEOUT_MS 1

#ifdef WIN32
#ifdef __windows__
fd_set rfds, wfds;
struct timeval tv;
tv.tv_sec = 0;
Expand All @@ -841,7 +841,7 @@ static int _connect_check(int ifd) {
struct pollfd fds = { .fd = ifd, .events = POLLIN | POLLOUT, };
pollrc = poll(&fds, 1, POLL_TIMEOUT_MS);
avail = pollrc > 0 && (fds.revents & (POLLIN | POLLOUT));
#endif /* WIN32 */
#endif /* __windows__ */

if (pollrc < 0) {
log_err("Failed to poll for events during connection establishment");
Expand Down Expand Up @@ -884,11 +884,11 @@ int Client<IoType, SwitchDataIntegrity, SwitchActivityInfo, SwitchCycleDuration,
struct sockaddr_store_t unix_addr;
socklen_t unix_addr_len;
if (p_client_bind_addr->ss_family == AF_UNIX && g_pApp->m_const_params.sock_type == SOCK_DGRAM) { // Need to bind localy
#ifdef WIN32
#ifdef __windows__
log_err("AF_UNIX with DGRAM isn't supported in windows");
rc = SOCKPERF_ERR_SOCKET;
break;
#else
#else // __windows__
if (p_client_bind_addr->addr_un.sun_path[0] == 0) { // no specific addr client_info was provoided
std::string sun_path = build_client_socket_name(&s_user_params.addr.addr_un, getpid(), ifd);
log_dbg("No client name was provided, setting addr_un.sun_path to %s\n",
Expand All @@ -906,7 +906,7 @@ int Client<IoType, SwitchDataIntegrity, SwitchActivityInfo, SwitchCycleDuration,
p_client_bind_addr = &unix_addr;
client_bind_addr_len = unix_addr_len;
}
#endif
#endif //__windows__
}

log_dbg("[fd=%d] Binding to: %s...", ifd, hostport.c_str());
Expand Down Expand Up @@ -1258,7 +1258,7 @@ void client_handler(handler_info *p_info) {
client_handler<IoRecvfromMUX>(p_info->fd_min, p_info->fd_max, p_info->fd_num);
break;
}
#ifndef WIN32
#ifndef __windows__
case POLL: {
client_handler<IoPoll>(p_info->fd_min, p_info->fd_max, p_info->fd_num);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void hexdump(void *ptr, int buflen) {
const char *handler2str(fd_block_handler_t type) {
// must be coordinated with fd_block_handler_t in defs.h
static const char *s_fds_handle_desc[FD_HANDLE_MAX] = { "recvfrom", "recvfrom", "select"
#ifndef WIN32
#ifndef __windows__
,
"poll", "epoll",
#ifdef USING_VMA_EXTRA_API
Expand Down
4 changes: 2 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static inline int msg_sendto(int fd, uint8_t *buf, int nbytes,
* the MSG_NOSIGNAL flag.
* Note: another way is call signal (SIGPIPE,SIG_IGN);
*/
#ifndef WIN32
#ifndef __windows__
flags = MSG_NOSIGNAL;

/*
Expand All @@ -94,7 +94,7 @@ static inline int msg_sendto(int fd, uint8_t *buf, int nbytes,
if (g_pApp->m_const_params.is_nonblocked_send) {
flags |= MSG_DONTWAIT;
}
#endif
#endif // __windows__

int size = nbytes;
if (g_fds_array[fd]->sock_type == SOCK_STREAM) {
Expand Down
8 changes: 4 additions & 4 deletions src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define __STDC_FORMAT_MACROS

#ifdef WIN32
#ifdef __windows__
#include <WS2tcpip.h>
#include <Winsock2.h>
#include <unordered_map>
Expand Down Expand Up @@ -96,7 +96,7 @@ typedef unsigned short int sa_family_t;
#include "playback.h"
#include "ip_address.h"

#if !defined(WIN32) && !defined(__FreeBSD__)
#if !defined(__windows__) && !defined(__FreeBSD__)
#include "vma-xlio-redirect.h"
#ifdef USING_VMA_EXTRA_API
#include <mellanox/vma_extra.h>
Expand Down Expand Up @@ -152,7 +152,7 @@ const uint32_t TEST_FIRST_CONNECTION_FIRST_PACKET_TTL_THRESHOLD_MSEC = 50;
":(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[0-5]?[0-9]{1,4})" \
"(:([a-zA-Z0-9\\.\\-]+|\\[([a-fA-F0-9.:]+)\\]))?[\r\n]"

#ifdef WIN32
#ifdef __windows__
#define UNIX_DOMAIN_SOCKET_FORMAT_REG_EXP \
"^[UuTt]:([A-Za-z]:[\\\\/].*)[\r\n]*"
#define RESOLVE_ADDR_FORMAT_SOCKET \
Expand Down Expand Up @@ -635,7 +635,7 @@ typedef enum { // must be coordinated with s_fds_handle_desc in common.cpp
RECVFROM = 0,
RECVFROMMUX,
SELECT,
#ifndef WIN32
#ifndef __windows__
POLL,
EPOLL,
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/input_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RecvFromInputHandler : public MessageParser<InPlaceAccumulation> {
the MSG_NOSIGNAL flag.
Note: another way is call signal (SIGPIPE,SIG_IGN);
*/
#ifndef WIN32
#ifndef __windows__
flags = MSG_NOSIGNAL;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/iohandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int IoSelect::prepareNetwork() {

return rc;
}
#ifndef WIN32
#ifndef __windows__
//==============================================================================
//------------------------------------------------------------------------------
IoPoll::IoPoll(int _fd_min, int _fd_max, int _fd_num)
Expand Down
2 changes: 1 addition & 1 deletion src/iohandlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class IoSelect : public IoHandler {
fd_set m_readfds, m_save_fds;
};

#ifndef WIN32
#ifndef __windows__
//==============================================================================
class IoPoll : public IoHandler {
public:
Expand Down
2 changes: 1 addition & 1 deletion src/ip_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "ip_address.h"
#include "common.h"

#ifdef WIN32
#ifdef __windows__
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ip_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef IP_ADDRESS_H_
#define IP_ADDRESS_H_

#ifdef WIN32
#ifdef __windows__
#include <WS2tcpip.h>
#include <Winsock2.h>
#include <unordered_map>
Expand Down
Loading

0 comments on commit 7f6e22c

Please sign in to comment.