/* -*-C-*-
-$Id: acconfig.h,v 11.6 2003/02/14 18:28:14 cph Exp $
+$Id: acconfig.h,v 11.7 2003/05/17 02:21:04 cph Exp $
-Copyright (c) 2000-2001 Massachusetts Institute of Technology
+Copyright 2002,2001,2003 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
# endif
#endif
+#ifdef HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+
+#ifdef HAVE_MMAP
+# if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
+# define MAP_ANONYMOUS MAP_ANON
+# endif
+# ifdef MAP_ANONYMOUS
+# define USE_MMAP_HEAP_MALLOC
+# endif
+#endif
+
/* Include the shared configuration header. */
#include "confshared.h"
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
dnl 02111-1307, USA.
-AC_REVISION([$Id: configure.in,v 11.21 2003/05/12 20:02:24 cph Exp $])
+AC_REVISION([$Id: configure.in,v 11.22 2003/05/17 02:21:09 cph Exp $])
AC_INIT(boot.c)
AC_CONFIG_HEADER(config.h)
AC_CHECK_HEADERS(sys/ptyio.h sys/socket.h sys/time.h sys/un.h sys/vfs.h)
AC_CHECK_HEADERS(stdbool.h termio.h termios.h unistd.h utime.h)
AC_CHECK_HEADERS(openssl/blowfish.h openssl/md5.h blowfish.h md5.h)
-AC_CHECK_HEADERS(mhash.h mcrypt.h gdbm.h curses.h term.h dlfcn.h)
+AC_CHECK_HEADERS(mhash.h mcrypt.h gdbm.h curses.h term.h dlfcn.h sys/mman.h)
dnl Checks for typedefs
AC_TYPE_MODE_T
AC_CHECK_FUNCS(ctermid)
AC_CHECK_FUNCS(dup2)
AC_CHECK_FUNCS(fcntl floor fpathconf frexp ftruncate)
-AC_CHECK_FUNCS(getcwd gethostbyname gethostname getlogin getpgrp)
+AC_CHECK_FUNCS(getcwd gethostbyname gethostname getlogin getpagesize getpgrp)
AC_CHECK_FUNCS(gettimeofday getwd grantpt)
AC_CHECK_FUNCS(kill)
AC_CHECK_FUNCS(lockf)
/* -*-C-*-
-$Id: confshared.h,v 11.5 2003/02/14 18:28:18 cph Exp $
+$Id: confshared.h,v 11.6 2003/05/17 02:21:13 cph Exp $
-Copyright (c) 2000, 2002 Massachusetts Institute of Technology
+Copyright 2000,2002,2003 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
# define MACHINE_TYPE "IA-32"
#endif
-#ifdef __linux__
- extern void * linux_heap_malloc (unsigned long);
-# define HEAP_MALLOC linux_heap_malloc
-# define HEAP_FREE(address)
-#endif
-
-#ifdef __FreeBSD__
- extern void * freebsd_heap_malloc (unsigned long);
-# define HEAP_MALLOC freebsd_heap_malloc
-# define HEAP_FREE(address)
-#endif
-
#endif /* __IA32__ */
\f
#ifdef mips
#endif
#endif /* __alpha */
+
+#ifdef USE_MMAP_HEAP_MALLOC
+ extern void * mmap_heap_malloc (unsigned long);
+# define HEAP_MALLOC mmap_heap_malloc
+# define HEAP_FREE(address)
+#endif
\f
#ifdef __OS2__
/* -*-C-*-
-$Id: ux.c,v 1.23 2003/02/14 18:28:24 cph Exp $
+$Id: ux.c,v 1.24 2003/05/17 02:21:17 cph Exp $
-Copyright (c) 1990-2002 Massachusetts Institute of Technology
+Copyright 1991,1992,1993,1996,1997,2000 Massachusetts Institute of Technology
+Copyright 2002,2003 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
UX_free (ptr);
}
-#ifdef __linux__
+#ifdef EMULATE_GETPAGESIZE
+#ifdef HAVE_SYSCONF
-#include <sys/mman.h>
-
-void *
-linux_heap_malloc (unsigned long requested_length)
+unsigned long
+DEFUN_VOID (UX_getpagesize)
{
- unsigned long ps = (getpagesize ());
- void * addr
- = (mmap (((void *)
-#ifndef VALGRIND_MODE
- ps
-#else
- 0x10000
-#endif
- ),
- (((requested_length + (ps - 1)) / ps) * ps),
- (PROT_EXEC | PROT_READ | PROT_WRITE),
- (MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED),
- 0, 0));
- return ((addr == ((void *) (-1))) ? 0 : addr);
+ static int vp = 0;
+ static long v;
+ if (!vp)
+ {
+ v = (sysconf (_SC_PAGESIZE));
+ vp = 1;
+ }
+ return ((v <= 0) ? 0x1000 : v);
}
-#endif /* __linux__ */
+#endif /* HAVE_SYSCONF */
+#endif /* EMULATE_GETPAGESIZE */
-#ifdef __FreeBSD__
+#ifdef USE_MMAP_HEAP_MALLOC
-#include <sys/mman.h>
+#ifdef VALGRIND_MODE
+# define MMAP_BASE_ADDRESS 0x10000
+#else
+# define MMAP_BASE_ADDRESS (UX_getpagesize ())
+#endif
-void *
-freebsd_heap_malloc (unsigned long requested_length)
+#ifndef MAP_FAILED
+# define MAP_FAILED ((void *) (-1))
+#endif
+
+static void *
+mmap_heap_malloc_1 (unsigned long requested_length, int fixedp)
{
- unsigned long ps = (getpagesize ());
+ unsigned long ps = (UX_getpagesize ());
void * addr
- = (mmap (((void *) ps),
+ = (mmap (((void *) MMAP_BASE_ADDRESS),
(((requested_length + (ps - 1)) / ps) * ps),
(PROT_EXEC | PROT_READ | PROT_WRITE),
- (MAP_PRIVATE | MAP_ANON | MAP_FIXED),
- (-1), 0));
+ (MAP_PRIVATE | MAP_ANONYMOUS | (fixedp ? MAP_FIXED : 0)),
+ /* Ignored by GNU/Linux, required by FreeBSD and Solaris. */
+ (-1),
+ 0));
return ((addr == MAP_FAILED) ? 0 : addr);
}
-#endif /* __FreeBSD__ */
+void *
+mmap_heap_malloc (unsigned long requested_length)
+{
+ void * addr = (mmap_heap_malloc_1 (requested_length, 1));
+ if (addr == 0)
+ /* Can't get exact address; try for something nearby. */
+ addr = (mmap_heap_malloc_1 (requested_length, 0));
+ if (addr == 0)
+ /* mmap not returning anything useful. */
+ addr = (UX_malloc (requested_length));
+ return (addr);
+}
+
+#endif /* USE_MMAP_HEAP_MALLOC */
/* -*-C-*-
-$Id: ux.h,v 1.76 2003/02/14 18:28:24 cph Exp $
+$Id: ux.h,v 1.77 2003/05/17 02:21:22 cph Exp $
-Copyright (c) 1988-2000 Massachusetts Institute of Technology
+Copyright 1990,1991,1992,1993,1994,1995 Massachusetts Institute of Technology
+Copyright 1996,1997,1998,1999,2000,2003 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
# include <unistd.h>
#endif
+#ifdef HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+
/* GNU C library defines environ if __USE_GNU is defined. */
#ifndef __USE_GNU
extern char ** environ;
extern int EXFUN (UX_kill, (pid_t pid, int sig));
# define EMULATE_KILL
#endif
+
+#ifdef HAVE_GETPAGESIZE
+# define UX_getpagesize getpagesize
+#else
+ extern unsigned long EXFUN (UX_getpagesize, (void));
+# define EMULATE_GETPAGESIZE
+#endif
\f
#ifdef HAVE_POLL
# ifndef INFTIM