Annotation of lucent/sys/src/libmach/swap.c, revision 1.1.1.1

1.1       root        1: #include <u.h>
                      2: 
                      3: /*
                      4:  * read big-endian short s
                      5:  */
                      6: ushort
                      7: beswab(ushort s)
                      8: {
                      9:        uchar *p;
                     10: 
                     11:        p = (uchar*)&s;
                     12:        return (p[0]<<8) | p[1];
                     13: }
                     14: 
                     15: /*
                     16:  * read big-endian long l
                     17:  */
                     18: long
                     19: beswal(long l)
                     20: {
                     21:        uchar *p;
                     22: 
                     23:        p = (uchar*)&l;
                     24:        return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
                     25: }
                     26: 
                     27: /*
                     28:  * read little-endian short s
                     29:  */
                     30: ushort
                     31: leswab(ushort s)
                     32: {
                     33:        uchar *p;
                     34: 
                     35:        p = (uchar*)&s;
                     36:        return (p[1]<<8) | p[0];
                     37: }
                     38: 
                     39: /*
                     40:  * read little-endian long l
                     41:  */
                     42: long
                     43: leswal(long l)
                     44: {
                     45:        uchar *p;
                     46: 
                     47:        p = (uchar*)&l;
                     48:        return (p[3]<<24) | (p[2]<<16) | (p[1]<<8) | p[0];
                     49: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.