From owner-svn-src-all@FreeBSD.ORG Sun Jul 10 07:25:35 2011 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 564E2106564A; Sun, 10 Jul 2011 07:25:35 +0000 (UTC) (envelope-from avatar@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4489F8FC13; Sun, 10 Jul 2011 07:25:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6A7PZcw035173; Sun, 10 Jul 2011 07:25:35 GMT (envelope-from avatar@svn.freebsd.org) Received: (from avatar@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6A7PZfG035166; Sun, 10 Jul 2011 07:25:35 GMT (envelope-from avatar@svn.freebsd.org) Message-Id: <201107100725.p6A7PZfG035166@svn.freebsd.org> From: Tai-hwa Liang Date: Sun, 10 Jul 2011 07:25:35 +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: r223905 - head/lib/libstand 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: Sun, 10 Jul 2011 07:25:35 -0000 Author: avatar Date: Sun Jul 10 07:25:34 2011 New Revision: 223905 URL: http://svn.freebsd.org/changeset/base/223905 Log: - Removing some unneeded definitions of NULL(cruft related to 1970's C). In C90, NULL is guaranteed to be declared in and also in . Though the correct way to define NULL in FreeBSD is to include , other parts of libstand still require to build; therefore, we keep in stand.h and add a note about this; - Removing no longer used 'Prototype' definition. Quote from bde@: 'Cruft related to getting incomplete struct declarations within prototypes forward-declared before the structs. It doesn't mean "prototype" but only part of a prototype-related hack. No longer used.' - Replacing iaddr_t with uintptr_t; - Removing use of long double to determine alignment. Use a fixed 16 byte alignment instead; Reviewed by: bde Obtained from: DragonFlyBSD (partially) MFC after: 1 month Modified: head/lib/libstand/stand.h head/lib/libstand/zalloc.c head/lib/libstand/zalloc_defs.h head/lib/libstand/zalloc_malloc.c head/lib/libstand/zalloc_mem.h head/lib/libstand/zalloc_protos.h Modified: head/lib/libstand/stand.h ============================================================================== --- head/lib/libstand/stand.h Sun Jul 10 07:14:32 2011 (r223904) +++ head/lib/libstand/stand.h Sun Jul 10 07:25:34 2011 (r223905) @@ -65,15 +65,13 @@ #include #include #include + +/* this header intentionally exports NULL from */ #include #define CHK(fmt, args...) printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args) #define PCHK(fmt, args...) {printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args); getchar();} -#ifndef NULL -#define NULL 0 -#endif - /* Avoid unwanted userlandish components */ #define _KERNEL #include Modified: head/lib/libstand/zalloc.c ============================================================================== --- head/lib/libstand/zalloc.c Sun Jul 10 07:14:32 2011 (r223904) +++ head/lib/libstand/zalloc.c Sun Jul 10 07:25:34 2011 (r223905) @@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$"); */ void * -znalloc(MemPool *mp, iaddr_t bytes) +znalloc(MemPool *mp, uintptr_t bytes) { /* * align according to pool object size (can be 0). This is @@ -136,7 +136,7 @@ znalloc(MemPool *mp, iaddr_t bytes) */ void -zfree(MemPool *mp, void *ptr, iaddr_t bytes) +zfree(MemPool *mp, void *ptr, uintptr_t bytes) { /* * align according to pool object size (can be 0). This is @@ -153,7 +153,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t by if ((char *)ptr < (char *)mp->mp_Base || (char *)ptr + bytes > (char *)mp->mp_End || - ((iaddr_t)ptr & MEMNODE_SIZE_MASK) != 0) + ((uintptr_t)ptr & MEMNODE_SIZE_MASK) != 0) panic("zfree(%p,%ju): wild pointer", ptr, (uintmax_t)bytes); /* @@ -245,7 +245,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t by */ void -zextendPool(MemPool *mp, void *base, iaddr_t bytes) +zextendPool(MemPool *mp, void *base, uintptr_t bytes) { if (mp->mp_Size == 0) { mp->mp_Base = base; Modified: head/lib/libstand/zalloc_defs.h ============================================================================== --- head/lib/libstand/zalloc_defs.h Sun Jul 10 07:14:32 2011 (r223904) +++ head/lib/libstand/zalloc_defs.h Sun Jul 10 07:25:34 2011 (r223905) @@ -39,20 +39,11 @@ #define ZALLOCDEBUG #include -#include #include "stand.h" - -typedef uintptr_t iaddr_t; /* unsigned int same size as pointer */ -typedef intptr_t saddr_t; /* signed int same size as pointer */ #include "zalloc_mem.h" -#define Prototype extern #define Library extern -#ifndef NULL -#define NULL ((void *)0) -#endif - /* * block extension for sbrk() */ @@ -61,8 +52,7 @@ typedef intptr_t saddr_t; /* signed int #define BLKEXTENDMASK (BLKEXTEND - 1) /* - * required malloc alignment. Use sizeof(long double) for architecture - * independance. + * required malloc alignment. Just hardwire to 16. * * Note: if we implement a more sophisticated realloc, we should ensure that * MALLOCALIGN is at least as large as MemNode. @@ -73,10 +63,8 @@ typedef struct Guard { size_t ga_Magic; /* must be at least 32 bits */ } Guard; -#define MATYPE long double -#define MALLOCALIGN ((sizeof(MATYPE) > sizeof(Guard)) ? sizeof(MATYPE) : sizeof(Guard)) +#define MALLOCALIGN 16 #define GAMAGIC 0x55FF44FD #define GAFREE 0x5F54F4DF #include "zalloc_protos.h" - Modified: head/lib/libstand/zalloc_malloc.c ============================================================================== --- head/lib/libstand/zalloc_malloc.c Sun Jul 10 07:14:32 2011 (r223904) +++ head/lib/libstand/zalloc_malloc.c Sun Jul 10 07:25:34 2011 (r223905) @@ -126,7 +126,7 @@ Free(void *ptr, const char *file, int li void * Calloc(size_t n1, size_t n2, const char *file, int line) { - iaddr_t bytes = (iaddr_t)n1 * (iaddr_t)n2; + uintptr_t bytes = (uintptr_t)n1 * (uintptr_t)n2; void *res; if ((res = Malloc(bytes, file, line)) != NULL) { Modified: head/lib/libstand/zalloc_mem.h ============================================================================== --- head/lib/libstand/zalloc_mem.h Sun Jul 10 07:14:32 2011 (r223904) +++ head/lib/libstand/zalloc_mem.h Sun Jul 10 07:25:34 2011 (r223905) @@ -37,15 +37,15 @@ typedef struct MemNode { struct MemNode *mr_Next; - iaddr_t mr_Bytes; + uintptr_t mr_Bytes; } MemNode; typedef struct MemPool { void *mp_Base; void *mp_End; MemNode *mp_First; - iaddr_t mp_Size; - iaddr_t mp_Used; + uintptr_t mp_Size; + uintptr_t mp_Used; } MemPool; #define MEMNODE_SIZE_MASK ((sizeof(MemNode) <= 8) ? 7 : 15) Modified: head/lib/libstand/zalloc_protos.h ============================================================================== --- head/lib/libstand/zalloc_protos.h Sun Jul 10 07:14:32 2011 (r223904) +++ head/lib/libstand/zalloc_protos.h Sun Jul 10 07:25:34 2011 (r223905) @@ -29,7 +29,7 @@ * $FreeBSD$ */ -Library void *znalloc(struct MemPool *mpool, iaddr_t bytes); -Library void zfree(struct MemPool *mpool, void *ptr, iaddr_t bytes); -Library void zextendPool(MemPool *mp, void *base, iaddr_t bytes); +Library void *znalloc(struct MemPool *mpool, uintptr_t bytes); +Library void zfree(struct MemPool *mpool, void *ptr, uintptr_t bytes); +Library void zextendPool(MemPool *mp, void *base, uintptr_t bytes); Library void zallocstats(struct MemPool *mp);