[CONTACT]

[ABOUT]

[POLICY]

The following are the versions of

Found at: ftp.icm.edu.pl:70/packages/netlib/lanz/lanz_file4

/**********************************************************************
*      The following are the C versions of the machine dependent      *
*      routines for LANZ.                                             *
*                                                                     *
*      See lanz.file3 for more information.                           *
**********************************************************************/

/**********************************************************************
*                         LANZ Software Package                       *
*      Filename: falloc.msc                                           *
*      Author: Mark Jones                                             *
*      Purpose: MACHINE DEPENDENT MODULE                              *
*               Allocates and deallocates memory                      *
*               (more information available in documents/memory.doc)  *
**********************************************************************/
 
#include <stdio.h>
 
#include <malloc.h>
falloc_(number,e_type,ptr,total,index,addr)
long int	*number;
long int	*e_type;
long int		*ptr;
long int	*total;
long int	*index;
long int	*addr;
{
/* some local variables */
unsigned	amount; /* the total number of bytes allowed */
long int	*new_space; /* the location of the new space */
unsigned	e_size; /* the number of bytes for the element type */
 
/*  return if 0 bytes are asked for */
	if ((*number) == 0) {
		*index = 1;
		*addr = *ptr;
		return;
	}
 
	if (*e_type == 0) {
		e_size = 8;
	}
	else if (*e_type == 1) {
		e_size = 4;
	}
	else if (*e_type == 2) {
		e_size = 4;
	};
 
 
/* we always allocate one more element than necessary to allow */
/* for alignment problems */
	amount = ((*number)+1)*e_size;
 
/* update the total */
	(*total) = (*total) + amount;
 
 
 
amount = (*number)+1;
/* allocate the new space */
	new_space = (long int *) calloc(amount,e_size);
 
/* check to see if we got the space */
	if (new_space == (long int *)NULL)
	{
		printf("ERROR: Error allocating memory\n");
		printf("REMEDY: Not enough memory on system for the problem\n");
		exit(-1);
	}
 
 
/*  put the address of the new space in addr */
	(*addr) = (long int) new_space;
 
 
/* calculate the index */
	(*index) = ((((long int)new_space)-((long int)ptr)+e_size)/e_size)+1;
 
}
 
/* Free memory allocated by falloc */
ffree_(number,e_type,total,addr)
long int	*number;
long int	*e_type;
long int	*total;
long int	*addr;
{
/* some local variables */
long int	e_size; /* the number of bytes for the element type */
 
/*  return if 0 bytes are asked for */
	if (*number == 0) {
		return;
	}
 
	if (*e_type == 0) {
		e_size = 8;
	}
	else if (*e_type == 1) {
		e_size = 4;
	}
	else if (*e_type == 2) {
		e_size = 4;
	};
 
 
 
	free((char *)(*addr));
 
	(*total) = (*total) - ((*number)+1)*(e_size);
}
 
/* print out the addresses passed in */
fcaddr_(addr1,addr2)
long int	*addr1;
long int	*addr2;
{
	printf("The calculated address is %ld %lx\n",addr1,addr1);
	if ((*addr2)!=0) {
		printf("The real address is %ld %lx\n",(*addr2),(*addr2));
	}
}
 
/**********************************************************************
*                         LANZ Software Package                       *
*      Filename: timdep.msc                                           *
*      Author: Mark Jones                                             *
*      Purpose: MACHINE DEPENDENT                                     *
*               Access time values from computer's clock (see below)  *
**********************************************************************/
 
/* timing routines for the sun3 and sun4 */
#include 	<math.h>
#include    <sys/time.h>
#include    <sys/resource.h>
 
/* a routine that returns the user time in milliseconds */
nt time1_() {
        struct  rusage   tp;
		int retval;
 
        getrusage(RUSAGE_SELF,&tp);
 
		retval = (tp.ru_utime.tv_sec * 1000) +
				 (tp.ru_utime.tv_usec/1000);
		return(retval);
}
 
/* a routine that returns the system time in milliseconds */
nt time2_() {
        struct  rusage   tp;
		int retval;
 
        getrusage(RUSAGE_SELF,&tp);
 
		retval = ((tp.ru_stime.tv_sec * 1000000) + tp.ru_stime.tv_usec)
				 / 1000;
		return(retval);
}
 
/* a routine that returns the real time in milliseconds */
nt time3_() {
		return(0);
}

.


AD:

NEW PAGES:

[ODDNUGGET]

[GOPHER]