GRUB-1.98 changes
[grub2/jjazz.git] / lib / libgcrypt / cipher / bithelp.h
blob15053243304f6d4189bc7be7f9fb3c2e911a1aee
1 /* bithelp.h - Some bit manipulation helpers
2 * Copyright (C) 1999, 2002 Free Software Foundation, Inc.
4 * This file is part of Libgcrypt.
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.
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.
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
20 #ifndef G10_BITHELP_H
21 #define G10_BITHELP_H
24 /****************
25 * Rotate the 32 bit unsigned integer X by N bits left/right
27 #if defined(__GNUC__) && defined(__i386__)
28 static inline u32
29 rol( u32 x, int n)
31 __asm__("roll %%cl,%0"
32 :"=r" (x)
33 :"0" (x),"c" (n));
34 return x;
36 #else
37 #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
38 #endif
40 #if defined(__GNUC__) && defined(__i386__)
41 static inline u32
42 ror(u32 x, int n)
44 __asm__("rorl %%cl,%0"
45 :"=r" (x)
46 :"0" (x),"c" (n));
47 return x;
49 #else
50 #define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
51 #endif
54 #endif /*G10_BITHELP_H*/