00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "config.h"
00038
00039 #ifdef HAVE_GETRUSAGE
00040 #include <sys/time.h>
00041 #include <sys/resource.h>
00042 #endif
00043
00044 #ifdef HAVE_TIMES
00045 #ifdef HAVE_SYS_PARAM_H
00046 #include <sys/param.h>
00047 #endif
00048 #include <sys/times.h>
00049 #endif
00050
00051 #ifdef HAVE_UNISTD_H
00052 #include <unistd.h>
00053 #endif
00054
00055 #ifdef _SC_CLK_TCK
00056 #define GNU_HZ sysconf(_SC_CLK_TCK)
00057 #else
00058 #ifdef HZ
00059 #define GNU_HZ HZ
00060 #else
00061 #ifdef CLOCKS_PER_SEC
00062 #define GNU_HZ CLOCKS_PER_SEC
00063 #endif
00064 #endif
00065 #endif
00066
00067
00068
00069 long
00070 clock ()
00071 {
00072 #ifdef HAVE_GETRUSAGE
00073 struct rusage rusage;
00074
00075 getrusage (0, &rusage);
00076 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
00077 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
00078 #else
00079 #ifdef HAVE_TIMES
00080 struct tms tms;
00081
00082 times (&tms);
00083 return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ);
00084 #else
00085 #ifdef VMS
00086 struct
00087 {
00088 int proc_user_time;
00089 int proc_system_time;
00090 int child_user_time;
00091 int child_system_time;
00092 } vms_times;
00093
00094 times (&vms_times);
00095 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
00096 #else
00097
00098 return 0;
00099 #endif
00100 #endif
00101 #endif
00102 }
00103