sim: use socklen_t with accept()

The accept() function takes a socklen_t, not an int.  Using an int causes:
dv-sockser.c: In function 'connected_p':
dv-sockser.c:273: warning: pointer targets in passing argument 3
                           of 'accept' differ in signedness

So use the same socklen_t detection code as gdb and convert the accept().
This commit is contained in:
Mike Frysinger
2010-03-30 23:09:48 +00:00
parent 2422fad9eb
commit 75005b3a8e
5 changed files with 100 additions and 14 deletions

View File

@@ -1,3 +1,9 @@
2010-03-30 Mike Frysinger <vapier@gentoo.org>
* configure.ac: Check for socklen_t.
* configure, config.in: Regenerated.
* dv-sockser.c (connected_p): Change addrlen type to socklen_t.
2010-03-30 Mike Frysinger <vapier@gentoo.org>
* sim-utils.c (sim_io_eprintf_cpu): Use %s with printf string.

View File

@@ -46,6 +46,9 @@
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION
/* Define to 1 if the system has the type `socklen_t'. */
#undef HAVE_SOCKLEN_T
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -58,43 +61,43 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if st_atime is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_atime'. */
#undef HAVE_STRUCT_STAT_ST_ATIME
/* Define to 1 if st_blksize is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_blksize'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
/* Define to 1 if st_blocks is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_blocks'. */
#undef HAVE_STRUCT_STAT_ST_BLOCKS
/* Define to 1 if st_ctime is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_ctime'. */
#undef HAVE_STRUCT_STAT_ST_CTIME
/* Define to 1 if st_dev is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_dev'. */
#undef HAVE_STRUCT_STAT_ST_DEV
/* Define to 1 if st_gid is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_gid'. */
#undef HAVE_STRUCT_STAT_ST_GID
/* Define to 1 if st_ino is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_ino'. */
#undef HAVE_STRUCT_STAT_ST_INO
/* Define to 1 if st_mode is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_mode'. */
#undef HAVE_STRUCT_STAT_ST_MODE
/* Define to 1 if st_mtime is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_mtime'. */
#undef HAVE_STRUCT_STAT_ST_MTIME
/* Define to 1 if st_nlink is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_nlink'. */
#undef HAVE_STRUCT_STAT_ST_NLINK
/* Define to 1 if st_rdev is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_rdev'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
/* Define to 1 if st_size is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_size'. */
#undef HAVE_STRUCT_STAT_ST_SIZE
/* Define to 1 if st_uid is a member of struct stat. */
/* Define to 1 if `struct stat' is a member of `st_uid'. */
#undef HAVE_STRUCT_STAT_ST_UID
/* Define to 1 if you have the <sys/mman.h> header file. */

68
sim/common/configure vendored
View File

@@ -1852,6 +1852,60 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_member
# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
# -------------------------------------------
# Tests whether TYPE exists after having included INCLUDES, setting cache
# variable VAR accordingly.
ac_fn_c_check_type ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
eval "$3=no"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
if (sizeof ($2))
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
if (sizeof (($2)))
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
eval "$3=yes"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_type
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -4563,6 +4617,20 @@ _ACEOF
fi
ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h>
#include <sys/socket.h>
"
if test "x$ac_cv_type_socklen_t" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SOCKLEN_T 1
_ACEOF
fi
ac_config_files="$ac_config_files Makefile"
ac_config_commands="$ac_config_commands default"

View File

@@ -49,5 +49,10 @@ AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif]])
AC_CHECK_TYPES(socklen_t, [], [],
[#include <sys/types.h>
#include <sys/socket.h>
])
AC_OUTPUT(Makefile,
[case x$CONFIG_HEADERS in xcconfig.h:config.in) echo > stamp-h ;; esac])

View File

@@ -55,6 +55,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "dv-sockser.h"
#ifndef HAVE_SOCKLEN_T
typedef int socklen_t;
#endif
/* Get definitions for both O_NONBLOCK and O_NDELAY. */
#ifndef O_NDELAY
@@ -243,7 +247,7 @@ connected_p (SIM_DESC sd)
struct timeval tv;
fd_set readfds;
struct sockaddr sockaddr;
int addrlen;
socklen_t addrlen;
if (sockser_listen_fd == -1)
return 0;