From owner-p4-projects@FreeBSD.ORG Thu Nov 10 18:39:28 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A6CFA16A426; Thu, 10 Nov 2005 18:39:27 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 50F5116A422 for ; Thu, 10 Nov 2005 18:39:27 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0470443D53 for ; Thu, 10 Nov 2005 18:39:27 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jAAIdQn9008828 for ; Thu, 10 Nov 2005 18:39:26 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jAAIdQYQ008825 for perforce@freebsd.org; Thu, 10 Nov 2005 18:39:26 GMT (envelope-from millert@freebsd.org) Date: Thu, 10 Nov 2005 18:39:26 GMT Message-Id: <200511101839.jAAIdQYQ008825@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 86609 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Nov 2005 18:39:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=86609 Change 86609 by millert@millert_ibook on 2005/11/10 18:38:40 Remove #ifdefs and make this Darwin-specific. The #ifdefs just make things more difficult to read and diffing against the sebsd version will give you a better idea of what is different. Affected files ... .. //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/linux-compat.h#9 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin7/src/sedarwin/sedarwin/linux-compat.h#9 (text+ko) ==== @@ -39,49 +39,33 @@ /* * Try and convert some of the linux kernel routines to something that - * works in FreeBSD. Perhaps a bit dangerous, but the hope is that + * works in Darwin. Perhaps a bit dangerous, but the hope is that * diffs to the SELinux tree will be quite a bit smaller. */ #include -#ifdef __APPLE__ -#include -#include -#else /* Probably FreeBSD */ -#include -#endif - typedef u_int64_t u64; typedef u_int32_t u32; typedef u_int16_t u16; typedef u_int8_t u8; -#if !defined(_KERNEL) && !defined(KERNEL) + #if BYTE_ORDER == LITTLE_ENDIAN #define cpu_to_le32(x) ((__uint32_t)(x)) #define cpu_to_le64(x) ((__uint64_t)(x)) #define le32_to_cpu(x) ((__uint32_t)(x)) #define le64_to_cpu(x) ((__uint64_t)(x)) #else /* BYTE_ORDER != LITTLE_ENDIAN */ - -#ifdef __APPLE__ #define le32_to_cpu(x) NXSwapLittleLongToHost(x) #define le64_to_cpu(x) NXSwapLittleLongLongToHost(x) #define cpu_to_le32(x) NXSwapHostLongToLittle(x) #define cpu_to_le64(x) NXSwapHostLongLongToLittle(x) -#else - -#define cpu_to_le32(x) bswap32((x)) -#define cpu_to_le64(x) bswap64((x)) -#define le32_to_cpu(x) bswap32((x)) -#define le64_to_cpu(x) bswap64((x)) - -#endif #endif /* BYTE_ORDER */ -/* sebsd uses same ss source files for userspace */ +#if !defined(_KERNEL) && !defined(KERNEL) +/* sedarwin uses same ss source files for userspace */ #define kmalloc(size,flags) malloc(size) #define kfree(v) free(v) #define __get_free_page(flags) malloc(PAGE_SIZE) @@ -90,19 +74,6 @@ #else /* _KERNEL */ -#ifdef __APPLE__ -#if BYTE_ORDER == LITTLE_ENDIAN -#define le32_to_cpu(x) ((__uint32_t)(x)) -#define le64_to_cpu(x) ((__uint64_t)(x)) -#else /* BYTE_ORDER != LITTLE_ENDIAN */ -#define le32_to_cpu(x) NXSwapLittleLongToHost(x) -#define le64_to_cpu(x) NXSwapLittleLongLongToHost(x) -#endif -#else -#define le32_to_cpu(a) le32toh(a) -#define le64_to_cpu(a) le64toh(a) -#endif - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define NIPQUAD(addr) \ @@ -113,33 +84,22 @@ #define __init -/* kmalloc */ - -#include - -#ifdef __APPLE__ - extern void *sebsd_malloc(size_t size, int flags); extern void sebsd_free(void *); +/* BSD-style malloc/free emulation */ +#include #define malloc(size, type, flags) sebsd_malloc(size, flags) #define free(addr, type) sebsd_free(addr) +#define M_SEBSD M_MACTEMP -#define M_SEBSD M_MACTEMP -#else -#ifndef _M_SEBSD_DEF -MALLOC_DECLARE(M_SEBSD); -#define _M_SEBSD_DEF -#endif -#endif /* __APPLE__ */ - +/* Linux-style kmalloc/kfree (note kfree namespace collision) */ #define kmalloc(size, flags) sebsd_malloc(size, flags) -#define kfree(v) sebsd_free(v) +#define kfree(addr) sebsd_free(addr) #define __get_free_page(flags) sebsd_malloc(PAGE_SIZE, flags) #define GFP_ATOMIC M_NOWAIT #define GFP_KERNEL M_WAITOK -#ifdef __APPLE__ /* TBD: no boot-time tunable support yet */ #define TUNABLE_INT_FETCH(str,var) @@ -148,14 +108,6 @@ #define spin_lock_irqsave(m,flags) mutex_lock(*(m)) #define spin_unlock_irqrestore(m,flags) mutex_unlock(*(m)) -#else /* ! __APPLE__ */ - -/* spinlock */ -#define spinlock_t struct mtx -#define spin_lock_irqsave(m,flags) mtx_lock(m) -#define spin_unlock_irqrestore(m,flags) mtx_unlock(m) -#endif /* !__APPLE__ */ - #endif /* _KERNEL */ #define BUG() printf("BUG: %s:%d", __FILE__, __LINE__) @@ -164,8 +116,11 @@ #define wmb() /* printk */ - +#ifdef MACH_KDB +#define printk kprintf +#else #define printk printf +#endif #define KERN_WARNING "warning: " #define KERN_INFO #define KERN_ERR "error: "