~ubuntu-branches/ubuntu/trusty/bmagic/trusty

« back to all changes in this revision

Viewing changes to src/bmutil.h

  • Committer: Bazaar Package Importer
  • Author(s): Roberto C. Sanchez
  • Date: 2009-12-09 16:02:55 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091209160255-hu2bnjrbncl92z5w
Tags: 3.6.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef BMUTIL__H__INCLUDED__
 
2
#define BMUTIL__H__INCLUDED__
1
3
/*
2
4
Copyright(c) 2002-2009 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)
3
5
 
23
25
For more information please visit:  http://bmagic.sourceforge.net
24
26
 
25
27
*/
26
 
#ifndef BMUTIL__H__INCLUDED__
27
 
#define BMUTIL__H__INCLUDED__
28
28
 
29
29
#include "bmdef.h"
30
30
#include "bmconst.h"
47
47
}
48
48
*/
49
49
 
 
50
// From:
 
51
// http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.37.8562
 
52
//
 
53
template<typename T>
 
54
T bit_scan_fwd(T v)
 
55
{
 
56
    return 
 
57
        DeBruijn_bit_position<true>::_multiply[((word_t)((v & -v) * 0x077CB531U)) >> 27];
 
58
}
 
59
 
 
60
 
50
61
/**
51
62
    Fast loop-less function to find LOG2
52
63
*/
74
85
}
75
86
 
76
87
 
 
88
 
77
89
/**
78
90
    Lookup table based integer LOG2
79
91
*/
135
147
{   
136
148
  __asm  bsr  eax, value
137
149
}
 
150
 
 
151
BMFORCEINLINE unsigned int bsf_asm32(register unsigned int value)
 
152
{   
 
153
  __asm  bsf  eax, value
 
154
}
 
155
 
138
156
#endif
139
157
 
140
158
#endif // BM_x86