* bfd/bfd.m4 (BFD_HAVE_TIME_TYPE_MEMBER, BFD_HAVE_SYS_STAT_TYPE_MEMBER): New config functions. * bfd/configure.in: Use them. * bfd/configure: Regenerate. * bfd/config.in: Regnerate. * bfd/vmsutil.c: Include sysdep.h, remove ansidecl.h. #define _BSD_SOURCE. Add comments. (vms_file_stats_name): Calculate creation date based on available runtime data. Return 1 for version instead of 0. Index: bfd/bfd.m4 =================================================================== RCS file: /cvs/src/src/bfd/bfd.m4,v retrieving revision 1.4 diff -u -p -r1.4 bfd.m4 --- bfd/bfd.m4 13 Jul 2005 21:19:13 -0000 1.4 +++ bfd/bfd.m4 12 May 2009 00:39:56 -0000 @@ -40,3 +40,41 @@ AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE_MEMBE AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2) ]) +dnl Check for existence of member $2 in type $1 in time.h + +AC_DEFUN([BFD_HAVE_TIME_TYPE_MEMBER], +[AC_MSG_CHECKING([for $1.$2 in time.h]) + AC_CACHE_VAL(bfd_cv_have_time_type_member_$2, + [AC_TRY_COMPILE([ +#define _BSD_SOURCE 1 +#include ], + [$1 avar; void* aref = (void*) &avar.$2], + bfd_cv_have_time_type_member_$2=yes, + bfd_cv_have_time_type_member_$2=no + )]) + if test $bfd_cv_have_time_type_member_$2 = yes; then + AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z]), 1, + [Define if has $1.$2.]) + fi + AC_MSG_RESULT($bfd_cv_have_time_type_member_$2) +]) + +dnl Check for existence of member $2.$3 in type $1 in sys/stat.h + +AC_DEFUN([BFD_HAVE_SYS_STAT_TYPE_MEMBER], +[AC_MSG_CHECKING([for $1.$2.$3 in sys/stat.h]) + AC_CACHE_VAL(bfd_cv_have_sys_stat_type_member_$2_$3, + [AC_TRY_COMPILE([ +#define _BSD_SOURCE 1 +#include ], + [$1 avar; void* aref = (void*) &avar.$2.$3], + bfd_cv_have_sys_stat_type_member_$2_$3=yes, + bfd_cv_have_sys_stat_type_member_$2_$3=no + )]) + if test $bfd_cv_have_sys_stat_type_member_$2_$3 = yes; then + AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_]translit($3, [a-z], [A-Z]), 1, + [Define if has $1.$2.$3]) + fi + AC_MSG_RESULT($bfd_cv_have_sys_stat_type_member_$2_$3) +]) + Index: bfd/configure.in =================================================================== RCS file: /cvs/src/src/bfd/configure.in,v retrieving revision 1.260 diff -u -p -r1.260 configure.in --- bfd/configure.in 17 Apr 2009 13:46:16 -0000 1.260 +++ bfd/configure.in 12 May 2009 00:40:01 -0000 @@ -183,7 +183,7 @@ AC_SUBST(BFD_HOSTPTR_T) BFD_CC_FOR_BUILD AC_CHECK_HEADERS(alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h) -AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h) +AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h) GCC_HEADER_STDINT(bfd_stdint.h) AC_HEADER_TIME AC_HEADER_DIRENT @@ -209,6 +209,17 @@ AC_CHECK_DECLS(strstr) AC_CHECK_DECLS(snprintf) AC_CHECK_DECLS(vsnprintf) +# Support for VMS timestamps via cross compile + +if test "$ac_cv_header_time_h" = yes; then + BFD_HAVE_TIME_TYPE_MEMBER(struct tm, tm_gmtoff) +fi + +if test "$ac_cv_header_sys_stat_h" = yes; then + BFD_HAVE_SYS_STAT_TYPE_MEMBER(struct stat, st_mtim, tv_sec) + BFD_HAVE_SYS_STAT_TYPE_MEMBER(struct stat, st_mtim, tv_nsec) +fi + # Link in zlib if we can. This allows us to read compressed debug sections. # This is used only by compress.c. AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)]) Index: bfd/vmsutil.c =================================================================== RCS file: /cvs/src/src/bfd/vmsutil.c,v retrieving revision 1.3 diff -u -p -r1.3 vmsutil.c --- bfd/vmsutil.c 20 Feb 2009 18:53:12 -0000 1.3 +++ bfd/vmsutil.c 12 May 2009 01:23:54 -0000 @@ -17,9 +17,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "ansidecl.h" +#include "sysdep.h" #include "vmsutil.h" +/* + The purspose of the two alternate versions below is to have one that + works for native VMS and one that works on an NFS mounted filesystem + (Unix Server/VMS client). The main issue being to generated the special + VMS file timestamps for the debug info. +*/ + #ifdef VMS #define __NEW_STARLET 1 #include @@ -90,6 +97,7 @@ to_vms_file_spec (char *filespec) } #else +#define _BSD_SOURCE 1 #include #include #define VMS_EPOCH_OFFSET 35067168000000000LL @@ -237,14 +245,46 @@ vms_file_stats_name (const char *filenam return 0; #else struct stat buff; + struct tm *ts; + long long gmtoff, secs, nsecs; if ((stat (filename, &buff)) != 0) return 1; if (cdt) { - *cdt = (long long) (buff.st_mtime * VMS_GRANULARITY_FACTOR) - + VMS_EPOCH_OFFSET; + ts = localtime (&buff.st_mtime); + +#ifdef HAVE_TM_GMTOFF + gmtoff = ts->tm_gmtoff; +#else + { + extern long timezone; + + if (ts->tm_isdst == 1) + gmtoff = -(timezone - 3600); + else + gmtoff = -timezone; + } +#endif + +#ifdef HAVE_ST_MTIM_TV_SEC + secs = buff.st_mtim.tv_sec; +#else + secs = buff.st_mtime; +#endif + +#ifdef HAVE_ST_MTIM_TV_NSEC + nsecs = buff.st_mtim.tv_nsec; +#else + nsecs = 0; +#endif + + /* VMS timestamps are stored in local time to 100 nsec accuracy, but by + experiment I found timestamps truncated to (at least) microseconds + on an NFS mounted filesystem, hence the adjustment below. DBR. */ + *cdt = ((secs + gmtoff) * VMS_GRANULARITY_FACTOR) + + (nsecs / 1000 * 10) + VMS_EPOCH_OFFSET; } if (siz) @@ -253,8 +293,11 @@ vms_file_stats_name (const char *filenam if (rfo) *rfo = 2; /* Stream LF format. */ + /* Returning a file version of 0 is never correct for debug info, version 1 + will be correct if file editing is done only on the Unix side. If editing + is done on the VMS side, then its TBD. */ if (ver) - *ver = 0; + *ver = 1; return 0; #endif