#define PROT_EXEC 0x04 /* pages can be executed */
/* flags argument for mmap() */
-#define MAP_SHARED 0x0001 /* share changes */
#define MAP_PRIVATE 0x0002 /* changes are private */
#define MAP_ANON 0x0004 /* anonymous memory */
#define MAP_PREALLOC 0x0008 /* not on-demand */
#define MAP_LOWER16M 0x0020 /* physically below 16MB */
#define MAP_ALIGN64K 0x0040 /* physically aligned at 64kB */
#define MAP_LOWER1M 0x0080 /* physically below 16MB */
+#define MAP_IPC_SHARED 0x0100 /* used to implement shared memory */
/* mmap() error return */
#define MAP_FAILED ((void *)-1)
* Flags contain sharing type and options.
* Sharing types; choose one.
*/
+#ifndef __minix
#define MAP_SHARED 0x0001 /* share changes */
+#endif
#define MAP_PRIVATE 0x0002 /* changes are private */
/*
#define MAP_ALIGN64K 0x0040 /* physically aligned at 64kB */
#define MAP_LOWER1M 0x0080 /* physically below 16MB */
#define MAP_ALIGNMENT_64KB MAP_ALIGN64K
+#define MAP_IPC_SHARED 0x0100 /* share changes */
/*
* Error indicator returned by mmap(2)
memset(shm, 0, sizeof(struct shm_struct));
shm->page = (vir_bytes) mmap(0, size,
PROT_READ|PROT_WRITE,
- MAP_CONTIG|MAP_PREALLOC|MAP_ANON|MAP_SHARED,
+ MAP_CONTIG|MAP_PREALLOC|MAP_ANON|MAP_IPC_SHARED,
-1, 0);
if (shm->page == (vir_bytes) MAP_FAILED)
return ENOMEM;
(vri->vri_prot & PROT_READ) ? 'r' : '-',
(vri->vri_prot & PROT_WRITE) ? 'w' : '-',
(vri->vri_prot & PROT_EXEC) ? 'x' : '-',
- (vri->vri_flags & MAP_SHARED) ? 's' : 'p',
+ (vri->vri_flags & MAP_IPC_SHARED) ? 's' : 'p',
vri->vri_length / 1024L);
(*n)++;
}
(vri[i].vri_prot & PROT_READ) ? 'r' : '-',
(vri[i].vri_prot & PROT_WRITE) ? 'w' : '-',
(vri[i].vri_prot & PROT_EXEC) ? 'x' : '-',
- (vri[i].vri_flags & MAP_SHARED) ? 's' : 'p');
+ (vri[i].vri_flags & MAP_IPC_SHARED) ? 's' : 'p');
count++;
}
if(m->VMM_FLAGS & MAP_LOWER16M) vrflags |= VR_LOWER16MB;
if(m->VMM_FLAGS & MAP_LOWER1M) vrflags |= VR_LOWER1MB;
if(m->VMM_FLAGS & MAP_ALIGN64K) vrflags |= VR_PHYS64K;
- if(m->VMM_FLAGS & MAP_SHARED) vrflags |= VR_SHARED;
+ if(m->VMM_FLAGS & MAP_IPC_SHARED) {
+ vrflags |= VR_SHARED;
+ /* Shared memory has to be preallocated. */
+ if(m->VMM_FLAGS & (MAP_PREALLOC|MAP_ANON) !=
+ (MAP_PREALLOC|MAP_ANON)) {
+ return EINVAL;
+ }
+ }
if(m->VMM_FLAGS & MAP_CONTIG) vrflags |= VR_CONTIG;
if(len % VM_PAGE_SIZE)
if (!(vr->flags & VR_WRITABLE))
vri->vri_prot &= ~PROT_WRITE;
- vri->vri_flags = (vr->flags & VR_SHARED) ? MAP_SHARED : 0;
+ vri->vri_flags = (vr->flags & VR_SHARED) ? MAP_IPC_SHARED : 0;
next = vr->vaddr + vr->length;
region_incr_iter(&v_iter);