From owner-svn-src-all@FreeBSD.ORG Sat Dec 12 15:49:28 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8655D106568F; Sat, 12 Dec 2009 15:49:28 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A6258FC18; Sat, 12 Dec 2009 15:49:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBCFnSjP056883; Sat, 12 Dec 2009 15:49:28 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBCFnS99056881; Sat, 12 Dec 2009 15:49:28 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200912121549.nBCFnS99056881@svn.freebsd.org> From: Luigi Rizzo Date: Sat, 12 Dec 2009 15:49:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200439 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Dec 2009 15:49:28 -0000 Author: luigi Date: Sat Dec 12 15:49:28 2009 New Revision: 200439 URL: http://svn.freebsd.org/changeset/base/200439 Log: Make the code buildable in userland so it is easier to test it: this requires a small reordering of headers and a few #defines to map functions not available in userland. Remove a useless #ifndef block at the beginning of the file. Introduce (temporarily) rn_init2(), see the comment in the code for the proper long term change. No ABI or functional change. MFC after: 7 days Modified: head/sys/net/radix.c Modified: head/sys/net/radix.c ============================================================================== --- head/sys/net/radix.c Sat Dec 12 14:44:04 2009 (r200438) +++ head/sys/net/radix.c Sat Dec 12 15:49:28 2009 (r200439) @@ -33,7 +33,6 @@ /* * Routines to build and maintain radix trees for routing lookups. */ -#ifndef _RADIX_H_ #include #ifdef _KERNEL #include @@ -42,19 +41,21 @@ #include #include #include -#else -#include -#endif #include #include -#endif - #include "opt_mpath.h" - #ifdef RADIX_MPATH #include #endif - +#else /* !_KERNEL */ +#include +#include +#include +#define log(x, arg...) fprintf(stderr, ## arg) +#define panic(x) fprintf(stderr, "PANIC: %s", x), exit(1) +#define min(a, b) ((a) < (b) ? (a) : (b) ) +#include +#endif /* !_KERNEL */ static int rn_walktree_from(struct radix_node_head *h, void *a, void *m, walktree_f_t *f, void *w); @@ -1188,3 +1189,19 @@ rn_init() if (rn_inithead((void **)(void *)&mask_rnhead, 0) == 0) panic("rn_init 2"); } + +#ifndef _KERNEL +/* + * A simple function to make the code usable from userland. + * A proper fix (maybe later) would be to change rn_init() so that it + * takes maxkeylen as an argument, and move the scan of + * domains into net/route.c::route_init(). + */ +void rn_init2(int maxk); +void +rn_init2(int maxk) +{ + max_keylen = maxk; + rn_init(); +} +#endif /* !_KERNEL */