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
25 * Rotate the 32 bit unsigned integer X by N bits left/right
27 #if defined(__GNUC__) && defined(__i386__)
31 __asm__("roll %%cl,%0"
37 #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
40 #if defined(__GNUC__) && defined(__i386__)
44 __asm__("rorl %%cl,%0"
50 #define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
54 #endif /*G10_BITHELP_H*/