mem: add private mapping flag

This commit is contained in:
Wim Taymans 2019-09-10 09:59:31 +02:00
parent b9e517ee67
commit 3142d3b979
3 changed files with 9 additions and 3 deletions

@ -1 +1 @@
Subproject commit 2736c227a19b1db48dd849af6f7f3e929bb53c00
Subproject commit 35bf6bfa5c3969b65e63dbfe48578c5c040849d4

View file

@ -266,13 +266,18 @@ static struct mapping * memblock_map(struct memblock *b,
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
struct mapping *m;
void *ptr;
int prot = 0;
int prot = 0, fl = 0;
if (flags & PW_MEMMAP_FLAG_READ)
prot |= PROT_READ;
if (flags & PW_MEMMAP_FLAG_WRITE)
prot |= PROT_WRITE;
if (flags & PW_MEMMAP_FLAG_PRIVATE)
fl |= MAP_PRIVATE;
else
fl |= MAP_SHARED;
if (flags & PW_MEMMAP_FLAG_TWICE) {
pw_log_error(NAME" %p: implement me PW_MEMMAP_FLAG_TWICE", p);
errno = ENOTSUP;
@ -280,7 +285,7 @@ static struct mapping * memblock_map(struct memblock *b,
}
ptr = mmap(NULL, size, prot, MAP_SHARED, b->this.fd, offset);
ptr = mmap(NULL, size, prot, fl, b->this.fd, offset);
if (ptr == MAP_FAILED) {
pw_log_error(NAME" %p: Failed to mmap memory fd:%d offset:%u size:%u: %m",
p, b->this.fd, offset, size);

View file

@ -49,6 +49,7 @@ enum pw_memmap_flags {
PW_MEMMAP_FLAG_WRITE = (1 << 1), /**< map in write mode */
PW_MEMMAP_FLAG_TWICE = (1 << 2), /**< map the same area twice afer eachother,
* creating a circular ringbuffer */
PW_MEMMAP_FLAG_PRIVATE = (1 << 3), /**< writes will be private */
PW_MEMMAP_FLAG_READWRITE = PW_MEMMAP_FLAG_READ | PW_MEMMAP_FLAG_WRITE,
};