1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin *                                                                      *
3da2e3ebdSchin *               This software is part of the ast package               *
4*b30d1939SAndy Fiddaman *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5da2e3ebdSchin *                      and is licensed under the                       *
6*b30d1939SAndy Fiddaman *                 Eclipse Public License, Version 1.0                  *
77c2fbfb3SApril Chin *                    by AT&T Intellectual Property                     *
8da2e3ebdSchin *                                                                      *
9da2e3ebdSchin *                A copy of the License is available at                 *
10*b30d1939SAndy Fiddaman *          http://www.eclipse.org/org/documents/epl-v10.html           *
11*b30d1939SAndy Fiddaman *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12da2e3ebdSchin *                                                                      *
13da2e3ebdSchin *              Information and Software Systems Research               *
14da2e3ebdSchin *                            AT&T Research                             *
15da2e3ebdSchin *                           Florham Park NJ                            *
16da2e3ebdSchin *                                                                      *
17da2e3ebdSchin *                 Glenn Fowler <gsf@research.att.com>                  *
18da2e3ebdSchin *                  David Korn <dgk@research.att.com>                   *
19da2e3ebdSchin *                   Phong Vo <kpv@research.att.com>                    *
20da2e3ebdSchin *                                                                      *
21da2e3ebdSchin ***********************************************************************/
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 Chin debug_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 
40*b30d1939SAndy Fiddaman #include <times.h>
417c2fbfb3SApril Chin #include <sys/resource.h>
427c2fbfb3SApril Chin 
437c2fbfb3SApril Chin double
debug_elapsed(int set)447c2fbfb3SApril Chin debug_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 Chin debug_elapsed(int set)
627c2fbfb3SApril Chin {
637c2fbfb3SApril Chin 	return 0;
647c2fbfb3SApril Chin }
657c2fbfb3SApril Chin 
66da2e3ebdSchin #endif
67