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

Side by Side Diff: third_party/tcmalloc/vendor/src/tests/tcmalloc_unittest.cc

Issue 9701040: Revert 126715 - Update the tcmalloc vendor branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #ifdef HAVE_MALLOC_H 81 #ifdef HAVE_MALLOC_H
82 #include <malloc.h> // defines pvalloc/etc on cygwin 82 #include <malloc.h> // defines pvalloc/etc on cygwin
83 #endif 83 #endif
84 #include <assert.h> 84 #include <assert.h>
85 #include <vector> 85 #include <vector>
86 #include <algorithm> 86 #include <algorithm>
87 #include <string> 87 #include <string>
88 #include <new> 88 #include <new>
89 #include "base/logging.h" 89 #include "base/logging.h"
90 #include "base/simple_mutex.h" 90 #include "base/simple_mutex.h"
91 #include "gperftools/malloc_hook.h" 91 #include "google/malloc_hook.h"
92 #include "gperftools/malloc_extension.h" 92 #include "google/malloc_extension.h"
93 #include "gperftools/tcmalloc.h" 93 #include "google/tcmalloc.h"
94 #include "thread_cache.h" 94 #include "thread_cache.h"
95 #include "tests/testutil.h" 95 #include "tests/testutil.h"
96 96
97 // Windows doesn't define pvalloc and a few other obsolete unix 97 // Windows doesn't define pvalloc and a few other obsolete unix
98 // functions; nor does it define posix_memalign (which is not obsolete). 98 // functions; nor does it define posix_memalign (which is not obsolete).
99 #if defined(_WIN32) 99 #if defined(_WIN32)
100 # define cfree free // don't bother to try to test these obsolete fns 100 # define cfree free // don't bother to try to test these obsolete fns
101 # define valloc malloc 101 # define valloc malloc
102 # define pvalloc malloc 102 # define pvalloc malloc
103 // I'd like to map posix_memalign to _aligned_malloc, but _aligned_malloc 103 // I'd like to map posix_memalign to _aligned_malloc, but _aligned_malloc
104 // must be paired with _aligned_free (not normal free), which is too 104 // must be paired with _aligned_free (not normal free), which is too
105 // invasive a change to how we allocate memory here. So just bail 105 // invasive a change to how we allocate memory here. So just bail
106 static bool kOSSupportsMemalign = false; 106 static bool kOSSupportsMemalign = false;
107 static inline void* Memalign(size_t align, size_t size) { 107 static inline void* Memalign(size_t align, size_t size) {
108 //LOG(FATAL) << "memalign not supported on windows"; 108 //LOG(FATAL) << "memalign not supported on windows";
109 exit(1); 109 exit(1);
110 return NULL;
111 } 110 }
112 static inline int PosixMemalign(void** ptr, size_t align, size_t size) { 111 static inline int PosixMemalign(void** ptr, size_t align, size_t size) {
113 //LOG(FATAL) << "posix_memalign not supported on windows"; 112 //LOG(FATAL) << "posix_memalign not supported on windows";
114 exit(1); 113 exit(1);
115 return -1;
116 } 114 }
117 115
118 // OS X defines posix_memalign in some OS versions but not others; 116 // OS X defines posix_memalign in some OS versions but not others;
119 // it's confusing enough to check that it's easiest to just not to test. 117 // it's confusing enough to check that it's easiest to just not to test.
120 #elif defined(__APPLE__) 118 #elif defined(__APPLE__)
121 static bool kOSSupportsMemalign = false; 119 static bool kOSSupportsMemalign = false;
122 static inline void* Memalign(size_t align, size_t size) { 120 static inline void* Memalign(size_t align, size_t size) {
123 //LOG(FATAL) << "memalign not supported on OS X"; 121 //LOG(FATAL) << "memalign not supported on OS X";
124 exit(1); 122 exit(1);
125 return NULL;
126 } 123 }
127 static inline int PosixMemalign(void** ptr, size_t align, size_t size) { 124 static inline int PosixMemalign(void** ptr, size_t align, size_t size) {
128 //LOG(FATAL) << "posix_memalign not supported on OS X"; 125 //LOG(FATAL) << "posix_memalign not supported on OS X";
129 exit(1); 126 exit(1);
130 return -1;
131 } 127 }
132 128
133 #else 129 #else
134 static bool kOSSupportsMemalign = true; 130 static bool kOSSupportsMemalign = true;
135 static inline void* Memalign(size_t align, size_t size) { 131 static inline void* Memalign(size_t align, size_t size) {
136 return memalign(align, size); 132 return memalign(align, size);
137 } 133 }
138 static inline int PosixMemalign(void** ptr, size_t align, size_t size) { 134 static inline int PosixMemalign(void** ptr, size_t align, size_t size) {
139 return posix_memalign(ptr, align, size); 135 return posix_memalign(ptr, align, size);
140 } 136 }
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 p1 = Memalign(sizeof(p1) * 2, 50); 1076 p1 = Memalign(sizeof(p1) * 2, 50);
1081 CHECK(p1 != NULL); 1077 CHECK(p1 != NULL);
1082 VerifyNewHookWasCalled(); 1078 VerifyNewHookWasCalled();
1083 free(p1); 1079 free(p1);
1084 VerifyDeleteHookWasCalled(); 1080 VerifyDeleteHookWasCalled();
1085 } 1081 }
1086 1082
1087 // Windows has _aligned_malloc. Let's test that that's captured too. 1083 // Windows has _aligned_malloc. Let's test that that's captured too.
1088 #if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(PERFTOOLS_NO_ALIGNED _MALLOC) 1084 #if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(PERFTOOLS_NO_ALIGNED _MALLOC)
1089 p1 = _aligned_malloc(sizeof(p1) * 2, 64); 1085 p1 = _aligned_malloc(sizeof(p1) * 2, 64);
1090 CHECK(p1 != NULL);
1091 VerifyNewHookWasCalled(); 1086 VerifyNewHookWasCalled();
1092 _aligned_free(p1); 1087 _aligned_free(p1);
1093 VerifyDeleteHookWasCalled(); 1088 VerifyDeleteHookWasCalled();
1094 #endif 1089 #endif
1095 1090
1096 p1 = valloc(60); 1091 p1 = valloc(60);
1097 CHECK(p1 != NULL); 1092 CHECK(p1 != NULL);
1098 VerifyNewHookWasCalled(); 1093 VerifyNewHookWasCalled();
1099 free(p1); 1094 free(p1);
1100 VerifyDeleteHookWasCalled(); 1095 VerifyDeleteHookWasCalled();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 int minor; 1313 int minor;
1319 const char* patch; 1314 const char* patch;
1320 char mmp[64]; 1315 char mmp[64];
1321 const char* human_version = tc_version(&major, &minor, &patch); 1316 const char* human_version = tc_version(&major, &minor, &patch);
1322 snprintf(mmp, sizeof(mmp), "%d.%d%s", major, minor, patch); 1317 snprintf(mmp, sizeof(mmp), "%d.%d%s", major, minor, patch);
1323 CHECK(!strcmp(PACKAGE_STRING, human_version)); 1318 CHECK(!strcmp(PACKAGE_STRING, human_version));
1324 CHECK(!strcmp(PACKAGE_VERSION, mmp)); 1319 CHECK(!strcmp(PACKAGE_VERSION, mmp));
1325 1320
1326 fprintf(LOGSTREAM, "PASS\n"); 1321 fprintf(LOGSTREAM, "PASS\n");
1327 } 1322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698