Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit274328c

Browse files
committed
Avoid use of int64_t, which seems not to be very portable. Simplify
padding logic for struct sockaddr_storage --- original version did notdo what it claimed to when SALEN is defined.
1 parentbbac418 commit274328c

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

‎src/include/libpq/pqcomm.h

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: pqcomm.h,v 1.88 2003/06/24 01:49:22 momjian Exp $
12+
* $Id: pqcomm.h,v 1.89 2003/07/15 17:54:34 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -34,41 +34,35 @@
3434

3535
#ifndefHAVE_STRUCT_SOCKADDR_STORAGE
3636
/* Define a struct sockaddr_storage if we don't have one. */
37-
/*
38-
* Desired design of maximum size and alignment
39-
*/
40-
#define_SS_MAXSIZE 128/* Implementation specific max size */
41-
#define_SS_ALIGNSIZE (sizeof (int64_t))
42-
/* Implementation specific desired alignment */
43-
/*
44-
* Definitions used for sockaddr_storage structure paddings design.
45-
*/
46-
#define_SS_PAD1SIZE(_SS_ALIGNSIZE - sizeof (sa_family_t))
47-
#define_SS_PAD2SIZE(_SS_MAXSIZE - (sizeof (sa_family_t) + \
48-
_SS_PAD1SIZE + _SS_ALIGNSIZE))
37+
38+
#define_SS_MAXSIZE 128/* Implementation specific max size */
4939

5040
#ifdef__CYGWIN__
5141
typedefunsigned shortsa_family_t;
5242
#endif
5343

44+
/* This must exactly match the non-padding fields of sockaddr_storage! */
45+
structnopad_sockaddr_storage {
46+
#ifdefSALEN
47+
uint8__ss_len;/* address length */
48+
#endif
49+
sa_family_tss_family;/* address family */
50+
51+
int64__ss_align;/* ensures struct is properly aligned */
52+
};
53+
5454
structsockaddr_storage {
5555
#ifdefSALEN
56-
uint8_t__ss_len;/* address length */
56+
uint8__ss_len;/* address length */
5757
#endif
58-
sa_family_tss_family;/* address family */
59-
60-
char__ss_pad1[_SS_PAD1SIZE];
61-
/* 6 byte pad, this is to make implementation
62-
* specific pad up to alignment field that
63-
* follows explicit in the data structure */
64-
int64_t__ss_align;
65-
/* field to force desired structure
66-
* storage alignment */
67-
char__ss_pad2[_SS_PAD2SIZE];
68-
/* 112 byte pad to achieve desired size,
69-
* _SS_MAXSIZE value minus size of ss_family
70-
* __ss_pad1, __ss_align fields is 112 */
58+
sa_family_tss_family;/* address family */
59+
60+
int64__ss_align;/* ensures struct is properly aligned */
61+
62+
char__ss_pad[_SS_MAXSIZE-sizeof(structnopad_sockaddr_storage)];
63+
/* ensures struct has desired size */
7164
};
65+
7266
#elif !defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)
7367
# ifdefHAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
7468
# definess_family __ss_family

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp