Libraries updates and cleanup

* Updating common/lib
 * Updating lib/csu
 * Updating lib/libc
 * Updating libexec/ld.elf_so
 * Corrected test on __minix in featuretest to actually follow the
   meaning of the comment.
 * Cleaned up _REENTRANT-related defintions.
 * Disabled -D_REENTRANT for libfetch
 * Removing some unneeded __NBSD_LIBC defines and tests

Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
This commit is contained in:
2012-11-15 12:06:41 +01:00
parent f6aac1c3b5
commit f14fb60209
1285 changed files with 44244 additions and 14308 deletions

View File

@@ -1,6 +1,8 @@
# Makefile for kernel
.include <bsd.own.mk>
BINDIR= /usr/sbin
MAN=
PROG= kernel
.include "arch/${MACHINE_ARCH}/Makefile.inc"
@@ -8,29 +10,28 @@ PROG= kernel
SRCS+= clock.c cpulocals.c interrupt.c main.c proc.c system.c \
table.c utility.c usermapped_data.c
LINKERSCRIPT=${.CURDIR}/arch/${MACHINE_ARCH}/kernel.lds
DPADD+= ${LIBTIMERS} ${LIBSYS} ${LIBEXEC} ${LIBMINLIB}
LDADD+= -ltimers -lsys -lexec -lminlib -L/usr/lib
DPADD+= ${LIBTIMERS} ${LIBSYS} ${LIBEXEC} ${LINKERSCRIPT}
LDADD+= -ltimers -lsys -lexec
LINKERSCRIPT= ${.CURDIR}/arch/${MACHINE_ARCH}/kernel.lds
CFLAGS += -D__kernel__
CPPFLAGS+= -fno-stack-protector -D_NETBSD_SOURCE -D_MINIX
LDFLAGS+= -T ${LINKERSCRIPT}
LDFLAGS+= -nostdlib -L${DESTDIR}/${LIBDIR}
LDADD+= -lminlib
DPADD+= ${LIBMINLIB}
.if !empty(CC:M*gcc)
LDADD+= -lgcc -lsys -lgcc -lminc
.elif !empty(CC:M*clang)
LDADD+= -L/usr/pkg/compiler-rt/lib -lCompilerRT-Generic -lsys -lCompilerRT-Generic -lminc
DPADD+= ${LIBC}
.endif
LDFLAGS+= -nostdlib
CFLAGS += -fno-stack-protector
CPPFLAGS+= -I${.CURDIR} -I${.CURDIR}/arch/${MACHINE_ARCH}/include -I${NETBSDSRCDIR}
CPPFLAGS+= -D_NETBSD_SOURCE -D_MINIX -D__kernel__
BINDIR= /usr/sbin
MAN=
# kernel headers are always called through kernel/*.h
CPPFLAGS+= -I${NETBSDSRCDIR}
# kernel headers are always called through kernel/*.hi, this
# time for generated headers, during cross compilation
CPPFLAGS+= -I${.OBJDIR}/..
# Machine-dependent headers, order is important!
CPPFLAGS+= -I${.CURDIR}/arch/${MACHINE_ARCH}
CPPFLAGS+= -I${.CURDIR}/arch/${MACHINE_ARCH}/include
CPPFLAGS+= -I${NETBSDSRCDIR}/include/arch/${MACHINE_ARCH}/include
.include "system/Makefile.inc"
@@ -69,12 +70,10 @@ CPPFLAGS+= -DUSE_STATECTL
CPPFLAGS+= -DUSE_TRACE
.endif
.include <bsd.prog.mk>
CLEANFILES+=extracted-errno.h extracted-mfield.h extracted-mtype.h procoffsets.h
debug.d: extracted-errno.h extracted-mfield.h extracted-mtype.h
CLEANFILES+=extracted-errno.h extracted-mfield.h extracted-mtype.h procoffsets.h
extracted-errno.h: extract-errno.sh ../include/errno.h
${_MKTARGET_CREATE}
cd ${.CURDIR} ; ${HOST_SH} extract-errno.sh > ${.OBJDIR}/extracted-errno.h
@@ -87,7 +86,4 @@ extracted-mtype.h: extract-mtype.sh ../include/minix/com.h
${_MKTARGET_CREATE}
cd ${.CURDIR} ; ${HOST_SH} extract-mtype.sh > ${.OBJDIR}/extracted-mtype.h
clean:
rm -f extracted-errno.h extracted-mfield.h extracted-mtype.h
.include <minix.bootprog.mk>

View File

@@ -1,5 +1,5 @@
#include "kernel.h"
#include "kernel/kernel.h"
#include <minix/minlib.h>
#include <minix/const.h>
#include <minix/cpufeature.h>

View File

@@ -14,7 +14,7 @@
/* sections */
#include <machine/vm.h>
#include "../../kernel.h"
#include "kernel/kernel.h"
#include <minix/config.h>
#include <minix/const.h>
#include <minix/com.h>

View File

@@ -4,7 +4,7 @@
#include <minix/type.h>
#include <libexec.h>
#include <assert.h>
#include "kernel.h"
#include "kernel/kernel.h"
#include "arch_proto.h"
#include <machine/cpu.h>

View File

@@ -1,7 +1,7 @@
#define UNPAGED 1 /* for proper kmain() prototype */
#include "kernel.h"
#include "kernel/kernel.h"
#include <assert.h>
#include <stdlib.h>
#include <minix/minlib.h>

View File

@@ -1,6 +1,6 @@
include "kernel.h"
include "proc.h"
include "kernel/kernel.h"
include "kernel/proc.h"
struct proc
member REG0 p_reg.retreg

View File

@@ -1,16 +1,50 @@
# Makefile for arch-dependent kernel code
.include <bsd.own.mk>
HERE=${.CURDIR}/arch/${MACHINE_ARCH}
.PATH: ${HERE}
# objects we want unpaged from -lminlib, -lminc
# objects we want unpaged from -lminlib
MINLIB_OBJS_UNPAGED=_cpufeature.o _cpuid.o get_bp.o
MINC_OBJS_UNPAGED=strcat.o strlen.o memcpy.o strcpy.o strncmp.o memset.o \
memmove.o strcmp.o atoi.o ctype_.o _stdfile.o strtol.o _errno.o errno.o \
udivdi3.o umoddi3.o qdivrem.o
SYS_OBJS_UNPAGED=kprintf.o vprintf.o assert.o stacktrace.o
_cpufeature.o: ${NETBSDSRCDIR}/lib/libminlib/${MACHINE_ARCH}/_cpufeature.c
_cpuid.o: ${NETBSDSRCDIR}/lib/libminlib/${MACHINE_ARCH}/_cpuid.S
get_bp.o: ${NETBSDSRCDIR}/lib/libminlib/${MACHINE_ARCH}/get_bp.S
# objects we want unpaged from -lsys
SYS_OBJS_UNPAGED=assert.o kprintf.o stacktrace.o vprintf.o
assert.o: ${NETBSDSRCDIR}/lib/libsys/assert.c
kprintf.o: ${NETBSDSRCDIR}/lib/libsys/kprintf.c
stacktrace.o: ${NETBSDSRCDIR}/lib/libsys/stacktrace.c
vprintf.o: ${NETBSDSRCDIR}/lib/libsys/vprintf.c
# objects we want unpaged from -lminc
MINC_OBJS_UNPAGED=findfp.o strcat.o strlen.o memcpy.o strcpy.o strncmp.o \
memset.o memmove.o strcmp.o atoi.o ctype_.o strtol.o \
_errno.o errno.o udivdi3.o umoddi3.o qdivrem.o
memcpy.o: ${NETBSDSRCDIR}/common/lib/libc/string/memcpy.c
memmove.o: ${NETBSDSRCDIR}/common/lib/libc/string/memmove.c
memset.o: ${NETBSDSRCDIR}/common/lib/libc/string/memset.c
strcat.o: ${NETBSDSRCDIR}/common/lib/libc/string/strcat.c
strlen.o: ${NETBSDSRCDIR}/common/lib/libc/string/strlen.c
strcpy.o: ${NETBSDSRCDIR}/common/lib/libc/string/strcpy.c
strcmp.o: ${NETBSDSRCDIR}/common/lib/libc/string/strcmp.c
strncmp.o: ${NETBSDSRCDIR}/common/lib/libc/string/strncmp.c
udivdi3.o: ${NETBSDSRCDIR}/common/lib/libc/quad/udivdi3.c
umoddi3.o: ${NETBSDSRCDIR}/common/lib/libc/quad/umoddi3.c
qdivrem.o: ${NETBSDSRCDIR}/common/lib/libc/quad/qdivrem.c
atoi.o: ${NETBSDSRCDIR}/lib/libc/stdlib/atoi.c
strtol.o: ${NETBSDSRCDIR}/lib/libc/stdlib/strtol.c
findfp.o: ${NETBSDSRCDIR}/lib/libc/stdio/findfp.c
ctype_.o: ${NETBSDSRCDIR}/lib/libc/gen/ctype_.c
_errno.o: ${NETBSDSRCDIR}/lib/libc/gen/_errno.c
errno.o: ${NETBSDSRCDIR}/lib/libc/gen/errno.c
# Specific flags needed to compile a few of the object files.
CPPFLAGS.strtol.c+= -I ${NETBSDSRCDIR}/common/lib/libc/stdlib
CPPFLAGS.ctype_.c+= -I ${NETBSDSRCDIR}/lib/libc/locale
CPPFLAGS._errno.c+= -I ${NETBSDSRCDIR}/lib/libc/include
CPPFLAGS.assert.c+= -I ${NETBSDSRCDIR}/lib/libc/include
CPPFLAGS.findfp.c+= -I ${NETBSDSRCDIR}/lib/libc/include
# some object files we give a symbol prefix (or namespace) of __k_unpaged_
# that must live in their own unique namespace.
@@ -19,18 +53,12 @@ SYS_OBJS_UNPAGED=kprintf.o vprintf.o assert.o stacktrace.o
io_inb.o pg_utils.o klib.o utility.o arch_reset.o \
${MINLIB_OBJS_UNPAGED} ${MINC_OBJS_UNPAGED} ${SYS_OBJS_UNPAGED}
unpaged_${UNPAGED_OBJ}: ${UNPAGED_OBJ}
${OBJCOPY} --prefix-symbols=__k_unpaged_ ${UNPAGED_OBJ} unpaged_${UNPAGED_OBJ}
${OBJCOPY} --prefix-symbols=__k_unpaged_ ${.OBJDIR}/${UNPAGED_OBJ} $@
UNPAGED_OBJS += unpaged_${UNPAGED_OBJ}
ORIG_UNPAGED_OBJS += ${UNPAGED_OBJ}
.endfor
# we have to extract some object files from libminc.a and libminlib.a
${MINLIB_OBJS_UNPAGED} ${MINC_OBJS_UNPAGED} ${SYS_OBJS_UNPAGED}: ${LIBMINLIB} ${LIBMINC} ${LIBSYS}
${AR} x ${LIBMINLIB} ${MINLIB_OBJS_UNPAGED}
${AR} x ${LIBMINC} ${MINC_OBJS_UNPAGED}
${AR} x ${LIBSYS} ${SYS_OBJS_UNPAGED}
CLEANFILES+= $(ORIG_UNPAGED_OBJS)
CLEANFILES+= ${ORIG_UNPAGED_OBJS}
SRCS+= mpx.S arch_clock.c arch_do_vmctl.c arch_system.c \
do_iopenable.c do_readbios.c do_sdevio.c exception.c i8259.c io_inb.S \
@@ -40,6 +68,10 @@ SRCS+= mpx.S arch_clock.c arch_do_vmctl.c arch_system.c \
OBJS.kernel+= ${UNPAGED_OBJS}
.ifdef CONFIG_SMP
SRCS += arch_smp.c trampoline.S
.endif
.if ${USE_ACPI} != "no"
SRCS+= acpi.c
CPPFLAGS+= -DUSE_ACPI
@@ -59,25 +91,18 @@ SRCS+= arch_watchdog.c
CPPFLAGS+= -DUSE_WATCHDOG
.endif
sconst.h: procoffsets.h
apic_asm.S head.S klib16.S klib.S mpx.S: sconst.h
SRCS+= procoffsets.h
CPPFLAGS+=-I.
# It's OK to hardcode the arch as i386 here as this and procoffsets.cf
# are i386-specific.
TMP=procoffsets.h.tmp
INCLS=../include/arch/i386/include/
PROCOFFSETSCF=procoffsets.cf
procoffsets.h: ${PROCOFFSETSCF} kernel.h proc.h ${INCLS}/stackframe.h ${INCLS}/archtypes.h
.PATH: ${NETBSDSRCDIR}/include/arch/${MACHINE_ARCH}/include
procoffsets.h: ${PROCOFFSETSCF} kernel.h proc.h stackframe.h archtypes.h
${_MKTARGET_CREATE}
${TOOL_CAT} ${HERE}/${PROCOFFSETSCF} | \
${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$TMP && \
mv -f $TMP $@
.ifdef CONFIG_SMP
SRCS += arch_smp.c trampoline.S
.endif
${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} >$@.tmp && \
mv -f $@.tmp $@
sconst.h: procoffsets.h
apic_asm.S head.S klib16.S klib.S mpx.S: sconst.h

View File

@@ -10,14 +10,14 @@
#include "kernel/interrupt.h"
#include <minix/u64.h>
#include "glo.h"
#include "profile.h"
#include "kernel/profile.h"
#ifdef USE_APIC
#include "apic.h"
#endif
#include "spinlock.h"
#include "kernel/spinlock.h"
#ifdef CONFIG_SMP
#include "kernel/smp.h"

View File

@@ -1,5 +1,5 @@
#include "kernel.h"
#include "kernel/kernel.h"
#include <minix/minlib.h>
#include <minix/const.h>
#include <minix/cpufeature.h>

View File

@@ -3,7 +3,7 @@
/* sections */
#include <machine/vm.h>
#include "../../kernel.h"
#include "kernel/kernel.h"
#include <minix/config.h>
#include <minix/const.h>
#include <minix/com.h>

View File

@@ -17,7 +17,7 @@ void eoi_8259_slave(void);
* either
*/
#if defined(USE_APIC)
#include "arch/i386/apic.h"
#include "kernel/arch/i386/apic.h"
#define hw_intr_mask(irq) ioapic_mask_irq(irq)
#define hw_intr_unmask(irq) ioapic_unmask_irq(irq)

View File

@@ -33,4 +33,5 @@ SECTIONS
__k_unpaged__kern_size = . - _kern_vir_base;
_kern_size = __k_unpaged__kern_size;
}
_end = .;
}

