make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now. CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate arrays, you'll lose. bump shlib minor for libc. NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1, you need to recompile IPv6-related binaries. there is no way to guarantee backward compat in this aspect. sorry for this. this should be the last backward compat breakage for IPv6-related ancillary data manipulation. (we still have PR 9516 for unix-domain sockets...)
This commit is contained in:
parent
52c11b789a
commit
2dc247fc34
@ -1,7 +1,7 @@
|
||||
# $NetBSD: shl.mi,v 1.55 2000/02/23 07:00:55 itojun Exp $
|
||||
# $NetBSD: shl.mi,v 1.56 2000/03/02 07:41:50 itojun Exp $
|
||||
./usr/lib/libamu.so.1.1
|
||||
./usr/lib/libbz2.so.0.0
|
||||
./usr/lib/libc.so.12.56
|
||||
./usr/lib/libc.so.12.57
|
||||
./usr/lib/libcrypt.so.0.0
|
||||
./usr/lib/libcurses.so.2.5
|
||||
./usr/lib/libedit.so.2.3
|
||||
|
@ -1,11 +1,11 @@
|
||||
# $NetBSD: Makefile.inc,v 1.51 2000/02/23 15:44:00 itojun Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.52 2000/03/02 07:41:52 itojun Exp $
|
||||
# @(#)Makefile.inc 8.2 (Berkeley) 9/5/93
|
||||
|
||||
# net sources
|
||||
.PATH: ${ARCHDIR}/net ${.CURDIR}/net
|
||||
|
||||
SRCS+= base64.c ethers.c gethnamaddr.c getifaddrs.c getnetnamadr.c \
|
||||
getnetent.c getproto.c \
|
||||
SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \
|
||||
getnetnamadr.c getnetent.c getproto.c \
|
||||
getprotoent.c getprotoname.c getservbyname.c getservbyport.c \
|
||||
getservent.c herror.c hesiod.c inet_lnaof.c inet_makeaddr.c \
|
||||
inet_net_ntop.c inet_net_pton.c inet_neta.c inet_ntop.c inet_pton.c \
|
||||
|
65
lib/libc/net/__cmsg_alignbytes.c
Normal file
65
lib/libc/net/__cmsg_alignbytes.c
Normal file
@ -0,0 +1,65 @@
|
||||
/* $NetBSD: __cmsg_alignbytes.c,v 1.1 2000/03/02 07:41:52 itojun 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.
|
||||
* 3. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 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/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
int
|
||||
__cmsg_alignbytes()
|
||||
{
|
||||
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, sizeof(mib)/sizeof(mib[0]), (void *)&alignbytes,
|
||||
&len, NULL, 0);
|
||||
if (ret >= 0 && alignbytes >= 0)
|
||||
return alignbytes;
|
||||
#endif
|
||||
/* last resort */
|
||||
alignbytes = ALIGNBYTES;
|
||||
return alignbytes;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
# $NetBSD: shlib_version,v 1.84 2000/02/23 07:00:54 itojun Exp $
|
||||
# $NetBSD: shlib_version,v 1.85 2000/03/02 07:41:49 itojun Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
major=12
|
||||
minor=56
|
||||
minor=57
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.53 1999/05/07 14:49:52 drochner Exp $
|
||||
# $NetBSD: Makefile,v 1.54 2000/03/02 07:41:51 itojun Exp $
|
||||
|
||||
LIB= kern
|
||||
MKPIC= no
|
||||
@ -23,7 +23,7 @@ SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
|
||||
.endif
|
||||
|
||||
# Other stuff
|
||||
SRCS+= inet_addr.c intoa.c md5c.c sha1.c pmatch.c
|
||||
SRCS+= __cmsg_alignbytes.c inet_addr.c intoa.c md5c.c sha1.c pmatch.c
|
||||
|
||||
# Files to clean up
|
||||
CLEANFILES+= lib${LIB}.o lib${LIB}.po
|
||||
|
44
sys/lib/libkern/__cmsg_alignbytes.c
Normal file
44
sys/lib/libkern/__cmsg_alignbytes.c
Normal file
@ -0,0 +1,44 @@
|
||||
/* $NetBSD: __cmsg_alignbytes.c,v 1.1 2000/03/02 07:41:51 itojun 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.
|
||||
* 3. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* 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/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
int
|
||||
__cmsg_alignbytes()
|
||||
{
|
||||
|
||||
return ALIGNBYTES;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: socket.h,v 1.50 2000/02/18 05:19:25 itojun Exp $ */
|
||||
/* $NetBSD: socket.h,v 1.51 2000/03/02 07:41:50 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -401,10 +401,14 @@ struct cmsghdr {
|
||||
|
||||
/*
|
||||
* Alignment requirement for CMSG struct manipulation.
|
||||
* This is different from ALIGN() defined in ARCH/include/param.h.
|
||||
* XXX think again carefully about architecture dependencies.
|
||||
* This basically behaves the same as ALIGN() ARCH/include/param.h.
|
||||
* We declare it separately for two reasons:
|
||||
* (1) avoid dependency between machine/param.h, and (2) to sync with kernel's
|
||||
* idea of ALIGNBYTES at runtime.
|
||||
* without (2), we can't guarantee binary compatibility in case of future
|
||||
* changes in ALIGNBYTES.
|
||||
*/
|
||||
#define CMSG_ALIGN(n) (((n) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
|
||||
#define CMSG_ALIGN(n) (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes())
|
||||
|
||||
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
|
||||
#define CMSG_NXTHDR(mhdr, cmsg) \
|
||||
@ -455,6 +459,8 @@ struct omsghdr {
|
||||
};
|
||||
#endif
|
||||
|
||||
int __cmsg_alignbytes __P((void));
|
||||
|
||||
#ifndef _KERNEL
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user