This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: [Build failure] tm struct tm_gmtoff field build error
- From: Cary Coutant <ccoutant at google dot com>
- To: Pierre Muller <muller at ics dot u-strasbg dot fr>
- Cc: nickc at redhat dot com, binutils at sourceware dot org, gdb at sourceware dot org
- Date: Tue, 17 Feb 2009 13:48:21 -0800
- Subject: Re: [Build failure] tm struct tm_gmtoff field build error
- References: <004301c97a33$0fa174d0$2ee45e70$@u-strasbg.fr>
> 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;
}