Panda3D
|
00001 // Filename: pbitops.h 00002 // Created by: drose (10May08) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PBITOPS_H 00016 #define PBITOPS_H 00017 00018 #include "pandabase.h" 00019 #include "numeric_types.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // This file defines a few low-level bit-operation routines, optimized 00023 // all to heck. 00024 //////////////////////////////////////////////////////////////////// 00025 00026 INLINE int count_bits_in_word(PN_uint16 x); 00027 INLINE int count_bits_in_word(PN_uint32 x); 00028 INLINE int count_bits_in_word(PN_uint64 x); 00029 00030 INLINE PN_uint16 flood_bits_down(PN_uint16 x); 00031 INLINE PN_uint32 flood_bits_down(PN_uint32 x); 00032 INLINE PN_uint64 flood_bits_down(PN_uint64 x); 00033 INLINE PN_uint16 flood_bits_up(PN_uint16 x); 00034 INLINE PN_uint32 flood_bits_up(PN_uint32 x); 00035 INLINE PN_uint64 flood_bits_up(PN_uint64 x); 00036 00037 INLINE int get_lowest_on_bit(PN_uint16 x); 00038 INLINE int get_lowest_on_bit(PN_uint32 x); 00039 INLINE int get_lowest_on_bit(PN_uint64 x); 00040 INLINE int get_highest_on_bit(PN_uint16 x); 00041 INLINE int get_highest_on_bit(PN_uint32 x); 00042 INLINE int get_highest_on_bit(PN_uint64 x); 00043 00044 INLINE int get_next_higher_bit(PN_uint16 x); 00045 INLINE int get_next_higher_bit(PN_uint32 x); 00046 INLINE int get_next_higher_bit(PN_uint64 x); 00047 00048 // This table precomputes the number of on bits in each 16-bit word. 00049 extern EXPCL_PANDA_PUTIL unsigned char num_bits_on[65536]; 00050 00051 #include "pbitops.I" 00052 00053 #endif