* [Build failure] tm struct tm_gmtoff field build error
@ 2009-01-19 12:40 Pierre Muller
2009-02-17 21:48 ` Cary Coutant
0 siblings, 1 reply; 4+ messages in thread
From: Pierre Muller @ 2009-01-19 12:40 UTC (permalink / raw)
To: nickc, binutils; +Cc: gdb
Trying to compile a "--enable-targets=all" GDB
on current cvs HEAD on cygwin,
I found a new error in src/bfd:
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../purecvs/bfd -I. -I.
-I../../p
urecvs/bfd -I../../purecvs/bfd/../include -W -Wall -Wstrict-prototypes
-Wmissing
-prototypes -Werror -g -O2 -c ../../purecvs/bfd/vmsutil.c -o vmsutil.o
../../purecvs/bfd/vmsutil.c: In function `vms_file_stats_name':
../../purecvs/bfd/vmsutil.c:249: error: structure has no member named
`tm_gmtoff
'
make[3]: *** [vmsutil.lo] Error 1
245-
246- if (cdt)
247- {
248- ts = localtime (&buff.st_mtime);
249: gmtoff = ts->tm_gmtoff;
250- *cdt = (long long) (((buff.st_mtim.tv_sec + gmtoff) *
VMS_GRANULARITY_FACTOR)
251- + (buff.st_mtim.tv_nsec / 100))
252- + VMS_EPOCH_OFFSET;
253- }
The failure is related to a commit by Nick Clifton dated January 15. 2009
adding vmsutils.c file.
tm_gmtoff seems to be an optional field according to:
http://www.delorie.com/gnu/docs/glibc/libc_435.html
and some configure script do check for its presence
before using it, for instance
src/config/tcl.m4
AC_CACHE_CHECK([tm_gmtoff in struct tm], tcl_cv_member_tm_gmtoff, [
AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no)])
if test $tcl_cv_member_tm_gmtoff = yes ; then
AC_DEFINE(HAVE_TM_GMTOFF)
fi
Could this test be added and vmsutils.c
be updated accordingly?
Thanks in advance,
Pierre Muller
Pascal language support maintainer for GDB
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Build failure] tm struct tm_gmtoff field build error
2009-01-19 12:40 [Build failure] tm struct tm_gmtoff field build error Pierre Muller
@ 2009-02-17 21:48 ` Cary Coutant
2009-02-20 9:44 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Cary Coutant @ 2009-02-17 21:48 UTC (permalink / raw)
To: Pierre Muller; +Cc: nickc, binutils, gdb
> Trying to compile a "--enable-targets=all" GDB
> on current cvs HEAD on cygwin,
> I found a new error in src/bfd:
> libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../purecvs/bfd -I. -I.
> -I../../p
> urecvs/bfd -I../../purecvs/bfd/../include -W -Wall -Wstrict-prototypes
> -Wmissing
> -prototypes -Werror -g -O2 -c ../../purecvs/bfd/vmsutil.c -o vmsutil.o
> ../../purecvs/bfd/vmsutil.c: In function `vms_file_stats_name':
> ../../purecvs/bfd/vmsutil.c:249: error: structure has no member named
> `tm_gmtoff'
Nick's follow-up patch on 1/21 still didn't fix the compilation
problems. The non-VMS code in this routine seems a bit confused:
struct stat buff;
struct tm *ts;
if ((stat (filename, &buff)) != 0)
return 1;
if (cdt)
{
ts = localtime (&buff.st_mtime);
*cdt = (long long) ((buff.st_mtim.tv_sec * VMS_GRANULARITY_FACTOR)
+ (buff.st_mtim.tv_nsec / 100))
+ VMS_EPOCH_OFFSET;
}
The call to localtime was apparently there originally to get the
tm_gmtoff value -- after the 1/21 patch, the variable ts is not used.
On top of that, st_mtime is misspelled twice, and, when spelled
correctly, isn't a struct timeval, so it doesn't have tv_sec and
tv_nsec fields. This appears to be an attempt to get sub-second
granularity, but as far as I know, the stat() call does not provide
it.
I propose the following patch, but since I'm not sure what the code is
really meant to be doing, I don't consider it obvious.
-cary
* vmsutil.c (vms_file_stats_name): Fix incorrect use of
st_mtime in struct stat.
Index: vmsutil.c
===================================================================
RCS file: /cvs/src/src/bfd/vmsutil.c,v
retrieving revision 1.2
diff -u -p -r1.2 vmsutil.c
--- vmsutil.c 21 Jan 2009 11:58:05 -0000 1.2
+++ vmsutil.c 17 Feb 2009 21:32:30 -0000
@@ -237,16 +237,13 @@ vms_file_stats_name (const char *filenam
return 0;
#else
struct stat buff;
- struct tm *ts;
if ((stat (filename, &buff)) != 0)
return 1;
if (cdt)
{
- ts = localtime (&buff.st_mtime);
- *cdt = (long long) ((buff.st_mtim.tv_sec * VMS_GRANULARITY_FACTOR)
- + (buff.st_mtim.tv_nsec / 100))
+ *cdt = (long long) (buff.st_mtime * VMS_GRANULARITY_FACTOR)
+ VMS_EPOCH_OFFSET;
}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Build failure] tm struct tm_gmtoff field build error
2009-02-17 21:48 ` Cary Coutant
@ 2009-02-20 9:44 ` Nick Clifton
2009-02-20 19:05 ` Cary Coutant
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2009-02-20 9:44 UTC (permalink / raw)
To: Cary Coutant; +Cc: Pierre Muller, binutils, gdb
Hi Cary,
> * vmsutil.c (vms_file_stats_name): Fix incorrect use of
> st_mtime in struct stat.
Approved - please apply.
Note - personally I do not think that we should be storing timestamps in
binaries at all since it makes comparisons of identical files
impossible, but that is another issue.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-02-20 19:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-19 12:40 [Build failure] tm struct tm_gmtoff field build error Pierre Muller
2009-02-17 21:48 ` Cary Coutant
2009-02-20 9:44 ` Nick Clifton
2009-02-20 19:05 ` Cary Coutant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox