00001 /* 00002 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 00003 * Copyright (C) 1999-2001 Internet Software Consortium. 00004 * 00005 * Permission to use, copy, modify, and/or distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 00010 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00011 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 00012 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00013 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00014 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00015 * PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 /* $Id: serial.c,v 1.12 2007/06/19 23:47:17 tbox Exp $ */ 00019 00020 /*! \file */ 00021 00022 #include <config.h> 00023 00024 #include <isc/serial.h> 00025 00026 isc_boolean_t 00027 isc_serial_lt(isc_uint32_t a, isc_uint32_t b) { 00028 /* 00029 * Undefined => ISC_FALSE 00030 */ 00031 if (a == (b ^ 0x80000000U)) 00032 return (ISC_FALSE); 00033 return (((isc_int32_t)(a - b) < 0) ? ISC_TRUE : ISC_FALSE); 00034 } 00035 00036 isc_boolean_t 00037 isc_serial_gt(isc_uint32_t a, isc_uint32_t b) { 00038 return (((isc_int32_t)(a - b) > 0) ? ISC_TRUE : ISC_FALSE); 00039 } 00040 00041 isc_boolean_t 00042 isc_serial_le(isc_uint32_t a, isc_uint32_t b) { 00043 return ((a == b) ? ISC_TRUE : isc_serial_lt(a, b)); 00044 } 00045 00046 isc_boolean_t 00047 isc_serial_ge(isc_uint32_t a, isc_uint32_t b) { 00048 return ((a == b) ? ISC_TRUE : isc_serial_gt(a, b)); 00049 } 00050 00051 isc_boolean_t 00052 isc_serial_eq(isc_uint32_t a, isc_uint32_t b) { 00053 return ((a == b) ? ISC_TRUE : ISC_FALSE); 00054 } 00055 00056 isc_boolean_t 00057 isc_serial_ne(isc_uint32_t a, isc_uint32_t b) { 00058 return ((a != b) ? ISC_TRUE : ISC_FALSE); 00059 }