Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 63939 invoked from network); 24 Oct 2007 01:11:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Oct 2007 01:11:05 -0000 Received: (qmail 88252 invoked by uid 500); 24 Oct 2007 01:10:53 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 88240 invoked by uid 500); 24 Oct 2007 01:10:53 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 88229 invoked by uid 99); 24 Oct 2007 01:10:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2007 18:10:52 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msebor@gmail.com designates 64.233.162.236 as permitted sender) Received: from [64.233.162.236] (HELO nz-out-0506.google.com) (64.233.162.236) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2007 01:10:56 +0000 Received: by nz-out-0506.google.com with SMTP id o37so36422nzf for ; Tue, 23 Oct 2007 18:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:subject:content-type:sender; bh=cMZ/zYZGB/XS2qNNfnbI2RY8fpXK2stCuHRm1vgm0ss=; b=Ed3QqnTWHpSr0Sb9nlHnA2BAEjld5MHkXd/g91uA0xInA8gRzY232MRxlzIhIdQJtkEmQYZFBReiZbU4vR0X0n/KpDEwJBkuvJJc2f4Rzetw/TzWJSRg54HqSY5WfuEoDGAkMaDwjuypp5qPAJOd1o64+dKseJgbUiB4nlOXHnA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:organization:user-agent:mime-version:to:subject:content-type:sender; b=ILJp6jTbd9GhHyAfW9ViDT4OljMarJPnM3XUVYTrOjRwDtFpIjw+tnKRnBja8VyU4VFiwon3tYzg01kQFwi5utlCRdX2hPBaATXGLKBHzR53y+vbbkBE2FDvSvvyQnkhpfkRaU67h5lKahDZbdgSr2tLk3sNeTnZl1qq2VHCsYg= Received: by 10.65.242.7 with SMTP id u7mr52943qbr.1193188235248; Tue, 23 Oct 2007 18:10:35 -0700 (PDT) Received: from ?192.168.1.104? ( [71.229.200.170]) by mx.google.com with ESMTPS id f17sm118799qba.2007.10.23.18.10.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 23 Oct 2007 18:10:33 -0700 (PDT) Message-ID: <471E9B88.80301@roguewave.com> Date: Tue, 23 Oct 2007 19:10:32 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.12) Gecko/20071019 Fedora/1.0.9-3.fc6 pango-text SeaMonkey/1.0.9 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: [PATCH] to get exec utility to compile with EDG eccp/Linux Content-Type: multipart/mixed; boundary="------------010705020101040801090707" Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org --------------010705020101040801090707 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The attached patch makes changes to get the exec utility to compile with the EDG eccp demo. It resolves STDCXX-414 in addition to a few other related or similar issues that popped up once I fixed it. The patch isn't "beautiful" but given the super-strict mode we turn on when using the compiler in (the pure "C" headers that declare only the symbols specified by the C++ '03 standard and nothing else, not even any POSIX names), it's the best I could come up with. An alternative apporach would be to avoid compiling the utility in C++ more or with our own headers which seems far too invasive for 4.2.1. The ChangeLog is below. Comments appreciated. 2007-10-23 Martin Sebor * util.h (rw_sleep, rw_signal): Declared helper functions. * cmdopt.cpp (rw_sleep, rw_signal): Moved formerly static functions from here... * util.cpp: ...to here and declared extern. * exec.cpp (SIGHUP, SIGQUIT, SIGKILL, SIGALRM, ESRCH, EINTR, ECHILD, EINVAL): #defined macros when they're not #defined in system headers. [!_RWSTD_NO_PURE_C_HEADERS] (kill, fdopen): Declared. (wait_for_child): Called rw_signal() instead of sigaction() directly. STDCXX-414 * util.cpp: [!_RWSTD_NO_PURE_C_HEADERS] (rw_signal): Implemented in terms of signal() instead of sigaction() so as to avoid a dependency on POSIX symbols in . --------------010705020101040801090707 Content-Type: text/x-patch; name="eccp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="eccp.patch" Index: /home/sebor/stdcxx-4.2.x/util/util.h =================================================================== --- /home/sebor/stdcxx-4.2.x/util/util.h (revision 587687) +++ /home/sebor/stdcxx-4.2.x/util/util.h (working copy) @@ -118,4 +118,31 @@ */ char* output_name (const char* target); + +/** + Portability interface to sleep. + + @param seconds the number of seconds to sleep + */ +void rw_sleep (int seconds); + + +/** + Portability interface to signal or sigaction. + + @param signo signal number + @param func signal handler + @return 0 on success, -1 otherwise + */ + +#ifdef __cplusplus +extern "C" { +#endif + +int rw_signal (int signo, void (*func)(int)); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + #endif /* RW_UTIL_H */ Index: /home/sebor/stdcxx-4.2.x/util/exec.cpp =================================================================== --- /home/sebor/stdcxx-4.2.x/util/exec.cpp (revision 587687) +++ /home/sebor/stdcxx-4.2.x/util/exec.cpp (working copy) @@ -71,6 +71,34 @@ # define STATUS_INVALID_CRUNTIME_PARAMETER ((DWORD)0xC0000417L) # endif #endif + +#ifndef SIGHUP +# define SIGHUP 1 /* Linux value */ +#endif +#ifndef SIGQUIT +# define SIGQUIT 3 /* Linux value */ +#endif +#ifndef SIGKILL +# define SIGKILL 9 /* Linux value */ +#endif +#ifndef SIGALRM +# define SIGALRM 14 /* Linux value */ +#endif + + +#ifndef ESRCH +# define ESRCH 3 /* Linux value */ +#endif +#ifndef EINTR +# define EINTR 4 /* Linux value */ +#endif +#ifndef ECHILD +# define ECHILD 10 /* Linux value */ +#endif +#ifndef EINVAL +# define EINVAL 22 /* Linux value */ +#endif + #include /* for S_* */ #include @@ -80,6 +108,21 @@ #include "exec.h" +#ifndef _RWSTD_NO_PURE_C_HEADERS +# ifdef __cplusplus +extern "C" { +# endif + +int kill (pid_t pid, int sig); + +FILE* fdopen (int fd, const char *mode); + +# ifdef __cplusplus +} /* extern "C" */ +# endif +#endif /* _RWSTD_NO_PURE_C_HEADERS */ + + /** Status flag used to comunicate that an alarm has triggered. @@ -444,8 +487,6 @@ static const unsigned sigcount = sizeof (signals) / sizeof (int); - struct sigaction act; - unsigned siginx = 0; int stopped = 0; @@ -463,32 +504,20 @@ /* Clear timeout */ alarm_timeout = 0; - /* Set handler (if needed). Need to use sigaction rather than signal due - to linux glitch + /* Set handler (if needed). */ - memset (&act, 0, sizeof act); - - /* avoid extern "C"/"C++" mismatch due to an HP aCC 6 bug - (see STDCXX-291) - */ - alarm_handler phandler = handle_alrm; - memcpy (&act.sa_handler, &phandler, sizeof act.sa_handler); - - sigaction (SIGALRM, &act, 0); + rw_signal (SIGALRM, handle_alrm); /* Set handlers for SIGHUP, SIGINT, SIGQUIT, SIGTERM so we can kill the child process prior to dieing. */ kill_signal = 0; - phandler = handle_term_signal; - memcpy (&act.sa_handler, &phandler, sizeof act.sa_handler); + rw_signal (SIGHUP, handle_term_signal); + rw_signal (SIGINT, handle_term_signal); + rw_signal (SIGQUIT, handle_term_signal); + rw_signal (SIGTERM, handle_term_signal); - sigaction (SIGHUP, &act, 0); - sigaction (SIGINT, &act, 0); - sigaction (SIGQUIT, &act, 0); - sigaction (SIGTERM, &act, 0); - if (timeout > 0) alarm (timeout); @@ -623,11 +652,10 @@ /* Check if we were signaled to quit. */ if (kill_signal) { /* Reset the handlers to normal */ - act.sa_handler = SIG_DFL; - sigaction (SIGHUP, &act, 0); - sigaction (SIGINT, &act, 0); - sigaction (SIGQUIT, &act, 0); - sigaction (SIGTERM, &act, 0); + rw_signal (SIGHUP, SIG_DFL); + rw_signal (SIGINT, SIG_DFL); + rw_signal (SIGQUIT, SIG_DFL); + rw_signal (SIGTERM, SIG_DFL); if (0 > raise (kill_signal)) terminate (1, "raise(%s) failed: %s\n", Index: /home/sebor/stdcxx-4.2.x/util/cmdopt.cpp =================================================================== --- /home/sebor/stdcxx-4.2.x/util/cmdopt.cpp (revision 587687) +++ /home/sebor/stdcxx-4.2.x/util/cmdopt.cpp (working copy) @@ -160,60 +160,7 @@ " xlc IBM XLC++\n" }; -#if !defined (_WIN32) && !defined (_WIN64) -static void -rw_sleep (int seconds) -{ - sleep (seconds); -} - - -#ifdef __cplusplus - -extern "C" { - -#endif /* __cplusplus */ - -static int -rw_signal (int signo, void (*func)(int)) -{ - struct sigaction act; - memset (&act, 0, sizeof act); - - /* avoid extern "C"/"C++" mismatch due to an HP aCC 6 bug - (see STDCXX-291) */ - if (func) - memcpy (&act.sa_handler, &func, sizeof func); - else - act.sa_handler = 0; - - return 0 > sigaction (signo, &act, 0); -} - -#ifdef __cplusplus - -} /* extern "C" */ - -#endif /* __cplusplus */ - -#else /* if defined (_WIN32) || defined (_WIN64) */ - -static void -rw_sleep (int seconds) -{ - Sleep (seconds * 1000); -} - - -static int -rw_signal (int signo, void (*func)(int)) -{ - return SIG_ERR == signal (signo, func); -} - -#endif /* _WIN{32,64}*/ - /** Display command line switches for program and terminate. Index: /home/sebor/stdcxx-4.2.x/util/util.cpp =================================================================== --- /home/sebor/stdcxx-4.2.x/util/util.cpp (revision 587687) +++ /home/sebor/stdcxx-4.2.x/util/util.cpp (working copy) @@ -26,6 +26,7 @@ #include /* for assert */ #include /* for errno */ +#include /* for sigaction(), signal() */ #include /* for vfprintf */ #include /* for exit, malloc */ #include /* for va_* */ @@ -34,6 +35,13 @@ #include /* for stat() */ #include /* for size_t */ +#ifndef _WIN32 +# include /* for sleep() */ +#else +# include /* for Sleep() */ +#endif /* _WIN{32,64} */ + + #include "cmdopt.h" /* for exe_name, target_name */ #include "util.h" @@ -228,3 +236,80 @@ memcpy (tmp_name + exe_len + 1, suffix, sfx_len + 1); return tmp_name; } + + +#ifndef _WIN32 + +void +rw_sleep (int seconds) +{ + sleep (seconds); +} + + +# ifdef _RWSTD_NO_PURE_C_HEADERS + +# ifdef __cplusplus + +extern "C" { + +# endif /* __cplusplus */ + +int +rw_signal (int signo, void (*func)(int)) +{ + struct sigaction act; + memset (&act, 0, sizeof act); + + /* avoid extern "C"/"C++" mismatch due to an HP aCC 6 bug + (see STDCXX-291) */ + if (func) + memcpy (&act.sa_handler, &func, sizeof func); + else + act.sa_handler = 0; + + return 0 > sigaction (signo, &act, 0); +} + +# ifdef __cplusplus + +} /* extern "C" */ + +# endif /* __cplusplus */ + +# else /* if defined (_RWSTD_NO_PURE_C_HEADERS) */ + +# ifdef __cplusplus + +extern "C" { + +# endif /* __cplusplus */ + +int +rw_signal (int signo, void (*func)(int)) +{ + return SIG_ERR == signal (signo, func); +} + +# ifdef __cplusplus + +} /* extern "C" */ + +# endif /* __cplusplus */ +# endif /* _RWSTD_NO_PURE_C_HEADERS */ +#else /* if defined (_WIN32) || defined (_WIN64) */ + +void +rw_sleep (int seconds) +{ + Sleep (seconds * 1000); +} + + +int +rw_signal (int signo, void (*func)(int)) +{ + return SIG_ERR == signal (signo, func); +} + +#endif /* _WIN32 */ --------------010705020101040801090707--