From 3f098aed4500da38db8afdff111f02198158203a Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 20 Aug 1998 14:37:17 +0000 Subject: FreeBSD stack compiles for the first time (except libc/strsep.c). --- c/src/exec/libnetworking/machine/conf.h | 0 c/src/exec/libnetworking/machine/cpu.h | 0 c/src/exec/libnetworking/machine/cpufunc.h | 0 c/src/exec/libnetworking/machine/endian.h | 60 ++++++++++++++ c/src/exec/libnetworking/machine/in_cksum.h | 118 ++++++++++++++++++++++++++++ c/src/exec/libnetworking/machine/limits.h | 0 c/src/exec/libnetworking/machine/param.h | 88 +++++++++++++++++++++ c/src/exec/libnetworking/machine/types.h | 32 ++++++++ c/src/exec/libnetworking/machine/vmparam.h | 0 9 files changed, 298 insertions(+) create mode 100644 c/src/exec/libnetworking/machine/conf.h create mode 100644 c/src/exec/libnetworking/machine/cpu.h create mode 100644 c/src/exec/libnetworking/machine/cpufunc.h create mode 100644 c/src/exec/libnetworking/machine/endian.h create mode 100644 c/src/exec/libnetworking/machine/in_cksum.h create mode 100644 c/src/exec/libnetworking/machine/limits.h create mode 100644 c/src/exec/libnetworking/machine/param.h create mode 100644 c/src/exec/libnetworking/machine/types.h create mode 100644 c/src/exec/libnetworking/machine/vmparam.h (limited to 'c/src/exec/libnetworking') diff --git a/c/src/exec/libnetworking/machine/conf.h b/c/src/exec/libnetworking/machine/conf.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/c/src/exec/libnetworking/machine/cpu.h b/c/src/exec/libnetworking/machine/cpu.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/c/src/exec/libnetworking/machine/cpufunc.h b/c/src/exec/libnetworking/machine/cpufunc.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/c/src/exec/libnetworking/machine/endian.h b/c/src/exec/libnetworking/machine/endian.h new file mode 100644 index 0000000000..cd0d6f551c --- /dev/null +++ b/c/src/exec/libnetworking/machine/endian.h @@ -0,0 +1,60 @@ +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +#include + +/* + * BSD-style endian declaration + */ +#define BIG_ENDIAN 4321 +#define LITTLE_ENDIAN 1234 + +#if CPU_BIG_ENDIAN +# define BYTE_ORDER BIG_ENDIAN +#elif CPU_LITTLE_ENDIAN +# define BYTE_ORDER LITTLE_ENDIAN +#else +# error "Can't decide which end is which!" +#endif + +#if ( CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES == FALSE ) + +#if ( CPU_BIG_ENDIAN == TRUE ) + +/* + * Very simply on big endian CPUs + */ + +#define ntohl(_x) (_x) +#define ntohs(_x) (_x) +#define htonl(_x) (_x) +#define htons(_x) (_x) + +#define NTOHS(x) +#define HTONS(x) +#define NTOHL(x) +#define HTONL(x) + +#elif ( CPU_LITTLE_ENDIAN == TRUE ) + +/* + * A little more complicated on little endian CPUs + */ + +#define ntohl(_x) ((long) CPU_swap_u32((unsigned32)_x)) +#define ntohs(_x) ((short) CPU_swap_u16((unsigned16)_x)) +#define htonl(_x) ((long) CPU_swap_u32((unsigned32)_x)) +#define htons(_x) ((short) CPU_swap_u16((unsigned16)_x)) + +#define NTOHS(x) (x) = ntohs(x) +#define HTONS(x) (x) = htons(x) +#define NTOHL(x) (x) = ntohl(x) +#define HTONL(x) (x) = htonl(x) + +#else +#error "Unknown endian-ness for this cpu" +#endif + +#endif /* CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES */ + +#endif /* _MACHINE_ENDIAN_H_ */ diff --git a/c/src/exec/libnetworking/machine/in_cksum.h b/c/src/exec/libnetworking/machine/in_cksum.h new file mode 100644 index 0000000000..15509b3888 --- /dev/null +++ b/c/src/exec/libnetworking/machine/in_cksum.h @@ -0,0 +1,118 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * 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 tahoe: in_cksum.c 1.2 86/01/05 + * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 + * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp + * $Id$ + */ + +#ifndef _MACHINE_IN_CKSUM_H_ +#define _MACHINE_IN_CKSUM_H_ 1 + +#include + +/* + * It it useful to have an Internet checksum routine which is inlineable + * and optimized specifically for the task of computing IP header checksums + * in the normal case (where there are no options and the header length is + * therefore always exactly five 32-bit words. + */ +#if (defined(__GNUC__) && defined(__i386__)) +static __inline u_int +in_cksum_hdr(const struct ip *ip) +{ + register u_int sum = 0; + +#define ADD(n) __asm("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip)) +#define ADDC(n) __asm("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip)) +#define MOP __asm("adcl $0, %0" : "=r" (sum) : "0" (sum)) + + ADD(0); + ADDC(4); + ADDC(8); + ADDC(12); + ADDC(16); + MOP; + sum = (sum & 0xffff) + (sum >> 16); + if (sum > 0xffff) + sum -= 0xffff; + + return ~sum & 0xffff; +} + +static __inline void +in_cksum_update(struct ip *ip) +{ + int __tmpsum; + __tmpsum = (int)ntohs(ip->ip_sum) + 256; + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); +} + +#elif (defined(__GNUC__) && (defined(__mc68000__) || defined(__m68k__))) + +static __inline__ u_int +in_cksum_hdr(const struct ip *ip) +{ + register u_int *ap = (u_int *)ip; + register u_int sum = *ap++; + register u_int tmp; + + __asm__("addl %2@+,%0\n\t" + "movel %2@+,%1\n\t" + "addxl %1,%0\n\t" + "movel %2@+,%1\n\t" + "addxl %1,%0\n\t" + "movel %2@,%1\n\t" + "addxl %1,%0\n\t" + "moveq #0,%1\n\t" + "addxl %1,%0\n" : + "=d" (sum), "=d" (tmp), "=a" (ap) : + "0" (sum), "2" (ap)); + sum = (sum & 0xffff) + (sum >> 16); + if (sum > 0xffff) + sum -= 0xffff; + return ~sum & 0xffff; +} + +#else +u_int in_cksum_hdr __P((const struct ip *)); +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) + +#endif + +#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/c/src/exec/libnetworking/machine/limits.h b/c/src/exec/libnetworking/machine/limits.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/c/src/exec/libnetworking/machine/param.h b/c/src/exec/libnetworking/machine/param.h new file mode 100644 index 0000000000..eae8554c2a --- /dev/null +++ b/c/src/exec/libnetworking/machine/param.h @@ -0,0 +1,88 @@ +#ifndef _MACHINE_PARAM_H_ +#define _MACHINE_PARAM_H_ + +/* + * These aren't really machine-dependent for RTEMS..... + */ + +/* +#define MACHINE "i386" +#define MID_MACHINE MID_I386 +*/ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#define ALIGNBYTES (sizeof(int) - 1) +#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) + +#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 dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((off_t)(db) << DEV_BSHIFT) + +/* + * Mach derived conversion macros + */ +#define trunc_page(x) ((unsigned)(x) & ~PAGE_MASK) +#define round_page(x) ((((unsigned)(x)) + PAGE_MASK) & ~PAGE_MASK) + +#define atop(x) ((unsigned)(x) >> PAGE_SHIFT) +#define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) + +#endif /* !_MACHINE_PARAM_H_ */ diff --git a/c/src/exec/libnetworking/machine/types.h b/c/src/exec/libnetworking/machine/types.h new file mode 100644 index 0000000000..1f9ee143a5 --- /dev/null +++ b/c/src/exec/libnetworking/machine/types.h @@ -0,0 +1,32 @@ +/* + * This file will have to be incorparated into the RTEMS source + * tree (probably in the existing so that these + * contents are included when an application source file includes + * . + */ + +#ifndef _MACHINE_TYPES_H_ +#define _MACHINE_TYPES_H_ + +#include +#include + +typedef rtems_signed64 int64_t; +typedef rtems_signed32 int32_t; +typedef rtems_signed16 int16_t; +typedef rtems_signed8 int8_t; + +typedef rtems_unsigned64 u_int64_t; +typedef rtems_unsigned32 u_int32_t; +typedef rtems_unsigned16 u_int16_t; +typedef rtems_unsigned8 u_int8_t; + +#define _CLOCK_T_ unsigned long +#define _TIME_T_ long + +#ifdef _COMPILING_BSD_KERNEL_ +#include +#include +#endif + +#endif /* _MACHINE_TYPES_H_ */ diff --git a/c/src/exec/libnetworking/machine/vmparam.h b/c/src/exec/libnetworking/machine/vmparam.h new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3