72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
/* Check cf5-opt.vim defs.
|
|
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
|
|
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
|
|
VIM-: let g:cppflags=g:Iboost.g:Itbb
|
|
VIM-: let g:ldflags=g:Lboost.g:Ltbb.g:tbbmalloc.g:tbbmproxy
|
|
VIM-: let g:ldlibpath=g:Bboost.g:Btbb
|
|
VIM-: let g:argv=""
|
|
VIM-: let g:cf5output=0
|
|
*/
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
#include <exception>
|
|
|
|
#define HI_BIT_MASK( m, b ) (!((m)&unsigned(~0)<<b))
|
|
#define ENUM_SHIFT( m ) (32-(\
|
|
HI_BIT_MASK(m,0)+HI_BIT_MASK(m,1)+HI_BIT_MASK(m,2)+HI_BIT_MASK(m,3)\
|
|
+HI_BIT_MASK(m,4)+HI_BIT_MASK(m,5)+HI_BIT_MASK(m,6)+HI_BIT_MASK(m,7)\
|
|
+HI_BIT_MASK(m,8)+HI_BIT_MASK(m,9)+HI_BIT_MASK(m,10)+HI_BIT_MASK(m,11)\
|
|
+HI_BIT_MASK(m,12)+HI_BIT_MASK(m,13)+HI_BIT_MASK(m,14)+HI_BIT_MASK(m,15)\
|
|
+HI_BIT_MASK(m,16)+HI_BIT_MASK(m,17)+HI_BIT_MASK(m,18)+HI_BIT_MASK(m,19)\
|
|
+HI_BIT_MASK(m,20)+HI_BIT_MASK(m,21)+HI_BIT_MASK(m,22)+HI_BIT_MASK(m,23)\
|
|
+HI_BIT_MASK(m,24)+HI_BIT_MASK(m,25)+HI_BIT_MASK(m,26)+HI_BIT_MASK(m,27)\
|
|
+HI_BIT_MASK(m,28)+HI_BIT_MASK(m,29)+HI_BIT_MASK(m,30)+HI_BIT_MASK(m,31)))
|
|
#define ENUM_MASK(m) (~(~(unsigned long long)0<<ENUM_SHIFT(m)))
|
|
|
|
void test( int i )
|
|
{
|
|
char t[ENUM_SHIFT(2345)];
|
|
std::cout << std::setw(10) << i
|
|
<< " ==> mask:" << std::setw(10) << ENUM_MASK( i )
|
|
<< " shift: " << std::setw(10) << ENUM_SHIFT( i )
|
|
<< std::endl;
|
|
}
|
|
|
|
int main ( void )
|
|
{try{
|
|
|
|
std::cout << std::hex << std::showbase;
|
|
test( 0x00000000 );
|
|
test( 0x00000001 );
|
|
test( 0x00000010 );
|
|
test( 0x00000100 );
|
|
test( 0x00001000 );
|
|
test( 0x00010000 );
|
|
test( 0x00100000 );
|
|
test( 0x01000000 );
|
|
test( 0x10000000 );
|
|
test( 0x80000000 );
|
|
test( 0x80008000 );
|
|
test( 0x00100010 );
|
|
test( 0x000040a0 );
|
|
test( 0x000040a0 );
|
|
test( 0x00c04fa0 );
|
|
test( 0xffffffff );
|
|
test( 0xcccccccc );
|
|
|
|
return 0;
|
|
}
|
|
catch ( const std::exception& e )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
|
return 2;
|
|
}
|
|
catch ( ... )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "unknown exception." << std::endl;
|
|
return 1;
|
|
}}
|
|
|