tweak the idea between having a MMU and actually using it

This commit is contained in:
Mike Frysinger 2006-02-18 07:03:24 +00:00
parent aa5490a851
commit 010301e968
29 changed files with 69 additions and 59 deletions

View File

@ -45,7 +45,7 @@ include/bits/uClibc_config.h: extra/config/conf .config
# in order to generate the headers correctly :(. That
# means we can't use the $(HOSTCC) in order to get the
# correct output.
ifeq ($(ARCH_HAS_MMU),y)
ifeq ($(ARCH_USE_MMU),y)
export header_extra_args =
else
export header_extra_args = -n

View File

@ -48,6 +48,16 @@ config ARCH_HAS_MMU
Most people will answer Y.
config ARCH_USE_MMU
bool "Do you want to utilize the MMU?"
depends on ARCH_HAS_MMU
default y
help
If your target CPU has a MMU, and you wish to actually utilize it,
then answer Y here. Normal Linux requires an MMU.
If you're unsure, answer Y.
config UCLIBC_HAS_FLOATS
bool "Enable floating point number support"
default y

View File

@ -99,7 +99,7 @@ extern int madvise (void *__addr, size_t __len, int __advice) __THROW;
extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
#endif
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
be memory resident. */
extern int mlock (__const void *__addr, size_t __len) __THROW;

View File

@ -703,7 +703,7 @@ extern int setresgid (__gid_t __egid, __gid_t __rgid, __gid_t __sgid)
#endif
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
/* Clone the calling process, creating an exact copy.
Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
@ -885,7 +885,7 @@ extern void endusershell (void) __THROW; /* Discard cached info. */
extern void setusershell (void) __THROW; /* Rewind and re-read the file. */
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
/* Put the program in the background, and dissociate from the controlling
terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
redirects stdin, stdout, and stderr to /dev/null. */

View File

