changed configure.ac to check the offset of sa_family in struct sockaddr

This commit is contained in:
hyung-hwan 2018-02-01 09:34:12 +00:00
parent b7e540d6cf
commit 46cd39cabb
5 changed files with 65 additions and 2 deletions

36
qse/configure vendored
View File

@ -22344,6 +22344,25 @@ $as_echo "#define QSE_SA_FAMILY_T_IS_SIGNED 1" >>confdefs.h
fi fi
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking offset of sa_family in struct sockaddr" >&5
$as_echo_n "checking offset of sa_family in struct sockaddr... " >&6; }
if ac_fn_c_compute_int "$LINENO" "offsetof(struct sockaddr, sa_family)" "ac_cv_offsetof_sa_family" "#include <stddef.h>
#include <winsock2.h>
#include <ws2tcpip.h>"; then :
else
ac_cv_offsteof_sa_family=0
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_offsetof_sa_family" >&5
$as_echo "$ac_cv_offsetof_sa_family" >&6; }
cat >>confdefs.h <<_ACEOF
#define QSE_OFFSETOF_SA_FAMILY ${ac_cv_offsetof_sa_family}
_ACEOF
else else
# The cast to long int works around a bug in the HP C Compiler # The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
@ -22690,6 +22709,23 @@ $as_echo "#define QSE_SA_FAMILY_T_IS_SIGNED 1" >>confdefs.h
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking offset of sa_family in struct sockaddr" >&5
$as_echo_n "checking offset of sa_family in struct sockaddr... " >&6; }
if ac_fn_c_compute_int "$LINENO" "offsetof(struct sockaddr, sa_family)" "ac_cv_offsetof_sa_family" "#include <stddef.h>
#include <sys/types.h>
#include <sys/socket.h>"; then :
else
ac_cv_offsteof_sa_family=0
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_offsetof_sa_family" >&5
$as_echo "$ac_cv_offsetof_sa_family" >&6; }
cat >>confdefs.h <<_ACEOF
#define QSE_OFFSETOF_SA_FAMILY ${ac_cv_offsetof_sa_family}
_ACEOF
fi fi

View File

@ -463,6 +463,16 @@ then
[#include <winsock2.h> [#include <winsock2.h>
#include <ws2tcpip.h>]) #include <ws2tcpip.h>])
fi fi
AC_MSG_CHECKING([offset of sa_family in struct sockaddr])
AC_COMPUTE_INT([ac_cv_offsetof_sa_family],
[[offsetof(struct sockaddr, sa_family)]],
[#include <stddef.h>
#include <winsock2.h>
#include <ws2tcpip.h>], [ac_cv_offsteof_sa_family=0])
AC_MSG_RESULT([$ac_cv_offsetof_sa_family])
AC_DEFINE_UNQUOTED(QSE_OFFSETOF_SA_FAMILY, ${ac_cv_offsetof_sa_family}, [offsetof(struct sockaddr, sa_family)])
else else
AC_CHECK_SIZEOF(struct sockaddr_in,,[ AC_CHECK_SIZEOF(struct sockaddr_in,,[
#include <sys/types.h> #include <sys/types.h>
@ -510,6 +520,14 @@ else
#include <netinet/in.h>]) #include <netinet/in.h>])
fi fi
AC_MSG_CHECKING([offset of sa_family in struct sockaddr])
AC_COMPUTE_INT([ac_cv_offsetof_sa_family],
[[offsetof(struct sockaddr, sa_family)]],
[#include <stddef.h>
#include <sys/types.h>
#include <sys/socket.h>], [ac_cv_offsteof_sa_family=0])
AC_MSG_RESULT([$ac_cv_offsetof_sa_family])
AC_DEFINE_UNQUOTED(QSE_OFFSETOF_SA_FAMILY, ${ac_cv_offsetof_sa_family}, [offsetof(struct sockaddr, sa_family)])
fi fi

View File

@ -936,6 +936,9 @@
/* Define if mode_t is signed */ /* Define if mode_t is signed */
#undef QSE_MODE_T_IS_SIGNED #undef QSE_MODE_T_IS_SIGNED
/* offsetof(struct sockaddr, sa_family) */
#undef QSE_OFFSETOF_SA_FAMILY
/* Author */ /* Author */
#undef QSE_PACKAGE_AUTHOR #undef QSE_PACKAGE_AUTHOR

View File

@ -197,7 +197,13 @@ struct qse_skad_t
/* TODO: is this large enough?? */ /* TODO: is this large enough?? */
union union
{ {
struct
{
#if defined(QSE_OFFSETOF_SA_FAMILY) && (QSE_OFFSET_OF_SA_FAMILY > 0)
qse_uint8_t filler[QSE_OFFSETOF_SA_FAMILY];
#endif
qse_skaf_t family; qse_skaf_t family;
} sa;
qse_uint8_t data[QSE_SKAD_DATA_SIZE]; qse_uint8_t data[QSE_SKAD_DATA_SIZE];
} u; } u;

View File

@ -106,7 +106,7 @@ typedef union sockaddr_t sockaddr_t;
#endif #endif
*/ */
#define FAMILY(x) (((qse_skad_t*)x)->u.family) #define FAMILY(x) (((qse_skad_t*)x)->u.sa.family)
static QSE_INLINE int skad_to_nwad (const sockaddr_t* skad, qse_nwad_t* nwad) static QSE_INLINE int skad_to_nwad (const sockaddr_t* skad, qse_nwad_t* nwad)
{ {