From 6224148fdd809170d138216d72b8e6180d626aec Mon Sep 17 00:00:00 2001 From: xleroy Date: Wed, 17 Feb 2010 13:44:32 +0000 Subject: Reorganization test directory git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1253 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/ccured_olden/bh/util.c | 152 -------------------------------------------- 1 file changed, 152 deletions(-) delete mode 100644 test/ccured_olden/bh/util.c (limited to 'test/ccured_olden/bh/util.c') diff --git a/test/ccured_olden/bh/util.c b/test/ccured_olden/bh/util.c deleted file mode 100644 index b7e3347d..00000000 --- a/test/ccured_olden/bh/util.c +++ /dev/null @@ -1,152 +0,0 @@ -/****************************************************************************/ -/* UTIL: various useful routines and functions. */ -/* */ -/* Copyright (c) 1993 by Joshua E. Barnes, Honolulu, HI. */ -/* It's free because it's yours. */ -/****************************************************************************/ - -#include "stdinc.h" -#include "real.h" -#include "vectmath.h" -#include -#include -#include -#include -#ifndef _MSVC -#include -#include -#endif - - -#ifndef HZ -# include -# define HZ CLK_TCK -#endif - -/* - * ERROR: print error message and exit. - */ - -void error(string msg, ...) -{ - va_list args; - - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); - exit(-1); /* quit with error status */ -} - -/* - * EPRINTF: print error message, but don't exit. - */ - -void eprintf(string msg, ...) -{ - va_list args; - - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); -} - - -extern double drand48(void); /* should be in math.h */ - -/* - * XRANDOM: generate floating-point random number. - */ - -real xrandom(real xl, real xh) -{ - real r = (real)rand() / (real)RAND_MAX; - return (xl + (xh - xl) * r); -} - -/* - * RSQR: compute x*x. - */ - -real rsqr(real x) -{ - return (x * x); -} - -/* - * DISTV: subtract vectors and return distance between. - */ - -real distv(vector v, vector u) -{ - real s, d; - int n = NDIM; - - s = 0.0; - while (--n >= 0) { - d = (*v++) - (*u++); - s += d * d; - } - return (rsqrt(s)); -} - -/* - * STREQ: test for equality of strings. - */ - -bool streq(string a, string b) -{ - return (strcmp(a, b) == 0); -} - -/* - * SCANOPT: scan string of the form "word1,word2,..." for match. Warning: - * words must be separated by exactly one comma -- no spaces allowed! - */ - -bool scanopt(string opt, string key) -{ - char *op, *kp; - - op = (char *) opt; /* start scan of options */ - while (*op != NULLCHR) { /* loop over words in opt */ - kp = (char *) key; /* start at front of key */ - while ((*op != ',' ? *op : NULLCHR) /* loop while this word */ - == *kp) { /* ...matches text of key */ - if (*kp++ == NULLCHR) /* at end of key word? */ - return (TRUE); /* keyword found */ - op++; /* else advance ptrs */ - } - while (*op != NULLCHR && *op++ != ',') /* loop till end of word, */ - continue; /* passing "," at end */ - } - return (FALSE); /* keyword not found */ -} - -/* - * CPUTIME: compute CPU time in minutes. - */ - -real cputime() -{ -#ifdef _MSVC - return 1.0; -#else - struct tms buffer; - - if (times(&buffer) == -1) - error("times() call failed\n"); - return (buffer.tms_utime / (60.0 * HZ)); -#endif -} - - -void *allocate(nb) -int nb; -{ - void *mem; - - mem = (void *) calloc(nb, 1); /* calloc zeros memory */ - if (mem == NULL) - error("allocate: not enuf memory (%d bytes)\n", nb); - return (mem); -} -- cgit