Changeset 8cce445 in rtems


Ignore:
Timestamp:
Feb 4, 1999, 2:56:03 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
1564ca8
Parents:
c1a37d3e
Message:

Added PowerPC specific header checksum code.

Added volatile to i386 assembly statements in header checksum code.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/libnetworking/machine/in_cksum.h

    rc1a37d3e r8cce445  
    1 /*-
     1/*
    22 * Copyright (c) 1990 The Regents of the University of California.
    33 * All rights reserved.
     
    4848 * therefore always exactly five 32-bit words.
    4949 */
     50
     51/*
     52 *  Optimized version for the i386 family
     53 */
     54
    5055#if (defined(__GNUC__) && defined(__i386__))
     56
    5157static __inline u_int
    5258in_cksum_hdr(const struct ip *ip)
     
    5460        register u_int sum = 0;
    5561                   
    56 #define ADD(n)  __asm("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    57 #define ADDC(n) __asm("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    58 #define MOP     __asm("adcl         $0, %0" : "=r" (sum) : "0" (sum))
     62#define ADD(n)  \
     63    __asm__ volatile ("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     64#define ADDC(n) \
     65    __asm__ volatile ("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     66#define MOP     \
     67    __asm__ volatile ("adcl         $0, %0" : "=r" (sum) : "0" (sum))
    5968
    6069        ADD(0);
     
    7887        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
    7988}
     89
     90/*
     91 *  Optimized version for the MC68xxx and Coldfire families
     92 */
    8093
    8194#elif (defined(__GNUC__) && (defined(__mc68000__) || defined(__m68k__)))
     
    105118}
    106119
     120/*
     121 *  Optimized version for the PowerPC family
     122 */
     123
     124#elif (defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__)))
     125
     126static __inline u_int
     127in_cksum_hdr(const struct ip *ip)
     128{
     129        register u_int sum = 0;
     130        register u_int tmp;
     131
     132#define ADD(n) \
     133         __asm__ volatile ("addc  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     134#define ADDC(n) \
     135        __asm__ volatile ("adde  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     136#define MOP     \
     137        __asm__ volatile ("addic %0,%0,0"  : "=r" (sum) : "0" (sum))
     138
     139        tmp = *(((u_int *) ip));      ADD(tmp);
     140        tmp = *(((u_int *) ip) + 1);  ADDC(tmp);
     141        tmp = *(((u_int *) ip) + 2);  ADDC(tmp);
     142        tmp = *(((u_int *) ip) + 3);  ADDC(tmp);
     143        tmp = *(((u_int *) ip) + 4);  ADDC(tmp);
     144        tmp = 0;                      ADDC(tmp);
     145        sum = (sum & 0xffff) + (sum >> 16);
     146        if (sum > 0xffff)
     147                sum -= 0xffff;
     148
     149        return ~sum & 0xffff;
     150}
     151
     152static __inline void
     153in_cksum_update(struct ip *ip)
     154{
     155        int __tmpsum;
     156        __tmpsum = (int)ntohs(ip->ip_sum) + 256;
     157        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
     158}
     159
     160/*
     161 *  Here is the generic, portable, inefficient algorithm.
     162 */
     163
    107164#else
    108165u_int in_cksum_hdr __P((const struct ip *));
  • c/src/lib/libnetworking/machine/in_cksum.h

    rc1a37d3e r8cce445  
    1 /*-
     1/*
    22 * Copyright (c) 1990 The Regents of the University of California.
    33 * All rights reserved.
     
    4848 * therefore always exactly five 32-bit words.
    4949 */
     50
     51/*
     52 *  Optimized version for the i386 family
     53 */
     54
    5055#if (defined(__GNUC__) && defined(__i386__))
     56
    5157static __inline u_int
    5258in_cksum_hdr(const struct ip *ip)
     
    5460        register u_int sum = 0;
    5561                   
    56 #define ADD(n)  __asm("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    57 #define ADDC(n) __asm("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    58 #define MOP     __asm("adcl         $0, %0" : "=r" (sum) : "0" (sum))
     62#define ADD(n)  \
     63    __asm__ volatile ("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     64#define ADDC(n) \
     65    __asm__ volatile ("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     66#define MOP     \
     67    __asm__ volatile ("adcl         $0, %0" : "=r" (sum) : "0" (sum))
    5968
    6069        ADD(0);
     
    7887        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
    7988}
     89
     90/*
     91 *  Optimized version for the MC68xxx and Coldfire families
     92 */
    8093
    8194#elif (defined(__GNUC__) && (defined(__mc68000__) || defined(__m68k__)))
     
    105118}
    106119
     120/*
     121 *  Optimized version for the PowerPC family
     122 */
     123
     124#elif (defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__)))
     125
     126static __inline u_int
     127in_cksum_hdr(const struct ip *ip)
     128{
     129        register u_int sum = 0;
     130        register u_int tmp;
     131
     132#define ADD(n) \
     133         __asm__ volatile ("addc  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     134#define ADDC(n) \
     135        __asm__ volatile ("adde  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     136#define MOP     \
     137        __asm__ volatile ("addic %0,%0,0"  : "=r" (sum) : "0" (sum))
     138
     139        tmp = *(((u_int *) ip));      ADD(tmp);
     140        tmp = *(((u_int *) ip) + 1);  ADDC(tmp);
     141        tmp = *(((u_int *) ip) + 2);  ADDC(tmp);
     142        tmp = *(((u_int *) ip) + 3);  ADDC(tmp);
     143        tmp = *(((u_int *) ip) + 4);  ADDC(tmp);
     144        tmp = 0;                      ADDC(tmp);
     145        sum = (sum & 0xffff) + (sum >> 16);
     146        if (sum > 0xffff)
     147                sum -= 0xffff;
     148
     149        return ~sum & 0xffff;
     150}
     151
     152static __inline void
     153in_cksum_update(struct ip *ip)
     154{
     155        int __tmpsum;
     156        __tmpsum = (int)ntohs(ip->ip_sum) + 256;
     157        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
     158}
     159
     160/*
     161 *  Here is the generic, portable, inefficient algorithm.
     162 */
     163
    107164#else
    108165u_int in_cksum_hdr __P((const struct ip *));
  • c/src/libnetworking/machine/in_cksum.h

    rc1a37d3e r8cce445  
    1 /*-
     1/*
    22 * Copyright (c) 1990 The Regents of the University of California.
    33 * All rights reserved.
     
    4848 * therefore always exactly five 32-bit words.
    4949 */
     50
     51/*
     52 *  Optimized version for the i386 family
     53 */
     54
    5055#if (defined(__GNUC__) && defined(__i386__))
     56
    5157static __inline u_int
    5258in_cksum_hdr(const struct ip *ip)
     
    5460        register u_int sum = 0;
    5561                   
    56 #define ADD(n)  __asm("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    57 #define ADDC(n) __asm("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    58 #define MOP     __asm("adcl         $0, %0" : "=r" (sum) : "0" (sum))
     62#define ADD(n)  \
     63    __asm__ volatile ("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     64#define ADDC(n) \
     65    __asm__ volatile ("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     66#define MOP     \
     67    __asm__ volatile ("adcl         $0, %0" : "=r" (sum) : "0" (sum))
    5968
    6069        ADD(0);
     
    7887        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
    7988}
     89
     90/*
     91 *  Optimized version for the MC68xxx and Coldfire families
     92 */
    8093
    8194#elif (defined(__GNUC__) && (defined(__mc68000__) || defined(__m68k__)))
     
    105118}
    106119
     120/*
     121 *  Optimized version for the PowerPC family
     122 */
     123
     124#elif (defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__)))
     125
     126static __inline u_int
     127in_cksum_hdr(const struct ip *ip)
     128{
     129        register u_int sum = 0;
     130        register u_int tmp;
     131
     132#define ADD(n) \
     133         __asm__ volatile ("addc  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     134#define ADDC(n) \
     135        __asm__ volatile ("adde  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     136#define MOP     \
     137        __asm__ volatile ("addic %0,%0,0"  : "=r" (sum) : "0" (sum))
     138
     139        tmp = *(((u_int *) ip));      ADD(tmp);
     140        tmp = *(((u_int *) ip) + 1);  ADDC(tmp);
     141        tmp = *(((u_int *) ip) + 2);  ADDC(tmp);
     142        tmp = *(((u_int *) ip) + 3);  ADDC(tmp);
     143        tmp = *(((u_int *) ip) + 4);  ADDC(tmp);
     144        tmp = 0;                      ADDC(tmp);
     145        sum = (sum & 0xffff) + (sum >> 16);
     146        if (sum > 0xffff)
     147                sum -= 0xffff;
     148
     149        return ~sum & 0xffff;
     150}
     151
     152static __inline void
     153in_cksum_update(struct ip *ip)
     154{
     155        int __tmpsum;
     156        __tmpsum = (int)ntohs(ip->ip_sum) + 256;
     157        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
     158}
     159
     160/*
     161 *  Here is the generic, portable, inefficient algorithm.
     162 */
     163
    107164#else
    108165u_int in_cksum_hdr __P((const struct ip *));
  • cpukit/libnetworking/machine/in_cksum.h

    rc1a37d3e r8cce445  
    1 /*-
     1/*
    22 * Copyright (c) 1990 The Regents of the University of California.
    33 * All rights reserved.
     
    4848 * therefore always exactly five 32-bit words.
    4949 */
     50
     51/*
     52 *  Optimized version for the i386 family
     53 */
     54
    5055#if (defined(__GNUC__) && defined(__i386__))
     56
    5157static __inline u_int
    5258in_cksum_hdr(const struct ip *ip)
     
    5460        register u_int sum = 0;
    5561                   
    56 #define ADD(n)  __asm("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    57 #define ADDC(n) __asm("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
    58 #define MOP     __asm("adcl         $0, %0" : "=r" (sum) : "0" (sum))
     62#define ADD(n)  \
     63    __asm__ volatile ("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     64#define ADDC(n) \
     65    __asm__ volatile ("adcl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (ip))
     66#define MOP     \
     67    __asm__ volatile ("adcl         $0, %0" : "=r" (sum) : "0" (sum))
    5968
    6069        ADD(0);
     
    7887        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
    7988}
     89
     90/*
     91 *  Optimized version for the MC68xxx and Coldfire families
     92 */
    8093
    8194#elif (defined(__GNUC__) && (defined(__mc68000__) || defined(__m68k__)))
     
    105118}
    106119
     120/*
     121 *  Optimized version for the PowerPC family
     122 */
     123
     124#elif (defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__)))
     125
     126static __inline u_int
     127in_cksum_hdr(const struct ip *ip)
     128{
     129        register u_int sum = 0;
     130        register u_int tmp;
     131
     132#define ADD(n) \
     133         __asm__ volatile ("addc  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     134#define ADDC(n) \
     135        __asm__ volatile ("adde  %0,%0,%2" : "=r" (sum) : "0" (sum), "r" (n))
     136#define MOP     \
     137        __asm__ volatile ("addic %0,%0,0"  : "=r" (sum) : "0" (sum))
     138
     139        tmp = *(((u_int *) ip));      ADD(tmp);
     140        tmp = *(((u_int *) ip) + 1);  ADDC(tmp);
     141        tmp = *(((u_int *) ip) + 2);  ADDC(tmp);
     142        tmp = *(((u_int *) ip) + 3);  ADDC(tmp);
     143        tmp = *(((u_int *) ip) + 4);  ADDC(tmp);
     144        tmp = 0;                      ADDC(tmp);
     145        sum = (sum & 0xffff) + (sum >> 16);
     146        if (sum > 0xffff)
     147                sum -= 0xffff;
     148
     149        return ~sum & 0xffff;
     150}
     151
     152static __inline void
     153in_cksum_update(struct ip *ip)
     154{
     155        int __tmpsum;
     156        __tmpsum = (int)ntohs(ip->ip_sum) + 256;
     157        ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
     158}
     159
     160/*
     161 *  Here is the generic, portable, inefficient algorithm.
     162 */
     163
    107164#else
    108165u_int in_cksum_hdr __P((const struct ip *));
Note: See TracChangeset for help on using the changeset viewer.