/[jscoverage]/trunk/js/jslog2.cpp
ViewVC logotype

Diff of /trunk/js/jslog2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 459 by siliconforks, Thu Oct 23 19:03:33 2008 UTC revision 460 by siliconforks, Sat Sep 26 23:15:22 2009 UTC
# Line 41  Line 41 
41  #include "jsutil.h"  #include "jsutil.h"
42    
43  /*  /*
44  ** Compute the log of the least power of 2 greater than or equal to n   * Check that we can use js_bitscan_clz32 to implement JS_FLOOR_LOG2 and
45  */   * JS_FLOOR_LOG2W and js_bitscan_clz64 to implement JS_FLOOR_LOG2W on 64-bit
46  JS_PUBLIC_API(JSIntn) JS_CeilingLog2(JSUint32 n)   * systems.
47     */
48    #ifdef JS_HAS_BUILTIN_BITSCAN32
49    JS_STATIC_ASSERT(sizeof(unsigned int) == sizeof(JSUint32));
50    JS_STATIC_ASSERT_IF(JS_BYTES_PER_WORD == 4,
51                        sizeof(unsigned int) == sizeof(JSUword));
52    #endif
53    #ifdef JS_HAS_BUILTIN_BITSCAN64
54    JS_STATIC_ASSERT_IF(JS_BYTES_PER_WORD == 8,
55                        sizeof(unsigned long long) == sizeof(JSUword));
56    #endif
57    
58    /*
59     * Compute the log of the least power of 2 greater than or equal to n
60     */
61    JS_PUBLIC_API(JSIntn)
62    JS_CeilingLog2(JSUint32 n)
63  {  {
64      JSIntn log2;      JSIntn log2;
65    
# Line 52  Line 68 
68  }  }
69    
70  /*  /*
71  ** Compute the log of the greatest power of 2 less than or equal to n.   * Compute the log of the greatest power of 2 less than or equal to n.
72  ** This really just finds the highest set bit in the word.   * This really just finds the highest set bit in the word.
73  */   */
74  JS_PUBLIC_API(JSIntn) JS_FloorLog2(JSUint32 n)  JS_PUBLIC_API(JSIntn)
75    JS_FloorLog2(JSUint32 n)
76  {  {
77      JSIntn log2;      JSIntn log2;
78    

Legend:
Removed from v.459  
changed lines
  Added in v.460

  ViewVC Help
Powered by ViewVC 1.1.24