Home | History | Annotate | Download | only in memory

Lines Matching defs:memory

5 #include "base/memory/shared_memory.h"
10 #include <memory>
14 #include "base/memory/shared_memory_handle.h"
44 // Each thread will open the shared memory. Each thread will take a different 4
46 // Verify that each thread's value in the shared memory is always correct.
53 SharedMemory memory;
54 memory.Delete(s_test_name_);
60 SharedMemory memory;
61 bool rv = memory.CreateNamedDeprecated(s_test_name_, true, kDataSize);
63 rv = memory.Map(kDataSize);
65 int* ptr = static_cast<int*>(memory.memory()) + id_;
76 memory.Close();
100 // Open two handles to a memory segment, confirm that they are mapped
118 EXPECT_NE(memory1.memory(), memory2.memory()); // Compare the pointers.
121 ASSERT_NE(memory1.memory(), static_cast<void*>(NULL));
122 ASSERT_NE(memory2.memory(), static_cast<void*>(NULL));
124 // Write data to the first memory segment, verify contents of second.
125 memset(memory1.memory(), '1', kDataSize);
126 EXPECT_EQ(memcmp(memory1.memory(), memory2.memory(), kDataSize), 0);
128 // Close the first memory segment, and verify the second has the right data.
130 char* start_ptr = static_cast<char*>(memory2.memory());
135 // Close the second memory segment.
152 // Open two handles to a memory segment and check that
171 memset(memory1.memory(), 'G', kDataSize);
196 // Verify that opening memory2 didn't truncate or delete memory 1.
197 char* start_ptr = static_cast<char*>(memory2.memory());
211 // Check that memory is still mapped after its closed.
215 SharedMemory memory;
216 ASSERT_TRUE(memory.CreateAndMapAnonymous(kDataSize));
217 char* ptr = static_cast<char*>(memory.memory());
221 memory.Close();
223 EXPECT_EQ(ptr, memory.memory());
224 EXPECT_EQ(SharedMemory::NULLHandle(), memory.handle());
230 memory.Unmap();
231 EXPECT_EQ(nullptr, memory.memory());
235 // Create a set of N threads to each open a shared memory segment and write to
275 // Allocate private (unique) shared memory with an empty string for a
292 int* ptr = static_cast<int*>(memories[i].memory());
332 memcpy(writable_shmem.memory(), contents.data(), contents.size());
342 StringPiece(static_cast<const char*>(readonly_shmem.memory()),
349 memcpy(writable_shmem.memory(), new_contents.data(), new_contents.size());
351 StringPiece(static_cast<const char*>(writable_shmem.memory()),
384 << "Shouldn't be able to map memory writable.";
411 memcpy(shmem.memory(), contents.data(), contents.size());
424 StringPiece(static_cast<const char*>(shared.memory()), contents.size()));
435 StringPiece(static_cast<const char*>(readonly.memory()),
444 SharedMemory memory;
445 ASSERT_TRUE(memory.CreateAndMapAnonymous(kDataSize));
446 uint32_t* ptr = static_cast<uint32_t*>(memory.memory());
453 memory.Unmap();
456 ASSERT_TRUE(memory.MapAt(offset, kDataSize - offset));
458 ptr = static_cast<uint32_t*>(memory.memory());
467 SharedMemory memory;
468 bool rv = memory.CreateAndMapAnonymous(kDataSize);
471 void* old_address = memory.memory();
473 rv = memory.Map(kDataSize);
475 EXPECT_EQ(old_address, memory.memory());
481 // Create a shared memory object, mmap it, and mprotect it to PROT_EXEC.
497 memory(), shared_memory.requested_size(),
503 // shared memory implementation. So the tests about file permissions are not
519 // Create a shared memory object, check its permissions.
539 // Neither the group, nor others should be able to read the shared memory
545 // Create a shared memory object, check its permissions.
566 // memory file while its name existed.
583 shared_memory.memory()) & (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
606 EXPECT_EQ(nullptr, shared_memory_open.memory());
611 EXPECT_EQ(nullptr, shared_memory_handle_local.memory());
626 EXPECT_EQ(nullptr, shared_memory_handle_no_query.memory());
631 // Android ashmem does not support named shared memory.
632 // Mac SharedMemory does not support named shared memory. crbug.com/345734
639 SharedMemory memory;
640 memory.Delete(s_test_name_);
645 SharedMemory memory;
646 bool rv = memory.CreateNamedDeprecated(s_test_name_, true, s_data_size_);
650 rv = memory.Map(s_data_size_);
654 int* ptr = static_cast<int*>(memory.memory());
658 memory.Close();
674 // Create a shared memory region. Set the first word to 0.
675 SharedMemory memory;
676 bool rv = memory.CreateNamedDeprecated(s_test_name_, true, s_data_size_);
678 rv = memory.Map(s_data_size_);
680 int* ptr = static_cast<int*>(memory.memory());
698 // Check that the shared memory region reflects |kNumTasks| increments.
701 memory.Close();