Article View: gnu.utils.bug
Article #1256time-1.4
From: Bruno Haible
Date: Tue, 05 Jan 1993 22:44
Date: Tue, 05 Jan 1993 22:44
128 lines
4127 bytes
4127 bytes
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
Technical Details
Message-ID:
<9301052044.AA28629@ma2s2.mathematik.uni-karlsruhe.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!olivea!charnel!rat!usc!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ma2s2.mathematik.uni-karlsruhe.de!haibleShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!charnel!rat!usc!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ma2s2.mathematik.uni-karlsruhe.de!haible From: haible@ma2s2.mathematik.uni-karlsruhe.de (Bruno Haible) Newsgroups: gnu.utils.bug Subject: time-1.4 Message-ID: <9301052044.AA28629@ma2s2.mathematik.uni-karlsruhe.de> Date: 5 Jan 93 22:44:00 GMT Sender: gnulists@ai.mit.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 128 Approved: bug-gnu-utils@prep.ai.mit.edu