diff --git a/configure.ac b/configure.ac index 50b2873..fe9eec2 100644 --- a/configure.ac +++ b/configure.ac @@ -130,7 +130,8 @@ AC_CHECK_HEADERS([arpa/inet.h errno.h fcntl.h limits.h netinet/in.h sgtty.h \ sys/socket.h sys/time.h termios.h unistd.h net/if_tun.h \ linux/if_tun.h linux/if_packet.h net/if_tap.h sys/mtio.h \ net/nit.h sys/dlpi.h net/if_dl.h net/if_types.h \ - sys/io.h libvdeplug.h, sys/ioctl_compat.h]) + sys/io.h libvdeplug.h, sys/ioctl_compat.h sys/stream.h \ + sys/times.h sys/resource.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE @@ -149,8 +150,8 @@ AC_FUNC_REALLOC AC_CHECK_FUNCS([alarm dup2 gettimeofday localtime_r memset socket strcasecmp \ strchr strcspn strerror strncasecmp strpbrk strrchr strtol \ getifaddrs if_nameindex sigaction nanosleep \ - gettimeofday getrusage setitimer tcsetattr mlockall \ - setpriority]) + getrusage setitimer tcsetattr mlockall \ + setpriority times]) # Check for BSD TTY stuff as fallback for termios. AC_CHECK_MEMBER(struct tchars.t_intrc, diff --git a/src/osdsup.c b/src/osdsup.c index 8b182b7..2148e7c 100644 --- a/src/osdsup.c +++ b/src/osdsup.c @@ -57,6 +57,10 @@ # include #endif +#if HAVE_UNISTD_H +# include /* read, write, lseek */ +#endif + #if CENV_SYS_UNIX # include # include @@ -73,37 +77,35 @@ # include /* BSD: For getrusage() */ # endif -# if CENV_SYS_SOLARIS -# include +# if HAVE_SYS_STREAM_H +# include /* Solaris, mostly */ # include # endif -# if CENV_SYS_SOLARIS || CENV_SYS_XBSD || CENV_SYS_LINUX -# if CENV_SYS_LINUX -# include /* For FIONREAD */ -# else -# include /* For FIONREAD */ -# endif -# include /* BSD: For setitimer() */ +# if HAVE_SYS_IOCTL_H +# include /* For FIONREAD, ioctl, stty, gtty */ +# endif +# if HAVE_SYS_IOCTL_COMPAT_H +# include +# endif +# if HAVE_SYS_FILIO_H +# include /* For FIONREAD */ +# endif +# if HAVE_SYS_TIME_H +# include /* For setitimer(), gettimeofday */ +# endif +# if HAVE_SYS_TIMES_H # include /* No getrusage(), use times() */ +# endif +# if HAVE_LIMITS_H # include /* For CLK_TCK */ # endif - # if CENV_SYSF_TERMIOS # include /* SV4: For terminal stuff */ # else -# include +# include /* fallback to BSDTTY */ # endif - - /* Declare syscalls used */ -# if CENV_SYS_UNIX && !CENV_SYS_V7 -# include /* read, write, lseek */ -# include /* ioctl, stty, gtty */ +# if HAVE_SYS_RESOURCE_H # include /* getrusage */ - /* sys/stat.h: fstat */ - /* sys/time.h: gettimeofday, setitimer */ -# else - extern int gtty(), stty(), ioctl(), read(), write(), lseek(), fstat(); - extern int gettimeofday(), setitimer(), getrusage(); # endif #elif CENV_SYS_MAC @@ -942,17 +944,7 @@ os_rtmget(register osrtm_t *art) int os_vrtmget(register osrtm_t *art) { -#if CENV_SYS_SOLARIS /* Precision sucks, but it's all we have */ - struct tms tms; - - if (times(&tms) == 0) { - art->tv_sec = tms.tms_utime / CLK_TCK; - art->tv_usec = (tms.tms_utime % CLK_TCK) - * (1000000/CLK_TCK); /* Turn into usec */ - return TRUE; - } - return FALSE; -#elif HAVE_GETRUSAGE +#if HAVE_GETRUSAGE /* WARNING!!! Some systems turn out not to report getrusage runtime in a ** monotonically increasing way! This can result in negative deltas ** from one get to the next. @@ -967,6 +959,16 @@ os_vrtmget(register osrtm_t *art) return TRUE; } return FALSE; +#elif HAVE_TIMES /* Precision sucks, but it's all we have */ + struct tms tms; + + if (times(&tms) == 0) { + art->tv_sec = tms.tms_utime / CLK_TCK; + art->tv_usec = (tms.tms_utime % CLK_TCK) + * (1000000/CLK_TCK); /* Turn into usec */ + return TRUE; + } + return FALSE; #elif CENV_SYS_MAC Microseconds(art); return TRUE;