Module Name: src
Committed By: joerg
Date: Fri Jan 20 00:25:29 UTC 2012
Modified Files:
src/sys/lib/libkern: Makefile.libkern
src/sys/sys: socket.h
Log Message:
Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/lib/libkern/Makefile.libkern
cvs rdiff -u -r1.101 -r1.102 src/sys/sys/socket.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libkern/Makefile.libkern
diff -u src/sys/lib/libkern/Makefile.libkern:1.15 src/sys/lib/libkern/Makefile.libkern:1.16
--- src/sys/lib/libkern/Makefile.libkern:1.15 Sat Nov 19 22:51:25 2011
+++ src/sys/lib/libkern/Makefile.libkern Fri Jan 20 00:25:29 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.libkern,v 1.15 2011/11/19 22:51:25 tls Exp $
+# $NetBSD: Makefile.libkern,v 1.16 2012/01/20 00:25:29 joerg Exp $
#
# Variable definitions for libkern.
@@ -58,7 +58,7 @@ SRCS+= adddi3.c anddi3.c ashldi3.c ashrd
# Other stuff
SRCS+= kern_assert.c __main.c
-SRCS+= __cmsg_alignbytes.c cpuset.c inet_addr.c intoa.c
+SRCS+= cpuset.c inet_addr.c intoa.c
.if empty(SRCS:Mbyte_swap_8.*)
SRCS+= bswap64.c
.endif
Index: src/sys/sys/socket.h
diff -u src/sys/sys/socket.h:1.101 src/sys/sys/socket.h:1.102
--- src/sys/sys/socket.h:1.101 Tue Dec 20 23:56:29 2011
+++ src/sys/sys/socket.h Fri Jan 20 00:25:29 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: socket.h,v 1.101 2011/12/20 23:56:29 christos Exp $ */
+/* $NetBSD: socket.h,v 1.102 2012/01/20 00:25:29 joerg Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -531,8 +531,11 @@ struct cmsghdr {
* without (2), we can't guarantee binary compatibility in case of future
* changes in ALIGNBYTES.
*/
-#define __CMSG_ALIGN(n) (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes())
#ifdef _KERNEL
+#define __CMSG_ALIGN(n) (((n) + ALIGNBYTES) & ~ALIGNBYTES)
+#define CMSG_ALIGN(n) __CMSG_ALIGN(n)
+#else
+#define __CMSG_ALIGN(n) (((n) + __cmsg_alignbytes()) & ~__cmsg_alignbytes())
#define CMSG_ALIGN(n) __CMSG_ALIGN(n)
#endif
@@ -574,9 +577,11 @@ struct cmsghdr {
#include <sys/cdefs.h>
+#ifndef _KERNEL
__BEGIN_DECLS
-int __cmsg_alignbytes(void);
+int __cmsg_alignbytes(void) __constfunc;
__END_DECLS
+#endif
#ifdef _KERNEL
static inline socklen_t