summaryrefslogtreecommitdiffabout
path: root/pwmanager/libcrypt/cipher/bithelp.h
Unidiff
Diffstat (limited to 'pwmanager/libcrypt/cipher/bithelp.h') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/libcrypt/cipher/bithelp.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/pwmanager/libcrypt/cipher/bithelp.h b/pwmanager/libcrypt/cipher/bithelp.h
new file mode 100644
index 0000000..1505324
--- a/dev/null
+++ b/pwmanager/libcrypt/cipher/bithelp.h
@@ -0,0 +1,54 @@
1/* bithelp.h - Some bit manipulation helpers
2 *Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3 *
4 * This file is part of Libgcrypt.
5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser general Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
10 *
11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */
20#ifndef G10_BITHELP_H
21#define G10_BITHELP_H
22
23
24/****************
25 * Rotate the 32 bit unsigned integer X by N bits left/right
26 */
27#if defined(__GNUC__) && defined(__i386__)
28static inline u32
29rol( u32 x, int n)
30{
31 __asm__("roll %%cl,%0"
32 :"=r" (x)
33 :"0" (x),"c" (n));
34 return x;
35}
36#else
37#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
38#endif
39
40#if defined(__GNUC__) && defined(__i386__)
41static inline u32
42ror(u32 x, int n)
43{
44 __asm__("rorl %%cl,%0"
45 :"=r" (x)
46 :"0" (x),"c" (n));
47 return x;
48}
49#else
50#define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
51#endif
52
53
54#endif /*G10_BITHELP_H*/