/*
*      SCCS:   @(#)install/userintf/base_cputime	Rel 4.4.3 (07/20/98)
*
*	UniSoft Ltd., London, England
*/
/***********************************************************************

NAME:		base_cputime - user-modifiable use-CPU-time routines
PROJECT:	VSX (X/OPEN Validation Suite)
AUTHOR:		Geoff Clare, UniSoft Ltd.
DATE CREATED:	December 1996
MODIFICATIONS:

	Geoff Clare, October 1997
		Increase default amount of processing performed.

	Andrew Josey, January 2005
		use_time() modified to update a global variable
************************************************************************/

/* Note that these values are increased for LSB ABI testing
 * over the defaults in VSX4.
 * This is since for source testing the SPEEDFACTOR
 * is generally reduced for faster machines. For LSB
 * we compile a fixed SPEEDFACTOR.
 * The net effect is that the LSB version of tests using these
 * routines may execute slowly on slow machines
 */

/*
 *	Sys_call() makes one or more calls to an interface which is
 *	known to be a system call.  I.e. after several calls the system
 *	CPU time for the process will have increased measurably.
 *	It returns 0 for success, -1 for failure.
 */

public int
sys_call()
{
	int i, ret;

	for (i = 0; i < 250; i++)
		ret = access("/", F_OK);

	return ret;
}

/*
 *	Use_time() performs processing which will accumulate
 *	user CPU time.  The number of iterations may be	adjusted
 *	if necessary.
 */

public unsigned int vsx4_use_time_result;

public void
use_time(void)
{
	int i;
	unsigned int dummy = 0;

	for (i = 0; i < 2500; i++)
		dummy = dummy + i / (dummy + 1) * (dummy % 3);

	vsx4_use_time_result = dummy;
}

