mirror of https://github.com/c-ares/c-ares.git
parent
49bdc5bb98
commit
affdf92306
6 changed files with 0 additions and 128 deletions
@ -1,64 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
||||
* Copyright (c) 1996,1999 by Internet Software Consortium. |
||||
* |
||||
* Permission to use, copy, modify, and distribute this software for any |
||||
* purpose with or without fee is hereby granted, provided that the above |
||||
* copyright notice and this permission notice appear in all copies. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR |
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
* |
||||
* SPDX-License-Identifier: MIT |
||||
*/ |
||||
|
||||
#ifndef HAVE_BITNCMP |
||||
|
||||
# include "ares_setup.h" |
||||
# include "bitncmp.h" |
||||
|
||||
/*
|
||||
* int |
||||
* bitncmp(l, r, n) |
||||
* compare bit masks l and r, for n bits. |
||||
* return: |
||||
* <0, >0, or 0 in the libc tradition. |
||||
* note: |
||||
* network byte order assumed. this means 192.5.5.240/28 has |
||||
* 0x11110000 in its fourth octet. |
||||
* author: |
||||
* Paul Vixie (ISC), June 1996 |
||||
*/ |
||||
int ares__bitncmp(const void *l, const void *r, size_t n) |
||||
{ |
||||
size_t lb; |
||||
size_t rb; |
||||
ares_ssize_t x; |
||||
size_t b; |
||||
|
||||
b = n / 8; |
||||
x = memcmp(l, r, b); |
||||
if (x || (n % 8) == 0) { |
||||
return (int)x; |
||||
} |
||||
|
||||
lb = ((const unsigned char *)l)[b]; |
||||
rb = ((const unsigned char *)r)[b]; |
||||
for (b = n % 8; b > 0; b--) { |
||||
if ((lb & 0x80) != (rb & 0x80)) { |
||||
if (lb & 0x80) { |
||||
return (1); |
||||
} |
||||
return (-1); |
||||
} |
||||
lb <<= 1; |
||||
rb <<= 1; |
||||
} |
||||
return (0); |
||||
} |
||||
#endif |
@ -1,35 +0,0 @@ |
||||
/* MIT License
|
||||
* |
||||
* Copyright (c) 2005 Dominick Meglio |
||||
* |
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
* of this software and associated documentation files (the "Software"), to deal |
||||
* in the Software without restriction, including without limitation the rights |
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
* copies of the Software, and to permit persons to whom the Software is |
||||
* furnished to do so, subject to the following conditions: |
||||
* |
||||
* The above copyright notice and this permission notice (including the next |
||||
* paragraph) shall be included in all copies or substantial portions of the |
||||
* Software. |
||||
* |
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
* SOFTWARE. |
||||
* |
||||
* SPDX-License-Identifier: MIT |
||||
*/ |
||||
#ifndef __ARES_BITNCMP_H |
||||
#define __ARES_BITNCMP_H |
||||
|
||||
#ifndef HAVE_BITNCMP |
||||
int ares__bitncmp(const void *l, const void *r, size_t n); |
||||
#else |
||||
# define ares__bitncmp(x, y, z) bitncmp(x, y, z) |
||||
#endif |
||||
|
||||
#endif /* __ARES_BITNCMP_H */ |
Loading…
Reference in new issue