From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92575 invoked by alias); 22 May 2017 12:04:39 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 92483 invoked by uid 89); 22 May 2017 12:04:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=william, William, Units, 022 X-HELO: dedi548.your-server.de Received: from dedi548.your-server.de (HELO dedi548.your-server.de) (85.10.215.148) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 May 2017 12:04:35 +0000 Received: from [88.198.220.132] (helo=sslproxy03.your-server.de) by dedi548.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1dCm4h-0002ud-HW for newlib@sourceware.org; Mon, 22 May 2017 14:04:35 +0200 Received: from [82.135.62.35] (helo=mail.embedded-brains.de) by sslproxy03.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dCm4g-0006z9-0m for newlib@sourceware.org; Mon, 22 May 2017 14:04:34 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 104202A160A for ; Mon, 22 May 2017 14:05:14 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 0zSupV-JG-lA for ; Mon, 22 May 2017 14:05:13 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 13E9D2A167D for ; Mon, 22 May 2017 14:05:13 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id on7rPgkAVuj5 for ; Mon, 22 May 2017 14:05:12 +0200 (CEST) Received: from huber-linux.eb.localhost (unknown [192.168.96.129]) by mail.embedded-brains.de (Postfix) with ESMTP id F28332A160A for ; Mon, 22 May 2017 14:05:12 +0200 (CEST) From: Sebastian Huber To: newlib@sourceware.org Subject: [PATCH 2/8] FreeBSD compatibility for RTEMS Date: Mon, 22 May 2017 12:04:00 -0000 Message-Id: <1495454672-9131-2-git-send-email-sebastian.huber@embedded-brains.de> In-Reply-To: <1495454672-9131-1-git-send-email-sebastian.huber@embedded-brains.de> References: <1495454672-9131-1-git-send-email-sebastian.huber@embedded-brains.de> X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00344.txt.bz2 Update the RTEMS and to be compatible with the latest FreeBSD version. Signed-off-by: Sebastian Huber --- newlib/libc/sys/rtems/include/machine/param.h | 125 +++++++++--------- newlib/libc/sys/rtems/include/sys/param.h | 180 +++++++++++++++++--------- 2 files changed, 180 insertions(+), 125 deletions(-) diff --git a/newlib/libc/sys/rtems/include/machine/param.h b/newlib/libc/sys/rtems/include/machine/param.h index 622194b..4892b61 100644 --- a/newlib/libc/sys/rtems/include/machine/param.h +++ b/newlib/libc/sys/rtems/include/machine/param.h @@ -1,94 +1,85 @@ -/* - * $Id$ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)param.h 5.8 (Berkeley) 6/28/91 */ #ifndef _MACHINE_PARAM_H_ #define _MACHINE_PARAM_H_ /* - * These aren't really machine-dependent for RTEMS..... + * Machine dependent constants for RTEMS. */ -/* -#define MACHINE "i386" -#define MID_MACHINE MID_I386 -*/ - #include -#define ALIGNBYTES _ALIGNBYTES -#define ALIGN(p) _ALIGN(p) - -#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ -#define PAGE_SIZE (1<>PAGE_SHIFT) - -/* - * btodb() is messy and perhaps slow because `bytes' may be an off_t. We - * want to shift an unsigned type to avoid sign extension and we don't - * want to widen `bytes' unnecessarily. Assume that the result fits in - * a daddr_t. - */ -#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ - (sizeof (bytes) > sizeof(long) \ - ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ - : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */ +#define PAGE_MASK (PAGE_SIZE - 1) -#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ - ((off_t)(db) << DEV_BSHIFT) +#define MAXPAGESIZES 1 /* maximum number of supported page sizes */ /* * Mach derived conversion macros */ -#define trunc_page(x) ((unsigned)(x) & ~PAGE_MASK) -#define round_page(x) ((((unsigned)(x)) + PAGE_MASK) & ~PAGE_MASK) +#define round_page(x) (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK) +#define trunc_page(x) ((unsigned long)(x) & ~PAGE_MASK) + +#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) +#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) -#define atop(x) ((unsigned)(x) >> PAGE_SHIFT) -#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) +#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) #endif /* !_MACHINE_PARAM_H_ */ diff --git a/newlib/libc/sys/rtems/include/sys/param.h b/newlib/libc/sys/rtems/include/sys/param.h index db9786b..1778ec3 100644 --- a/newlib/libc/sys/rtems/include/sys/param.h +++ b/newlib/libc/sys/rtems/include/sys/param.h @@ -15,7 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,29 +32,16 @@ * SUCH DAMAGE. * * @(#)param.h 8.3 (Berkeley) 4/4/95 - * $Id$ + * $FreeBSD: head/sys/sys/param.h 317383 2017-04-24 21:21:49Z brooks $ */ #ifndef _SYS_PARAM_H_ #define _SYS_PARAM_H_ -/* from newlib's */ - -#include -#include - -# define PATHSIZE (1024) - -/* end of from newlib's */ - #define BSD 199506 /* System version (year & month). */ #define BSD4_3 1 #define BSD4_4 1 -#ifndef NULL -#define NULL 0 -#endif - #ifndef LOCORE #include #endif @@ -78,32 +65,95 @@ #define MAXHOSTNAMELEN 256 /* max hostname size */ #define SPECNAMELEN 63 /* max length of devicename */ -/* More types and definitions used throughout the kernel. */ -#if defined(KERNEL) || defined(_KERNEL) -#include -#include -#include -#include -#include -#include +#ifndef _KERNEL +/* Signals. */ +#include +#endif + +/* Machine type dependent parameters. */ +#include +#ifndef _KERNEL +#include +#endif + +#ifndef DEV_BSHIFT +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#endif +#define DEV_BSIZE (1< +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than PAGE_SIZE. + */ +#ifndef MSIZE +#define MSIZE 128 /* size of an mbuf */ +#endif -/* Machine type dependent parameters. */ -#include -#include +#ifndef MCLSHIFT +#define MCLSHIFT 11 /* convert bytes to mbuf clusters */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ + +#if PAGE_SIZE < 2048 +#define MJUMPAGESIZE MCLBYTES +#elif PAGE_SIZE <= 8192 +#define MJUMPAGESIZE PAGE_SIZE +#else +#define MJUMPAGESIZE (8 * 1024) +#endif + +#define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */ +#define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */ + +/* + * Some macros for units conversion + */ + +/* clicks to bytes */ +#ifndef ctob +#define ctob(x) ((x)<>PAGE_SHIFT) +#endif + +/* + * btodb() is messy and perhaps slow because `bytes' may be an off_t. We + * want to shift an unsigned type to avoid sign extension and we don't + * want to widen `bytes' unnecessarily. Assume that the result fits in + * a daddr_t. + */ +#ifndef btodb +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + (sizeof (bytes) > sizeof(long) \ + ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ + : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) +#endif + +#ifndef dbtob +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((off_t)(db) << DEV_BSHIFT) +#endif #define PRIMASK 0x0ff #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ +#define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ #define NZERO 0 /* default "nice" */ @@ -111,13 +161,8 @@ #define NBPW sizeof(int) /* number of bytes per word (integer) */ #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ -#define NODEV (dev_t)(-1) /* non-existent device */ -#define CBLOCK 128 /* Clist block size, must be a power of 2. */ -#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ - /* Data chars/clist. */ -#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) -#define CROUND (CBLOCK - 1) /* Clist rounding. */ +#define NODEV (dev_t)(-1) /* non-existent device */ /* * File system parameters and macros. @@ -128,10 +173,19 @@ * and may be made smaller at the risk of not being able to use * filesystems which require a block size exceeding MAXBSIZE. * + * MAXBCACHEBUF - Maximum size of a buffer in the buffer cache. This must + * be >= MAXBSIZE and can be set differently for different + * architectures by defining it in . + * Making this larger allows NFS to do larger reads/writes. + * * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the * minimum KVM memory reservation the kernel is willing to make. * Filesystems can of course request smaller chunks. Actual * backing memory uses a chunk size of a page (PAGE_SIZE). + * The default value here can be overridden on a per-architecture + * basis by defining it in . This should + * probably be done to increase its value, when MAXBCACHEBUF is + * defined as a larger value in . * * If you make BKVASIZE too small you risk seriously fragmenting * the buffer KVM map which may slow things down a bit. If you @@ -143,7 +197,12 @@ * normal UFS filesystem. */ #define MAXBSIZE 65536 /* must be power of 2 */ +#ifndef MAXBCACHEBUF +#define MAXBCACHEBUF MAXBSIZE /* must be a power of 2 >= MAXBSIZE */ +#endif +#ifndef BKVASIZE #define BKVASIZE 16384 /* must be power of 2 */ +#endif #define BKVAMASK (BKVASIZE-1) /* @@ -170,34 +229,16 @@ #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) #endif +#define nitems(x) (sizeof((x)) / sizeof((x)[0])) #define rounddown(x, y) (((x)/(y))*(y)) +#define rounddown2(x, y) ((x)&(~((y)-1))) /* if y is power of two */ #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ #define powerof2(x) ((((x)-1)&(x))==0) /* Macros for min/max. */ -#if !(defined(KERNEL) || defined(_KERNEL)) #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) -#endif - -/* - * Constants for setting the parameters of the kernel memory allocator. - * - * 2 ** MINBUCKET is the smallest unit of memory that will be - * allocated. It must be at least large enough to hold a pointer. - * - * Units of memory less or equal to MAXALLOCSAVE will permanently - * allocate physical memory; requests for these size pieces of - * memory are quite fast. Allocations greater than MAXALLOCSAVE must - * always allocate and free physical memory; requests for these - * size allocations should be done infrequently as they will be slow. - * - * Constraints: PAGE_SIZE <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and - * MAXALLOCSIZE must be a power of two. - */ -#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ -#define MAXALLOCSAVE (2 * PAGE_SIZE) /* * Scale factor for scaled integers used to count %cpu time and load avgs. @@ -213,4 +254,27 @@ #define FSHIFT 11 /* bits to right of fixed binary point */ #define FSCALE (1<> (PAGE_SHIFT - DEV_BSHIFT)) + +#define ctodb(db) /* calculates pages to devblks */ \ + ((db) << (PAGE_SHIFT - DEV_BSHIFT)) + +/* + * Old spelling of __containerof(). + */ +#define member2struct(s, m, x) \ + ((struct s *)(void *)((char *)(x) - offsetof(struct s, m))) + +/* + * Access a variable length array that has been declared as a fixed + * length array. + */ +#define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) + +#ifdef _KERNEL +/* Header file provided outside of Newlib */ +#include +#endif + #endif /* _SYS_PARAM_H_ */ -- 1.8.4.5