Skip to content

Commit c459d50

Browse files
committed
build: Probe MSG_DONTWAIT in the same way as MSG_NOSIGNAL
Instead of the WIN32-specific workaround, detect lack of `MSG_DONTWAIT` in the build system. This allows other platforms without `MSG_DONTWAIT` to work too.
1 parent 53c300f commit c459d50

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

configure.ac

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,15 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
558558
[ AC_MSG_RESULT(no)]
559559
)
560560

561+
dnl Check for MSG_DONTWAIT
562+
AC_MSG_CHECKING(for MSG_DONTWAIT)
563+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
564+
[[ int f = MSG_DONTWAIT; ]])],
565+
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DONTWAIT, 1,[Define this symbol if you have MSG_DONTWAIT]) ],
566+
[ AC_MSG_RESULT(no)]
567+
)
568+
569+
561570
AC_MSG_CHECKING([for visibility attribute])
562571
AC_LINK_IFELSE([AC_LANG_SOURCE([
563572
int foo_def( void ) __attribute__((visibility("default")));

src/compat.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747
#include <unistd.h>
4848
#endif
4949

50-
#ifdef WIN32
51-
#define MSG_DONTWAIT 0
52-
#else
50+
#ifndef WIN32
5351
typedef u_int SOCKET;
5452
#include "errno.h"
5553
#define WSAGetLastError() errno
@@ -79,6 +77,11 @@ typedef u_int SOCKET;
7977
#define MSG_NOSIGNAL 0
8078
#endif
8179

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+
8285
#if HAVE_DECL_STRNLEN == 0
8386
size_t strnlen( const char *start, size_t max_len);
8487
#endif // HAVE_DECL_STRNLEN

0 commit comments

Comments
 (0)