View File

@@ -26,7 +26,7 @@
/* sections */
#include <machine/vm.h>
#include "../../kernel.h"
#include "kernel/kernel.h"
#include <minix/config.h>
#include <minix/const.h>
#include <minix/com.h>

View File

@@ -2,7 +2,7 @@
#include <minix/cpufeature.h>
#include <assert.h>
#include "kernel.h"
#include "kernel/kernel.h"
#include <libexec.h>
#include "arch_proto.h"

View File

@@ -1,7 +1,7 @@
#define UNPAGED 1 /* for proper kmain() prototype */
#include "kernel.h"
#include "kernel/kernel.h"
#include <assert.h>
#include <stdlib.h>
#include <minix/minlib.h>

View File

@@ -1,5 +1,5 @@
include "kernel.h"
include "kernel/kernel.h"
struct proc
member DIREG p_reg.di

View File

@@ -1,13 +1,8 @@
#ifndef __SCONST_H__
#define __SCONST_H__
/*
* LSC Weirdness going on with the const.h header: FIXME
#include "kernel/const.h"
#include "kernel/procoffsets.h"
*/
#include "const.h"
#include "procoffsets.h"
/*
* offset to current process pointer right after trap, we assume we always have

View File

@@ -1,4 +1,4 @@
#include "kernel.h"
#include "kernel/kernel.h"
#include "arch_proto.h"
struct minix_ipcvecs minix_ipcvecs_softint = {

View File

@@ -29,7 +29,7 @@
* Instead, notify(), which always returns, should be used.
*/
#include "kernel.h"
#include "kernel/kernel.h"
#include <minix/endpoint.h>
#include <assert.h>

