From d3ea68091c7b557fa76c915778273f6b9a743938 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 21 Mar 2005 21:23:35 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 10 +++ gdb/config.in | 9 ++ gdb/configure | 213 ++++++++++++++++++++++++++++++++++++++++++++ gdb/configure.ac | 2 + gdb/remote-fileio.c | 23 ++++- 5 files changed, 254 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 369c0c24d7..5756020456 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2005-03-21 Mark Mitchell + + * 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. + 2005-03-21 Christopher Faylor * win32-nat.c (do_initial_child_stuff): Don't clear the thread list diff --git a/gdb/config.in b/gdb/config.in index 9c6414a369..18807c9e4f 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -247,12 +247,18 @@ /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD +/* Define to 1 if you have the `getgid' function. */ +#undef HAVE_GETGID + /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE /* Define as 1 if you have gettext and don't want to use GNU gettext. */ #undef HAVE_GETTEXT +/* Define to 1 if you have the `getuid' function. */ +#undef HAVE_GETUID + /* Define to 1 if you have the header file. */ #undef HAVE_GNU_LIBC_VERSION_H @@ -457,6 +463,9 @@ /* Define to 1 if `r_gs' is member of `struct reg'. */ #undef HAVE_STRUCT_REG_R_GS +/* Define to 1 if `st_blksize' is member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BLKSIZE + /* Define to 1 if `st_blocks' is member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BLOCKS diff --git a/gdb/configure b/gdb/configure index 0f654781a4..c30726e347 100755 --- a/gdb/configure +++ b/gdb/configure @@ -13470,6 +13470,116 @@ cat >>confdefs.h <<_ACEOF _ACEOF +fi + +echo "$as_me:$LINENO: checking for struct stat.st_blksize" >&5 +echo $ECHO_N "checking for struct stat.st_blksize... $ECHO_C" >&6 +if test "${ac_cv_member_struct_stat_st_blksize+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static struct stat ac_aggr; +if (ac_aggr.st_blksize) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_stat_st_blksize=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static struct stat ac_aggr; +if (sizeof ac_aggr.st_blksize) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_stat_st_blksize=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_stat_st_blksize=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_blksize" >&5 +echo "${ECHO_T}$ac_cv_member_struct_stat_st_blksize" >&6 +if test $ac_cv_member_struct_stat_st_blksize = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 +_ACEOF + + fi @@ -15176,6 +15286,109 @@ fi done + +for ac_func in getuid getgid +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + for ac_func in poll do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/gdb/configure.ac b/gdb/configure.ac index 9bdaa753cb..3318c2c537 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -425,6 +425,7 @@ AC_CHECK_DECLS(getopt) # ----------------------- # AC_CHECK_MEMBERS([struct stat.st_blocks]) +AC_CHECK_MEMBERS([struct stat.st_blksize]) # ------------------ # # Checks for types. # @@ -447,6 +448,7 @@ 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) diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 7d8744dff3..9c2e430062 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -417,6 +417,8 @@ remote_fileio_to_fio_ulong (LONGEST num, fio_ulong_t fnum) 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); @@ -425,15 +427,20 @@ remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst) 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); +#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 + st->st_blksize - 1) - / (LONGEST) st->st_blksize, + 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); @@ -1150,11 +1157,21 @@ remote_fileio_func_fstat (char *buf) 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; +#ifdef HAVE_GETUID st.st_uid = getuid (); +#else + st.st_uid = 0; +#endif +#ifdef 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