]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - eBones/include/lsb_addr_comp.h
This commit was generated by cvs2svn to compensate for changes in r24269,
[FreeBSD/FreeBSD.git] / eBones / include / lsb_addr_comp.h
1 /*
2  * Copyright 1988 by the Massachusetts Institute of Technology.
3  * For copying and distribution information, please see the file
4  * <Copyright.MIT>.
5  *
6  * Comparison macros to emulate LSBFIRST comparison results of network
7  * byte-order quantities
8  *
9  *      from: lsb_addr_comp.h,v 4.0 89/01/23 15:44:46 jtkohl Exp $
10  *      $Id$
11  */
12
13 #ifndef LSB_ADDR_COMP_DEFS
14 #define LSB_ADDR_COMP_DEFS
15
16 #include "osconf.h"
17
18 #ifdef LSBFIRST
19 #define lsb_net_ulong_less(x,y) ((x < y) ? -1 : ((x > y) ? 1 : 0))
20 #define lsb_net_ushort_less(x,y) ((x < y) ? -1 : ((x > y) ? 1 : 0))
21 #else
22 /* MSBFIRST */
23 #define u_char_comp(x,y) \
24         (((x)>(y))?(1):(((x)==(y))?(0):(-1)))
25 /* This is gross, but... */
26 #define lsb_net_ulong_less(x, y) long_less_than((u_char *)&x, (u_char *)&y)
27 #define lsb_net_ushort_less(x, y) short_less_than((u_char *)&x, (u_char *)&y)
28
29 #define long_less_than(x,y) \
30         (u_char_comp((x)[3],(y)[3])?u_char_comp((x)[3],(y)[3]): \
31          (u_char_comp((x)[2],(y)[2])?u_char_comp((x)[2],(y)[2]): \
32           (u_char_comp((x)[1],(y)[1])?u_char_comp((x)[1],(y)[1]): \
33            (u_char_comp((x)[0],(y)[0])))))
34 #define short_less_than(x,y) \
35           (u_char_comp((x)[1],(y)[1])?u_char_comp((x)[1],(y)[1]): \
36            (u_char_comp((x)[0],(y)[0])))
37
38 #endif /* LSBFIRST */
39
40 #endif /*  LSB_ADDR_COMP_DEFS */