Skip to content

Commit 25da1ee

Browse files
committed
build: cleanup: define MSG_DONTWAIT/MSG_NO_SIGNAL locally
Define MSG_DONTWAIT and MSG_NO_SIGNAL in the implementation files that use them (`net.cpp` and `netbase.cpp`), instead of compat.h which is included all over the place. This avoids putting them in the global namespace, as defining them as 0 is a hack that works for our specific usage, but it is not a general solution. Also makes sure they are defined only once so the `!defined(MSG_x)` guard can go.
1 parent c459d50 commit 25da1ee

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

src/compat.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ typedef u_int SOCKET;
7272
#define MAX_PATH 1024
7373
#endif
7474

75-
// As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
76-
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
77-
#define MSG_NOSIGNAL 0
78-
#endif
79-
80-
// MSG_DONTWAIT is not available on some platforms, if it doesn't exist define it as 0
81-
#if !defined(HAVE_MSG_DONTWAIT) && !defined(MSG_DONTWAIT)
82-
#define MSG_DONTWAIT 0
83-
#endif
84-
8575
#if HAVE_DECL_STRNLEN == 0
8676
size_t strnlen( const char *start, size_t max_len);
8777
#endif // HAVE_DECL_STRNLEN

src/net.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@
4444
// We add a random period time (0 to 1 seconds) to feeler connections to prevent synchronization.
4545
#define FEELER_SLEEP_WINDOW 1
4646

47-
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
47+
#if !defined(HAVE_MSG_NOSIGNAL)
4848
#define MSG_NOSIGNAL 0
4949
#endif
5050

51+
// MSG_DONTWAIT is not available on some platforms, if it doesn't exist define it as 0
52+
#if !defined(HAVE_MSG_DONTWAIT)
53+
#define MSG_DONTWAIT 0
54+
#endif
55+
5156
// Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h.
5257
// Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version.
5358
#ifdef WIN32

src/netbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
2626
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
2727

28-
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
28+
#if !defined(HAVE_MSG_NOSIGNAL)
2929
#define MSG_NOSIGNAL 0
3030
#endif
3131

0 commit comments

Comments
 (0)