17c2fbfb3SApril Chin /*********************************************************************** 27c2fbfb3SApril Chin * * 37c2fbfb3SApril Chin * This software is part of the ast package * 4*3e14f97fSRoger A. Faulkner * Copyright (c) 1985-2010 AT&T Intellectual Property * 57c2fbfb3SApril Chin * and is licensed under the * 67c2fbfb3SApril Chin * Common Public License, Version 1.0 * 77c2fbfb3SApril Chin * by AT&T Intellectual Property * 87c2fbfb3SApril Chin * * 97c2fbfb3SApril Chin * A copy of the License is available at * 107c2fbfb3SApril Chin * http://www.opensource.org/licenses/cpl1.0.txt * 117c2fbfb3SApril Chin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 127c2fbfb3SApril Chin * * 137c2fbfb3SApril Chin * Information and Software Systems Research * 147c2fbfb3SApril Chin * AT&T Research * 157c2fbfb3SApril Chin * Florham Park NJ * 167c2fbfb3SApril Chin * * 177c2fbfb3SApril Chin * Glenn Fowler <gsf@research.att.com> * 187c2fbfb3SApril Chin * David Korn <dgk@research.att.com> * 197c2fbfb3SApril Chin * Phong Vo <kpv@research.att.com> * 207c2fbfb3SApril Chin * * 217c2fbfb3SApril Chin ***********************************************************************/ 227c2fbfb3SApril Chin #pragma prototyped 237c2fbfb3SApril Chin /* 247c2fbfb3SApril Chin * <debug.h> support 257c2fbfb3SApril Chin */ 267c2fbfb3SApril Chin 277c2fbfb3SApril Chin #include <ast.h> 287c2fbfb3SApril Chin #include <error.h> 297c2fbfb3SApril Chin #include <debug.h> 307c2fbfb3SApril Chin 317c2fbfb3SApril Chin void debug_fatal(const char * file,int line)327c2fbfb3SApril Chindebug_fatal(const char* file, int line) 337c2fbfb3SApril Chin { 347c2fbfb3SApril Chin error(2, "%s:%d: debug error", file, line); 357c2fbfb3SApril Chin abort(); 367c2fbfb3SApril Chin } 377c2fbfb3SApril Chin 387c2fbfb3SApril Chin #if _sys_times 397c2fbfb3SApril Chin 407c2fbfb3SApril Chin #include <sys/times.h> 417c2fbfb3SApril Chin #include <sys/resource.h> 427c2fbfb3SApril Chin 437c2fbfb3SApril Chin double debug_elapsed(int set)447c2fbfb3SApril Chindebug_elapsed(int set) 457c2fbfb3SApril Chin { 467c2fbfb3SApril Chin double tm; 477c2fbfb3SApril Chin struct rusage ru; 487c2fbfb3SApril Chin 497c2fbfb3SApril Chin static double prev; 507c2fbfb3SApril Chin 517c2fbfb3SApril Chin getrusage(RUSAGE_SELF, &ru); 527c2fbfb3SApril Chin tm = (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec/1000000.0; 537c2fbfb3SApril Chin if (set) 547c2fbfb3SApril Chin return prev = tm; 557c2fbfb3SApril Chin return tm - prev; 567c2fbfb3SApril Chin } 577c2fbfb3SApril Chin 587c2fbfb3SApril Chin #else 597c2fbfb3SApril Chin 607c2fbfb3SApril Chin double debug_elapsed(int set)617c2fbfb3SApril Chindebug_elapsed(int set) 627c2fbfb3SApril Chin { 637c2fbfb3SApril Chin return 0; 647c2fbfb3SApril Chin } 657c2fbfb3SApril Chin 667c2fbfb3SApril Chin #endif 67