]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* remote-fileio.c (remote_fileio_to_fio_stat)
authorEli Zaretskii <eliz@gnu.org>
Tue, 30 Dec 2003 06:52:09 +0000 (06:52 +0000)
committerEli Zaretskii <eliz@gnu.org>
Tue, 30 Dec 2003 06:52:09 +0000 (06:52 +0000)
(remote_fileio_func_fstat) [HAVE_STRUCT_STAT_ST_BLOCKS]: Support
systems that don't have `st_blocks' member in `struct stat'.

* configure.in (HAVE_STRUCT_STAT_ST_BLOCKS): Ditto.

gdb/ChangeLog
gdb/configure.in
gdb/remote-fileio.c

index 7c460c40bd3894282af27e4167df3386549b82c8..7e65a00ab9881a4286c34fdf9769f9a878187307 100644 (file)
@@ -1,3 +1,11 @@
+2003-12-30  Eli Zaretskii  <eliz@elta.co.il>
+
+       * remote-fileio.c (remote_fileio_to_fio_stat)
+       (remote_fileio_func_fstat) [HAVE_STRUCT_STAT_ST_BLOCKS]: Support
+       systems that don't have `st_blocks' member in `struct stat'.
+
+       * configure.in (HAVE_STRUCT_STAT_ST_BLOCKS): Ditto.
+
 2003-12-29  Eli Zaretskii  <eliz@elta.co.il>
 
        * go32-nat.c (go32_sldt, go32_sgdt, go32_sidt, go32_pte): Fix
index d27470cb6c8fe2069641020961f71520a234180b..f0f65c22c58045210bb20c9517492b653917558e 100644 (file)
@@ -383,6 +383,12 @@ AC_CHECK_HEADERS(curses.h ncurses.h term.h)
 # unconditionally, so what's the point in checking these?
 AC_CHECK_HEADERS(ctype.h time.h)
 
+# remote-fileio.c needs st_blocks
+AC_CHECK_MEMBER(struct stat.st_blocks,
+               [AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS, 1,
+                          [Define if struct stat has st_blocks member.])],
+               [#include <sys/stat.h>])
+
 # ------------------------- #
 # Checks for declarations.  #
 # ------------------------- #
index fd57617acd5e37ca8ec6b7be31397066032d66e0..ead40f047832cd2dc0da4d8045f8a8290201db4a 100644 (file)
@@ -411,7 +411,16 @@ remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst)
   remote_fileio_to_fio_uint ((long) st->st_rdev, fst->fst_rdev);
   remote_fileio_to_fio_ulong ((LONGEST) st->st_size, fst->fst_size);
   remote_fileio_to_fio_ulong ((LONGEST) st->st_blksize, fst->fst_blksize);
+#if HAVE_STRUCT_STAT_ST_BLOCKS
   remote_fileio_to_fio_ulong ((LONGEST) st->st_blocks, fst->fst_blocks);
+#else
+  /* FIXME: This is correct for DJGPP, but other systems that don't
+     have st_blocks, if any, might prefer 512 instead of st_blksize.
+     (eliz, 30-12-2003)  */
+  remote_fileio_to_fio_ulong (((LONGEST) st->st_size + st->st_blksize - 1)
+                             / (LONGEST) st->st_blksize,
+                             fst->fst_blocks);
+#endif
   remote_fileio_to_fio_time (st->st_atime, fst->fst_atime);
   remote_fileio_to_fio_time (st->st_mtime, fst->fst_mtime);
   remote_fileio_to_fio_time (st->st_ctime, fst->fst_ctime);
@@ -1131,7 +1140,9 @@ remote_fileio_func_fstat (char *buf)
       st.st_rdev = 0;
       st.st_size = 0;
       st.st_blksize = 512;
+#if HAVE_STRUCT_STAT_ST_BLOCKS
       st.st_blocks = 0;
+#endif
       if (!gettimeofday (&tv, NULL))
        st.st_atime = st.st_mtime = st.st_ctime = tv.tv_sec;
       else