roff_reset(roff);
if (ln.buf)
free(ln.buf);
+#ifdef __minix
+ assert(!with_mmap);
+#else
if (with_mmap)
munmap(blk.buf, blk.sz);
else
+#endif
free(blk.buf);
return;
free(i_ptr);
i_ptr = NULL;
if (i_womp != NULL) {
+#ifndef __minix
munmap(i_womp, i_size);
+#else
+ free(i_womp);
+#endif
i_womp = NULL;
}
} else {
new_size = *lines_allocated * 3 / 2;
p = realloc(i_ptr, (new_size + 2) * sizeof(char *));
if (p == NULL) { /* shucks, it was a near thing */
+#ifndef __minix
munmap(i_womp, i_size);
+#else
+ free(i_womp);
+#endif
i_womp = NULL;
free(i_ptr);
i_ptr = NULL;
if(vlen % PAGE_SIZE) {
vlen -= vlen % PAGE_SIZE;
}
- munmap((void *) vaddr, vlen);
+ minix_munmap((void *) vaddr, vlen);
m_geom[IMGRD_DEV].dv_base= cvul64(0);
m_geom[IMGRD_DEV].dv_size= cvul64(0);
m_vaddrs[IMGRD_DEV] = 0;
panic("huge old ramdisk");
}
size = ex64lo(dv->dv_size);
- munmap((void *) m_vaddrs[dev], size);
+ minix_munmap((void *) m_vaddrs[dev], size);
m_vaddrs[dev] = (vir_bytes) NULL;
}
#endif
/* Try to allocate a piece of memory for the RAM disk. */
- if((mem = mmap(NULL, ramdev_size, PROT_READ|PROT_WRITE,
+ if((mem = minix_mmap(NULL, ramdev_size, PROT_READ|PROT_WRITE,
MAP_PREALLOC|MAP_ANON, -1, 0)) == MAP_FAILED) {
printf("MEM: failed to get memory for ramdisk\n");
return(ENOMEM);
/* mmap() error return */
#define MAP_FAILED ((void *)-1)
-_PROTOTYPE( void *mmap, (void *, size_t, int, int, int, off_t));
-_PROTOTYPE( int munmap, (void *, size_t));
-_PROTOTYPE( int munmap_text, (void *, size_t));
+_PROTOTYPE( void *minix_mmap, (void *, size_t, int, int, int, off_t));
+_PROTOTYPE( int minix_munmap, (void *, size_t));
+_PROTOTYPE( int minix_munmap_text, (void *, size_t));
_PROTOTYPE( void *vm_remap, (endpoint_t d, endpoint_t s, void *da,
void *sa, size_t si));
_PROTOTYPE( int vm_unmap, (endpoint_t endpt, void *addr));
/* unmap 0-page code */
push $I386_PAGE_SIZE
push $crtso
- call _munmap_text /* unmap_text(crtso, I386_PAGE_SIZE) */
+ call _minix_munmap_text /* unmap_text(crtso, I386_PAGE_SIZE) */
add $8, %esp
#ifdef __ACK__
/* unmap 0-page data */
push $I386_PAGE_SIZE
push $romstart
- call _munmap /* munmap(romstart, I386_PAGE_SIZE) */
+ call _minix_munmap /* munmap(romstart, I386_PAGE_SIZE) */
add $8, %esp
#endif
#include <string.h>
#include <sys/mman.h>
+#define mmap minix_mmap
+#define munmap minix_munmap
+
#include "malloc-debug.h"
#if 0
#define system _system
#define tcdrain _tcdrain
#define wait _wait
+#define minix_mmap _minix_mmap
+#define minix_munmap _minix_munmap
+#define minix_munmap_text _minix_munmap_text
#endif
#endif /* _NAMESPACE_H_ */
#define _SYSTEM 1
#include <lib.h>
-#define mmap _mmap
-#define munmap _munmap
-#define munmap_text _munmap_text
+#define minix_mmap _minix_mmap
+#define minix_munmap _minix_munmap
+#define minix_munmap_text _minix_munmap_text
#define vm_remap _vm_remap
#define vm_unmap _vm_unmap
#define vm_getphys _vm_getphys
#include <string.h>
#include <errno.h>
-PUBLIC void *mmap(void *addr, size_t len, int prot, int flags,
+PUBLIC void *minix_mmap(void *addr, size_t len, int prot, int flags,
int fd, off_t offset)
{
message m;
return (void *) m.VMM_RETADDR;
}
-PUBLIC int munmap(void *addr, size_t len)
+PUBLIC int minix_munmap(void *addr, size_t len)
{
message m;
}
-PUBLIC int munmap_text(void *addr, size_t len)
+PUBLIC int minix_munmap_text(void *addr, size_t len)
{
message m;
#include <machine/asm.h>
-IMPORT(_mmap)
-ENTRY(mmap)
- jmp _C_LABEL(_mmap)
+IMPORT(_minix_mmap)
+ENTRY(minix_mmap)
+ jmp _C_LABEL(_minix_mmap)
#include <machine/asm.h>
-IMPORT(_munmap)
-ENTRY(munmap)
- jmp _C_LABEL(_munmap)
+IMPORT(_minix_munmap)
+ENTRY(minix_munmap)
+ jmp _C_LABEL(_minix_munmap)
-IMPORT(_munmap_text)
-ENTRY(munmap_text)
- jmp _C_LABEL(_munmap_text)
+IMPORT(_minix_munmap_text)
+ENTRY(minix_munmap_text)
+ jmp _C_LABEL(_minix_munmap_text)
if(flags & AC_ALIGN64K)
mmapflags |= MAP_ALIGN64K;
- /* First try to get memory with mmap. This is guaranteed
+ /* First try to get memory with minix_mmap. This is guaranteed
* to be page-aligned, and we can tell VM it has to be
* pre-allocated and contiguous.
*/
errno = 0;
- buf = (vir_bytes) mmap(0, len, PROT_READ|PROT_WRITE, mmapflags, -1, 0);
+ buf = (vir_bytes) minix_mmap(0, len, PROT_READ|PROT_WRITE, mmapflags, -1, 0);
/* If that failed, maybe we're not running in paged mode.
* If that's the case, ENXIO will be returned.
int free_contig(void *addr, size_t len)
{
- return munmap(addr, len);
+ return minix_munmap(addr, len);
}
cdbr->mmap_size = (size_t)sb.st_size;
#ifdef __minix
- cdbr->mmap_base = mmap(NULL, cdbr->mmap_size, PROT_READ, MAP_ANON, -1, (off_t)0);
- if (cdbr->mmap_base == MAP_FAILED) {
+ if(!(cdbr->mmap_base = malloc(cdbr->mmap_size))) {
free(cdbr);
return NULL;
}
if (read(fd, cdbr->mmap_base, cdbr->mmap_size) != cdbr->mmap_size)
{
- munmap(cdbr->mmap_base, cdbr->mmap_size);
+ free(cdbr->mmap_base);
free(cdbr);
return NULL;
}
void
cdbr_close(struct cdbr *cdbr)
{
+#ifdef __minix
+ free(cdbr->mmap_base);
+#else
munmap(cdbr->mmap_base, cdbr->mmap_size);
+#endif
free(cdbr);
}
}
#ifdef __minix
- head = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_ANON, -1, (off_t)0);
- if (head == MAP_FAILED) {
+ if(!(head = malloc(st.st_size))) {
ret = errno;
goto error;
}
_DIAGASSERT(r != NULL);
if (_region_head(r) != NULL) {
+#ifdef __minix
+ free(_region_head(r));
+#else
(void)munmap(_region_head(r), _region_size(r));
+#endif
_region_init(r, NULL, 0);
}
}
/* Committed to closing. */
status = RET_SUCCESS;
+#ifndef __minix
if (F_ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize))
status = RET_ERROR;
+#else
+ assert(!F_ISSET(t, R_MEMMAPPED));
+#endif
if (!F_ISSET(t, R_INMEM)) {
if (F_ISSET(t, R_CLOSEFP)) {
#define mi_vector_hash _mi_vector_hash
#define mkstemp _mkstemp
#define mktime_z _mktime_z
-#define mmap _mmap
#define mpool_close _mpool_close
#define mpool_filter _mpool_filter
#define mpool_get _mpool_get
#define mkdir _mkdir
#define mkfifo _mkfifo
#define mknod _mknod
-#define munmap _munmap
-#define munmap_text _munmap_text
#define open _open
#define pathconf _pathconf
#define ptrace _ptrace
}
if (catd) {
+#ifdef __minix
+ free(catd->__data);
+#else
munmap(catd->__data, (size_t)catd->__size);
+#endif
free (catd);
}
}
#ifdef __minix
- data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_ANON, -1, (off_t)0);
- if (data == MAP_FAILED) {
+ if(!(data = malloc((size_t)st.st_size))) {
return (nl_catd)-1;
}
if (read(fd, data, st.st_size) != st.st_size)
{
- munmap(data, (size_t)st.st_size);
+ free(data);
return (nl_catd)-1;
}
close (fd);
if (ntohl((u_int32_t)((struct _nls_cat_hdr *)data)->__magic) !=
_NLS_MAGIC) {
+#ifdef __minix
+ free(data);
+#else
munmap(data, (size_t)st.st_size);
+#endif
return (nl_catd)-1;
}
if ((catd = malloc(sizeof (*catd))) == NULL) {
+#ifdef __minix
+ free(data);
+#else
munmap(data, (size_t)st.st_size);
+#endif
return (nl_catd)-1;
}
*
*/
+#ifdef __minix
+#define mmap minix_mmap
+#define munmap minix_munmap
+#endif
+
/*
* Defining MALLOC_EXTRA_SANITY will enable extra checks which are related
* to internal conditions and consistency in malloc.c. This has a
/* INCLUDES HERE */
#ifdef __weak_alias
-__weak_alias(mmap, _mmap)
-__weak_alias(munmap, _munmap)
-__weak_alias(munmap_text, _munmap_text)
__weak_alias(vm_remap, _vm_remap)
__weak_alias(vm_unmap, _vm_unmap)
__weak_alias(vm_getphys, _vm_getphys)
#include <string.h>
#include <errno.h>
-PUBLIC void *mmap(void *addr, size_t len, int prot, int flags,
+PUBLIC void *minix_mmap(void *addr, size_t len, int prot, int flags,
int fd, off_t offset)
{
message m;
return (void *) m.VMM_RETADDR;
}
-PUBLIC int munmap(void *addr, size_t len)
+PUBLIC int minix_munmap(void *addr, size_t len)
{
message m;
}
-PUBLIC int munmap_text(void *addr, size_t len)
+PUBLIC int minix_munmap_text(void *addr, size_t len)
{
message m;
#include <sys/cdefs.h>
__BEGIN_DECLS
+#ifndef __minix
void * mmap(void *, size_t, int, int, int, off_t);
int munmap(void *, size_t);
-
-#ifdef __minix
-int munmap_text(void *, size_t);
+#else
+void * minix_mmap(void *, size_t, int, int, int, off_t);
+int minix_munmap(void *, size_t);
+int minix_munmap_text(void *, size_t);
void * vm_remap(int d, int s, void *da, void *sa, size_t si);
int vm_unmap(int endpt, void *addr);
unsigned long vm_getphys(int endpt, void *addr);
return ENOSPC;
shm = &shm_list[shm_list_nr];
memset(shm, 0, sizeof(struct shm_struct));
- shm->page = (vir_bytes) mmap(0, size,
+ shm->page = (vir_bytes) minix_mmap(0, size,
PROT_READ|PROT_WRITE,
MAP_CONTIG|MAP_PREALLOC|MAP_ANON|MAP_IPC_SHARED,
-1, 0);
int size = shm_list[i].shmid_ds.shm_segsz;
if (size % I386_PAGE_SIZE)
size += I386_PAGE_SIZE - size % I386_PAGE_SIZE;
- munmap((void *)shm_list[i].page, size);
+ minix_munmap((void *)shm_list[i].page, size);
}
}
shm_list_nr = j;
#include "kernel/type.h"
#include "kernel/proc.h"
-#define munmap _munmap
-#define munmap_text _munmap_text
+#define minix_munmap _minix_munmap
+#define minix_munmap_text _minix_munmap_text
#include <sys/mman.h>
-#undef munmap
-#undef munmap_text
+#undef minix_munmap
+#undef minix_munmap_text
/*===========================================================================*
* get_free_pid *
int unmap_ok = 0;
-PUBLIC int munmap(void *addrstart, vir_bytes len)
+PUBLIC int minix_munmap(void *addrstart, vir_bytes len)
{
if(!unmap_ok)
return ENOSYS;
- return _munmap(addrstart, len);
+ return _minix_munmap(addrstart, len);
}
-PUBLIC int munmap_text(void *addrstart, vir_bytes len)
+PUBLIC int minix_munmap_text(void *addrstart, vir_bytes len)
{
if(!unmap_ok)
return ENOSYS;
- return _munmap_text(addrstart, len);
+ return _minix_munmap_text(addrstart, len);
}
#include "inc.h"
-#define munmap _munmap
-#define munmap_text _munmap_text
+#define minix_munmap _minix_munmap
+#define minix_munmap_text _minix_munmap_text
#include <sys/mman.h>
-#undef munmap
-#undef munmap_text
+#undef minix_munmap
+#undef minix_munmap_text
PUBLIC int unmap_ok = 0;
/*===========================================================================*
- * munmap *
+ * minix_munmap *
*===========================================================================*/
-PUBLIC int munmap(void *addrstart, vir_bytes len)
+PUBLIC int minix_munmap(void *addrstart, vir_bytes len)
{
if(!unmap_ok)
return ENOSYS;
- return _munmap(addrstart, len);
+ return _minix_munmap(addrstart, len);
}
/*===========================================================================*
- * munmap_text *
+ * minix_munmap_text *
*===========================================================================*/
-PUBLIC int munmap_text(void *addrstart, vir_bytes len)
+PUBLIC int minix_munmap_text(void *addrstart, vir_bytes len)
{
if(!unmap_ok)
return ENOSYS;
- return _munmap_text(addrstart, len);
+ return _minix_munmap_text(addrstart, len);
}