@ -174,7 +174,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
hstbuflen = 1024;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
tmphstbuf = alloca (hstbuflen);
#else
tmphstbuf = malloc (hstbuflen);
@ -186,7 +186,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
if (herr != NETDB_INTERNAL || errno != ERANGE)
{
__set_h_errno (herr);
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
free(tmphstbuf);
#endif
herror(*ahost);
@ -196,7 +196,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
{
/* Enlarge the buffer. */
hstbuflen *= 2;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
tmphstbuf = alloca (hstbuflen);
#else
if (tmphstbuf) {
@ -206,7 +206,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
#endif
}
}
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
free(tmphstbuf);
#endif
#else /* call the non-reentrant version */
@ -388,7 +388,7 @@ int ruserok(rhost, superuser, ruser, luser)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
buflen = 1024;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
buffer = alloca (buflen);
#else
buffer = malloc (buflen);
@ -398,7 +398,7 @@ int ruserok(rhost, superuser, ruser, luser)
buflen, &hp, &herr) != 0 || hp == NULL)
{
if (herr != NETDB_INTERNAL || errno != ERANGE) {
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
return -1;
@ -406,7 +406,7 @@ int ruserok(rhost, superuser, ruser, luser)
{
/* Enlarge the buffer. */
buflen *= 2;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
buffer = alloca (buflen);
#else
if (buffer) {
@ -416,7 +416,7 @@ int ruserok(rhost, superuser, ruser, luser)
#endif
}
}
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
#else
@ -513,7 +513,7 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
struct passwd pwdbuf;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
char *buffer = alloca (buflen);
#else
char *buffer = malloc (buflen);
@ -522,12 +522,12 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
if (getpwnam_r (luser, &pwdbuf, buffer,
buflen, &pwd) != 0 || pwd == NULL)
{
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
return -1;
}
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
free(buffer);
#endif
#else

View File

@ -33,7 +33,7 @@ libc_hidden_proto(exit)
#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
libc_hidden_proto(strrchr)
#endif
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
libc_hidden_proto(memcpy)
libc_hidden_proto(getgid)
libc_hidden_proto(getuid)
@ -131,7 +131,7 @@ libc_hidden_data_def(__pagesize)
# define O_NOFOLLOW 0
#endif
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
static void __check_one_fd(int fd, int mode)
{
/* Check if the specified fd is already open */
@ -272,7 +272,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
char **argv, void (*app_init)(void), void (*app_fini)(void),
void (*rtld_fini)(void), void *stack_end)
{
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
unsigned long *aux_dat;
ElfW(auxv_t) auxvt[AT_EGID + 1];
#endif
@ -293,7 +293,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
__environ = &argv[argc];
}
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
/* Pull stuff from the ELF header when possible */
aux_dat = (unsigned long*)__environ;
while (*aux_dat) {
@ -314,7 +314,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
* __uClibc_init() regardless, to be sure the right thing happens. */
__uClibc_init();
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
/* Make certain getpagesize() gives the correct answer */
__pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;

View File

@ -36,7 +36,7 @@ void *malloc(size_t size)
#endif
}
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
# define MMAP_FLAGS MAP_PRIVATE | MAP_ANONYMOUS
#else
# define MMAP_FLAGS MAP_SHARED | MAP_ANONYMOUS

View File

@ -354,7 +354,7 @@ libc_hidden_proto(__malloc_lock)
#define MAP_ANONYMOUS MAP_ANON
#endif
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
#define MMAP(addr, size, prot) \
(mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS, 0, 0))

View File

@ -106,7 +106,7 @@ malloc_from_heap (size_t size, struct heap *heap)
#else /* !MALLOC_USE_SBRK */
/* Otherwise, use mmap. */
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
block = mmap ((void *)0, block_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#else

View File

@ -44,7 +44,7 @@ libc_hidden_proto(__pagesize)
heap, instead of mmap/munmap. This is a tradeoff -- sbrk is faster than
mmap/munmap, and guarantees contiguous allocation, but is also less
flexible, and causes the heap to only be shrinkable from the end. */
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
# define MALLOC_USE_SBRK
#endif

View File

@ -110,7 +110,7 @@ _start:
mov fp, #0
mov lr, #0
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
/* Pop argc off the stack and save a pointer to argv */
ldr a2, [sp], #4
mov a3, sp

View File

@ -43,21 +43,21 @@
#define _POSIX_MAPPED_FILES 200112L
/* Locking of all memory is supported. */
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
# define _POSIX_MEMLOCK 200112L
#else
# undef _POSIX_MEMLOCK
#endif
/* Locking of ranges of memory is supported. */
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
# define _POSIX_MEMLOCK_RANGE 200112L
#else
# define _POSIX_MEMLOCK_RANGE
#endif
/* Setting of memory protections is supported. */
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
# define _POSIX_MEMORY_PROTECTION 1
#else
# undef _POSIX_MEMORY_PROTECTION

View File

@ -10,7 +10,7 @@
#include "syscalls.h"
#include <unistd.h>
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
#ifdef __NR_fork
extern __typeof(fork) __libc_fork;
#define __NR___libc_fork __NR_fork

View File

@ -8,7 +8,7 @@
*/
#include "syscalls.h"
#if defined __ARCH_HAS_MMU__ && defined __NR_ioperm
#if defined __ARCH_USE_MMU__ && defined __NR_ioperm
/* psm: can't #include <sys/io.h>, some archs miss it */
extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on) __THROW;
_syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);

View File

@ -8,7 +8,7 @@
*/
#include "syscalls.h"
#if defined __ARCH_HAS_MMU__ && defined __NR_iopl
#if defined __ARCH_USE_MMU__ && defined __NR_iopl
/* psm: can't #include <sys/io.h>, some archs miss it */
extern int iopl(int __level) __THROW;
_syscall1(int, iopl, int, level);

View File

@ -9,6 +9,6 @@
#include "syscalls.h"
#include <sys/mman.h>
#if defined __ARCH_HAS_MMU__ && defined __NR_mlock
#if defined __ARCH_USE_MMU__ && defined __NR_mlock
_syscall2(int, mlock, const void *, addr, size_t, len);
#endif

View File

@ -9,6 +9,6 @@
#include "syscalls.h"
#include <sys/mman.h>
#if defined __ARCH_HAS_MMU__ && defined __NR_mlockall
#if defined __ARCH_USE_MMU__ && defined __NR_mlockall
_syscall1(int, mlockall, int, flags);
#endif

