- Check for caddr_t. On some systems like Solaris/SPARC, mmap() address

type (first parameter) is caddr_t instead of void *. Explicitly cast
  address to (caddr_t) type and C++ implicit pointer conversion rules
  will do the rest. aka. caddr_t -> void * is OK unlike the opposite.
This commit is contained in:
gbeauche 2002-03-16 10:51:17 +00:00
parent 7ec7300784
commit 99efbfc712
3 changed files with 8 additions and 4 deletions

View File

@ -17,6 +17,9 @@
/* Define to 'off_t' if <sys/types.h> doesn't define. */
#undef loff_t
/* Define to 'char *' if <sys/types.h> doesn't define. */
#undef caddr_t
/* Define to 'int' if <sys/types.h> doesn't define. */
#undef socklen_t

View File

@ -216,6 +216,7 @@ AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(void *, 4)
AC_TYPE_OFF_T
AC_CHECK_TYPE(loff_t, off_t)
AC_CHECK_TYPE(caddr_t, [char *])
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_HEADER_TIME

View File

@ -96,7 +96,7 @@ void * vm_acquire(size_t size)
return VM_MAP_FAILED;
#else
#ifdef HAVE_MMAP_VM
if ((addr = mmap(next_address, size, VM_PAGE_DEFAULT, map_flags, zero_fd, 0)) == MAP_FAILED)
if ((addr = mmap((caddr_t)next_address, size, VM_PAGE_DEFAULT, map_flags, zero_fd, 0)) == MAP_FAILED)
return VM_MAP_FAILED;
next_address = (char *)addr + size;
@ -132,7 +132,7 @@ int vm_acquire_fixed(void * addr, size_t size)
return -1;
#else
#ifdef HAVE_MMAP_VM
if (mmap(addr, size, VM_PAGE_DEFAULT, map_flags | MAP_FIXED, zero_fd, 0) == MAP_FAILED)
if (mmap((caddr_t)addr, size, VM_PAGE_DEFAULT, map_flags | MAP_FIXED, zero_fd, 0) == MAP_FAILED)
return -1;
// Since I don't know the standard behavior of mmap(), zero-fill here
@ -166,7 +166,7 @@ int vm_release(void * addr, size_t size)
return -1;
#else
#ifdef HAVE_MMAP_VM
if (munmap(addr, size) != 0)
if (munmap((caddr_t)addr, size) != 0)
return -1;
#else
free(addr);
@ -186,7 +186,7 @@ int vm_protect(void * addr, size_t size, int prot)
return ret_code == KERN_SUCCESS ? 0 : -1;
#else
#ifdef HAVE_MMAP_VM
int ret_code = mprotect(addr, size, prot);
int ret_code = mprotect((caddr_t)addr, size, prot);
return ret_code == 0 ? 0 : -1;
#else
// Unsupported