Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Mitchell <mark@codesourcery.com>
To: gdb-patches@sources.redhat.com
Subject: PATCH: Adjust for more Windows oddities
Date: Wed, 16 Mar 2005 16:37:00 -0000	[thread overview]
Message-ID: <200503161637.j2GGbEAw023701@sethra.codesourcery.com> (raw)


Windows does not have getuid or getgid, so I've added autoconf checks
for those functions.  There is also no "st_blksize" member in "struct
stat".  Technically, this patch should perhaps be two separate
patches, but since the code modified in remote-fileio.c was all in the
same place, I've submitted it as one patch.

Tested on x86_64-unknown-linux-gnu.  OK to apply?

(After this patch, we'll be on to the "good part".)

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
 
2005-03-16  Mark Mitchell  <mark@codesourcery.com>

	* configure.ac (stat.st_blksize): Check for it.
	(getuid): Likewise.
	(getgid): Likewise.
	* configure: Regenerated.
	* config.in: Likewise.
	* remote-fileio.c (remote_fileio_to_fio_stat): Check
	HAVE_STRUCT_STAT_ST_BLKSIZE. 

Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.14
diff -c -5 -p -r1.14 configure.ac
*** configure.ac	13 Mar 2005 05:37:48 -0000	1.14
--- configure.ac	16 Mar 2005 16:30:21 -0000
*************** AC_CHECK_DECLS(getopt)
*** 423,432 ****
--- 423,433 ----
  # ----------------------- #
  # Checks for structures.  #
  # ----------------------- #
  
  AC_CHECK_MEMBERS([struct stat.st_blocks])
+ AC_CHECK_MEMBERS([struct stat.st_blksize])
  
  # ------------------ #
  # Checks for types.  #
  # ------------------ #
  
*************** AC_C_INLINE
*** 445,454 ****
--- 446,456 ----
  
  AC_FUNC_ALLOCA
  AC_FUNC_MMAP
  AC_FUNC_VFORK
  AC_CHECK_FUNCS(canonicalize_file_name realpath)
+ AC_CHECK_FUNCS(getuid getgid)
  AC_CHECK_FUNCS(poll)
  AC_CHECK_FUNCS(pread64)
  AC_CHECK_FUNCS(sbrk)
  AC_CHECK_FUNCS(setpgid setpgrp)
  AC_CHECK_FUNCS(sigaction sigprocmask sigsetmask)
Index: remote-fileio.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-fileio.c,v
retrieving revision 1.13
diff -c -5 -p -r1.13 remote-fileio.c
*** remote-fileio.c	16 Mar 2005 15:58:41 -0000	1.13
--- remote-fileio.c	16 Mar 2005 16:30:21 -0000
*************** remote_fileio_to_fio_ulong (LONGEST num,
*** 415,441 ****
  }
  
  static void
  remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst)
  {
    /* `st_dev' is set in the calling function */
    remote_fileio_to_fio_uint ((long) st->st_ino, fst->fst_ino);
    remote_fileio_to_fio_mode (st->st_mode, fst->fst_mode);
    remote_fileio_to_fio_uint ((long) st->st_nlink, fst->fst_nlink);
    remote_fileio_to_fio_uint ((long) st->st_uid, fst->fst_uid);
    remote_fileio_to_fio_uint ((long) st->st_gid, fst->fst_gid);
    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);
--- 415,448 ----
  }
  
  static void
  remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst)
  {
+   LONGEST blksize;
+ 
    /* `st_dev' is set in the calling function */
    remote_fileio_to_fio_uint ((long) st->st_ino, fst->fst_ino);
    remote_fileio_to_fio_mode (st->st_mode, fst->fst_mode);
    remote_fileio_to_fio_uint ((long) st->st_nlink, fst->fst_nlink);
    remote_fileio_to_fio_uint ((long) st->st_uid, fst->fst_uid);
    remote_fileio_to_fio_uint ((long) st->st_gid, fst->fst_gid);
    remote_fileio_to_fio_uint ((long) st->st_rdev, fst->fst_rdev);
    remote_fileio_to_fio_ulong ((LONGEST) st->st_size, fst->fst_size);
! #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
!   blksize = st->st_blksize;
! #else
!   blksize = 512;
! #endif
!   remote_fileio_to_fio_ulong (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 + blksize - 1)
! 			      / 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);
*************** remote_fileio_func_fstat (char *buf)
*** 1148,1162 ****
--- 1155,1179 ----
    if (fd == FIO_FD_CONSOLE_IN || fd == FIO_FD_CONSOLE_OUT)
      {
        remote_fileio_to_fio_uint (1, fst.fst_dev);
        st.st_mode = S_IFCHR | (fd == FIO_FD_CONSOLE_IN ? S_IRUSR : S_IWUSR);
        st.st_nlink = 1;
+ #if HAVE_GETUID
        st.st_uid = getuid ();
+ #else
+       st.st_uid = 0;
+ #endif
+ #if HAVE_GETGID
        st.st_gid = getgid ();
+ #else
+       st.st_gid = 0;
+ #endif
        st.st_rdev = 0;
        st.st_size = 0;
+ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
        st.st_blksize = 512;
+ #endif
  #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;


             reply	other threads:[~2005-03-16 16:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-16 16:37 Mark Mitchell [this message]
2005-03-21 21:02 ` Daniel Jacobowitz
2005-03-21 21:24   ` Mark Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200503161637.j2GGbEAw023701@sethra.codesourcery.com \
    --to=mark@codesourcery.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox