Module Name:    src
Committed By:   maxv
Date:           Fri Apr 27 06:56:21 UTC 2018

Modified Files:
        src/sys/kern: uipc_mbuf.c
        src/sys/net80211: ieee80211_netbsd.c ieee80211_netbsd.h
        src/sys/sys: mbuf.h

Log Message:
Move m_align and m_append into iee80211_netbsd.c. They are part of
net80211, and shouldn't be used outside.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.30 -r1.31 src/sys/net80211/ieee80211_netbsd.c
cvs rdiff -u -r1.19 -r1.20 src/sys/net80211/ieee80211_netbsd.h
cvs rdiff -u -r1.190 -r1.191 src/sys/sys/mbuf.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/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.200 src/sys/kern/uipc_mbuf.c:1.201
--- src/sys/kern/uipc_mbuf.c:1.200	Fri Apr 27 06:36:16 2018
+++ src/sys/kern/uipc_mbuf.c	Fri Apr 27 06:56:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.200 2018/04/27 06:36:16 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.201 2018/04/27 06:56:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.200 2018/04/27 06:36:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.201 2018/04/27 06:56:21 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -488,75 +488,6 @@ m_add(struct mbuf *c, struct mbuf *m)
 	return c;
 }
 
-/*
- * Set the m_data pointer of a newly-allocated mbuf
- * to place an object of the specified size at the
- * end of the mbuf, longword aligned.
- */
-void
-m_align(struct mbuf *m, int len)
-{
-	int adjust;
-
-	KASSERT(len != M_COPYALL);
-
-	if (m->m_flags & M_EXT)
-		adjust = m->m_ext.ext_size - len;
-	else if (m->m_flags & M_PKTHDR)
-		adjust = MHLEN - len;
-	else
-		adjust = MLEN - len;
-	m->m_data += adjust &~ (sizeof(long)-1);
-}
-
-/*
- * Append the specified data to the indicated mbuf chain,
- * Extend the mbuf chain if the new data does not fit in
- * existing space.
- *
- * Return 1 if able to complete the job; otherwise 0.
- */
-int
-m_append(struct mbuf *m0, int len, const void *cpv)
-{
-	struct mbuf *m, *n;
-	int remainder, space;
-	const char *cp = cpv;
-
-	KASSERT(len != M_COPYALL);
-	for (m = m0; m->m_next != NULL; m = m->m_next)
-		continue;
-	remainder = len;
-	space = M_TRAILINGSPACE(m);
-	if (space > 0) {
-		/*
-		 * Copy into available space.
-		 */
-		if (space > remainder)
-			space = remainder;
-		memmove(mtod(m, char *) + m->m_len, cp, space);
-		m->m_len += space;
-		cp = cp + space, remainder -= space;
-	}
-	while (remainder > 0) {
-		/*
-		 * Allocate a new mbuf; could check space
-		 * and allocate a cluster instead.
-		 */
-		n = m_get(M_DONTWAIT, m->m_type);
-		if (n == NULL)
-			break;
-		n->m_len = min(MLEN, remainder);
-		memmove(mtod(n, void *), cp, n->m_len);
-		cp += n->m_len, remainder -= n->m_len;
-		m->m_next = n;
-		m = n;
-	}
-	if (m0->m_flags & M_PKTHDR)
-		m0->m_pkthdr.len += len - remainder;
-	return (remainder == 0);
-}
-
 void
 m_reclaim(void *arg, int flags)
 {

Index: src/sys/net80211/ieee80211_netbsd.c
diff -u src/sys/net80211/ieee80211_netbsd.c:1.30 src/sys/net80211/ieee80211_netbsd.c:1.31
--- src/sys/net80211/ieee80211_netbsd.c:1.30	Thu Jan 18 17:57:49 2018
+++ src/sys/net80211/ieee80211_netbsd.c	Fri Apr 27 06:56:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $ */
+/* $NetBSD: ieee80211_netbsd.c,v 1.31 2018/04/27 06:56:21 maxv Exp $ */
 
 /*
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
@@ -31,7 +31,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
 #else
-__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.30 2018/01/18 17:57:49 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.31 2018/04/27 06:56:21 maxv Exp $");
 #endif
 
 /*
@@ -720,3 +720,74 @@ ieee80211_load_module(const char *modnam
 	printf("%s: load the %s module by hand for now.\n", __func__, modname);
 #endif
 }
+
+/* -------------------------------------------------------------------------- */
+
+/*
+ * Set the m_data pointer of a newly-allocated mbuf
+ * to place an object of the specified size at the
+ * end of the mbuf, longword aligned.
+ */
+void
+m_align(struct mbuf *m, int len)
+{
+	int adjust;
+
+	KASSERT(len != M_COPYALL);
+
+	if (m->m_flags & M_EXT)
+		adjust = m->m_ext.ext_size - len;
+	else if (m->m_flags & M_PKTHDR)
+		adjust = MHLEN - len;
+	else
+		adjust = MLEN - len;
+	m->m_data += adjust &~ (sizeof(long)-1);
+}
+
+/*
+ * Append the specified data to the indicated mbuf chain,
+ * Extend the mbuf chain if the new data does not fit in
+ * existing space.
+ *
+ * Return 1 if able to complete the job; otherwise 0.
+ */
+int
+m_append(struct mbuf *m0, int len, const void *cpv)
+{
+	struct mbuf *m, *n;
+	int remainder, space;
+	const char *cp = cpv;
+
+	KASSERT(len != M_COPYALL);
+	for (m = m0; m->m_next != NULL; m = m->m_next)
+		continue;
+	remainder = len;
+	space = M_TRAILINGSPACE(m);
+	if (space > 0) {
+		/*
+		 * Copy into available space.
+		 */
+		if (space > remainder)
+			space = remainder;
+		memmove(mtod(m, char *) + m->m_len, cp, space);
+		m->m_len += space;
+		cp = cp + space, remainder -= space;
+	}
+	while (remainder > 0) {
+		/*
+		 * Allocate a new mbuf; could check space
+		 * and allocate a cluster instead.
+		 */
+		n = m_get(M_DONTWAIT, m->m_type);
+		if (n == NULL)
+			break;
+		n->m_len = min(MLEN, remainder);
+		memmove(mtod(n, void *), cp, n->m_len);
+		cp += n->m_len, remainder -= n->m_len;
+		m->m_next = n;
+		m = n;
+	}
+	if (m0->m_flags & M_PKTHDR)
+		m0->m_pkthdr.len += len - remainder;
+	return (remainder == 0);
+}

Index: src/sys/net80211/ieee80211_netbsd.h
diff -u src/sys/net80211/ieee80211_netbsd.h:1.19 src/sys/net80211/ieee80211_netbsd.h:1.20
--- src/sys/net80211/ieee80211_netbsd.h:1.19	Mon Apr  7 00:07:40 2014
+++ src/sys/net80211/ieee80211_netbsd.h	Fri Apr 27 06:56:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.h,v 1.19 2014/04/07 00:07:40 pooka Exp $ */
+/* $NetBSD: ieee80211_netbsd.h,v 1.20 2018/04/27 06:56:21 maxv Exp $ */
 /*-
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -249,4 +249,7 @@ void	ieee80211_init(void);
 	static void name(void)
 #endif
 
+void	m_align(struct mbuf *, int);
+int	m_append(struct mbuf *, int, const void *);
+
 #endif /* !_NET80211_IEEE80211_NETBSD_H_ */

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.190 src/sys/sys/mbuf.h:1.191
--- src/sys/sys/mbuf.h:1.190	Thu Apr 26 19:13:34 2018
+++ src/sys/sys/mbuf.h	Fri Apr 27 06:56:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.190 2018/04/26 19:13:34 maxv Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.191 2018/04/27 06:56:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -875,8 +875,6 @@ void	m_move_pkthdr(struct mbuf *, struct
 
 bool	m_ensure_contig(struct mbuf **, int);
 struct mbuf *m_add(struct mbuf *, struct mbuf *);
-void	m_align(struct mbuf *, int);
-int	m_append(struct mbuf *, int, const void *);
 
 /* Inline routines. */
 static __inline u_int m_length(const struct mbuf *) __unused;

Reply via email to