|
Boost-Commit : |
From: kbelco_at_[hidden]
Date: 2007-09-18 18:46:31
Author: noel_belcourt
Date: 2007-09-18 18:46:26 EDT (Tue, 18 Sep 2007)
New Revision: 39378
URL: http://svn.boost.org/trac/boost/changeset/39378
Log:
Remove unnecessary overhead in execunix.c related to
the timeout implementation. Also removed unused variables
as diagnosed by the Sgi (mipspro) compiler.
Fixed const-correctness error in operations.hpp that
Sgi complained about.
There's no strerror_r function on Irix 6.5 so I replaced
it with a strerror call.
With these changes, I can now build process jam log and
start running Sgi tests.
Text files modified:
trunk/boost/filesystem/operations.hpp | 4 +-
trunk/libs/system/src/error_code.cpp | 9 ++++++
trunk/tools/jam/src/execunix.c | 48 +++++++++++++++++++--------------------
3 files changed, 33 insertions(+), 28 deletions(-)
Modified: trunk/boost/filesystem/operations.hpp
==============================================================================
--- trunk/boost/filesystem/operations.hpp (original)
+++ trunk/boost/filesystem/operations.hpp 2007-09-18 18:46:26 EDT (Tue, 18 Sep 2007)
@@ -225,7 +225,7 @@
# endif
template<class Path>
- unsigned long remove_all_aux( const Path & ph );
+ unsigned long remove_all_aux( Path & ph );
} // namespace detail
@@ -739,7 +739,7 @@
namespace detail
{
template<class Path>
- unsigned long remove_all_aux( const Path & ph )
+ unsigned long remove_all_aux( Path & ph )
{
static const boost::filesystem::basic_directory_iterator<Path> end_itr;
unsigned long count = 1;
Modified: trunk/libs/system/src/error_code.cpp
==============================================================================
--- trunk/libs/system/src/error_code.cpp (original)
+++ trunk/libs/system/src/error_code.cpp 2007-09-18 18:46:26 EDT (Tue, 18 Sep 2007)
@@ -257,7 +257,14 @@
{
// strerror_r returns 0 on success, otherwise ERANGE if buffer too small,
// invalid_argument if ev not a valid error number
- if ( (result = strerror_r( ev, bp, sz )) == 0 )
+ # if defined (__sgi)
+ const char * c_str = strerror( ev );
+ result = 0;
+ return std::string( c_str ? c_str : "invalid_argument" );
+ # else
+ result = strerror_r( ev, bp, sz );
+ # endif
+ if (result == 0 )
break;
else
{
Modified: trunk/tools/jam/src/execunix.c
==============================================================================
--- trunk/tools/jam/src/execunix.c (original)
+++ trunk/tools/jam/src/execunix.c 2007-09-18 18:46:26 EDT (Tue, 18 Sep 2007)
@@ -59,7 +59,8 @@
* 06/02/97 (gsar) - full async multiprocess support for Win32
*/
-static struct timeval tv, *tv_ptr = 0;
+static clock_t tps = 0;
+static struct timeval tv;
static int intr = 0;
static int cmdsrunning = 0;
static void (*istat)( int );
@@ -110,7 +111,6 @@
int out[2], err[2];
int slot, len;
char *argv[ MAXARGC + 1 ]; /* +1 for NULL */
- FILE *stream;
/* Find a slot in the running commands table for this one. */
@@ -161,6 +161,8 @@
argv[3] = 0;
}
+ if (tps == 0) tps = sysconf(_SC_CLK_TCK);
+
/* increment jobs running */
++cmdsrunning;
@@ -317,7 +319,7 @@
int read_descriptor(int i, int s)
{
- int done, ret, len;
+ int ret, len;
char buffer[BUFSIZ];
while (0 < (ret = fread(buffer, sizeof(char), BUFSIZ-1, cmdtab[i].stream[s])))
@@ -378,7 +380,6 @@
if (globs.timeout && cmdtab[i].pid) {
struct tms buf;
- clock_t tps = sysconf(_SC_CLK_TCK);
clock_t current = times(&buf);
if (globs.timeout <= (current-cmdtab[i].start_time)/tps) {
kill(cmdtab[i].pid, SIGKILL);
@@ -395,31 +396,18 @@
int
execwait()
{
- int i, j, len, ret, fd_max;
+ int i, ret, fd_max;
int pid, status, w, finished;
int rstat;
timing_info time;
fd_set fds;
struct tms old_time, new_time;
- char *tmp;
- char buffer[BUFSIZ];
- struct tms buf;
/* Handle naive make1() which doesn't know if cmds are running. */
if( !cmdsrunning )
return 0;
- /* force select to timeout so we can terminate expired processes */
- if (globs.timeout) {
- tv.tv_sec = globs.timeout;
- tv.tv_usec = 0;
- tv_ptr = &tv;
- }
- else {
- tv_ptr = 0;
- }
-
/* process children that signaled */
finished = 0;
while (!finished && cmdsrunning)
@@ -427,16 +415,26 @@
/* compute max read file descriptor for use in select */
populate_file_descriptors(&fd_max, &fds);
- /* select will wait until io on a descriptor or a signal */
- ret = select(fd_max+1, &fds, 0, 0, tv_ptr);
+ if (0 < globs.timeout) {
+ /* force select to timeout so we can terminate expired processes */
+ tv.tv_sec = globs.timeout;
+ tv.tv_usec = 0;
- if (0 == ret) {
- /* select timed out, all processes have expired, kill them */
- for (i=0; i<globs.jobs; ++i) {
- cmdtab[i].start_time = 0;
+ /* select will wait until io on a descriptor or a signal */
+ ret = select(fd_max+1, &fds, 0, 0, &tv);
+
+ if (0 == ret) {
+ /* select timed out, all processes have expired, kill them */
+ for (i=0; i<globs.jobs; ++i) {
+ cmdtab[i].start_time = 0;
+ }
+ /* select will wait until io on a descriptor or a signal */
+ populate_file_descriptors(&fd_max, &fds);
+ ret = select(fd_max+1, &fds, 0, 0, 0);
}
+ }
+ else {
/* select will wait until io on a descriptor or a signal */
- populate_file_descriptors(&fd_max, &fds);
ret = select(fd_max+1, &fds, 0, 0, 0);
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk