Changeset 102390 in vbox for trunk/src/libs/xpcom18a4/nsprpub/pr/include/prbit.h
- Timestamp:
- Nov 30, 2023 8:12:27 AM (17 months ago)
- svn:sync-xref-src-repo-rev:
- 160526
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/include/prbit.h
r102245 r102390 46 46 47 47 /* 48 ** A prbitmap_t is a long integer that can be used for bitmaps49 */50 typedef unsigned long prbitmap_t;51 52 #define PR_TEST_BIT(_map,_bit) \53 ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] & (1L << ((_bit) & (PR_BITS_PER_LONG-1))))54 #define PR_SET_BIT(_map,_bit) \55 ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] |= (1L << ((_bit) & (PR_BITS_PER_LONG-1))))56 #define PR_CLEAR_BIT(_map,_bit) \57 ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] &= ~(1L << ((_bit) & (PR_BITS_PER_LONG-1))))58 59 /*60 48 ** Compute the log of the least power of 2 greater than or equal to n 61 49 */ … … 100 88 } 101 89 102 /* 103 ** Macro version of PR_CeilingLog2: Compute the log of the least power of 104 ** 2 greater than or equal to _n. The result is returned in _log2. 105 */ 106 #define PR_CEILING_LOG2(_log2,_n) \ 107 PR_BEGIN_MACRO \ 108 PRUint32 j_ = (PRUint32)(_n); \ 109 (_log2) = 0; \ 110 if ((j_) & ((j_)-1)) \ 111 (_log2) += 1; \ 112 if ((j_) >> 16) \ 113 (_log2) += 16, (j_) >>= 16; \ 114 if ((j_) >> 8) \ 115 (_log2) += 8, (j_) >>= 8; \ 116 if ((j_) >> 4) \ 117 (_log2) += 4, (j_) >>= 4; \ 118 if ((j_) >> 2) \ 119 (_log2) += 2, (j_) >>= 2; \ 120 if ((j_) >> 1) \ 121 (_log2) += 1; \ 122 PR_END_MACRO 90 PR_END_EXTERN_C 123 91 124 /*125 ** Macro version of PR_FloorLog2: Compute the log of the greatest power of126 ** 2 less than or equal to _n. The result is returned in _log2.127 **128 ** This is equivalent to finding the highest set bit in the word.129 */130 #define PR_FLOOR_LOG2(_log2,_n) \131 PR_BEGIN_MACRO \132 PRUint32 j_ = (PRUint32)(_n); \133 (_log2) = 0; \134 if ((j_) >> 16) \135 (_log2) += 16, (j_) >>= 16; \136 if ((j_) >> 8) \137 (_log2) += 8, (j_) >>= 8; \138 if ((j_) >> 4) \139 (_log2) += 4, (j_) >>= 4; \140 if ((j_) >> 2) \141 (_log2) += 2, (j_) >>= 2; \142 if ((j_) >> 1) \143 (_log2) += 1; \144 PR_END_MACRO145 146 PR_END_EXTERN_C147 92 #endif /* prbit_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.