Files
ldc/root/gc/gccbitops.h
Alexey Prokhin caad8cde58 Squashed 'dmd2/' content from commit 10017d5
git-subtree-dir: dmd2
git-subtree-split: 10017d50eaaff4ecdc37a0153b6c37ea0b004c81
2012-04-05 11:10:48 +04:00

70 lines
1.2 KiB
C

// Copyright (c) 2000-2011 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
// License for redistribution is by either the Artistic License
// in artistic.txt, or the GNU General Public License in gnu.txt.
// See the included readme.txt for details.
// Bit operations for GCC and I386
#ifndef GCCBITOPS_H
#define GCCBITOPS_H 1
inline int _inline_bsf(int w)
{ int index;
__asm__ __volatile__
(
"bsfl %1, %0 \n\t"
: "=r" (index)
: "r" (w)
);
return index;
}
inline int _inline_bt(unsigned *p, int i)
{
char result;
__asm__ __volatile__
(
"btl %2,%1 \n\t"
"setc %0 \n\t"
:"=r" (result)
:"m" (*p), "r" (i)
);
return result;
}
inline int _inline_bts(unsigned *p, int i)
{
char result;
__asm__ __volatile__
(
"btsl %2,%1 \n\t"
"setc %0 \n\t"
:"=r" (result)
:"m" (*p), "r" (i)
);
return result;
}
inline int _inline_btr(unsigned *p, int i)
{
char result;
__asm__ __volatile__
(
"btrl %2,%1 \n\t"
"setc %0 \n\t"
:"=r" (result)
:"m" (*p), "r" (i)
);
return result;
}
#endif