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

Side by Side Diff: src/core/SkVarAlloc.cpp

Issue 1006073003: Fix build for UCLIBC platforms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | tests/VarAllocTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "SkVarAlloc.h" 1 #include "SkVarAlloc.h"
2 2
3 // We use non-standard malloc diagnostic methods to make sure our allocations ar e sized well. 3 // We use non-standard malloc diagnostic methods to make sure our allocations ar e sized well.
4 #if defined(SK_BUILD_FOR_MAC) 4 #if defined(SK_BUILD_FOR_MAC)
5 #include <malloc/malloc.h> 5 #include <malloc/malloc.h>
6 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN32) 6 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN32)
7 #include <malloc.h> 7 #include <malloc.h>
8 #endif 8 #endif
9 9
10 struct SkVarAlloc::Block { 10 struct SkVarAlloc::Block {
(...skipping 29 matching lines...) Expand all
40 size_t alloc = 1<<fLgSize++; 40 size_t alloc = 1<<fLgSize++;
41 while (alloc < bytes + sizeof(Block)) { 41 while (alloc < bytes + sizeof(Block)) {
42 alloc *= 2; 42 alloc *= 2;
43 } 43 }
44 fBlock = Block::Alloc(fBlock, alloc, flags); 44 fBlock = Block::Alloc(fBlock, alloc, flags);
45 fByte = fBlock->data(); 45 fByte = fBlock->data();
46 fRemaining = alloc - sizeof(Block); 46 fRemaining = alloc - sizeof(Block);
47 47
48 #if defined(SK_BUILD_FOR_MAC) 48 #if defined(SK_BUILD_FOR_MAC)
49 SkASSERT(alloc == malloc_good_size(alloc)); 49 SkASSERT(alloc == malloc_good_size(alloc));
50 #elif defined(SK_BUILD_FOR_UNIX) 50 #elif defined(SK_BUILD_FOR_UNIX) && !defined(__UCLIBC__)
51 // TODO(mtklein): tune so we can assert something like this 51 // TODO(mtklein): tune so we can assert something like this
52 //SkASSERT(alloc == malloc_usable_size(fBlock)); 52 //SkASSERT(alloc == malloc_usable_size(fBlock));
53 #endif 53 #endif
54 } 54 }
55 55
56 static size_t heap_size(void* p) { 56 static size_t heap_size(void* p) {
57 #if defined(SK_BUILD_FOR_MAC) 57 #if defined(SK_BUILD_FOR_MAC)
58 return malloc_size(p); 58 return malloc_size(p);
59 #elif defined(SK_BUILD_FOR_UNIX) 59 #elif defined(SK_BUILD_FOR_UNIX) && !defined(__UCLIBC__)
60 return malloc_usable_size(p); 60 return malloc_usable_size(p);
61 #elif defined(SK_BUILD_FOR_WIN32) 61 #elif defined(SK_BUILD_FOR_WIN32)
62 return _msize(p); 62 return _msize(p);
63 #else 63 #else
64 return 0; // Tough luck. 64 return 0; // Tough luck.
65 #endif 65 #endif
66 } 66 }
67 67
68 size_t SkVarAlloc::approxBytesAllocated() const { 68 size_t SkVarAlloc::approxBytesAllocated() const {
69 size_t sum = 0; 69 size_t sum = 0;
70 for (Block* b = fBlock; b; b = b->prev) { 70 for (Block* b = fBlock; b; b = b->prev) {
71 sum += heap_size(b); 71 sum += heap_size(b);
72 } 72 }
73 return sum; 73 return sum;
74 } 74 }
OLDNEW
« no previous file with comments | « no previous file | tests/VarAllocTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698