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

Side by Side Diff: third_party/tcmalloc/chromium/src/tests/memalign_unittest.cc

Issue 7050034: Merge google-perftools r109 (the current contents of third_party/tcmalloc/vendor) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
OLDNEW
1 // Copyright (c) 2004, Google Inc. 1 // Copyright (c) 2004, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // _POSIX_C_SOURCE, which it needs so stdlib.h defines posix_memalign. 42 // _POSIX_C_SOURCE, which it needs so stdlib.h defines posix_memalign.
43 // unistd.h, on the other hand, requires _POSIX_C_SOURCE to be unset, 43 // unistd.h, on the other hand, requires _POSIX_C_SOURCE to be unset,
44 // at least on Mac OS X, in order to define getpagesize. The solution 44 // at least on Mac OS X, in order to define getpagesize. The solution
45 // is to #include unistd.h first. This is safe because unistd.h 45 // is to #include unistd.h first. This is safe because unistd.h
46 // doesn't sub-include stdlib.h, so we'll still get posix_memalign 46 // doesn't sub-include stdlib.h, so we'll still get posix_memalign
47 // when we #include stdlib.h. Blah. 47 // when we #include stdlib.h. Blah.
48 #ifdef HAVE_UNISTD_H 48 #ifdef HAVE_UNISTD_H
49 #include <unistd.h> // for getpagesize() 49 #include <unistd.h> // for getpagesize()
50 #endif 50 #endif
51 #include "tcmalloc.h" // must come early, to pick up posix_memalign 51 #include "tcmalloc.h" // must come early, to pick up posix_memalign
52 #include <assert.h>
52 #include <stdlib.h> // defines posix_memalign 53 #include <stdlib.h> // defines posix_memalign
53 #include <stdio.h> // for the printf at the end 54 #include <stdio.h> // for the printf at the end
54 #ifdef HAVE_STDINT_H 55 #ifdef HAVE_STDINT_H
55 #include <stdint.h> // for uintptr_t 56 #include <stdint.h> // for uintptr_t
56 #endif 57 #endif
57 #ifdef HAVE_UNISTD_H 58 #ifdef HAVE_UNISTD_H
58 #include <unistd.h> // for getpagesize() 59 #include <unistd.h> // for getpagesize()
59 #endif 60 #endif
60 #ifdef HAVE_MALLOC_H 61 // Malloc can be in several places on older versions of OS X.
61 #include <malloc.h> 62 #if defined(HAVE_MALLOC_H)
63 #include <malloc.h> // for memalign() and valloc()
64 #elif defined(HAVE_MALLOC_MALLOC_H)
65 #include <malloc/malloc.h>
66 #elif defined(HAVE_SYS_MALLOC_H)
67 #include <sys/malloc.h>
62 #endif 68 #endif
63 #include "base/basictypes.h" 69 #include "base/basictypes.h"
64 #include "base/logging.h" 70 #include "base/logging.h"
65 #include "tests/testutil.h" 71 #include "tests/testutil.h"
66 72
67 73
68 // Return the next interesting size/delta to check. Returns -1 if no more. 74 // Return the next interesting size/delta to check. Returns -1 if no more.
69 static int NextSize(int size) { 75 static int NextSize(int size) {
70 if (size < 100) { 76 if (size < 100) {
71 return size+1; 77 return size+1;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 int alloc_needed = ((s + pagesize - 1) / pagesize) * pagesize; 211 int alloc_needed = ((s + pagesize - 1) / pagesize) * pagesize;
206 Fill(p, alloc_needed, 'x'); 212 Fill(p, alloc_needed, 'x');
207 CHECK(Valid(p, alloc_needed, 'x')); 213 CHECK(Valid(p, alloc_needed, 'x'));
208 free(p); 214 free(p);
209 } 215 }
210 } 216 }
211 217
212 printf("PASS\n"); 218 printf("PASS\n");
213 return 0; 219 return 0;
214 } 220 }
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/tests/malloc_hook_test.cc ('k') | third_party/tcmalloc/chromium/src/tests/page_heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698