2 * Copyright 1988 by the Massachusetts Institute of Technology.
3 * For copying and distribution information, please see the file
6 * Comparison macros to emulate LSBFIRST comparison results of network
7 * byte-order quantities
9 * from: lsb_addr_comp.h,v 4.0 89/01/23 15:44:46 jtkohl Exp $
13 #ifndef LSB_ADDR_COMP_DEFS
14 #define LSB_ADDR_COMP_DEFS
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))
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)
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])))
40 #endif /* LSB_ADDR_COMP_DEFS */