From f0c3b1f3879a2fbe0596971172a057a29ed5ee1a Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Mon, 19 Jan 2015 21:48:35 +0100 Subject: [PATCH] Port to Openindiana --- CHANGES | 3 +++ config.h.in | 9 ++++++++ configure.in | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ error.c | 12 ++++++++-- test.sh | 16 +++++++------ xio-listen.c | 4 +++- xio.h | 2 +- 7 files changed, 99 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 15b705d..e9c6842 100644 --- a/CHANGES +++ b/CHANGES @@ -124,6 +124,9 @@ porting: including and a weakness in the conditional code. Thanks to Michel Normand for reporting this issue. + Changes for Openindiana: define _XPG4_2, __EXTENSIONS__, + _POSIX_PTHREAD_SEMANTICS; and minor changes + doc: In the man page the PTY example was badly formatted. Thanks to J.F.Sebastian for sending a patch. diff --git a/config.h.in b/config.h.in index dabfbe2..3f28702 100644 --- a/config.h.in +++ b/config.h.in @@ -344,6 +344,15 @@ /* Define if your termios.h likes _SVID3 defined */ #undef _SVID3 +/* Define if your sys/socket.h likes _XPG4_2 defined */ +#undef _XPG4_2 + +/* Define if your ctime_r() choices need _POSIX_PTHREAD_SEMANTICS */ +#undef _POSIX_PTHREAD_SEMANTICS + +/* Define if you need __EXTENSIONS__ */ +#undef __EXTENSIONS__ + /* Define if you have struct timespec (e.g. for nanosleep) */ #undef HAVE_STRUCT_TIMESPEC diff --git a/configure.in b/configure.in index 1ca574e..1090d86 100644 --- a/configure.in +++ b/configure.in @@ -1026,6 +1026,69 @@ if test $ac_cv_svid3 = yes; then fi AC_MSG_RESULT($ac_cv_svid3) + +# Openindiana needs _XPG4_2 for CMSG stuff +AC_MSG_CHECKING(if _XPG4_2 is helpful) +AC_CACHE_VAL(ac_cv_xpg4_2, + [AC_TRY_LINK([#include ], + [int i=CMSG_DATA(0)], + [ac_cv_xpg4_2=no], + [AC_TRY_LINK([#define _XPG4_2 1 +#include ], + [int i=CMSG_DATA(0)], + [ac_cv_xpg4_2=yes], + [ac_cv_xpg4_2=no] + )] +)]) +if test $ac_cv_xpg4_2 = yes; then + AC_DEFINE(_XPG4_2) +fi +AC_MSG_RESULT($ac_cv_xpg4_2) + +# When on Openindiana _XPG4_2 is defined (see above) +# we also need to define __EXTENSIONS__ for basic stuff. +# Note that is important on Openindiana +# but does not exist on Linux +if test "$ac_cv_xpg4_2" = yes; then + AC_MSG_CHECKING(if __EXTENSIONS__ is helpful) + AC_CACHE_VAL(ac_cv___extensions__, + [AC_TRY_COMPILE([#include ], + [procset_t *s=0;], + [ac_cv___extensions__=no], + [AC_TRY_COMPILE([#define __EXTENSIONS__ 1 +#include ], + [procset_t *s=0;], + [ac_cv___extensions__=yes], + [ac_cv___extensions__=no] + )] + )]) + if test $ac_cv___extensions__ = yes; then + AC_DEFINE(__EXTENSIONS__) + fi + AC_MSG_RESULT($ac_cv___extensions__) +fi + +# When on Openindiana __EXTENSIONS__ is defined (see above) +# _POSIX_PTHREAD_SEMANTICS must be defined for standard ctime_r() +if test "$ac_cv___extensions__" = yes; then + AC_MSG_CHECKING(if _POSIX_PTHREAD_SEMANTICS is helpful) + AC_CACHE_VAL(ac_cv__posix_pthread_semantics, + [AC_TRY_COMPILE([#include ], + [char *s = ctime_r(0,0);], + [ac_cv__posix_pthread_semantics=no], + [AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS 1 +#include ], + [char *s = ctime_r(0,0);], + [ac_cv__posix_pthread_semantics=yes], + [ac_cv__posix_pthread_semantics=no] + )] + )]) + if test $ac_cv__posix_pthread_semantics = yes; then + AC_DEFINE(_POSIX_PTHREAD_SEMANTICS) + fi + AC_MSG_RESULT($ac_cv__posix_pthread_semantics) +fi + # struct timespec AC_MSG_CHECKING(for struct timespec) @@ -1929,4 +1992,5 @@ else AC_DEFINE(BUILD_DATE, [__DATE__" "__TIME__]) fi +cp -p confdefs.h save-confdefs.h AC_OUTPUT(Makefile) diff --git a/error.c b/error.c index 1770d50..e5ae1e1 100644 --- a/error.c +++ b/error.c @@ -250,7 +250,11 @@ void msg(int level, const char *format, ...) { diag_dgram.exitcode = diagopts.exitstatus; vsnprintf_r(diag_dgram.text, sizeof(diag_dgram.text), format, ap); if (diag_in_handler && !diag_immediate_msg) { - send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN + strlen(diag_dgram.text)+1, MSG_DONTWAIT|MSG_NOSIGNAL); + send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN + strlen(diag_dgram.text)+1, MSG_DONTWAIT +#ifdef MSG_NOSIGNAL + |MSG_NOSIGNAL +#endif + ); diag_msg_avail = 1; va_end(ap); return; @@ -411,7 +415,11 @@ void diag_exit(int status) { if (diag_in_handler && !diag_immediate_exit) { diag_dgram.op = DIAG_OP_EXIT; diag_dgram.exitcode = status; - send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN, MSG_DONTWAIT|MSG_NOSIGNAL); + send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN, MSG_DONTWAIT +#ifdef MSG_NOSIGNAL + |MSG_NOSIGNAL +#endif + ); return; } _diag_exit(status); diff --git a/test.sh b/test.sh index 4378893..dd3843a 100755 --- a/test.sh +++ b/test.sh @@ -3768,7 +3768,9 @@ da="test$N $(date) $RANDOM" CMD="$TRACE $SOCAT -u $opts - open:$ff,append,o-trunc" printf "test $F_n $TEST... " $N rm -f $ff; $ECHO "prefix-\c" >$ff -if ! echo "$da" |$CMD >$tf 2>"$te" || +echo "$da" |$CMD >$tf 2>"$te" +rc0=$? +if ! [ $rc0 = 0 ] || ! echo "$da" |diff - $ff >"$tdiff"; then $PRINTF "$FAILED: $TRACE $SOCAT:\n" echo "$CMD" @@ -9805,21 +9807,21 @@ if [ "$rc1" -ne 0 ]; then numCANT=$((numCANT+1)) elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=" ${te}0 >/dev/null; then $PRINTF "$FAILED\n" + echo "variable $SCM_TYPE: $SCM_NAME not set" echo "$CMD0 &" echo "$CMD1" grep " $LEVELS " "${te}0" grep " $LEVELS " "${te}1" - echo "variable $SCM_TYPE: $SCM_NAME not set" numFAIL=$((numFAIL+1)) listFAIL="$listFAIL $N" elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=$SCM_VALUE" ${te}0 >/dev/null; then $PRINTF "$FAILED\n" + badval="$(grep "ancillary message: $SCM_TYPE: $SCM_NAME" ${te}0 |sed 's/.*=//g')" + echo "variable $SCM_TYPE: $SCM_NAME has value \"$badval\" instead of pattern \"$SCM_VALUE\"" >&2 echo "$CMD0 &" echo "$CMD1" grep " $LEVELS " "${te}0" grep " $LEVELS " "${te}1" - badval="$(grep "ancillary message: $SCM_TYPE: $SCM_NAME" ${te}0 |sed 's/.*=//g')" - echo "variable $SCM_TYPE: $SCM_NAME has value \"$badval\" instead of pattern \"$SCM_VALUE\"" numFAIL=$((numFAIL+1)) listFAIL="$listFAIL $N" else @@ -12085,16 +12087,16 @@ sleep 1 kill $pid0 2>/dev/null; wait if [ ! -f "$t0rc" ]; then $PRINTF "$FAILED\n" + echo "no return code of CMD0 stored" >&2 echo "$CMD0 &" cat "${te}0" - echo "did not terminate with error" numFAIL=$((numFAIL+1)) listFAIL="$listFAIL $N" -elif ! echo 1 |diff - "$t0rc"; then +elif ! echo 1 |diff - "$t0rc" >"$tdiff"; then $PRINTF "$FAILED\n" + echo "CMD0 exited with $(cat $t0rc), expected 1" echo "$CMD0 &" cat "${te}0" - echo "expected return code 1" numFAIL=$((numFAIL+1)) listFAIL="$listFAIL $N" else diff --git a/xio-listen.c b/xio-listen.c index 380088e..11a6b9a 100644 --- a/xio-listen.c +++ b/xio-listen.c @@ -328,7 +328,9 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl while (maxchildren) { if (num_child < maxchildren) break; Notice("maxchildren are active, waiting"); - while (!Sleep(UINT_MAX)) ; /* any signal lets us continue */ + /* UINT_MAX would even be nicer, but Openindiana works only + with 31 bits */ + while (!Sleep(INT_MAX)) ; /* any signal lets us continue */ } Info("still listening"); } else { diff --git a/xio.h b/xio.h index f050773..a5b6fe4 100644 --- a/xio.h +++ b/xio.h @@ -205,8 +205,8 @@ typedef struct single { struct { bool tight; } un; - } socket; #endif /* WITH_UNIX */ + } socket; #endif /* _WITH_SOCKET */ struct { pid_t pid; /* child PID, with EXEC: */