From: haible@ma2s2.mathematik.uni-karlsruhe.de (Bruno Haible)
Newsgroups: gnu.utils.bug
Subject: time-1.4
Date: 5 Jan 93 22:44:00 GMT
Distribution: gnu
Organization: GNUs Not Usenet

Compiling time-1.4 on linux, using GCC 2.3.3.

time.c:93: conflicting types for `wait3'
/usr/include/sys/wait.h:39: previous declaration of `wait3'
time.c:100: conflicting types for `getpagesize'
/usr/include/unistd.h:331: previous declaration of `getpagesize'
time.c: In function `run_command':
time.c:618: storage size of `status' isn't known
time.c:636: warning: passing arg 2 of `execvp' from incompatible pointer type
make: *** [time.o] Error 1

This is fixed by the following diff:

diff -r -c3 time-1.4/time.c time-1.41/time.c
*** time-1.4/time.c	Wed Oct 28 19:21:05 1992
--- time-1.41/time.c	Tue Jan  5 19:52:47 1993
***************
*** 89,95 ****
  void error P_((int status, int errnum, char *message, ...));
  
  int gettimeofday P_((struct timeval *tp, struct timezone *tz));
! #ifdef HAVE_SYS_RESOURCE_H
  int wait3 P_((union wait *status, int options, struct rusage *rusage));
  #else
  int wait3 P_((int *status, int options, struct rusage *rusage));
--- 89,95 ----
  void error P_((int status, int errnum, char *message, ...));
  
  int gettimeofday P_((struct timeval *tp, struct timezone *tz));
! #if defined(HAVE_SYS_RESOURCE_H) && !defined(linux)
  int wait3 P_((union wait *status, int options, struct rusage *rusage));
  #else
  int wait3 P_((int *status, int options, struct rusage *rusage));
***************
*** 97,104 ****
--- 97,108 ----
  
  #include "getpagesize.h"
  #ifndef getpagesize
+ #ifdef linux
+ size_t getpagesize P_((void));
+ #else
  int getpagesize P_((void));
  #endif
+ #endif
  
  void usage P_((void));
  
***************
*** 614,620 ****
       int *exitcode;
       char const *const cmd[];
  {
! #ifdef HAVE_SYS_RESOURCE_H
    union wait status;		/* Exit status of child. */
  #else
    int status;
--- 618,624 ----
       int *exitcode;
       char const *const cmd[];
  {
! #if defined(HAVE_SYS_RESOURCE_H) && !defined(linux)
    union wait status;		/* Exit status of child. */
  #else
    int status;
***************
*** 667,673 ****
      }
    finish->tv_usec -= start.tv_usec;
  
! #ifdef HAVE_SYS_RESOURCE_H
    *exitcode = (int) status.w_T.w_Retcode;
  #else
    *exitcode = status >> 8;
--- 671,677 ----
      }
    finish->tv_usec -= start.tv_usec;
  
! #if defined(HAVE_SYS_RESOURCE_H) && !defined(linux)
    *exitcode = (int) status.w_T.w_Retcode;
  #else
    *exitcode = status >> 8;


The first problem is that Linux has sys/resource.h, but declares wait3()
as follows in <sys/wait.h> :

extern pid_t    wait3 _ARGS ((int *__wait_stat, int __options,
                        struct rusage *__rup));

Instead of testing for the presence of <sys/resource.h>, you should perhaps
test if including <sys/wait.h> defines the "union wait" type.


The second problem is that Linux declares getpagesize() as follows in
<unistd.h> :

extern size_t   getpagesize  _ARGS((void));

and size_t is an unsigned type.

Usually, I use the following autoconf macro to check for the getpagesize()
return type:

define(AC_GETPAGESIZE,
[AC_COMPILE_CHECK([getpagesize], , [getpagesize();],
AC_DEFINE(HAVE_GETPAGESIZE) [have_getpagesize=1])dnl
if test -n "$have_getpagesize"; then
echo checking for getpagesize declaration
AC_TEST_PROGRAM([
#if STDC_HEADERS
#include <stdlib.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
extern int getpagesize();
main() { exit(0); }],
AC_DEFINE(RETGETPAGESIZETYPE,[int]),
AC_DEFINE(RETGETPAGESIZETYPE,[size_t]))
fi
])dnl
dnl


Regards,
                  Bruno Haible
                  haible@ma2s2.mathematik.uni-karlsruhe.de
Newsgroups: gnu.utils.bug