View File

@@ -1,7 +1,7 @@
#ifndef __CLOCK_H__
#define __CLOCK_H__
#include "kernel.h"
#include "kernel/kernel.h"
#include "arch_clock.h"
int boot_cpu_init_timer(unsigned freq);

View File

@@ -1,3 +1,3 @@
#include "kernel.h"
#include "kernel/kernel.h"
DEFINE_CPULOCAL_VARS;

View File

@@ -3,7 +3,7 @@
* functions and sanity checking of the scheduling queues.
*/
#include "kernel.h"
#include "kernel/kernel.h"
#include <minix/callnr.h>
#include <minix/sysutil.h>

View File

@@ -3,7 +3,7 @@
set -e
# grep message type and errno constants and make them into a .h file
cat ../include/sys/errno.h | \
cat ../sys/sys/errno.h | \
tr -s ' \t' ' ' | \
sed 's/^# /#/' | \
egrep '^#define [A-Z_][A-Z0-9_]* \( ?_SIGN ?[0-9]+ ?\)' | \

View File

@@ -15,7 +15,7 @@
#include <assert.h>
#include "kernel.h"
#include "kernel/kernel.h"
#include "archconst.h"
#include "hw_intr.h"

View File

@@ -37,16 +37,16 @@
#include <minix/param.h>
/* Important kernel header files. */
#include "config.h" /* configuration, MUST be first */
#include "const.h" /* constants, MUST be second */
#include "type.h" /* type definitions, MUST be third */
#include "proto.h" /* function prototypes */
#include "glo.h" /* global variables */
#include "ipc.h" /* IPC constants */
#include "profile.h" /* system profiling */
#include "proc.h" /* process table */
#include "cpulocals.h" /* CPU-local variables */
#include "debug.h" /* debugging, MUST be last kernel header */
#include "kernel/config.h" /* configuration, MUST be first */
#include "kernel/const.h" /* constants, MUST be second */
#include "kernel/type.h" /* type definitions, MUST be third */
#include "kernel/proto.h" /* function prototypes */
#include "kernel/glo.h" /* global variables */
#include "kernel/ipc.h" /* IPC constants */
#include "kernel/profile.h" /* system profiling */
#include "kernel/proc.h" /* process table */
#include "kernel/cpulocals.h" /* CPU-local variables */
#include "kernel/debug.h" /* debugging, MUST be last kernel header */
#ifndef CONFIG_SMP
/* We only support 1 cpu now */
@@ -57,7 +57,7 @@
#else
#include "smp.h"
#include "kernel/smp.h"
#endif

