Skip to content

Commit

Permalink
build: Probe MSG_DONTWAIT in the same way as MSG_NOSIGNAL
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laanwj committed Mar 5, 2017
1 parent 53c300f commit c459d50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,15 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
[ AC_MSG_RESULT(no)]
)

dnl Check for MSG_DONTWAIT
AC_MSG_CHECKING(for MSG_DONTWAIT)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]],
[[ int f = MSG_DONTWAIT; ]])],
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DONTWAIT, 1,[Define this symbol if you have MSG_DONTWAIT]) ],
[ AC_MSG_RESULT(no)]
)


AC_MSG_CHECKING([for visibility attribute])
AC_LINK_IFELSE([AC_LANG_SOURCE([
int foo_def( void ) __attribute__((visibility("default")));
Expand Down
9 changes: 6 additions & 3 deletions src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
#include <unistd.h>
#endif

#ifdef WIN32
#define MSG_DONTWAIT 0
#else
#ifndef WIN32
typedef u_int SOCKET;
#include "errno.h"
#define WSAGetLastError() errno
Expand Down Expand Up @@ -79,6 +77,11 @@ typedef u_int SOCKET;
#define MSG_NOSIGNAL 0
#endif

// MSG_DONTWAIT is not available on some platforms, if it doesn't exist define it as 0
#if !defined(HAVE_MSG_DONTWAIT) && !defined(MSG_DONTWAIT)
#define MSG_DONTWAIT 0
#endif

#if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len);
#endif // HAVE_DECL_STRNLEN
Expand Down

0 comments on commit c459d50

Please sign in to comment.