View File

@ -9,6 +9,6 @@
#include "syscalls.h"
#include <sys/mman.h>
#if defined __ARCH_HAS_MMU__ && defined __NR_munlock
#if defined __ARCH_USE_MMU__ && defined __NR_munlock
_syscall2(int, munlock, const void *, addr, size_t, len);
#endif

View File

@ -9,6 +9,6 @@
#include "syscalls.h"
#include <sys/mman.h>
#if defined __ARCH_HAS_MMU__
#if defined __ARCH_USE_MMU__
_syscall0(int, munlockall);
#endif

View File

@ -12,7 +12,7 @@ CSRC := $(notdir $(wildcard $(UNISTD_DIR)/*.c))
# multi source
CSRC := $(filter-out exec.c,$(CSRC))
ifeq ($(ARCH_HAS_MMU),y)
ifeq ($(ARCH_USE_MMU),y)
CSRC := $(filter-out __exec_alloc.c,$(CSRC))
else
CSRC := $(filter-out daemon.c,$(CSRC))

View File

@ -53,7 +53,7 @@ libc_hidden_proto(getenv)
libc_hidden_proto(__environ)
/**********************************************************************/
#if defined(__ARCH_HAS_MMU__) || defined(__UCLIBC_UCLINUX_BROKEN_MUNMAP__)
#if defined(__ARCH_USE_MMU__) || defined(__UCLIBC_UCLINUX_BROKEN_MUNMAP__)
/* We have an MMU, so use alloca() to grab space for buffers and
* arg lists. Also fall back to alloca() if munmap() is broken. */

View File

@ -258,7 +258,7 @@ extern pthread_descr __pthread_main_thread;
* the bounds a-priori. -StS */
extern char *__pthread_initial_thread_bos;
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
extern char *__pthread_initial_thread_tos;
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \
if ((tos)>=__pthread_initial_thread_bos \
@ -266,7 +266,7 @@ extern char *__pthread_initial_thread_tos;
__pthread_initial_thread_bos = (tos)+1
#else
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */
#endif /* __ARCH_HAS_MMU__ */
#endif /* __ARCH_USE_MMU__ */
/* Indicate whether at least one thread has a user-defined stack (if 1),
@ -330,7 +330,7 @@ extern size_t __pagesize;
THREAD_SELF implementation is used, this must be a power of two and
a multiple of PAGE_SIZE. */
#ifndef STACK_SIZE
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
#define STACK_SIZE (2 * 1024 * 1024)
#else
#define STACK_SIZE (4 * __pagesize)
@ -387,7 +387,7 @@ static inline pthread_descr thread_self (void)
return THREAD_SELF;
#else
char *sp = CURRENT_STACK_FRAME;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
if (sp >= __pthread_initial_thread_bos)
return &__pthread_initial_thread;
else if (sp >= __pthread_manager_thread_bos
@ -420,7 +420,7 @@ static inline pthread_descr thread_self (void)
else {
return __pthread_find_self();
}
#endif /* __ARCH_HAS_MMU__ */
#endif /* __ARCH_USE_MMU__ */
#endif
}

View File

@ -360,7 +360,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
}
else
{
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
stacksize = STACK_SIZE - pagesize;
if (attr != NULL)
stacksize = MIN (stacksize, roundup(attr->__stacksize, pagesize));
@ -450,7 +450,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
/* on non-MMU systems we always have non-standard stack frames */
__pthread_nonstandard_stacks = 1;
#endif /* __ARCH_HAS_MMU__ */
#endif /* __ARCH_USE_MMU__ */
}
/* Clear the thread data structure. */
@ -495,7 +495,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
&new_thread, &new_thread_bottom,
&guardaddr, &guardsize) == 0)
break;
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
else
/* When there is MMU, mmap () is used to allocate the stack. If one
* segment is already mapped, we should continue to see if we can
@ -632,14 +632,14 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* Free the stack if we allocated it */
if (attr == NULL || !attr->__stackaddr_set)
{
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
if (new_thread->p_guardsize != 0)
munmap(new_thread->p_guardaddr, new_thread->p_guardsize);
munmap((caddr_t)((char *)(new_thread+1) - INITIAL_STACK_SIZE),
INITIAL_STACK_SIZE);
#else
free(new_thread_bottom);
#endif /* __ARCH_HAS_MMU__ */
#endif /* __ARCH_USE_MMU__ */
}
__pthread_handles[sseg].h_descr = NULL;
__pthread_handles[sseg].h_bottom = NULL;
@ -716,7 +716,7 @@ static void pthread_free(pthread_descr th)
/* If initial thread, nothing to free */
if (th == &__pthread_initial_thread) return;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
if (!th->p_userstack)
{
/* Free the stack and thread descriptor area */
@ -729,7 +729,7 @@ static void pthread_free(pthread_descr th)
if (!th->p_userstack) {
free(h_bottom_save);
}
#endif /* __ARCH_HAS_MMU__ */
#endif /* __ARCH_USE_MMU__ */
}
/* Handle threads that have exited */

