Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Change CMSG_SPACE and CMSG_LEN to provide Integer Constant E...
details: https://anonhg.NetBSD.org/src/rev/8856f9071b8a
branches: trunk
changeset: 772894:8856f9071b8a
user: joerg <joerg%NetBSD.org@localhost>
date: Fri Jan 20 14:08:04 2012 +0000
description:
Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
diffstat:
common/lib/libc/net/__cmsg_alignbytes.c | 74 ----
external/bsd/tmux/dist/compat/imsg-buffer.c | 6 +-
external/bsd/tmux/dist/compat/imsg.c | 6 +-
external/ibm-public/postfix/dist/src/util/unix_recv_fd.c | 6 +-
external/ibm-public/postfix/dist/src/util/unix_send_fd.c | 6 +-
lib/libc/compat/net/Makefile.inc | 4 +-
lib/libc/compat/net/__cmsg_alignbytes.c | 68 ++++
lib/libc/net/Makefile.inc | 4 +-
sys/arch/alpha/include/cdefs.h | 4 +-
sys/arch/alpha/include/param.h | 4 +-
sys/arch/amd64/include/cdefs.h | 4 +-
sys/arch/amd64/include/param.h | 4 +-
sys/arch/arm/include/cdefs.h | 4 +-
sys/arch/arm/include/param.h | 4 +-
sys/arch/hppa/include/cdefs.h | 4 +-
sys/arch/hppa/include/param.h | 4 +-
sys/arch/i386/include/cdefs.h | 4 +-
sys/arch/i386/include/param.h | 4 +-
sys/arch/ia64/include/cdefs.h | 4 +-
sys/arch/ia64/include/param.h | 4 +-
sys/arch/m68k/include/cdefs.h | 4 +-
sys/arch/m68k/include/param.h | 4 +-
sys/arch/mips/include/cdefs.h | 4 +-
sys/arch/mips/include/mips_param.h | 4 +-
sys/arch/powerpc/include/cdefs.h | 4 +-
sys/arch/powerpc/include/param.h | 4 +-
sys/arch/sh3/include/cdefs.h | 4 +-
sys/arch/sh3/include/param.h | 4 +-
sys/arch/sparc/include/cdefs.h | 7 +-
sys/arch/sparc/include/param.h | 4 +-
sys/arch/sparc64/include/param.h | 8 +-
sys/arch/vax/include/cdefs.h | 4 +-
sys/arch/vax/include/param.h | 4 +-
sys/compat/linux/common/linux_socket.c | 8 +-
sys/compat/netbsd32/netbsd32_socket.c | 228 ++++++++++++++-
sys/compat/netbsd32/netbsd32_sysctl.c | 9 +-
sys/sys/socket.h | 12 +-
37 files changed, 369 insertions(+), 169 deletions(-)
diffs (truncated from 1057 to 300 lines):
diff -r b10b27105b62 -r 8856f9071b8a common/lib/libc/net/__cmsg_alignbytes.c
--- a/common/lib/libc/net/__cmsg_alignbytes.c Fri Jan 20 06:51:19 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/* $NetBSD: __cmsg_alignbytes.c,v 1.3 2009/03/16 05:59:21 cegger Exp $ */
-
-/*-
- * Copyright (c) 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jun-ichiro Hagino.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if !defined(_KERNEL) && !defined(_STANDALONE)
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: __cmsg_alignbytes.c,v 1.3 2009/03/16 05:59:21 cegger Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "namespace.h"
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/socket.h>
-#else
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#endif
-
-int
-__cmsg_alignbytes(void)
-{
- static int alignbytes = -1;
-#ifdef HW_ALIGNBYTES
- int mib[2];
- size_t len;
- int ret;
-#endif
-
- if (alignbytes > 0)
- return alignbytes;
-
-#ifdef HW_ALIGNBYTES
- mib[0] = CTL_HW;
- mib[1] = HW_ALIGNBYTES;
- len = sizeof(alignbytes);
- ret = sysctl(mib, (u_int) (sizeof(mib) / sizeof(mib[0])),
- (void *)&alignbytes, &len, NULL, (size_t)0);
- if (ret >= 0 && alignbytes >= 0)
- return alignbytes;
-#endif
- /* last resort */
- alignbytes = ALIGNBYTES;
- return alignbytes;
-}
diff -r b10b27105b62 -r 8856f9071b8a external/bsd/tmux/dist/compat/imsg-buffer.c
--- a/external/bsd/tmux/dist/compat/imsg-buffer.c Fri Jan 20 06:51:19 2012 +0000
+++ b/external/bsd/tmux/dist/compat/imsg-buffer.c Fri Jan 20 14:08:04 2012 +0000
@@ -1,4 +1,4 @@
-/* $Id: imsg-buffer.c,v 1.4 2011/08/31 20:13:31 plunky Exp $ */
+/* $Id: imsg-buffer.c,v 1.5 2012/01/20 14:08:04 joerg Exp $ */
/* $OpenBSD: imsg-buffer.c,v 1.3 2010/05/26 13:56:07 nicm Exp $ */
/*
@@ -228,11 +228,7 @@
struct cmsghdr *cmsg;
union {
struct cmsghdr hdr;
-#if defined(__clang__) || defined(__PCC__)
- char buf[128];
-#else
char buf[CMSG_SPACE(sizeof(int))];
-#endif
} cmsgbuf;
bzero(&iov, sizeof(iov));
diff -r b10b27105b62 -r 8856f9071b8a external/bsd/tmux/dist/compat/imsg.c
--- a/external/bsd/tmux/dist/compat/imsg.c Fri Jan 20 06:51:19 2012 +0000
+++ b/external/bsd/tmux/dist/compat/imsg.c Fri Jan 20 14:08:04 2012 +0000
@@ -1,4 +1,4 @@
-/* $Id: imsg.c,v 1.4 2011/08/31 20:13:31 plunky Exp $ */
+/* $Id: imsg.c,v 1.5 2012/01/20 14:08:04 joerg Exp $ */
/* $OpenBSD: imsg.c,v 1.3 2010/05/26 13:56:07 nicm Exp $ */
/*
@@ -48,11 +48,7 @@
struct cmsghdr *cmsg;
union {
struct cmsghdr hdr;
-#if defined(__clang__) || defined(__PCC__)
- char buf[128];
-#else
char buf[CMSG_SPACE(sizeof(int) * 16)];
-#endif
} cmsgbuf;
struct iovec iov;
ssize_t n;
diff -r b10b27105b62 -r 8856f9071b8a external/ibm-public/postfix/dist/src/util/unix_recv_fd.c
--- a/external/ibm-public/postfix/dist/src/util/unix_recv_fd.c Fri Jan 20 06:51:19 2012 +0000
+++ b/external/ibm-public/postfix/dist/src/util/unix_recv_fd.c Fri Jan 20 14:08:04 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: unix_recv_fd.c,v 1.6 2011/05/30 18:47:27 pgoyette Exp $ */
+/* $NetBSD: unix_recv_fd.c,v 1.7 2012/01/20 14:08:04 joerg Exp $ */
/*++
/* NAME
@@ -70,11 +70,7 @@
#if defined(CMSG_SPACE) && !defined(NO_MSGHDR_MSG_CONTROL)
union {
struct cmsghdr just_for_alignment;
-# ifdef __clang__
- char control[128];
-# else
char control[CMSG_SPACE(sizeof(newfd))];
-# endif
} control_un;
struct cmsghdr *cmptr;
diff -r b10b27105b62 -r 8856f9071b8a external/ibm-public/postfix/dist/src/util/unix_send_fd.c
--- a/external/ibm-public/postfix/dist/src/util/unix_send_fd.c Fri Jan 20 06:51:19 2012 +0000
+++ b/external/ibm-public/postfix/dist/src/util/unix_send_fd.c Fri Jan 20 14:08:04 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: unix_send_fd.c,v 1.5 2011/05/30 16:24:13 joerg Exp $ */
+/* $NetBSD: unix_send_fd.c,v 1.6 2012/01/20 14:08:05 joerg Exp $ */
/*++
/* NAME
@@ -72,11 +72,7 @@
#if defined(CMSG_SPACE) && !defined(NO_MSGHDR_MSG_CONTROL)
union {
struct cmsghdr just_for_alignment;
-# ifdef __clang__
- char control[128];
-# else
char control[CMSG_SPACE(sizeof(sendfd))];
-# endif
} control_un;
struct cmsghdr *cmptr;
diff -r b10b27105b62 -r 8856f9071b8a lib/libc/compat/net/Makefile.inc
--- a/lib/libc/compat/net/Makefile.inc Fri Jan 20 06:51:19 2012 +0000
+++ b/lib/libc/compat/net/Makefile.inc Fri Jan 20 14:08:04 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2006/08/26 16:07:01 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2012/01/20 14:08:05 joerg Exp $
.PATH: ${COMPATDIR}/net
-SRCS+=compat_ns_addr.c compat_ns_ntoa.c
+SRCS+= __cmsg_alignbytes.c compat_ns_addr.c compat_ns_ntoa.c
diff -r b10b27105b62 -r 8856f9071b8a lib/libc/compat/net/__cmsg_alignbytes.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/compat/net/__cmsg_alignbytes.c Fri Jan 20 14:08:04 2012 +0000
@@ -0,0 +1,68 @@
+/* $NetBSD: __cmsg_alignbytes.c,v 1.1 2012/01/20 14:08:05 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jun-ichiro Hagino.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: __cmsg_alignbytes.c,v 1.1 2012/01/20 14:08:05 joerg Exp $");
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/socket.h>
+
+int __cmsg_alignbytes(void);
+
+int
+__cmsg_alignbytes(void)
+{
+ static int alignbytes = -1;
+#ifdef HW_ALIGNBYTES
+ int mib[2];
+ size_t len;
+ int ret;
+#endif
+
+ if (alignbytes > 0)
+ return alignbytes;
+
+#ifdef HW_ALIGNBYTES
+ mib[0] = CTL_HW;
+ mib[1] = HW_ALIGNBYTES;
+ len = sizeof(alignbytes);
+ ret = sysctl(mib, (u_int) (sizeof(mib) / sizeof(mib[0])),
+ (void *)&alignbytes, &len, NULL, (size_t)0);
+ if (ret >= 0 && alignbytes >= 0)
+ return alignbytes;
+#endif
+ /* last resort */
+ alignbytes = ALIGNBYTES;
+ return alignbytes;
+}
diff -r b10b27105b62 -r 8856f9071b8a lib/libc/net/Makefile.inc
--- a/lib/libc/net/Makefile.inc Fri Jan 20 06:51:19 2012 +0000
+++ b/lib/libc/net/Makefile.inc Fri Jan 20 14:08:04 2012 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile.inc,v 1.80 2011/12/25 12:32:36 tsutsui Exp $
+# $NetBSD: Makefile.inc,v 1.81 2012/01/20 14:08:05 joerg Exp $
# @(#)Makefile.inc 8.2 (Berkeley) 9/5/93
# net sources
.PATH: ${ARCHDIR}/net ${.CURDIR}/net
-SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \
+SRCS+= base64.c ethers.c gethnamaddr.c getifaddrs.c \
getnetnamadr.c getnetent.c getpeereid.c \
getprotobyname.c getprotobynumber.c getprotoent.c \
getprotobyname_r.c getprotobynumber_r.c getprotoent_r.c \
diff -r b10b27105b62 -r 8856f9071b8a sys/arch/alpha/include/cdefs.h
--- a/sys/arch/alpha/include/cdefs.h Fri Jan 20 06:51:19 2012 +0000
+++ b/sys/arch/alpha/include/cdefs.h Fri Jan 20 14:08:04 2012 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: cdefs.h,v 1.11 1999/03/20 01:40:25 thorpej Exp $ */
+/* $NetBSD: cdefs.h,v 1.12 2012/01/20 14:08:05 joerg Exp $ */
#ifndef _MACHINE_CDEFS_H_
#define _MACHINE_CDEFS_H_
-/* No arch-specific cdefs. */
+#define __ALIGNBYTES 7
#endif /* !_MACHINE_CDEFS_H_ */
diff -r b10b27105b62 -r 8856f9071b8a sys/arch/alpha/include/param.h
--- a/sys/arch/alpha/include/param.h Fri Jan 20 06:51:19 2012 +0000
+++ b/sys/arch/alpha/include/param.h Fri Jan 20 14:08:04 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.38 2011/02/08 20:20:07 rmind Exp $ */
+/* $NetBSD: param.h,v 1.39 2012/01/20 14:08:05 joerg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -60,7 +60,7 @@
* (within reasonable limits).
*
*/
-#define ALIGNBYTES 7
+#define ALIGNBYTES __ALIGNBYTES
#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
diff -r b10b27105b62 -r 8856f9071b8a sys/arch/amd64/include/cdefs.h
--- a/sys/arch/amd64/include/cdefs.h Fri Jan 20 06:51:19 2012 +0000
+++ b/sys/arch/amd64/include/cdefs.h Fri Jan 20 14:08:04 2012 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: cdefs.h,v 1.2 2008/10/26 00:08:15 mrg Exp $ */
+/* $NetBSD: cdefs.h,v 1.3 2012/01/20 14:08:05 joerg Exp $ */
#ifndef _X86_64_CDEFS_H_
Home |
Main Index |
Thread Index |
Old Index