Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: base/cross/bits.h

Issue 159168: This fixes a number of things that are warnings in the Mac compiler.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | core/cross/bitmap.h » ('j') | core/cross/bitmap_dds.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 int log = 0; 48 int log = 0;
49 unsigned int value = n; 49 unsigned int value = n;
50 for (int i = 4; i >= 0; --i) { 50 for (int i = 4; i >= 0; --i) {
51 int shift = (1 << i); 51 int shift = (1 << i);
52 unsigned int x = value >> shift; 52 unsigned int x = value >> shift;
53 if (x != 0) { 53 if (x != 0) {
54 value = x; 54 value = x;
55 log += shift; 55 log += shift;
56 } 56 }
57 } 57 }
58 DCHECK_EQ(value, 1); 58 DCHECK_EQ(value, 1u);
59 return log; 59 return log;
60 } 60 }
61 61
62 // Returns the integer i such as 2^(i-1) < n <= 2^i 62 // Returns the integer i such as 2^(i-1) < n <= 2^i
63 static inline int Log2Ceiling(unsigned int n) { 63 static inline int Log2Ceiling(unsigned int n) {
64 if (n == 0) { 64 if (n == 0) {
65 return -1; 65 return -1;
66 } else { 66 } else {
67 // Log2Floor returns -1 for 0, so the following works correctly for n=1. 67 // Log2Floor returns -1 for 0, so the following works correctly for n=1.
68 return 1 + Log2Floor(n - 1); 68 return 1 + Log2Floor(n - 1);
69 } 69 }
70 } 70 }
71 71
72 } // namespace bits 72 } // namespace bits
73 } // namespace base 73 } // namespace base
74 } // namespace o3d 74 } // namespace o3d
75 75
76 #endif // O3D_BASE_CROSS_BITS_H_ 76 #endif // O3D_BASE_CROSS_BITS_H_
OLDNEW
« no previous file with comments | « no previous file | core/cross/bitmap.h » ('j') | core/cross/bitmap_dds.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698