dnsmasq: update to 2.73 (23.06.2015)
[tomato.git] / release / src / router / lzo / src / lzo_func.ch
bloba85b71f0ff564663c273513a02f199613c4e0acf
1 /* lzo_func.ch -- functions
3    This file is part of the LZO real-time data compression library.
5    Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer
6    Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
7    Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
8    Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
9    Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
10    Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
11    Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
12    Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
13    Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
14    Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
15    Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
16    Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
17    Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
18    Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
19    Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
20    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
21    All Rights Reserved.
23    The LZO library is free software; you can redistribute it and/or
24    modify it under the terms of the GNU General Public License as
25    published by the Free Software Foundation; either version 2 of
26    the License, or (at your option) any later version.
28    The LZO library is distributed in the hope that it will be useful,
29    but WITHOUT ANY WARRANTY; without even the implied warranty of
30    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31    GNU General Public License for more details.
33    You should have received a copy of the GNU General Public License
34    along with the LZO library; see the file COPYING.
35    If not, write to the Free Software Foundation, Inc.,
36    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
38    Markus F.X.J. Oberhumer
39    <markus@oberhumer.com>
40    http://www.oberhumer.com/opensource/lzo/
41  */
44 /* WARNING: this file should *not* be used by applications. It is
45    part of the implementation of the library and is subject
46    to change.
47  */
50 /***********************************************************************
51 // bitops
52 ************************************************************************/
54 #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
55 #include <intrin.h>
56 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
57 #pragma intrinsic(_BitScanReverse)
58 static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v)
60     unsigned long r;
61     (void) _BitScanReverse(&r, v);
62     return (unsigned) r;
64 #define lzo_bitops_clz32 lzo_bitops_clz32
65 #endif
66 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
67 #pragma intrinsic(_BitScanReverse64)
68 static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v)
70     unsigned long r;
71     (void) _BitScanReverse64(&r, v);
72     return (unsigned) r;
74 #define lzo_bitops_clz64 lzo_bitops_clz64
75 #endif
76 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
77 #pragma intrinsic(_BitScanForward)
78 static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v)
80     unsigned long r;
81     (void) _BitScanForward(&r, v);
82     return (unsigned) r;
84 #define lzo_bitops_ctz32 lzo_bitops_ctz32
85 #endif
86 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
87 #pragma intrinsic(_BitScanForward64)
88 static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v)
90     unsigned long r;
91     (void) _BitScanForward64(&r, v);
92     return (unsigned) r;
94 #define lzo_bitops_ctz64 lzo_bitops_ctz64
95 #endif
97 #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
98 #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
99 #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
100 #endif
101 #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
102 #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
103 #endif
104 #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
105 #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
106 #endif
107 #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
108 #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
109 #endif
110 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
111 #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
112 #endif
113 #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
114 #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
115 #endif
116 #endif
120 vi:ts=4:et