View File

@@ -8,7 +8,7 @@
* main: MINIX main program
* prepare_shutdown: prepare to take MINIX down
*/
#include "kernel.h"
#include "kernel/kernel.h"
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

View File

@@ -15,8 +15,8 @@
#include <minix/com.h>
#include <minix/const.h>
#include <minix/priv.h>
#include "const.h"
#include "type.h"
#include "kernel/const.h"
#include "kernel/type.h"
struct priv {
proc_nr_t s_proc_nr; /* number of associated process */

View File

@@ -35,7 +35,7 @@
#include <signal.h>
#include <assert.h>
#include "kernel.h"
#include "kernel/kernel.h"
#include "vm.h"
#include "clock.h"
#include "spinlock.h"

View File

@@ -17,7 +17,7 @@
#include <minix/config.h>
#include "kernel.h"
#include "kernel/kernel.h"
#include <minix/profile.h>
#include <minix/portio.h>

View File

@@ -5,7 +5,7 @@
#ifndef __ASSEMBLY__
#include "kernel.h"
#include "kernel/kernel.h"
#include "arch_smp.h"
#include "spinlock.h"

View File

@@ -1,7 +1,7 @@
#ifndef __SPINLOCK_H__
#define __SPINLOCK_H__
#include "kernel.h"
#include "kernel/kernel.h"
typedef struct spinlock {
atomic_t val;

View File

@@ -31,9 +31,9 @@
* Sep 30, 2004 source code documentation updated (Jorrit N. Herder)
*/
#include "kernel.h"
#include "system.h"
#include "vm.h"
#include "kernel/kernel.h"
#include "kernel/system.h"
#include "kernel/vm.h"
#include "kernel/clock.h"
#include <stdlib.h>
#include <assert.h>

View File

@@ -30,7 +30,7 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#include "kernel.h"
#include "kernel/kernel.h"
int do_exec(struct proc * caller, message *m_ptr);
#if ! USE_EXEC

View File

@@ -16,7 +16,7 @@
#include <assert.h>
#include "kernel/system.h"
#include "kernel.h"
#include "kernel/kernel.h"
#define MAX_INDIRECT_DEPTH 5 /* up to how many indirect grants to follow? */

View File

@@ -13,7 +13,7 @@
#include <minix/safecopies.h>
#include "kernel/system.h"
#include "kernel.h"
#include "kernel/kernel.h"
/*===========================================================================*
* do_safememset *

View File

@@ -14,7 +14,7 @@
*/
#include "kernel/system.h"
#include "watchdog.h"
#include "kernel/watchdog.h"
#if SPROFILE

View File

@@ -29,7 +29,7 @@
*/
#define _TABLE
#include "kernel.h"
#include "kernel/kernel.h"
#include <minix/com.h>
/* The system image table lists all programs that are part of the boot image.

View File

@@ -1,4 +1,4 @@
#include "kernel.h"
#include "kernel/kernel.h"
/* This is the user-visible struct that has pointers to other bits of data. */
struct minix_kerninfo minix_kerninfo;

View File

@@ -3,7 +3,7 @@
* kputc: buffered putc used by kernel printf
*/
#include "kernel.h"
#include "kernel/kernel.h"
#include "arch_proto.h"
#include <minix/syslib.h>
@@ -89,3 +89,11 @@ int c; /* character to append */
return;
}
/*===========================================================================*
* _exit *
*===========================================================================*/
void _exit(e)
int e; /* error code */
{
panic("_exit called from within the kernel, should not happen. (err %i)", e);
}

View File

@@ -1,7 +1,7 @@
#ifndef __WATCHDOG_H__
#define __WATCHDOG_H__
#include "kernel.h"
#include "kernel/kernel.h"
#include "arch_watchdog.h"
extern int watchdog_enabled; /* if set to non-zero the watch dog is enabled */