@@ -83,7 +83,8 @@ class GuardedPageAllocatorParamTest
8383};
8484
8585TEST_F (GuardedPageAllocatorTest, SingleAllocDealloc) {
86- auto alloc_with_status = gpa_.Allocate (PageSize (), 0 , GetStackTrace ());
86+ auto alloc_with_status =
87+ gpa_.Allocate (PageSize (), std::align_val_t {0 }, GetStackTrace ());
8788 EXPECT_EQ (alloc_with_status.status , Profile::Sample::GuardedStatus::Guarded);
8889 EXPECT_EQ (gpa_.successful_allocations (), 1 );
8990 char * buf = static_cast <char *>(alloc_with_status.alloc );
@@ -116,7 +117,8 @@ TEST_F(GuardedPageAllocatorTest, NoAlignmentProvided) {
116117 // Make several allocation attempts to encounter left/right-alignment in
117118 // the guarded region.
118119 for (int i = 0 ; i < kElements ; i++) {
119- auto alloc_with_status = gpa_.Allocate (size, 0 , GetStackTrace ());
120+ auto alloc_with_status =
121+ gpa_.Allocate (size, std::align_val_t {0 }, GetStackTrace ());
120122 EXPECT_EQ (alloc_with_status.status ,
121123 Profile::Sample::GuardedStatus::Guarded);
122124 ptrs[i] = alloc_with_status.alloc ;
@@ -140,7 +142,8 @@ TEST_F(GuardedPageAllocatorTest, NoAlignmentProvided) {
140142TEST_F (GuardedPageAllocatorTest, AllocDeallocAligned) {
141143 for (size_t align = 1 ; align <= PageSize (); align <<= 1 ) {
142144 constexpr size_t alloc_size = 1 ;
143- auto alloc_with_status = gpa_.Allocate (alloc_size, align, GetStackTrace ());
145+ auto alloc_with_status = gpa_.Allocate (
146+ alloc_size, static_cast <std::align_val_t >(align), GetStackTrace ());
144147 EXPECT_EQ (alloc_with_status.status ,
145148 Profile::Sample::GuardedStatus::Guarded);
146149 EXPECT_NE (alloc_with_status.alloc , nullptr );
@@ -157,8 +160,8 @@ TEST_F(GuardedPageAllocatorTest, MismatchedAlignment) {
157160 for (size_t align = 1 ; align <= PageSize (); align <<= 1 ) {
158161 for (size_t misalign = 1 ; misalign <= align; misalign <<= 1 ) {
159162 constexpr size_t alloc_size = 1 ;
160- auto alloc_with_status =
161- gpa_. Allocate ( alloc_size, align, GetStackTrace ());
163+ auto alloc_with_status = gpa_. Allocate (
164+ alloc_size, static_cast <std:: align_val_t >( align) , GetStackTrace ());
162165 EXPECT_EQ (alloc_with_status.status ,
163166 Profile::Sample::GuardedStatus::Guarded);
164167 EXPECT_NE (alloc_with_status.alloc , nullptr );
@@ -182,20 +185,22 @@ TEST_P(GuardedPageAllocatorParamTest, AllocDeallocAllPages) {
182185 size_t num_pages = GetParam ();
183186 char * bufs[kMaxGpaPages ];
184187 for (size_t i = 0 ; i < num_pages; i++) {
185- auto alloc_with_status = gpa_.Allocate (1 , 0 , GetStackTrace ());
188+ auto alloc_with_status =
189+ gpa_.Allocate (1 , std::align_val_t {0 }, GetStackTrace ());
186190 EXPECT_EQ (alloc_with_status.status ,
187191 Profile::Sample::GuardedStatus::Guarded);
188192 bufs[i] = reinterpret_cast <char *>(alloc_with_status.alloc );
189193 EXPECT_NE (bufs[i], nullptr );
190194 EXPECT_TRUE (gpa_.PointerIsMine (bufs[i]));
191195 }
192196 EXPECT_EQ (gpa_.successful_allocations (), num_pages);
193- auto alloc_with_status = gpa_.Allocate (1 , 0 , GetStackTrace ());
197+ auto alloc_with_status =
198+ gpa_.Allocate (1 , std::align_val_t {0 }, GetStackTrace ());
194199 EXPECT_EQ (alloc_with_status.status ,
195200 Profile::Sample::GuardedStatus::NoAvailableSlots);
196201 EXPECT_EQ (alloc_with_status.alloc , nullptr );
197202 gpa_.Deallocate (bufs[0 ]);
198- alloc_with_status = gpa_.Allocate (1 , 0 , GetStackTrace ());
203+ alloc_with_status = gpa_.Allocate (1 , std:: align_val_t { 0 } , GetStackTrace ());
199204 EXPECT_EQ (alloc_with_status.status , Profile::Sample::GuardedStatus::Guarded);
200205 bufs[0 ] = reinterpret_cast <char *>(alloc_with_status.alloc );
201206 EXPECT_NE (bufs[0 ], nullptr );
@@ -210,7 +215,8 @@ INSTANTIATE_TEST_SUITE_P(VaryNumPages, GuardedPageAllocatorParamTest,
210215 testing::Values (1 , kMaxGpaPages / 2 , kMaxGpaPages ));
211216
212217TEST_F (GuardedPageAllocatorTest, PointerIsMine) {
213- auto alloc_with_status = gpa_.Allocate (1 , 0 , GetStackTrace ());
218+ auto alloc_with_status =
219+ gpa_.Allocate (1 , std::align_val_t {0 }, GetStackTrace ());
214220 EXPECT_EQ (alloc_with_status.status , Profile::Sample::GuardedStatus::Guarded);
215221 EXPECT_EQ (gpa_.successful_allocations (), 1 );
216222 void * buf = alloc_with_status.alloc ;
@@ -229,7 +235,8 @@ TEST_F(GuardedPageAllocatorTest, Print) {
229235}
230236
231237TEST_F (GuardedPageAllocatorTest, ZeroByteAllocationAndDeallocation) {
232- auto alloc_with_status = gpa_.Allocate (0 , 0 , GetStackTrace ());
238+ auto alloc_with_status =
239+ gpa_.Allocate (0 , std::align_val_t {0 }, GetStackTrace ());
233240 EXPECT_EQ (alloc_with_status.status , Profile::Sample::GuardedStatus::Guarded);
234241 EXPECT_NE (alloc_with_status.alloc , nullptr );
235242 void * ptr = alloc_with_status.alloc ;
@@ -247,7 +254,8 @@ TEST_F(GuardedPageAllocatorTest, ZeroByteAllocationAndDeallocation) {
247254}
248255
249256TEST_F (GuardedPageAllocatorTest, ZeroByteUseAfterFree) {
250- auto alloc_with_status = gpa_.Allocate (0 , 0 , GetStackTrace ());
257+ auto alloc_with_status =
258+ gpa_.Allocate (0 , std::align_val_t {0 }, GetStackTrace ());
251259 EXPECT_EQ (alloc_with_status.status , Profile::Sample::GuardedStatus::Guarded);
252260 ASSERT_NE (alloc_with_status.alloc , nullptr );
253261 void * ptr = alloc_with_status.alloc ;
@@ -260,7 +268,8 @@ TEST_F(GuardedPageAllocatorTest, ZeroByteUseAfterFree) {
260268}
261269
262270TEST_F (GuardedPageAllocatorTest, ZeroByteDoubleFree) {
263- auto alloc_with_status = gpa_.Allocate (0 , 0 , GetStackTrace ());
271+ auto alloc_with_status =
272+ gpa_.Allocate (0 , std::align_val_t {0 }, GetStackTrace ());
264273 EXPECT_EQ (alloc_with_status.status , Profile::Sample::GuardedStatus::Guarded);
265274 ASSERT_NE (alloc_with_status.alloc , nullptr );
266275 void * ptr = alloc_with_status.alloc ;
@@ -280,7 +289,8 @@ TEST_F(GuardedPageAllocatorTest, ThreadedAllocCount) {
280289 for (size_t i = 0 ; i < kNumThreads ; i++) {
281290 threads.push_back (std::thread ([this , &allocations, i]() {
282291 for (size_t j = 0 ; j < kMaxGpaPages ; j++) {
283- allocations[i][j] = gpa_.Allocate (1 , 0 , GetStackTrace ()).alloc ;
292+ allocations[i][j] =
293+ gpa_.Allocate (1 , std::align_val_t {0 }, GetStackTrace ()).alloc ;
284294 }
285295 }));
286296 }
@@ -311,7 +321,8 @@ TEST_F(GuardedPageAllocatorTest, ThreadedHighContention) {
311321 threads.push_back (std::thread ([this ]() {
312322 char * buf;
313323 while (true ) {
314- auto alloc_with_status = gpa_.Allocate (1 , 0 , GetStackTrace ());
324+ auto alloc_with_status =
325+ gpa_.Allocate (1 , std::align_val_t {0 }, GetStackTrace ());
315326 if (alloc_with_status.status ==
316327 Profile::Sample::GuardedStatus::Guarded) {
317328 buf = reinterpret_cast <char *>(alloc_with_status.alloc );
@@ -341,7 +352,8 @@ TEST_F(GuardedPageAllocatorTest, ThreadedHighContention) {
341352 }
342353 // Verify all pages have been deallocated now that all threads are done.
343354 for (size_t i = 0 ; i < kMaxGpaPages ; i++) {
344- auto alloc_with_status = gpa_.Allocate (1 , 0 , GetStackTrace ());
355+ auto alloc_with_status =
356+ gpa_.Allocate (1 , std::align_val_t {0 }, GetStackTrace ());
345357 EXPECT_EQ (alloc_with_status.status ,
346358 Profile::Sample::GuardedStatus::Guarded);
347359 EXPECT_NE (alloc_with_status.alloc , nullptr );
0 commit comments