[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A macro to check for data type alignment
From: |
Paul Eggert |
Subject: |
Re: A macro to check for data type alignment |
Date: |
Wed, 13 Feb 2002 16:35:02 -0800 (PST) |
> From: Akim Demaille <address@hidden>
> Date: Wed, 13 Feb 2002 13:42:38 +0100
>
> I'm somewhat against using AC_DEFINE to replace functions (but until
> we can provide more convenient, I'll just shut up 1:), and against
> AC_FUNC which replaces without saying. Please, submit an
> AC_REPLACE_FUNC_GETTIMEOFDAY.
>
> Since there appears to be some debate about it, I'd like Paul's
> insight on this function.
First, does anybody still port to ancient hosts that insist on
1-argument gettimeofday? I last used one about 8 or 10 years ago.
Solaris 2.4 had an unprototyped gettimeofday precisely so that C code
worked either way. (Or maybe you're worried about C++ code? that
wasn't standardized in Solaris until 2.5 came out.)
Second, there's lots of prior art here. For example:
* Emacs defines GETTIMEOFDAY_ONE_ARGUMENT if gettimeofday cannot accept
two arguments.
* 'make' just sees whether a 2-arg gettimeofday exists, and if so defines
HAVE_GETTIMEOFDAY.
* textutils has a gettimeofday replacement that works around a Mac OS X
bug where gettimeofday clobbers the static buffer that localtime uses
for its return value.
If you want a fancy, general solution to this problem, I'd suggest
combining the approaches of 'make' and 'textutils'. User code should
assume a standard gettimeofday with two arguments. The textutils
method is reasonable; maybe it needs to be extended to support
one-argument gettimeofday, if that's still a real problem.
If it matters, modern software tends to prefer clock_gettime to
gettimeofday, since clock_gettime has higher resolution.