mirror of
https://github.com/boostorg/build.git
synced 2026-02-14 00:32:11 +00:00
Boost Jam code cleanup - extracted functions for finding a free running tables command slot in execnt.c & execunix.c modules.
[SVN r79051]
This commit is contained in:
@@ -95,6 +95,8 @@ static void close_alert( HANDLE );
|
||||
static void close_alerts();
|
||||
/* returns a string's value buffer if not empty or 0 if empty */
|
||||
static char const * null_if_empty( string const * str );
|
||||
/* find a free slot in the running commands table */
|
||||
static int get_free_cmdtab_slot();
|
||||
/* Reports the last failed Windows API related error message. */
|
||||
static void reportWindowsError( char const * const apiName );
|
||||
|
||||
@@ -197,20 +199,10 @@ void exec_cmd
|
||||
char const * target
|
||||
)
|
||||
{
|
||||
int slot;
|
||||
int const slot = get_free_cmdtab_slot();
|
||||
int raw_cmd = 0 ;
|
||||
string cmd_local[ 1 ];
|
||||
|
||||
/* Find a free slot in the running commands table. */
|
||||
for ( slot = 0; slot < MAXJOBS; ++slot )
|
||||
if ( !cmdtab[ slot ].pi.hProcess )
|
||||
break;
|
||||
if ( slot == MAXJOBS )
|
||||
{
|
||||
printf( "no slots for child!\n" );
|
||||
exit( EXITBAD );
|
||||
}
|
||||
|
||||
/* Trim all leading and trailing leading whitespace. */
|
||||
string_new_trimmed( cmd_local, cmd_orig );
|
||||
|
||||
@@ -1261,6 +1253,21 @@ static char const * null_if_empty( string const * str )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Find a free slot in the running commands table.
|
||||
*/
|
||||
|
||||
static int get_free_cmdtab_slot()
|
||||
{
|
||||
int slot;
|
||||
for ( slot = 0; slot < MAXJOBS; ++slot )
|
||||
if ( !cmdtab[ slot ].pi.hProcess )
|
||||
return slot;
|
||||
printf( "no slots for child!\n" );
|
||||
exit( EXITBAD );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Reports the last failed Windows API related error message.
|
||||
*/
|
||||
|
||||
@@ -57,6 +57,11 @@
|
||||
* exec_wait() - wait for any of the async command processes to terminate.
|
||||
*/
|
||||
|
||||
/* find a free slot in the running commands table */
|
||||
static int get_free_cmdtab_slot();
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
static clock_t tps;
|
||||
static int select_timeout;
|
||||
static int intr;
|
||||
@@ -125,23 +130,12 @@ void exec_cmd
|
||||
char const * target
|
||||
)
|
||||
{
|
||||
int slot;
|
||||
int const slot = get_free_cmdtab_slot();
|
||||
int out[ 2 ];
|
||||
int err[ 2 ];
|
||||
int len;
|
||||
char const * argv[ MAXARGC + 1 ]; /* +1 for NULL */
|
||||
|
||||
/* Find a slot in the running commands table for this one. */
|
||||
for ( slot = 0; slot < MAXJOBS; ++slot )
|
||||
if ( !cmdtab[ slot ].pid )
|
||||
break;
|
||||
|
||||
if ( slot == MAXJOBS )
|
||||
{
|
||||
printf( "no slots for child!\n" );
|
||||
exit( EXITBAD );
|
||||
}
|
||||
|
||||
/* Forumulate argv. If shell was defined, be prepared for % and ! subs.
|
||||
* Otherwise, use stock /bin/sh.
|
||||
*/
|
||||
@@ -592,6 +586,21 @@ int exec_wait()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Find a free slot in the running commands table.
|
||||
*/
|
||||
|
||||
static int get_free_cmdtab_slot()
|
||||
{
|
||||
int slot;
|
||||
for ( slot = 0; slot < MAXJOBS; ++slot )
|
||||
if ( !cmdtab[ slot ].pid )
|
||||
return slot;
|
||||
printf( "no slots for child!\n" );
|
||||
exit( EXITBAD );
|
||||
}
|
||||
|
||||
|
||||
void exec_done( void )
|
||||
{
|
||||
int slot;
|
||||
|
||||
Reference in New Issue
Block a user