View File

@ -18,7 +18,7 @@
#include <errno.h>
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
#include <stddef.h>
#include <stdlib.h>

View File

@ -172,9 +172,9 @@ char *__pthread_initial_thread_bos = NULL;
* This is adapted when other stacks are malloc'ed since we don't know
* the bounds a-priori. -StS */
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
char *__pthread_initial_thread_tos = NULL;
#endif /* __ARCH_HAS_MMU__ */
#endif /* __ARCH_USE_MMU__ */
/* File descriptor for sending requests to the thread manager. */
/* Initially -1, meaning that the thread manager is not running. */
@ -363,7 +363,7 @@ static void pthread_initialize(void)
{
struct sigaction sa;
sigset_t mask;
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
struct rlimit limit;
rlim_t max_stack;
#endif
@ -410,7 +410,7 @@ static void pthread_initialize(void)
beyond STACK_SIZE minus two pages (one page for the thread descriptor
immediately beyond, and one page to act as a guard page). */
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
/* We cannot allocate a huge chunk of memory to mmap all thread stacks later
* on a non-MMU system. Thus, we don't need the rlimit either. -StS */
getrlimit(RLIMIT_STACK, &limit);
@ -429,7 +429,7 @@ static void pthread_initialize(void)
__pthread_initial_thread_bos = (char *) 1; /* set it non-zero so we know we have been here */
PDEBUG("initial thread stack bounds: bos=%p, tos=%p\n",
__pthread_initial_thread_bos, __pthread_initial_thread_tos);
#endif /* __ARCH_HAS_MMU__ */
#endif /* __ARCH_USE_MMU__ */
/* Setup signal handlers for the initial thread.
Since signal handlers are shared between threads, these settings

View File

@ -648,7 +648,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
new_thread = (pthread_descr) stack_addr;
#endif
break;
#ifndef __ARCH_HAS_MMU__
#ifndef __ARCH_USE_MMU__
} else {
/* When there is MMU, mmap () is used to allocate the stack. If one
* segment is already mapped, we should continue to see if we can

View File

@ -17,7 +17,7 @@ libutil_DIR := $(top_srcdir)libutil
libutil_OUT := $(top_builddir)libutil
libutil_SRC := $(wildcard $(libutil_DIR)/*.c)
ifneq ($(ARCH_HAS_MMU),y)
ifneq ($(ARCH_USE_MMU),y)
libutil_SRC := $(filter-out $(libutil_DIR)/forkpty.c,$(libutil_SRC))
endif
libutil_OBJ := $(patsubst $(libutil_DIR)/%.c,$(libutil_OUT)/%.o,$(libutil_SRC))

View File

@ -193,7 +193,7 @@ timeout_handler (int sig __attribute__ ((unused)))
int
main (int argc, char *argv[])
{
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
int direct = 0; /* Directly call the test function? */
#else
int direct = 1;

View File

@ -32,7 +32,7 @@
#define GOT2 (1 << 2)
#define GOT3 (1 << 3)
#ifdef __ARCH_HAS_MMU__
#ifdef __ARCH_USE_MMU__
void child_handler(int sig)
{