Debian Codegraph @

android/app/jni/extern/macports-legacy-support/include/sys/socket.h

raw
1 /*
2 * Copyright (c) 2024 Frederick H. G. Wright II <[email protected]>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef _MACPORTS_SYS_SOCKET_H_
18 #define _MACPORTS_SYS_SOCKET_H_
19
20 /* MP support header */
21 #include "MacportsLegacySupport.h"
22
23 /* Include the primary system sys/socket.h */
24 #include_next <sys/socket.h>
25
26 /*
27 * OSX prior to 10.6 defines CMSG_DATA without properly considering 64-bit
28 * builds, due to bad alignment assumptions, though it happens to work in
29 * the 10.4 case and only actually fails in the 10.5 64-bit case.
30 *
31 * In those OS versions we substitute a version of the definition from 10.6.
32 */
33
34 #if __MP_LEGACY_SUPPORT_CMSG_DATA_FIX__
35
36 #define __DARWIN_ALIGNBYTES32 (sizeof(__uint32_t) - 1)
37 #define __DARWIN_ALIGN32(p) \
38 ((size_t)((char *)(size_t)(p) \
39 + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32)
40
41 /* given pointer to struct cmsghdr, return pointer to data */
42 #undef CMSG_DATA
43 #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
44 __DARWIN_ALIGN32(sizeof(struct cmsghdr)))
45
46 #endif /* __MP_LEGACY_SUPPORT_CMSG_DATA_FIX__ */
47
48 #endif /* _MACPORTS_SYS_SOCKET_H_ */