mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 15:31:39 +00:00
struct sockaddr has unsigned char sa_len as the first member in BSD
in BSD variants and the family member is also an unsigned char instead of (unsigned) short. So we define HAVE_SA_LEN for those BDS variants and check for the offsetof for the sa_family member and also change the struct qsockaddr to mirror that. This should matter only when PLATFORM_UNIX is defined. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@260 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
c09f459026
commit
19051b0f9b
2 changed files with 30 additions and 0 deletions
|
@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
net_defs.h
|
net_defs.h
|
||||||
functions and data private to the network layer
|
functions and data private to the network layer
|
||||||
|
|
||||||
|
net_sys.h and its dependencies must be included
|
||||||
|
before net_defs.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __NET_DEFS_H
|
#ifndef __NET_DEFS_H
|
||||||
|
@ -31,7 +33,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
struct qsockaddr
|
struct qsockaddr
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_SA_LEN)
|
||||||
|
unsigned char qsa_len;
|
||||||
|
unsigned char qsa_family;
|
||||||
|
#else
|
||||||
short qsa_family;
|
short qsa_family;
|
||||||
|
#endif /* BSD, sockaddr */
|
||||||
unsigned char qsa_data[14];
|
unsigned char qsa_data[14];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
limited SDL_net functionality. */
|
limited SDL_net functionality. */
|
||||||
#undef BAN_TEST
|
#undef BAN_TEST
|
||||||
|
|
||||||
|
#undef HAVE_SA_LEN
|
||||||
|
|
||||||
#define sys_socket_t int
|
#define sys_socket_t int
|
||||||
#define INVALID_SOCKET (-1)
|
#define INVALID_SOCKET (-1)
|
||||||
#define SOCKET_ERROR (-1)
|
#define SOCKET_ERROR (-1)
|
||||||
|
@ -53,11 +55,26 @@
|
||||||
#ifndef __NET_SYS_H__
|
#ifndef __NET_SYS_H__
|
||||||
#define __NET_SYS_H__
|
#define __NET_SYS_H__
|
||||||
|
|
||||||
|
#undef HAVE_SA_LEN
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||||
|
defined(__OpenBSD__) || defined(__NetBSD__) || \
|
||||||
|
defined(__MACOSX__)
|
||||||
|
/* struct sockaddr has unsigned char sa_len as the first member in BSD
|
||||||
|
* in BSD variants and the family member is also an unsigned char instead
|
||||||
|
* of (unsigned) short. This should matter only when PLATFORM_UNIX is
|
||||||
|
* defined. */
|
||||||
|
#define HAVE_SA_LEN 1
|
||||||
|
#define SA_FAM_OFFSET 1
|
||||||
|
#else
|
||||||
|
#define SA_FAM_OFFSET 0
|
||||||
|
#endif /* BSD, sockaddr */
|
||||||
|
|
||||||
/* unix includes and compatibility macros */
|
/* unix includes and compatibility macros */
|
||||||
#if defined(PLATFORM_UNIX) || defined(PLATFORM_AMIGA)
|
#if defined(PLATFORM_UNIX) || defined(PLATFORM_AMIGA)
|
||||||
|
|
||||||
|
@ -95,6 +112,9 @@ typedef int socklen_t;
|
||||||
|
|
||||||
#define socketerror(x) strerror((x))
|
#define socketerror(x) strerror((x))
|
||||||
|
|
||||||
|
/* Verify that we defined HAVE_SA_LEN correctly: */
|
||||||
|
typedef char _check_sockaddr[2 * (offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET) - 1];
|
||||||
|
|
||||||
#endif /* end of unix stuff */
|
#endif /* end of unix stuff */
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,6 +146,9 @@ typedef SOCKET sys_socket_t;
|
||||||
/* must #include "wsaerror.h" for this : */
|
/* must #include "wsaerror.h" for this : */
|
||||||
#define socketerror(x) __WSAE_StrError((x))
|
#define socketerror(x) __WSAE_StrError((x))
|
||||||
|
|
||||||
|
/* Verify that we defined HAVE_SA_LEN correctly: */
|
||||||
|
typedef char _check_sockaddr[2 * (offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET) - 1];
|
||||||
|
|
||||||
#endif /* end of windows stuff */
|
#endif /* end of windows stuff */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue