X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fvms-misc.c;h=8571e2f99799966945296b1147b8c914e6745633;hb=ec892a0718dc47c2d009532865c353daa749eaa1;hp=c7bd346837098a69421ebbf50f45b8b356e0fe36;hpb=953b49ed1301bc695c44c9981bc3739c4f60a6af;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c index c7bd346837..8571e2f997 100644 --- a/bfd/vms-misc.c +++ b/bfd/vms-misc.c @@ -1,7 +1,6 @@ /* vms-misc.c -- BFD back-end for VMS/VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1996-2015 Free Software Foundation, Inc. Miscellaneous functions. @@ -348,7 +347,7 @@ _bfd_vms_output_quad (struct vms_rec_wr *recwr, bfd_vma value) /* Output c-string as counted string. */ void -_bfd_vms_output_counted (struct vms_rec_wr *recwr, char *value) +_bfd_vms_output_counted (struct vms_rec_wr *recwr, const char *value) { int len; @@ -366,13 +365,13 @@ _bfd_vms_output_counted (struct vms_rec_wr *recwr, char *value) return; } _bfd_vms_output_byte (recwr, (unsigned int) len & 0xff); - _bfd_vms_output_dump (recwr, (unsigned char *) value, len); + _bfd_vms_output_dump (recwr, (const unsigned char *)value, len); } /* Output character area. */ void -_bfd_vms_output_dump (struct vms_rec_wr *recwr, unsigned char *data, int len) +_bfd_vms_output_dump (struct vms_rec_wr *recwr, const unsigned char *data, int len) { vms_debug2 ((6, "_bfd_vms_output_dump (%d)\n", len)); @@ -401,8 +400,8 @@ _bfd_vms_output_fill (struct vms_rec_wr *recwr, int value, int count) using undocumented system call sys$modify(). Pure VMS version. */ -void -_bfd_vms_convert_to_var (char * vms_filename) +static void +vms_convert_to_var (char * vms_filename) { struct FAB fab = cc$rms_fab; @@ -433,8 +432,8 @@ vms_convert_to_var_1 (char *filename, int type) using undocumented system call sys$modify(). Unix filename version. */ -static int -vms_convert_to_var_unix_filename (const char *unix_filename) +int +_bfd_vms_convert_to_var_unix_filename (const char *unix_filename) { if (decc$to_vms (unix_filename, &vms_convert_to_var_1, 0, 1) != 1) return FALSE; @@ -530,7 +529,10 @@ vms_get_module_name (const char *filename, bfd_boolean upcase) - 100ns granularity - epoch is Nov 17, 1858. Here has the constants and the routines used to convert VMS from/to UNIX time. - The conversion routines don't assume 64 bits arithmetic. */ + The conversion routines don't assume 64 bits arithmetic. + + Here we assume that the definition of time_t is the UNIX one, ie integer + type, expressing seconds since the epoch. */ /* UNIX time granularity for VMS, ie 1s / 100ns. */ #define VMS_TIME_FACTOR 10000000 @@ -546,6 +548,7 @@ vms_time_to_time_t (unsigned int hi, unsigned int lo) unsigned int tmp; unsigned int rlo; int i; + time_t res; /* First convert to seconds. */ tmp = hi % VMS_TIME_FACTOR; @@ -562,14 +565,18 @@ vms_time_to_time_t (unsigned int hi, unsigned int lo) lo = rlo; /* Return 0 in case of overflow. */ - if (lo > VMS_TIME_OFFSET && hi > 1) + if (hi > 1 + || (hi == 1 && lo >= VMS_TIME_OFFSET)) return 0; /* Return 0 in case of underflow. */ - if (lo < VMS_TIME_OFFSET) + if (hi == 0 && lo < VMS_TIME_OFFSET) return 0; - return lo - VMS_TIME_OFFSET; + res = lo - VMS_TIME_OFFSET; + if (res <= 0) + return 0; + return res; } /* Convert a time_t to a VMS time. */ @@ -585,16 +592,8 @@ vms_time_t_to_vms_time (time_t ut, unsigned int *hi, unsigned int *lo) /* Put into val. */ val[0] = ut & 0xffff; val[1] = (ut >> 16) & 0xffff; - if (sizeof (ut) > 4) - { - val[2] = (ut >> 32) & 0xffff; - val[3] = (ut >> 48) & 0xffff; - } - else - { - val[2] = 0; - val[3] = 0; - } + val[2] = sizeof (ut) > 4 ? (ut >> 32) & 0xffff : 0; + val[3] = sizeof (ut) > 4 ? (ut >> 48) & 0xffff : 0; /* Add offset. */ tmp[0] = VMS_TIME_OFFSET & 0xffff;