From: Ben Gras Date: Wed, 5 Mar 2014 11:21:55 +0000 (+0100) Subject: _MINIX_SYSTEM - fixes for in-minix crossbuild X-Git-Tag: v3.3.0~405 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/ddns-confgen.html?a=commitdiff_plain;h=3f38115c7b642bc4dee7eeb62bfd44373edce878;p=minix.git _MINIX_SYSTEM - fixes for in-minix crossbuild . define _MINIX_SYSTEM for all system code from minix.service.mk . hide some system-level declarations and definitions behind _MINIX_SYSTEM to cleanly fix host tool build problems on Minix (such as: NONE being defined and paddr_t being used but not declared) . the similar definition _SYSTEM is unsuitable as it changes the values of errno definitions Change-Id: I407de79e2575115243a074b16e79546a279cfa3e --- diff --git a/commands/ps/ps.c b/commands/ps/ps.c index 98e32b89f..ea6e9f645 100644 --- a/commands/ps/ps.c +++ b/commands/ps/ps.c @@ -39,6 +39,8 @@ * user space and converted into a concatenated argument list). */ +#define _MINIX_SYSTEM 1 + #include #include #include diff --git a/commands/service/parse.c b/commands/service/parse.c index fe2433687..478d2fa55 100644 --- a/commands/service/parse.c +++ b/commands/service/parse.c @@ -1,4 +1,6 @@ +#define _MINIX_SYSTEM 1 + #include #include #include diff --git a/commands/svrctl/svrctl.c b/commands/svrctl/svrctl.c index a481eabc1..820fe3891 100644 --- a/commands/svrctl/svrctl.c +++ b/commands/svrctl/svrctl.c @@ -1,3 +1,5 @@ +#define _MINIX_SYSTEM 1 + #include #include #include diff --git a/include/minix/ds.h b/include/minix/ds.h index 3a8c6db47..ebe24f3ed 100644 --- a/include/minix/ds.h +++ b/include/minix/ds.h @@ -3,6 +3,8 @@ #ifndef _MINIX_DS_H #define _MINIX_DS_H +#ifdef _MINIX_SYSTEM + #include #include @@ -66,5 +68,7 @@ int ds_delete_label(const char *ds_name); int ds_subscribe(const char *regex, int flags); int ds_check(char *ds_name, int *type, endpoint_t *owner_e); +#endif /* _MINIX_SYSTEM */ + #endif /* _MINIX_DS_H */ diff --git a/include/minix/endpoint.h b/include/minix/endpoint.h index 0cf3f3bb7..74ba24053 100644 --- a/include/minix/endpoint.h +++ b/include/minix/endpoint.h @@ -2,6 +2,8 @@ #ifndef _MINIX_ENDPOINT_H #define _MINIX_ENDPOINT_H 1 +#ifdef _MINIX_SYSTEM + #include #include #include @@ -68,4 +70,6 @@ #define _ENDPOINT_P(e) \ ((((e)+MAX_NR_TASKS) & (_ENDPOINT_GENERATION_SIZE - 1)) - MAX_NR_TASKS) +#endif /* _MINIX_SYSTEM */ + #endif diff --git a/include/minix/param.h b/include/minix/param.h index 90a8b1676..6e50debe8 100644 --- a/include/minix/param.h +++ b/include/minix/param.h @@ -8,6 +8,7 @@ /* Number of processes contained in the system image. */ #define NR_BOOT_PROCS (NR_TASKS + LAST_SPECIAL_PROC_NR + 1) +#ifdef _MINIX_SYSTEM /* This is used to obtain system information through SYS_GETINFO. */ #define MAXMEMMAP 40 typedef struct kinfo { @@ -44,5 +45,6 @@ typedef struct kinfo { int kernel_allocated_bytes; /* used by kernel */ int kernel_allocated_bytes_dynamic; /* used by kernel (runtime) */ } kinfo_t; +#endif /* _MINIX_SYSTEM */ #endif diff --git a/lib/libaudiodriver/Makefile b/lib/libaudiodriver/Makefile index eb2319972..c4d84ab0d 100644 --- a/lib/libaudiodriver/Makefile +++ b/lib/libaudiodriver/Makefile @@ -1,6 +1,7 @@ # Makefile for the common audio framework NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM LIB= audiodriver SRCS= audio_fw.c liveupdate.c diff --git a/lib/libbdev/Makefile b/lib/libbdev/Makefile index 3be2dad68..bf0e1c01c 100644 --- a/lib/libbdev/Makefile +++ b/lib/libbdev/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libbdev .include diff --git a/lib/libblockdriver/Makefile b/lib/libblockdriver/Makefile index c30150399..e61dc69bc 100644 --- a/lib/libblockdriver/Makefile +++ b/lib/libblockdriver/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libblockdriver .include diff --git a/lib/libc/sys-minix/minix_rs.c b/lib/libc/sys-minix/minix_rs.c index d858556c2..c0c0d38b5 100644 --- a/lib/libc/sys-minix/minix_rs.c +++ b/lib/libc/sys-minix/minix_rs.c @@ -1,4 +1,5 @@ #define _SYSTEM 1 +#define _MINIX_SYSTEM 1 #include diff --git a/lib/libc/sys-minix/mmap.c b/lib/libc/sys-minix/mmap.c index ca6b5f532..64b0b5ff0 100644 --- a/lib/libc/sys-minix/mmap.c +++ b/lib/libc/sys-minix/mmap.c @@ -1,4 +1,5 @@ #define _SYSTEM 1 +#define _MINIX_SYSTEM 1 #include #include "namespace.h" #include diff --git a/lib/libc/sys-minix/sem.c b/lib/libc/sys-minix/sem.c index 6f961d51b..de8ba6c7f 100644 --- a/lib/libc/sys-minix/sem.c +++ b/lib/libc/sys-minix/sem.c @@ -1,5 +1,6 @@ #define __USE_MISC #define _SYSTEM 1 +#define _MINIX_SYSTEM 1 #include #include diff --git a/lib/libc/sys-minix/shmat.c b/lib/libc/sys-minix/shmat.c index 2fa19bfe8..aa99007b4 100644 --- a/lib/libc/sys-minix/shmat.c +++ b/lib/libc/sys-minix/shmat.c @@ -1,4 +1,5 @@ #define _SYSTEM 1 +#define _MINIX_SYSTEM 1 #include #include diff --git a/lib/libc/sys-minix/shmctl.c b/lib/libc/sys-minix/shmctl.c index 474ecc39c..e3d10e760 100644 --- a/lib/libc/sys-minix/shmctl.c +++ b/lib/libc/sys-minix/shmctl.c @@ -1,4 +1,5 @@ #define _SYSTEM 1 +#define _MINIX_SYSTEM 1 #include #include diff --git a/lib/libc/sys-minix/stack_utils.c b/lib/libc/sys-minix/stack_utils.c index 77da25f29..95bf5d228 100644 --- a/lib/libc/sys-minix/stack_utils.c +++ b/lib/libc/sys-minix/stack_utils.c @@ -3,6 +3,8 @@ * Author: Lionel A. Sambuc. */ +#define _MINIX_SYSTEM + #include #include "namespace.h" #include diff --git a/lib/libchardriver/Makefile b/lib/libchardriver/Makefile index e32df4316..b6997d01f 100644 --- a/lib/libchardriver/Makefile +++ b/lib/libchardriver/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libchardriver .include diff --git a/lib/libclkconf/Makefile b/lib/libclkconf/Makefile index 7c4acfb9d..49cb3c659 100644 --- a/lib/libclkconf/Makefile +++ b/lib/libclkconf/Makefile @@ -3,7 +3,7 @@ NOCLANGERROR=yes # # Makefile for libclkconf -CPPFLAGS+= -D_SYSTEM +CPPFLAGS+= -D_SYSTEM -D_MINIX_SYSTEM LIB= clkconf diff --git a/lib/libddekit/build/ddekit/Makefile b/lib/libddekit/build/ddekit/Makefile index a37b91a62..9f789d9e0 100644 --- a/lib/libddekit/build/ddekit/Makefile +++ b/lib/libddekit/build/ddekit/Makefile @@ -7,7 +7,7 @@ VPATH = $(SRC_DIR) SRCS = pci.c printf.c mem.c pgtab.c dde.c initcall.c thread.c condvar.c lock.c semaphore.c timer.c panic.c irq.c resource.c msg_queue.c -CFLAGS += -D_NETBSD_SOURCE +CPPFLAGS += -D_NETBSD_SOURCE -D_MINIX_SYSTEM .include diff --git a/lib/libgpio/Makefile b/lib/libgpio/Makefile index 03b5a7e7e..ee86fbf27 100644 --- a/lib/libgpio/Makefile +++ b/lib/libgpio/Makefile @@ -1,6 +1,6 @@ # Makefile for libgpio -CPPFLAGS+= -D_SYSTEM +CPPFLAGS+= -D_SYSTEM -D_MINIX_SYSTEM LIB= gpio diff --git a/lib/libi2cdriver/Makefile b/lib/libi2cdriver/Makefile index 570d41578..066ecc8ab 100644 --- a/lib/libi2cdriver/Makefile +++ b/lib/libi2cdriver/Makefile @@ -1,6 +1,8 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+=-D_MINIX_SYSTEM + # Makefile for libi2cdriver LIB= i2cdriver diff --git a/lib/libinputdriver/Makefile b/lib/libinputdriver/Makefile index 3d42b72ae..032a5c9aa 100644 --- a/lib/libinputdriver/Makefile +++ b/lib/libinputdriver/Makefile @@ -1,5 +1,6 @@ # Makefile for libinputdriver .include +CPPFLAGS+= -D_MINIX_SYSTEM LIB= inputdriver diff --git a/lib/libminixfs/Makefile b/lib/libminixfs/Makefile index 47bd7d3ec..f714dfebf 100644 --- a/lib/libminixfs/Makefile +++ b/lib/libminixfs/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libminixfs .include diff --git a/lib/libnetdriver/Makefile b/lib/libnetdriver/Makefile index 19e2ab0ca..00b142b1f 100644 --- a/lib/libnetdriver/Makefile +++ b/lib/libnetdriver/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libnetdriver diff --git a/lib/libnetsock/Makefile b/lib/libnetsock/Makefile index 657717be0..e55e699ad 100644 --- a/lib/libnetsock/Makefile +++ b/lib/libnetsock/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM LIB = netsock diff --git a/lib/libpuffs/Makefile b/lib/libpuffs/Makefile index 0de6c9a55..fd47ff51f 100644 --- a/lib/libpuffs/Makefile +++ b/lib/libpuffs/Makefile @@ -23,6 +23,7 @@ SRCS+= inode.c link.c misc.c mount.c open.c path.c path_puffs.c \ protect.c read.c stadir.c time.c utility.c table.c CPFFLAGS+=-Dlchown=chown -Dlchmod=chmod +CPPFLAGS+= -D_MINIX_SYSTEM NOGCCERROR=yes NOCLANGERROR=yes diff --git a/lib/libsffs/Makefile b/lib/libsffs/Makefile index 4b716ba61..4fb0b80b0 100644 --- a/lib/libsffs/Makefile +++ b/lib/libsffs/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libsffs .include diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index 8365dba13..4d09fa4b9 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -4,6 +4,8 @@ NOCLANGERROR=yes # Makefile for libsys .include +CPPFLAGS+= -D_MINIX_SYSTEM -D_SYSTEM + LIB= sys CFLAGS+= -fno-builtin diff --git a/lib/libsys/asynsend.c b/lib/libsys/asynsend.c index bded01be1..59ca8b553 100644 --- a/lib/libsys/asynsend.c +++ b/lib/libsys/asynsend.c @@ -1,4 +1,3 @@ -#define _SYSTEM 1 #include #include diff --git a/lib/libsys/syslib.h b/lib/libsys/syslib.h index 7b0028d73..ba1add6a6 100644 --- a/lib/libsys/syslib.h +++ b/lib/libsys/syslib.h @@ -1,7 +1,5 @@ /* syslib.h - System library common definitions. */ -#define _SYSTEM - #include #include #include diff --git a/lib/libvirtio/Makefile b/lib/libvirtio/Makefile index 7049504d8..1df3297dc 100644 --- a/lib/libvirtio/Makefile +++ b/lib/libvirtio/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libvirtio .include diff --git a/lib/libvtreefs/Makefile b/lib/libvtreefs/Makefile index dc4735903..35f091728 100644 --- a/lib/libvtreefs/Makefile +++ b/lib/libvtreefs/Makefile @@ -1,5 +1,6 @@ NOGCCERROR=yes NOCLANGERROR=yes +CPPFLAGS+= -D_MINIX_SYSTEM # Makefile for libvtreefs diff --git a/share/mk/minix.service.mk b/share/mk/minix.service.mk index eac1032c1..3ab8be9d0 100644 --- a/share/mk/minix.service.mk +++ b/share/mk/minix.service.mk @@ -35,4 +35,7 @@ LDFLAGS+= ${${ACTIVE_CC} == "gcc":? -lgcc_eh:} .endif # ${MACHINE_ARCH} == "earm" +# Get (more) internal minix definitions and declarations. +CPPFLAGS += -D_MINIX_SYSTEM=1 + .include diff --git a/sys/arch/i386/include/multiboot.h b/sys/arch/i386/include/multiboot.h index bc07f689d..a11d41e90 100644 --- a/sys/arch/i386/include/multiboot.h +++ b/sys/arch/i386/include/multiboot.h @@ -43,9 +43,12 @@ #define MULTIBOOT_HEADER_HAS_VBE 0x00000004 #define MULTIBOOT_HEADER_HAS_ADDR 0x00010000 -#if defined(__minix) && !defined(__ASSEMBLY__) +#if defined(__minix) && !defined(__ASSEMBLY__) && (defined(_MINIX_SYSTEM) || defined(_STANDALONE)) #if !defined(_LOCORE) + +#include + struct multiboot_header { uint32_t mh_magic; uint32_t mh_flags; @@ -73,7 +76,7 @@ struct multiboot_header { extern struct multiboot_header *Multiboot_Header; #endif /* !defined(_LOCORE) && defined(_KERNEL) */ -#endif /* defined(__minix) && !defined(__ASSEMBLY__) */ +#endif /* defined(__minix) && !defined(__ASSEMBLY__) && (defined(_MINIX_SYSTEM) || defined(_STANDALONE))*/ /* --------------------------------------------------------------------- */ @@ -94,7 +97,7 @@ extern struct multiboot_header *Multiboot_Header; #define MULTIBOOT_INFO_HAS_APM_TABLE 0x00000400 #define MULTIBOOT_INFO_HAS_VBE 0x00000800 -#if defined(__minix) && !defined(__ASSEMBLY__) +#if defined(__minix) && !defined(__ASSEMBLY__) && (defined(_MINIX_SYSTEM) || defined(_STANDALONE)) #if !defined(_LOCORE) struct multiboot_info { @@ -197,7 +200,7 @@ struct multiboot_module { #endif /* !defined(_LOCORE) */ -#endif /* defined(__minix) && !defined(__ASSEMBLY__) */ +#endif /* defined(__minix) && !defined(__ASSEMBLY__) && (defined(_MINIX_SYSTEM) || defined(_STANDALONE))*/ #if defined(__minix) @@ -240,4 +243,4 @@ bool multiboot_ksyms_addsyms_elf(void); /* --------------------------------------------------------------------- */ -#endif /* _MACHINE_MULTIBOOT_H */ \ No newline at end of file +#endif /* _MACHINE_MULTIBOOT_H */ diff --git a/sys/sys/mman.h b/sys/sys/mman.h index c28f40eb5..19df99d08 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -200,14 +200,14 @@ void * mremap(void *, size_t, void *, size_t, int); #endif int posix_madvise(void *, size_t, int); -#if defined(__minix) +#if defined(__minix) && defined(_MINIX_SYSTEM) #include void * vm_remap(endpoint_t d, endpoint_t s, void *da, void *sa, size_t si); void * vm_remap_ro(endpoint_t d, endpoint_t s, void *da, void *sa, size_t si); int vm_unmap(endpoint_t endpt, void *addr); unsigned long vm_getphys(endpoint_t endpt, void *addr); u8_t vm_getrefcount(endpoint_t endpt, void *addr); -#endif /* defined(__minix) */ +#endif /* defined(__minix) && defined(_MINIX_SYSTEM) */ __END_DECLS diff --git a/test/test39.c b/test/test39.c index 0ec2931c3..c1f4cb033 100644 --- a/test/test39.c +++ b/test/test39.c @@ -1,4 +1,6 @@ +#define _MINIX_SYSTEM + #include #include #include diff --git a/test/test72.c b/test/test72.c index ca33e5ada..2b4b2ae9b 100644 --- a/test/test72.c +++ b/test/test72.c @@ -3,6 +3,8 @@ * Exercise the caching functionality of libminixfs in isolation. */ +#define _MINIX_SYSTEM + #include #include #include diff --git a/test/test73.c b/test/test73.c index 3c5c7f4b1..c16e29c41 100644 --- a/test/test73.c +++ b/test/test73.c @@ -4,6 +4,8 @@ * in testvm.c, started as a service by this test program. */ +#define _MINIX_SYSTEM 1 + #include #include #include diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 637f1abe3..cafa384ab 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -2,6 +2,8 @@ /* Author: Ben Gras 17 march 2006 */ /* Modified for ProcFS by Alen Stojanov and David van Moolenbroek */ +#define _MINIX_SYSTEM 1 + #include #include #include