Fri Jan 20 01:17:01 2012 UTC ()
CMSG_ALIGN is only for the kernel.


(joerg)
diff -r1.102 -r1.103 src/sys/sys/socket.h

cvs diff -r1.102 -r1.103 src/sys/sys/socket.h (expand / switch to unified diff)

--- src/sys/sys/socket.h 2012/01/20 00:25:29 1.102
+++ src/sys/sys/socket.h 2012/01/20 01:17:01 1.103
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: socket.h,v 1.102 2012/01/20 00:25:29 joerg Exp $ */ 1/* $NetBSD: socket.h,v 1.103 2012/01/20 01:17:01 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -526,27 +526,26 @@ struct cmsghdr { @@ -526,27 +526,26 @@ struct cmsghdr {
526 * Alignment requirement for CMSG struct manipulation. 526 * Alignment requirement for CMSG struct manipulation.
527 * This basically behaves the same as ALIGN() ARCH/include/param.h. 527 * This basically behaves the same as ALIGN() ARCH/include/param.h.
528 * We declare it separately for two reasons: 528 * We declare it separately for two reasons:
529 * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's 529 * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's
530 * idea of ALIGNBYTES at runtime. 530 * idea of ALIGNBYTES at runtime.
531 * without (2), we can't guarantee binary compatibility in case of future 531 * without (2), we can't guarantee binary compatibility in case of future
532 * changes in ALIGNBYTES. 532 * changes in ALIGNBYTES.
533 */ 533 */
534#ifdef _KERNEL 534#ifdef _KERNEL
535#define __CMSG_ALIGN(n) (((n) + ALIGNBYTES) & ~ALIGNBYTES) 535#define __CMSG_ALIGN(n) (((n) + ALIGNBYTES) & ~ALIGNBYTES)
536#define CMSG_ALIGN(n) __CMSG_ALIGN(n) 536#define CMSG_ALIGN(n) __CMSG_ALIGN(n)
537#else 537#else
538#define __CMSG_ALIGN(n) (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes()) 538#define __CMSG_ALIGN(n) (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes())
539#define CMSG_ALIGN(n) __CMSG_ALIGN(n) 
540#endif 539#endif
541 540
542/* given pointer to struct cmsghdr, return pointer to next cmsghdr */ 541/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
543#define CMSG_NXTHDR(mhdr, cmsg) \ 542#define CMSG_NXTHDR(mhdr, cmsg) \
544 (((char *)(cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len) + \ 543 (((char *)(cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len) + \
545 __CMSG_ALIGN(sizeof(struct cmsghdr)) > \ 544 __CMSG_ALIGN(sizeof(struct cmsghdr)) > \
546 (((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \ 545 (((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \
547 (struct cmsghdr *)0 : \ 546 (struct cmsghdr *)0 : \
548 (struct cmsghdr *)((char *)(cmsg) + \ 547 (struct cmsghdr *)((char *)(cmsg) + \
549 __CMSG_ALIGN((cmsg)->cmsg_len))) 548 __CMSG_ALIGN((cmsg)->cmsg_len)))
550 549
551/* 550/*
552 * RFC 2292 requires to check msg_controllen, in case that the kernel returns 551 * RFC 2292 requires to check msg_controllen, in case that the kernel returns