From cc17b27a2b312a8dce35647910c28c77f210277a Mon Sep 17 00:00:00 2001 From: Gianluca Guida Date: Wed, 27 Apr 2011 13:00:52 +0000 Subject: [PATCH] Build NetBSD libc library in world in ELF mode. 3 sets of libraries are built now: . ack: all libraries that ack can compile (/usr/lib/i386/) . clang+elf: all libraries with minix headers (/usr/lib/) . clang+elf: all libraries with netbsd headers (/usr/netbsd/) Once everything can be compiled with netbsd libraries and headers, the /usr/netbsd hierarchy will be obsolete and its libraries compiled with netbsd headers will be installed in /usr/lib, and its headers in /usr/include. (i.e. minix libc and current minix headers set will be gone.) To use the NetBSD libc system (libraries + headers) before it is the default libc, see: http://wiki.minix3.org/en/DevelopersGuide/UsingNetBSDCode This wiki page also documents the maintenance of the patch files of minix-specific changes to imported NetBSD code. Changes in this commit: . libsys: Add NBSD compilation and create a safe NBSD-based libc. . Port rest of libraries (except libddekit) to new header system. . Enable compilation of libddekit with new headers. . Enable kernel compilation with new headers. . Enable drivers compilation with new headers. . Port legacy commands to new headers and libc. . Port servers to new headers. . Add in compat library. . Remove dependency file in tree. . Enable compilation of common/lib/libc/atomic in libsys . Do not generate RCSID strings in libc. . Temporarily disable zoneinfo as they are incompatible with NetBSD format . obj-nbsd for .gitignore . Procfs: use only integer arithmetic. (Antoine Leca) . Increase ramdisk size to create NBSD-based images. . Remove INCSYMLINKS handling hack. . Add nbsd_include/sys/exec_elf.h . Enable ELF compilation with NBSD libc. . Add 'make nbsdsrc' in tools to download reference NetBSD sources. . Automate minix-port.patch creation. . Avoid using fstavfs() as it is *extremely* slow and unneeded. . Set err() as PRIVATE to avoid name clash with libc. . [NBSD] servers/vm: remove compilation warnings. . u32 is not a long in NBSD headers. . UPDATING info on netbsd hierarchy . commands fixes for netbsd libc --- .gitignore | 2 + Makefile | 12 +- commands/Makefile.inc | 6 + commands/aal/archiver.c | 3 + commands/add_route/add_route.c | 23 + commands/ash/input.c | 6 +- commands/ash/output.c | 4 +- commands/ash/output.h | 2 +- commands/ash/shell.h | 2 +- commands/ash/trap.c | 7 +- commands/awk/Makefile | 2 + commands/calendar/calendar.c | 4 + commands/de/de.h | 6 + commands/dhcpd/dhcpd.c | 15 + commands/dhcpd/ether.c | 41 +- commands/diff/diff.h | 3 + commands/dis386/type.h | 2 + commands/elle/sbm.c | 9 + commands/elvis/ref.c | 4 + commands/find/find.h | 2 + commands/finger/finger.c | 6 + commands/fix/fix.c | 4 + commands/ftp101/ftp.c | 5 + commands/ftp101/net.c | 12 + commands/ftpd200/ftpd.c | 5 + commands/gcov-pull/gcov-pull.c | 2 + commands/grep/Makefile | 2 +- commands/host/host.c | 176 ++- commands/hostaddr/hostaddr.c | 4 + commands/ipcs/ipcs.c | 2 + commands/irdpd/irdpd.c | 13 +- commands/logger/logger.c | 8 + commands/login/login.c | 4 + commands/ls/ls.c | 4 + commands/mdb/gnu_sym.c | 4 + commands/mdb/io.c | 5 + commands/mkfs.mfs/mkfs.c | 4 + commands/mknod/mknod.c | 3 + commands/nonamed/nonamed.c | 142 ++- commands/padtext/padtext.c | 4 + commands/pax/options.c | 4 + commands/pwdauth/pwdauth.c | 5 + commands/rarpd/rarpd.c | 5 + commands/reboot/log.c | 8 + commands/reboot/shutdown.c | 8 +- commands/recwave/recwave.c | 1 - commands/stty/stty.c | 3 + commands/syslogd/syslogd.c | 8 + commands/talk/talk.c | 5 + commands/talkd/finduser.c | 4 + commands/tar/config.h | 2 + commands/uniq/uniq.c | 4 + commands/writeisofs/writeisofs.c | 2 + common/lib/libc/arch/i386/atomic/Makefile.inc | 2 +- common/lib/libc/minix-port.patch | 30 +- docs/UPDATING | 6 + drivers/Makefile.inc | 6 + drivers/ramdisk/Makefile | 4 +- drivers/ramdisk/proto | 2 +- drivers/random/random.c | 4 + kernel/Makefile | 6 + kernel/proto.h | 2 +- lib/Makefile | 24 +- lib/Makefile.inc | 5 + lib/clang_build.sh | 1 + lib/elf_build.sh | 1 + lib/elf_build_base.sh | 6 +- lib/gnu_build.sh | 6 +- lib/libarchive/Makefile | 4 + lib/libarchive/config.h | 4 + lib/libbz2/Makefile | 4 + lib/libddekit/build/ddekit/Makefile | 4 + lib/libddekit/src/thread.c | 2 +- lib/libexec/exec_elf.c | 8 +- lib/libhgfs/inc.h | 2 + lib/libsys/Makefile | 5 + lib/libsys/Makefile.libc.inc | 136 ++ lib/libsys/_stdfile.c | 50 + lib/libsys/abort.c | 7 + lib/libsys/arch/i386/Makefile.libc.inc | 4 + lib/libsys/assert.c | 35 + lib/libsys/calloc.c | 28 + lib/libsys/errlist.c | 125 ++ lib/libsys/fputs.c | 15 + lib/libsys/malloc.c | 252 ++++ lib/libsys/panic.c | 2 + lib/libsys/vprintf.c | 48 + lib/libutil/Makefile | 6 +- lib/libvtreefs/inc.h | 3 +- lib/libz/Makefile | 5 + lib/nbsd_libc/Makefile | 2 - lib/nbsd_libc/Makefile.inc | 2 +- lib/nbsd_libc/citrus/Makefile.inc | 4 +- lib/nbsd_libc/dlfcn/dlfcn_elf.c | 7 + lib/nbsd_libc/gen/minix/gethostname.c | 1 - lib/nbsd_libc/gen/opendir.c | 4 +- lib/nbsd_libc/minix-port.patch | 838 +++++++++---- lib/nbsd_libcompat_minix/Makefile | 1 + lib/nbsd_libcompat_minix/include/Makefile.inc | 2 + .../include/i386/compat_jmp_buf.h | 16 + .../include/sys/jmp_buf.h | 2 + .../include/sys/sigcontext.h | 8 + lib/nbsd_libcompat_minix/mtab.c | 5 +- lib/nbsd_libm/arch/i387/.depend | 2 - lib/nbsd_libm/minix-port.patch | 0 nbsd_include/arch/Makefile | 4 +- nbsd_include/arch/i386/include/cdefs.h | 2 + nbsd_include/minix-port.patch | 134 +- nbsd_include/sys/Makefile | 26 +- nbsd_include/sys/cdefs_elf.h | 208 ++++ nbsd_include/sys/exec_elf.h | 1090 +++++++++++++++++ servers/Makefile.inc | 6 + servers/inet/generic/rand256.c | 4 + servers/inet/inet.h | 4 + servers/inet/inet_config.h | 11 + servers/init/Makefile | 3 - servers/init/init.c | 54 + servers/iso9660fs/read.c | 3 + servers/mfs/Makefile | 4 +- servers/pfs/inc.h | 4 + servers/pm/misc.c | 4 + servers/procfs/proto.h | 2 +- servers/procfs/root.c | 17 +- servers/procfs/type.h | 5 + servers/procfs/util.c | 8 +- servers/vfs/select.c | 4 + servers/vm/alloc.c | 4 +- servers/vm/arch/i386/pagetable.c | 23 +- servers/vm/pagefaults.c | 2 +- share/Makefile | 5 +- share/mk/bsd.prog.mk | 6 + share/mk/bsd.sys.mk | 2 +- tools/Makefile | 14 + tools/nbsd.config | 3 + tools/nbsd_diff.sh | 6 + tools/nbsd_ports | 4 + 136 files changed, 3567 insertions(+), 470 deletions(-) create mode 100644 lib/libsys/Makefile.libc.inc create mode 100644 lib/libsys/_stdfile.c create mode 100644 lib/libsys/abort.c create mode 100644 lib/libsys/arch/i386/Makefile.libc.inc create mode 100644 lib/libsys/calloc.c create mode 100644 lib/libsys/errlist.c create mode 100644 lib/libsys/fputs.c create mode 100644 lib/libsys/malloc.c create mode 100644 lib/nbsd_libcompat_minix/include/i386/compat_jmp_buf.h create mode 100644 lib/nbsd_libcompat_minix/include/sys/jmp_buf.h create mode 100644 lib/nbsd_libcompat_minix/include/sys/sigcontext.h delete mode 100644 lib/nbsd_libm/arch/i387/.depend create mode 100644 lib/nbsd_libm/minix-port.patch create mode 100644 nbsd_include/sys/cdefs_elf.h create mode 100644 nbsd_include/sys/exec_elf.h create mode 100644 tools/nbsd.config create mode 100644 tools/nbsd_diff.sh create mode 100644 tools/nbsd_ports diff --git a/.gitignore b/.gitignore index 33f193d73..7e16bfc18 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,11 @@ cscope.* *.a *.d .depend +nbsdsrc/* obj-ack obj-gnu obj-elf-base +obj-gnu-nbsd tools/revision TAGS tags diff --git a/Makefile b/Makefile index db671a644..7d0754233 100644 --- a/Makefile +++ b/Makefile @@ -55,8 +55,10 @@ mkfiles: make -C share/mk install includes: + $(MAKE) -C nbsd_include includes $(MAKE) -C include includes - $(MAKE) -C lib includes + $(MAKE) -C lib includes NBSD_LIBC=yes + $(MAKE) -C lib includes NBSD_LIBC=no libraries: includes $(MAKE) -C lib build_ack @@ -70,7 +72,7 @@ gnu-includes: includes SHELL=/bin/sh; if [ -f $(MKHEADERS443_PKGSRC) ] ; then sh -e $(MKHEADERS443_PKGSRC) ; fi .ifndef MINIX_GENERATE_ELF -gnu-libraries: #gnu-includes +gnu-libraries: includes #gnu-includes $(MAKE) -C lib build_gnu clang-libraries: includes @@ -89,7 +91,7 @@ commands: includes libraries $(MAKE) -C commands all depend: - $(MAKE) -C boot depend + $(MAKE) CC=cc -C boot depend $(MAKE) -C commands depend $(MAKE) -C kernel depend $(MAKE) -C servers depend @@ -102,12 +104,12 @@ etcforce: $(MAKE) -C etc installforce all: - $(MAKE) -C boot all + $(MAKE) CC=cc -C boot all $(MAKE) -C commands all $(MAKE) -C tools all install: - $(MAKE) -C boot install + $(MAKE) CC=cc -C boot install $(MAKE) -C man install makedb $(MAKE) -C commands install $(MAKE) -C share install diff --git a/commands/Makefile.inc b/commands/Makefile.inc index 07b38a6ae..f10e293fb 100644 --- a/commands/Makefile.inc +++ b/commands/Makefile.inc @@ -1,2 +1,8 @@ +.if (${NBSD_LIBC} != "no") +CPPFLAGS+= -D_MINIX -D_NETBSD_SOURCE -D_MINIX_COMPAT +LDADD+= -lminlib -lcompat_minix -lasyn +.else CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE +.endif + BINDIR?=/usr/bin diff --git a/commands/aal/archiver.c b/commands/aal/archiver.c index f88841d50..1cdff42b9 100644 --- a/commands/aal/archiver.c +++ b/commands/aal/archiver.c @@ -42,6 +42,9 @@ static char RcsId[] = "$Header$"; #include #include #include +#ifdef __NBSD_LIBC +#include +#endif #ifndef S_IREAD #define S_IREAD S_IRUSR #endif diff --git a/commands/add_route/add_route.c b/commands/add_route/add_route.c index 738952126..a45892cb8 100644 --- a/commands/add_route/add_route.c +++ b/commands/add_route/add_route.c @@ -181,26 +181,49 @@ int main(int argc, char *argv[]) if (!(high_byte & 0x80)) /* class A or 0 */ { if (destination) +#ifdef __NBSD_LIBC + defaultmask= htonl(0xff000000); +#else defaultmask= HTONL(0xff000000); +#endif + } else if (!(high_byte & 0x40)) /* class B */ { +#ifdef __NBSD_LIBC + defaultmask= htonl(0xffff0000); +#else defaultmask= HTONL(0xffff0000); +#endif + } else if (!(high_byte & 0x20)) /* class C */ { +#ifdef __NBSD_LIBC + defaultmask= htonl(0xffffff00); +#else defaultmask= HTONL(0xffffff00); + +#endif } else /* class D is multicast ... */ { fprintf(stderr, "%s: Warning: Martian address '%s'\n", prog_name, inet_ntoa(destination)); +#ifdef __NBSD_LIBC + defaultmask= htonl(0xffffffff); +#else defaultmask= HTONL(0xffffffff); +#endif } if (destination & ~defaultmask) { /* host route */ +#ifdef __NBSD_LIBC + defaultmask= htonl(0xffffffff); +#else defaultmask= HTONL(0xffffffff); +#endif } if (!cidr) netmask= defaultmask; diff --git a/commands/ash/input.c b/commands/ash/input.c index fcd06ebe0..fb234d2a6 100644 --- a/commands/ash/input.c +++ b/commands/ash/input.c @@ -225,7 +225,7 @@ retry: { (void) memcpy(parsenextc, rl_cp+rl_off, nr); parsenextc[nr++]= '\n'; - free(rl_cp); + free((void *)rl_cp); rl_cp= NULL; rl_off= 0; } @@ -385,7 +385,7 @@ pushstring(char *s, int len, void *ap) struct strpush *sp; INTOFF; -/*dprintf("*** calling pushstring: %s, %d\n", s, len);*/ +/*dbgprintf("*** calling pushstring: %s, %d\n", s, len);*/ if (parsefile->strpush) { sp = ckmalloc(sizeof (struct strpush)); sp->prev = parsefile->strpush; @@ -412,7 +412,7 @@ popstring(void) parsenextc = sp->prevstring; parsenleft = sp->prevnleft; parselleft = sp->prevlleft; -/*dprintf("*** calling popstring: restoring to '%s'\n", parsenextc);*/ +/*dbgprintf("*** calling popstring: restoring to '%s'\n", parsenextc);*/ if (sp->ap) sp->ap->flag &= ~ALIASINUSE; parsefile->strpush = sp->prev; diff --git a/commands/ash/output.c b/commands/ash/output.c index fb89e2ade..a1e8f2d2f 100644 --- a/commands/ash/output.c +++ b/commands/ash/output.c @@ -265,7 +265,7 @@ out1fmt(const char *fmt, ...) } void -dprintf(const char *fmt, ...) +dbgprintf(const char *fmt, ...) { va_list ap; @@ -325,7 +325,7 @@ out1fmt(va_alist) } void -dprintf(va_alist) +dbgprintf(va_alist) va_dcl { va_list ap; diff --git a/commands/ash/output.h b/commands/ash/output.h index 44b8b2a28..59c36b3a5 100644 --- a/commands/ash/output.h +++ b/commands/ash/output.h @@ -69,7 +69,7 @@ void flushout(struct output *); void freestdout(void); void outfmt(struct output *, const char *, ...) __printflike(2, 3); void out1fmt(const char *, ...) __printflike(1, 2); -void dprintf(const char *, ...) __printflike(1, 2); +void dbgprintf(const char *, ...) __printflike(1, 2); void fmtstr(char *, int, const char *, ...) __printflike(3, 4); void doformat(struct output *, const char *, va_list) __printflike(2, 0); int xwrite(int, char *, int); diff --git a/commands/ash/shell.h b/commands/ash/shell.h index 9b995c431..7e33f18c1 100644 --- a/commands/ash/shell.h +++ b/commands/ash/shell.h @@ -81,7 +81,7 @@ extern char nullstr[1]; /* null string */ #define TRACE(param) #endif -#ifdef __minix +#if defined(__minix) && !defined(__NBSD_LIBC) typedef long quad_t; /* XXX */ typedef unsigned long u_quad_t; /* XXX */ #endif diff --git a/commands/ash/trap.c b/commands/ash/trap.c index 9cddb6f37..204097351 100644 --- a/commands/ash/trap.c +++ b/commands/ash/trap.c @@ -62,11 +62,10 @@ __FBSDID("$FreeBSD: src/bin/sh/trap.c,v 1.29 2004/04/06 20:06:51 markm Exp $"); #endif #include "builtins.h" -#ifdef __minix +#if defined(__minix) && !defined(__NBSD_LIBC) #define NO_SIGINTERRUPT #define NO_SYS_SIGNAME #define NO_SYS_SIGLIST - #endif typedef void (*sig_T)(int); @@ -560,7 +559,7 @@ int sig; static char *strsigname(sig) int sig; { - return sys_signame[sig]; + return (char *)sys_signame[sig]; } #endif @@ -577,7 +576,7 @@ int sig; char *strsiglist(sig) int sig; { - return sys_siglist[sig]; + return (char *)sys_siglist[sig]; } #endif diff --git a/commands/awk/Makefile b/commands/awk/Makefile index 469184f10..6ceb42417 100644 --- a/commands/awk/Makefile +++ b/commands/awk/Makefile @@ -2,6 +2,8 @@ PROG= awk SRCS= awkgram.y b.c lex.c lib.c main.c parse.c proctab.c run.c tran.c +LDADD= -lm +DEPEND+= ${LIBM} YHEADER= yes QUIET_YACC= yes diff --git a/commands/calendar/calendar.c b/commands/calendar/calendar.c index 92b850291..ebc149d92 100644 --- a/commands/calendar/calendar.c +++ b/commands/calendar/calendar.c @@ -5,7 +5,11 @@ #include #include #include +#ifdef __NBSD_LIBC +#include +#else #include +#endif #include #include #include diff --git a/commands/de/de.h b/commands/de/de.h index 6674098d3..38b142853 100644 --- a/commands/de/de.h +++ b/commands/de/de.h @@ -94,6 +94,12 @@ #define K 1024 /* STD_BLK */ #define K_MASK (~(K-1)) /* Round to K boundary */ #define K_SHIFT 10 /* Ie. 1<<10 = K */ +#ifdef __NBSD_LIBC +/* Name pollution with more famous macros describing machine's + * page size. These defs should be renamed. */ +#undef PAGE_MASK +#undef PAGE_SHIFT +#endif /* __NBSD_LIBC */ #define PAGE_MASK 0x1f /* Word mode: 32 bytes */ #define PAGE_SHIFT 5 /* Ie. 1<<5 = 32 */ #define MAP_BITS_PER_BLOCK (8 * K) /* 1k block, 8192 bits */ diff --git a/commands/dhcpd/dhcpd.c b/commands/dhcpd/dhcpd.c index 6c780b578..b7f190e34 100644 --- a/commands/dhcpd/dhcpd.c +++ b/commands/dhcpd/dhcpd.c @@ -39,7 +39,11 @@ static char *cachefile= PATH_DHCPCACHE; static int qflag; /* True if printing cached DHCP data. */ static int aflag, rflag; /* True if adding or deleting pool addresses. */ +#ifdef __NBSD_LIBC +#define BCAST_IP htonl(0xFFFFFFFFUL) +#else #define BCAST_IP HTONL(0xFFFFFFFFUL) +#endif /* We try to play with up to this many networks. */ #define N_NETS 32 @@ -104,13 +108,24 @@ network_t *if2net(int n) static ipaddr_t defaultmask(ipaddr_t ip) { /* Compute netmask by the oldfashioned Class rules. */ +#ifdef __NBSD_LIBC + if (B(&ip)[0] < 0x80) return htonl(0xFF000000UL); /* Class A. */ + if (B(&ip)[0] < 0xC0) return htonl(0xFFFF0000UL); /* Class B. */ + if (B(&ip)[0] < 0xE0) return htonl(0xFFFFFF00UL); /* Class C. */ + return htonl(0xFFFFFFFFUL); /* Multicast? Shouldn't happen... */ +#else if (B(&ip)[0] < 0x80) return HTONL(0xFF000000UL); /* Class A. */ if (B(&ip)[0] < 0xC0) return HTONL(0xFFFF0000UL); /* Class B. */ if (B(&ip)[0] < 0xE0) return HTONL(0xFFFFFF00UL); /* Class C. */ return HTONL(0xFFFFFFFFUL); /* Multicast? Shouldn't happen... */ +#endif } +#ifdef __NBSD_LIBC +#define POOL_MAGIC htonl(0x81F85D00UL) +#else #define POOL_MAGIC HTONL(0x81F85D00UL) +#endif typedef struct pool { /* Dynamic pool entry. */ u32_t magic; /* Pool file magic number. */ diff --git a/commands/dhcpd/ether.c b/commands/dhcpd/ether.c index c17661b0f..202979471 100644 --- a/commands/dhcpd/ether.c +++ b/commands/dhcpd/ether.c @@ -21,8 +21,13 @@ #include "dhcpd.h" static ether_addr_t BCAST_ETH = {{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }}; +#ifdef __NBSD_LIBC +#define BCAST_IP htonl(0xFFFFFFFFUL) +#define LOCALHOST htonl(0x7F000001UL) +#else #define BCAST_IP HTONL(0xFFFFFFFFUL) #define LOCALHOST HTONL(0x7F000001UL) +#endif static u16_t udp_cksum(ipaddr_t src, ipaddr_t dst, udp_hdr_t *udp) { @@ -64,13 +69,21 @@ void udp2ether(buf_t *bp, network_t *np) /* Fill in the Ethernet, IP and UDP headers. */ bp->eth->eh_dst= BCAST_ETH; bp->eth->eh_src= np->eth; +#ifdef __NBSD_LIBC + bp->eth->eh_proto= htons(ETH_IP_PROTO); +#else bp->eth->eh_proto= HTONS(ETH_IP_PROTO); +#endif bp->ip->ih_vers_ihl= 0x45; bp->ip->ih_tos= 0; bp->ip->ih_length= htons(sizeof(ip_hdr_t) + sizeof(udp_hdr_t) + udpio.uih_data_len); bp->ip->ih_id= 0; +#ifdef __NBSD_LIBC + bp->ip->ih_flags_fragoff= ntohs(0x4000); +#else bp->ip->ih_flags_fragoff= NTOHS(0x4000); +#endif bp->ip->ih_ttl= IP_MAX_TTL; bp->ip->ih_proto= IPPROTO_UDP; bp->ip->ih_hdr_chk= 0; @@ -91,7 +104,11 @@ int ether2udp(buf_t *bp) */ udp_io_hdr_t udpio; +#ifdef __NBSD_LIBC + if (bp->eth->eh_proto != htons(ETH_IP_PROTO) +#else if (bp->eth->eh_proto != HTONS(ETH_IP_PROTO) +#endif || bp->ip->ih_vers_ihl != 0x45 || bp->ip->ih_proto != IPPROTO_UDP || oneC_sum(0, bp->ip, 20) != (u16_t) ~0 @@ -118,12 +135,20 @@ void make_arp(buf_t *bp, network_t *np) memset(arp, 0, sizeof(*arp)); arp->dstaddr= BCAST_ETH; arp->srcaddr= np->eth; +#ifdef __NBSD_LIBC + arp->ethtype= htons(ETH_ARP_PROTO); + arp->hdr= htons(ARP_ETHERNET); + arp->pro= htons(ETH_IP_PROTO); + arp->op= htons(ARP_REQUEST); +#else arp->ethtype= HTONS(ETH_ARP_PROTO); arp->hdr= HTONS(ARP_ETHERNET); arp->pro= HTONS(ETH_IP_PROTO); + arp->op= HTONS(ARP_REQUEST); +#endif arp->hln= 6; arp->pln= 4; - arp->op= HTONS(ARP_REQUEST); + arp->sha= np->eth; memcpy(arp->spa, &np->ip, sizeof(np->ip)); memcpy(arp->tpa, &np->ip, sizeof(np->ip)); @@ -136,10 +161,18 @@ int is_arp_me(buf_t *bp, network_t *np) */ arp46_t *arp= (arp46_t *) bp->eth; - if (arp->ethtype == HTONS(ETH_ARP_PROTO) + if ( +#ifdef __NBSD_LIBC + arp->ethtype == htons(ETH_ARP_PROTO) + && arp->hdr == htons(ARP_ETHERNET) + && arp->pro == htons(ETH_IP_PROTO) + && arp->op == htons(ARP_REPLY) +#else + arp->ethtype == HTONS(ETH_ARP_PROTO) && arp->hdr == HTONS(ARP_ETHERNET) && arp->pro == HTONS(ETH_IP_PROTO) && arp->op == HTONS(ARP_REPLY) +#endif && memcmp(&arp->spa, &np->ip, sizeof(np->ip)) == 0 && memcmp(&arp->sha, &np->eth, sizeof(np->eth)) != 0 ) { @@ -178,7 +211,11 @@ void icmp_advert(buf_t *bp, network_t *np) icmp->ih_hun.ihh_ram.iram_aes= 2; icmp->ih_hun.ihh_ram.iram_lt= htons(DELTA_ADV); ((u32_t *) icmp->ih_dun.uhd_data)[0] = np->gateway; +#ifdef __NBSD_LIBC + ((u32_t *) icmp->ih_dun.uhd_data)[1] = htonl((u32_t) -9999); +#else ((u32_t *) icmp->ih_dun.uhd_data)[1] = HTONL((u32_t) -9999); +#endif icmp->ih_chksum= 0; icmp->ih_chksum= ~oneC_sum(0, icmp, 16); } diff --git a/commands/diff/diff.h b/commands/diff/diff.h index 0eb6a5ef9..4ab7f4388 100644 --- a/commands/diff/diff.h +++ b/commands/diff/diff.h @@ -31,6 +31,9 @@ * @(#)diff.h 8.1 (Berkeley) 6/6/93 */ +#ifdef __NBSD_LIBC +#include +#endif #include #include diff --git a/commands/dis386/type.h b/commands/dis386/type.h index f11b5e238..cf27f8311 100644 --- a/commands/dis386/type.h +++ b/commands/dis386/type.h @@ -114,8 +114,10 @@ void info P((void)); void reboot P((void)); void reset_kbd_state P(()); +#ifndef __NBSD_LIBC /* getline.c */ char *getline P((char *startline, unsigned maxlength, unsigned offset)); +#endif /* ihexload.c */ void ihexload P((void)); diff --git a/commands/elle/sbm.c b/commands/elle/sbm.c index fa4fe0186..060502dda 100644 --- a/commands/elle/sbm.c +++ b/commands/elle/sbm.c @@ -50,7 +50,11 @@ char *sbm_brk(); #endif /*DBG_SIZE*/ /* Forward routine declarations */ +#ifdef __NBSD_LIBC +void *sbrk(); +#else char *sbrk(); +#endif struct smblk *sbm_nmak(), *sbm_nget(), *sbm_mget(), *sbm_split(); struct smblk *sbm_lmak(), *sbm_err(); @@ -759,6 +763,11 @@ free(ptr) char *ptr; { register struct smblk *sm, **smp; +#ifdef __NBSD_LIBC + /* In NetBSD, free is a nop if ptr == NULL; */ + if(ptr == NULL) + return(1); +#endif smp = &((struct smblk **)ptr)[-1]; /* Point to addr-1 */ sm = *smp; /* Pluck SM ptr therefrom */ if(((sm->smflags&0377) != SM_NID) || sm->smaddr != (SBMA)smp) diff --git a/commands/elvis/ref.c b/commands/elvis/ref.c index a0aaf4e86..c830464ae 100644 --- a/commands/elvis/ref.c +++ b/commands/elvis/ref.c @@ -123,6 +123,10 @@ char *cktagdir(tag, dir) /* This function reads a single textline from a binary file. It returns * the number of bytes read, or 0 at EOF. */ +#ifdef __NBSD_LIBC +/* Avoid name pollution with stdio's getline. */ +#define getline ref_getline +#endif int getline(buf, limit, fp) char *buf; /* buffer to read into */ int limit; /* maximum characters to read */ diff --git a/commands/find/find.h b/commands/find/find.h index 4949e90d1..ce4a95f24 100644 --- a/commands/find/find.h +++ b/commands/find/find.h @@ -53,7 +53,9 @@ enum ntype { N_PRUNE, N_REGEX, N_SIZE, N_TYPE, N_USER, N_XDEV, N_DELETE }; +#ifndef __NBSD_LIBC typedef unsigned int u_int32_t; +#endif /* node definition */ typedef struct _plandata { diff --git a/commands/finger/finger.c b/commands/finger/finger.c index ef39187fb..9d92e6643 100644 --- a/commands/finger/finger.c +++ b/commands/finger/finger.c @@ -127,6 +127,12 @@ char *ctime(); char *prog_name; +#ifdef __NBSD_LIBC +/* Already defined in stdio.h */ +#undef fwopen +#define fwopen finger_fwopen +#endif + int main (int argc, char *argv[]); static void doall(void); static void donames(char **args); diff --git a/commands/fix/fix.c b/commands/fix/fix.c index af04cd60e..8c7dba9dc 100644 --- a/commands/fix/fix.c +++ b/commands/fix/fix.c @@ -38,6 +38,10 @@ char *prog = 0, *processing = 0; +#ifdef __NBSD_LIBC +/* getline() already declared in stdio.h */ +#define getline fix_getline +#endif _PROTOTYPE(char *getline, (FILE *fp, char *b)); _PROTOTYPE(char *range, (char *s, int *p1, int *p2)); _PROTOTYPE(int getcommand, (FILE *fp, int *o1, int *o2, char *pcmd, int *n1, int *n2)); diff --git a/commands/ftp101/ftp.c b/commands/ftp101/ftp.c index 20c1661b9..65ee74fe1 100644 --- a/commands/ftp101/ftp.c +++ b/commands/ftp101/ftp.c @@ -45,6 +45,11 @@ char *cmdargv[NUMARGS]; int printreply = 1; char reply[1024]; +#ifdef __NBSD_LIBC +/* Already declared in stdio.h */ +#define getline ftp_getline +#endif + _PROTOTYPE(static void makeargs, (char *buff)); _PROTOTYPE(int DOver, (void)); _PROTOTYPE(int DOhelp, (void)); diff --git a/commands/ftp101/net.c b/commands/ftp101/net.c index a112e4439..09b9ca6d3 100644 --- a/commands/ftp101/net.c +++ b/commands/ftp101/net.c @@ -104,7 +104,11 @@ struct servent *servent; /* This HACK allows the server to establish data connections correctly */ /* when using the loopback device to talk to ourselves */ +#ifdef __NBSD_LIBC + if((hostip & ntohl(0xFF000000)) == inet_addr("127.0.0.0")) +#else if((hostip & NTOHL(0xFF000000)) == inet_addr("127.0.0.0")) +#endif hostip = myip; if((tcp_device = getenv("TCP_DEVICE")) == NULL) @@ -206,7 +210,11 @@ static int ftpdata_fd = -1; char *buff; ipaddr_t ripaddr; tcpport_t rport; +#ifdef __NBSD_LIBC +static tcpport_t lport = htons(0xF000); +#else static tcpport_t lport = HTONS(0xF000); +#endif int s; int i; int wpid; @@ -221,7 +229,11 @@ int wasopen; #endif ripaddr = hostip; +#ifdef __NBSD_LIBC + rport = htons(2); +#else rport = HTONS(20); +#endif /* here we set up a connection to listen on if not passive mode */ /* otherwise we use this to connect for passive mode */ diff --git a/commands/ftpd200/ftpd.c b/commands/ftpd200/ftpd.c index 5727f1b6d..ed0803cfd 100644 --- a/commands/ftpd200/ftpd.c +++ b/commands/ftpd200/ftpd.c @@ -39,6 +39,11 @@ char *FtpdVersion = "2.00"; #include "file.h" #include "net.h" +#ifdef __NBSD_LIBC +/* Already declared in stdio.h */ +#define getline ftpd_getline +#endif + _PROTOTYPE(static void init, (void)); _PROTOTYPE(static int doHELP, (char *buff)); _PROTOTYPE(static int doNOOP, (char *buff)); diff --git a/commands/gcov-pull/gcov-pull.c b/commands/gcov-pull/gcov-pull.c index 8739451af..518fe8f27 100644 --- a/commands/gcov-pull/gcov-pull.c +++ b/commands/gcov-pull/gcov-pull.c @@ -9,7 +9,9 @@ #include #include #include +#ifndef __NBSD_LIBC #include +#endif #include #include #include diff --git a/commands/grep/Makefile b/commands/grep/Makefile index 8aa2ff9c7..47ca3ec59 100644 --- a/commands/grep/Makefile +++ b/commands/grep/Makefile @@ -19,7 +19,7 @@ LDADD= -lz DPADD= ${LIBZ} .if ${COMPILER_TYPE} == "gnu" -CPPFLAGS+= -isystem ../../../include +CFLAGS+= -Wall .endif .if ${OPSYS} == "Minix" diff --git a/commands/host/host.c b/commands/host/host.c index ec800f86e..57808945c 100644 --- a/commands/host/host.c +++ b/commands/host/host.c @@ -16,7 +16,7 @@ * that copyright notice. */ -#if _MINIX +#if _MINIX && !defined(__NBSD_LIBC) #include #include #include @@ -50,6 +50,16 @@ #include #include #include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif extern int h_errno; @@ -73,11 +83,18 @@ extern int h_errno; #ifndef C_HS #define C_HS 4 #endif +#ifndef NOCHANGE +#define NOCHANGE 0xf +#endif FILE *filePtr; +#ifdef __NBSD_LIBC +static struct __res_state orig; +#else struct state orig; extern struct state _res; +#endif static u8_t *cname = NULL; int getclass = C_IN; int gettype, getdeftype = T_A; @@ -91,7 +108,7 @@ int main _ARGS(( int c, char *v[] )); static int parsetype _ARGS(( char *s )); static int parseclass _ARGS(( char *s )); -static void hperror _ARGS(( int errno )); +static void hperror _ARGS(( int err_no )); static void printanswer _ARGS(( struct hostent *hp )); static int ListHosts _ARGS(( char *namePtr, int queryType )); static int gethostinfo _ARGS(( char *name )); @@ -111,7 +128,11 @@ main(c, v) char **v; { char *domain; +#ifdef __NBSD_LIBC + struct in_addr addr; +#else ipaddr_t addr; +#endif register struct hostent *hp; register char *s, *p; register inverse = 0; @@ -195,11 +216,23 @@ main(c, v) hperror(h_errno); exit(1); } +#ifdef __NBSD_LIBC + memcpy(&_res.nsaddr.sin_addr, hp->h_addr, NS_INADDRSZ); +#else _res.nsaddr= *(ipaddr_t *)hp->h_addr; +#endif printf("Using domain server:\n"); printanswer(hp); } else { +#ifdef __NBSD_LIBC + _res.nsaddr.sin_family = AF_INET; + _res.nsaddr.sin_addr = addr; + _res.nsaddr.sin_port = htons(NAMESERVER_PORT); + printf("Using domain server %s:\n", + inet_ntoa(_res.nsaddr.sin_addr)); + +#else _res.nsaddr_list[0]= addr; _res.nsport_list[0]= htons(NAMESERVER_PORT); printf("Using domain server %s", @@ -209,6 +242,7 @@ main(c, v) _res.nsport_list[0]= htons(atoi(p)); } printf(":\n"); +#endif } } domain = v[1]; @@ -340,12 +374,21 @@ printanswer(hp) register struct hostent *hp; { register char **cp; +#ifdef __NBSD_LIBC + struct in_addr **hptr; +#else register ipaddr_t **hptr; +#endif printf("Name: %s\n", hp->h_name); printf("Address:"); +#ifdef __NBSD_LIBC + for (hptr = (struct in_addr **)hp->h_addr_list; *hptr; hptr++) + printf(" %s", inet_ntoa(**hptr)); +#else for (hptr = (ipaddr_t **)hp->h_addr_list; *hptr; hptr++) printf(" %s", inet_ntoa(*(ipaddr_t *)*hptr)); +#endif printf("\nAliases:"); for (cp = hp->h_aliases; cp && *cp && **cp; cp++) printf(" %s", *cp); @@ -353,10 +396,10 @@ printanswer(hp) } static void -hperror(errno) -int errno; +hperror(err_no) +int err_no; { -switch(errno) { +switch(err_no) { case HOST_NOT_FOUND: fprintf(stderr,"Host not found.\n"); break; @@ -372,9 +415,8 @@ switch(errno) { } } - typedef union querybuf { - dns_hdr_t qb1; + HEADER qb1; u8_t qb2[PACKETSZ]; } querybuf_t; @@ -450,7 +492,7 @@ getinfo(name, domain, type) char *name, *domain; { - dns_hdr_t *hp; + HEADER *hp; u8_t *eom, *bp, *cp; querybuf_t buf, answer; int n, n1, i, j, nmx, ancount, nscount, arcount, qdcount, buflen; @@ -488,7 +530,7 @@ printinfo(answer, eom, filter, isls) int filter; int isls; { - dns_hdr_t *hp; + HEADER *hp; u8_t *bp, *cp; int n, n1, i, j, nmx, ancount, nscount, arcount, qdcount, buflen; u_short pref, class; @@ -496,21 +538,44 @@ printinfo(answer, eom, filter, isls) /* * find first satisfactory answer */ - hp = (dns_hdr_t *) answer; + hp = (HEADER *) answer; ancount = ntohs(hp->dh_ancount); qdcount = ntohs(hp->dh_qdcount); nscount = ntohs(hp->dh_nscount); arcount = ntohs(hp->dh_arcount); if (_res.options & RES_DEBUG || (verbose && isls == 0)) printf("rcode = %d (%s), ancount=%d\n", +#ifdef __NBSD_LIBC + hp->rcode, + DecodeError(hp->rcode), +#else hp->dh_flag2 & DHF_RCODE, - DecodeError(hp->dh_flag2 & DHF_RCODE), ancount); - if (hp->dh_flag2 & DHF_RCODE != NOERROR || - (ancount+nscount+arcount) == 0) { - switch (hp->dh_flag2 & DHF_RCODE) { + DecodeError(hp->dh_flag2 & DHF_RCODE), +#endif + ancount); + if ( +#ifdef __NBSD_LIBC + hp->rcode != NOERROR || +#else + hp->dh_flag2 & DHF_RCODE != NOERROR || +#endif + (ancount+nscount+arcount) == 0) { + switch ( +#ifdef __NBSD_LIBC + hp->rcode +#else + hp->dh_flag2 & DHF_RCODE +#endif + ) { case NXDOMAIN: /* Check if it's an authoritive answer */ - if (hp->dh_flag1 & DHF_AA) { + if ( +#ifdef __NBSD_LIBC + hp->aa +#else + hp->dh_flag1 & DHF_AA +#endif + ) { h_errno = HOST_NOT_FOUND; return(0); } else { @@ -546,14 +611,20 @@ printinfo(answer, eom, filter, isls) bp = hostbuf; nmx = 0; buflen = sizeof(hostbuf); - cp = (u8_t *)answer + sizeof(dns_hdr_t); + cp = (u8_t *)answer + sizeof(HEADER); if (qdcount) { cp += dn_skipname((u8_t *)cp,(u8_t *)eom) + QFIXEDSZ; while (--qdcount > 0) cp += dn_skipname((u8_t *)cp,(u8_t *)eom) + QFIXEDSZ; } if (ancount) { - if (!(hp->dh_flag1 & DHF_AA)) + if (! +#ifdef __NBSD_LIBC + hp->aa +#else + (hp->dh_flag1 & DHF_AA) +#endif + ) if (verbose && isls == 0) printf("The following answer is not authoritative:\n"); while (--ancount >= 0 && cp && cp < eom) { @@ -597,7 +668,11 @@ pr_rr(cp, msg, file, filter) int filter; { int type, class, dlen, n, c, proto, ttl; +#ifdef __NBSD_LIBC + struct in_addr inaddr; +#else ipaddr_t inaddr; +#endif u8_t *cp1; struct protoent *protop; struct servent *servp; @@ -751,7 +826,7 @@ pr_rr(cp, msg, file, filter) } break; /* Roy end */ - +#ifndef __NBSD_LIBC case T_UINFO: if (doprint) fprintf(file,"%c%s", punc, cp); @@ -766,7 +841,7 @@ pr_rr(cp, msg, file, filter) cp += sizeof(int); } break; - +#endif case T_WKS: if (dlen < sizeof(u_long) + 1) break; @@ -868,12 +943,14 @@ pr_type(type) return("MAILA"); case T_ANY: /* matches any type */ return("ANY"); +#ifndef __NBSD_LIBC case T_UINFO: return("UINFO"); case T_UID: return("UID"); case T_GID: return("GID"); +#endif default: return (sprintf(nbuf, "%d", type) == EOF ? NULL : nbuf); } @@ -963,7 +1040,7 @@ ListHosts(namePtr, queryType) int queryType; /* e.g. T_A */ { querybuf_t buf, answer; - dns_hdr_t *headerPtr; + HEADER *headerPtr; int msglen; int amtToRead; @@ -1039,22 +1116,55 @@ ListHosts(namePtr, queryType) } if (_res.options & RES_DEBUG || verbose) printf("rcode = %d (%s), ancount=%d\n", +#ifdef __NBSD_LIBC + answer.qb1.rcode, + DecodeError(answer.qb1.rcode), + ntohs(answer.qb1.ancount) +#else answer.qb1.dh_flag2 & DHF_RCODE, DecodeError(answer.qb1.dh_flag2 & DHF_RCODE), - ntohs(answer.qb1.dh_ancount)); + ntohs(answer.qb1.dh_ancount) +#endif + ); /* * Analyze response to our NS lookup */ +#ifdef __NBSD_LIBC + nscount = ntohs(answer.qb1.ancount) + + ntohs(answer.qb1.nscount) + + ntohs(answer.qb1.arcount); +#else nscount = ntohs(answer.qb1.dh_ancount) + ntohs(answer.qb1.dh_nscount) + ntohs(answer.qb1.dh_arcount); +#endif - if (answer.qb1.dh_flag2 & DHF_RCODE != NOERROR || nscount == 0) { - switch (answer.qb1.dh_flag2 & DHF_RCODE) { + + if ( +#ifdef __NBSD_LIBC + answer.qb1.rcode != NOERROR || nscount == 0 +#else + answer.qb1.dh_flag2 & DHF_RCODE != NOERROR || nscount == 0 +#endif + ) { + switch ( +#ifdef __NBSD_LIBC + answer.qb1.rcode +#else + answer.qb1.dh_flag2 & DHF_RCODE +#endif + ) { case NXDOMAIN: /* Check if it's an authoritive answer */ - if (answer.qb1.dh_flag1 & DHF_AA) { + if ( +#ifdef __NBSD_LIBC + answer.qb1.aa +#else + answer.qb1.dh_flag1 & DHF_AA +#endif + ) { + printf("No such domain\n"); } else { printf("Unable to get information about domain -- try again later.\n"); @@ -1075,7 +1185,7 @@ ListHosts(namePtr, queryType) return (0); } - cp = answer.qb2 + sizeof(dns_hdr_t); + cp = answer.qb2 + sizeof(HEADER); if (ntohs(answer.qb1.dh_qdcount) > 0) cp += dn_skipname(cp, answer.qb2 + msglen) + QFIXEDSZ; @@ -1198,7 +1308,11 @@ again: tcpconf.nwtc_flags= NWTC_EXCL | NWTC_LP_SEL | NWTC_SET_RA | NWTC_SET_RP; tcpconf.nwtc_remaddr= *(ipaddr_t *)nsipaddr[thisns]; +#ifdef __NBSD_LIBC + tcpconf.nwtc_remport= _res.nsaddr.sin_port; +#else tcpconf.nwtc_remport= _res.nsport_list[0]; +#endif result= ioctl(tcp_fd, NWIOSTCPCONF, &tcpconf); if (result == -1) { @@ -1295,7 +1409,11 @@ again: break; } +#ifdef __NBSD_LIBC + i = buf.qb1.rcode; +#else i = buf.qb1.dh_flag2 & DHF_RCODE; +#endif if (i != NOERROR || ntohs(buf.qb1.dh_ancount) == 0) { if ((thisns+1) < numnsaddr && (i == SERVFAIL || i == NOTIMP || i == REFUSED)) { @@ -1319,7 +1437,7 @@ again: break; } numAnswers++; - cp = buf.qb2 + sizeof(dns_hdr_t); + cp = buf.qb2 + sizeof(HEADER); if (ntohs(buf.qb1.dh_qdcount) > 0) cp += dn_skipname(cp, buf.qb2 + len) + QFIXEDSZ; @@ -1351,11 +1469,15 @@ again: return(result); case ERR_READING_MSG: - headerPtr = (dns_hdr_t *) &buf; + headerPtr = (HEADER *) &buf; fprintf(stderr,"ListHosts: error receiving zone transfer:\n"); fprintf(stderr, " result: %s, answers = %d, authority = %d, additional = %d\n", +#ifdef __NBSD_LIBC + resultcodes[headerPtr->rcode], +#else resultcodes[headerPtr->dh_flag2 & DHF_RCODE], +#endif ntohs(headerPtr->dh_ancount), ntohs(headerPtr->dh_nscount), ntohs(headerPtr->dh_arcount)); diff --git a/commands/hostaddr/hostaddr.c b/commands/hostaddr/hostaddr.c index 01d7f4807..a33cba9c9 100644 --- a/commands/hostaddr/hostaddr.c +++ b/commands/hostaddr/hostaddr.c @@ -16,6 +16,10 @@ Created: Jan 27, 1992 by Philip Homburg #include #include +#ifdef __NBSD_LIBC +#include +#endif + #include #include #include diff --git a/commands/ipcs/ipcs.c b/commands/ipcs/ipcs.c index ebb9c6ef0..640efdb8f 100644 --- a/commands/ipcs/ipcs.c +++ b/commands/ipcs/ipcs.c @@ -35,6 +35,7 @@ /* remove _() stuff */ #define _(a) a +#ifndef __NBSD_LIBC typedef unsigned long ulong; void err(int eval, const char *fmt, ...) { @@ -44,6 +45,7 @@ void err(int eval, const char *fmt, ...) va_end(ap); exit(eval); } +#endif /*-------------------------------------------------------------------*/ /* SHM_DEST and SHM_LOCKED are defined in kernel headers, diff --git a/commands/irdpd/irdpd.c b/commands/irdpd/irdpd.c index e818cd2dd..2061ee95b 100644 --- a/commands/irdpd/irdpd.c +++ b/commands/irdpd/irdpd.c @@ -229,8 +229,11 @@ void time_functions(void) icmp_hdr= (icmp_hdr_t *) (ip_hdr + 1); ip_hdr->ih_vers_ihl= 0x45; +#ifdef __NBSD_LIBC + ip_hdr->ih_dst= htonl(0xFFFFFFFFL); +#else ip_hdr->ih_dst= HTONL(0xFFFFFFFFL); - +#endif icmp_hdr->ih_type= ICMP_TYPE_ROUTE_SOL; icmp_hdr->ih_code= 0; icmp_hdr->ih_chksum= 0; @@ -253,7 +256,11 @@ void time_functions(void) * broadcast them (to keep bad hosts up.) */ +#ifdef __NBSD_LIBC + advertize(bcast ? htonl(0xFFFFFFFFL) : htonl(0x7F000001L)); +#else advertize(bcast ? HTONL(0xFFFFFFFFL) : HTONL(0x7F000001L)); +#endif next_advert= now + MaxAdvertisementInterval; #if !__minix_vmd /* Make sure we are listening to RIP now. */ @@ -570,7 +577,11 @@ int main(int argc, char **argv) ipopt.nwio_ttl= 1; ipopt.nwio_df= 0; ipopt.nwio_hdropt.iho_opt_siz= 0; +#ifdef __NBSD_LIBC + ipopt.nwio_rem= htonl(0xFFFFFFFFL); +#else ipopt.nwio_rem= HTONL(0xFFFFFFFFL); +#endif ipopt.nwio_proto= IPPROTO_ICMP; if (ioctl(irdp_fd, NWIOSIPOPT, &ipopt) < 0) diff --git a/commands/logger/logger.c b/commands/logger/logger.c index cce35f3db..68aa271b6 100644 --- a/commands/logger/logger.c +++ b/commands/logger/logger.c @@ -100,14 +100,22 @@ int pencode(char *s) for (save = s; *s && *s != '.'; ++s); if (*s) { *s = '\0'; +#ifdef __NBSD_LIBC + fac = decode(save, facilitynames); +#else fac = decode(save, FacNames); +#endif if (fac < 0) bailout("unknown facility name:", save); *s++ = '.'; } else { fac = 0; s = save; } +#ifdef __NBSD_LIBC + lev = decode(s, prioritynames); +#else lev = decode(s, PriNames); +#endif if (lev < 0) bailout("unknown priority name:", save); return((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); } diff --git a/commands/login/login.c b/commands/login/login.c index 9f2fd81b4..9fbabcd94 100644 --- a/commands/login/login.c +++ b/commands/login/login.c @@ -135,7 +135,11 @@ int uid; /* user id */ if (fd >= 0) close(fd); /* Enter new fields. */ +#ifdef __NBSD_LIBC + strncpy(entry.ut_name, user, sizeof(entry.ut_name)); +#else strncpy(entry.ut_user, user, sizeof(entry.ut_user)); +#endif if (hostname) strncpy(entry.ut_host, hostname, sizeof(entry.ut_host)); if (entry.ut_pid == 0) entry.ut_pid = getpid(); diff --git a/commands/ls/ls.c b/commands/ls/ls.c index 4c45c3188..67965aa59 100644 --- a/commands/ls/ls.c +++ b/commands/ls/ls.c @@ -447,6 +447,10 @@ char *cxsize(struct file *f) static int (*CMP)(struct file *f1, struct file *f2); static int (*rCMP)(struct file *f1, struct file *f2); +#ifdef __NBSD_LIBC +#define mergesort _ls_mergesort +#endif + static void mergesort(struct file **al) /* This is either a stable mergesort, or thermal noise, I'm no longer sure. * It must be called like this: if (L != nil && L->next != nil) mergesort(&L); diff --git a/commands/mdb/gnu_sym.c b/commands/mdb/gnu_sym.c index 2c3a54e75..803d39b24 100644 --- a/commands/mdb/gnu_sym.c +++ b/commands/mdb/gnu_sym.c @@ -13,7 +13,11 @@ #include #include #include +#ifdef __NBSD_LIBC +#include +#else #include +#endif #include "proto.h" #define NN_UNDF 0 diff --git a/commands/mdb/io.c b/commands/mdb/io.c index 874fde4d1..968f55d9f 100644 --- a/commands/mdb/io.c +++ b/commands/mdb/io.c @@ -74,6 +74,7 @@ PUBLIC int Printf(const char *format, ...) { va_list ap; int retval; +#ifndef __NBSD_LIBC FILE tmp_stream; va_start(ap, format); @@ -86,7 +87,11 @@ PUBLIC int Printf(const char *format, ...) retval = _doprnt(format, ap, &tmp_stream); putc('\0',&tmp_stream); +#else + va_start(ap, format); + retval = vsnprintf(outbuf, OUTBUFSIZE, format, ap); +#endif va_end(ap); outstr(outbuf); diff --git a/commands/mkfs.mfs/mkfs.c b/commands/mkfs.mfs/mkfs.c index c76edb192..cad8d5b78 100644 --- a/commands/mkfs.mfs/mkfs.c +++ b/commands/mkfs.mfs/mkfs.c @@ -88,6 +88,10 @@ unsigned int block_size; FILE *proto; +#ifdef __NBSD_LIBC +#define getline _mkfs_getline +#endif + _PROTOTYPE(int main, (int argc, char **argv)); _PROTOTYPE(block_t sizeup, (char *device)); _PROTOTYPE(void super, (zone_t zones, Ino_t inodes)); diff --git a/commands/mknod/mknod.c b/commands/mknod/mknod.c index 223e2c1e6..7956c14d5 100644 --- a/commands/mknod/mknod.c +++ b/commands/mknod/mknod.c @@ -6,6 +6,9 @@ #include #include #include +#ifdef __NBSD_LIBC +#include +#endif _PROTOTYPE(int main, (int argc, char *argv [])); _PROTOTYPE(void badcomm, (void)); diff --git a/commands/nonamed/nonamed.c b/commands/nonamed/nonamed.c index 4206b3322..39feae121 100644 --- a/commands/nonamed/nonamed.c +++ b/commands/nonamed/nonamed.c @@ -26,6 +26,10 @@ static const char version[] = "2.7"; #include #include #include +#ifdef __NBSD_LIBC +#include +#include +#endif #include #include #include @@ -43,6 +47,13 @@ static const char version[] = "2.7"; #include +#ifdef __NBSD_LIBC +#undef HTONL +#undef HTONS +#define HTONL htonl +#define HTONS htons +#endif + #define HTTL 3600L /* Default time to live for /etc/hosts data. */ #define SHORT_TIMEOUT 2 /* If you expect an answer soon. */ #define MEDIUM_TIMEOUT 4 /* Soon, but not that soon. */ @@ -133,8 +144,8 @@ static char *nowgmt(void) #define namencmp(n1, n2, len) strncasecmp(PC(n1), PC(n2), len) typedef struct dns { /* A DNS packet. */ - dns_hdr_t hdr; /* DNS header. */ - u8_t data[PACKETSZ - sizeof(dns_hdr_t)]; /* DNS data. */ + HEADER hdr; /* DNS header. */ + u8_t data[PACKETSZ - sizeof(HEADER)]; /* DNS data. */ } dns_t; /* Addres of DNS packet to octet address, or vv. */ @@ -344,12 +355,25 @@ static void dns_tell(int indent, dns_t *dp, size_t size) "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED" }; - if (size < sizeof(dns_hdr_t)) return; + if (size < sizeof(HEADER)) return; printf("%*s", indent, ""); +#ifdef __NBSD_LIBC + printf("DNS %s:", (dp->hdr.qr) ? "reply" : "query"); + r = dp->hdr.rcode; +#else printf("DNS %s:", (dp->hdr.dh_flag1 & DHF_QR) ? "reply" : "query"); r= dp->hdr.dh_flag2 & DHF_RCODE; +#endif printf(" %s", r < arraysize(rcodes) ? rcodes[r] : itoa("ERR_%lu", r)); +#ifdef __NBSD_LIBC + if (dp->hdr.aa) printf(" AA"); + if (dp->hdr.tc) printf(" TC"); + if (dp->hdr.rd) printf(" RD"); + if (dp->hdr.ra) printf(" RA"); + if (dp->hdr.ad) printf(" AD"); + if (dp->hdr.cd) printf(" CD"); +#else if (dp->hdr.dh_flag1 & DHF_AA) printf(" AA"); if (dp->hdr.dh_flag1 & DHF_TC) printf(" TC"); if (dp->hdr.dh_flag1 & DHF_RD) printf(" RD"); @@ -357,6 +381,7 @@ static void dns_tell(int indent, dns_t *dp, size_t size) #ifdef DHF_AD if (dp->hdr.dh_flag2 & DHF_AD) printf(" AD"); if (dp->hdr.dh_flag2 & DHF_CD) printf(" CD"); +#endif #endif fputc('\n', stdout); @@ -394,9 +419,13 @@ static u32_t dns_ttl(dns_t *dp, size_t size, u32_t delta) hasttl= hassoa= 0; minttl= 365*24*3600L; dlim= dns2oct(dp) + size; - if (size < sizeof(dns_hdr_t)) return 0; + if (size < sizeof(HEADER)) return 0; +#ifdef __NBSD_LIBC + rcode= dp->hdr.rcode; +#else rcode= dp->hdr.dh_flag2 & DHF_RCODE; +#endif count[0]= ntohs(dp->hdr.dh_qdcount); count[1]= ntohs(dp->hdr.dh_ancount); count[2]= ntohs(dp->hdr.dh_nscount); @@ -898,8 +927,21 @@ static int query_hosts(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen) if (single) return 0; /* Assume we can answer. */ +#ifdef __NBSD_LIBC + dns.hdr.qr = 1; + dns.hdr.opcode = 0; + dns.hdr.aa = 1; + dns.hdr.tc = 0; + dns.hdr.rd = 0; + dns.hdr.ra = 1; + dns.hdr.unused = 0; + dns.hdr.ad = 0; + dns.hdr.cd = 0; + dns.hdr.rcode = 0; +#else dns.hdr.dh_flag1= DHF_QR | DHF_AA; dns.hdr.dh_flag2= DHF_RA; +#endif dns.hdr.dh_qdcount= HTONS(1); ancount= 0; dns.hdr.dh_nscount= HTONS(0); @@ -1035,8 +1077,21 @@ static int query_chaos(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen) if (type != HTONS(T_TXT) || namecmp(qname, "version.bind") != 0) return 0; +#ifdef __NBSD_LIBC + dns.hdr.qr = 1; + dns.hdr.opcode = 0; + dns.hdr.aa = 1; + dns.hdr.tc = 0; + dns.hdr.rd = 0; + dns.hdr.ra = 1; + dns.hdr.unused = 0; + dns.hdr.ad = 0; + dns.hdr.cd = 0; + dns.hdr.rcode = 0; +#else dns.hdr.dh_flag1= DHF_QR | DHF_AA; dns.hdr.dh_flag2= DHF_RA; +#endif dns.hdr.dh_qdcount= HTONS(1); dns.hdr.dh_ancount= HTONS(1); dns.hdr.dh_nscount= HTONS(0); @@ -1104,7 +1159,11 @@ static void cache_reply(dns_t *dp, size_t dlen) u8_t name[MAXDNAME]; u32_t minttl; +#if __NBSD_LIBC + if ((dp->hdr.rd && !dp->hdr.tc)) return; +#else if ((dp->hdr.dh_flag1 & (DHF_RD | DHF_TC)) != DHF_RD) return; +#endif if (dp->hdr.dh_qdcount != HTONS(1)) return; cp= dp->data; r= dn_expand(dns2oct(dp), dns2oct(dp) + dlen, cp, name, MAXDNAME); @@ -1188,14 +1247,27 @@ static int compose_reply(dns_t *dp, size_t *pdlen) /* Remember ID and RD. */ id= dp->hdr.dh_id; +#ifdef __NBSD_LIBC + rd= dp->hdr.rd; +#else rd= dp->hdr.dh_flag1 & DHF_RD; +#endif if (r == -1) { /* Malformed query, reply "FORMERR". */ +#ifdef __NBSD_LIBC + dp->hdr.tc = 0; + dp->hdr.qr = 1; + dp->hdr.aa = 1; + dp->hdr.unused = 0; + dp->hdr.ra = 1; + dp->hdr.rcode = FORMERR; +#else dp->hdr.dh_flag1 &= ~(DHF_TC); dp->hdr.dh_flag1 |= DHF_QR | DHF_AA; dp->hdr.dh_flag2 &= ~(DHF_UNUSED | DHF_RCODE); dp->hdr.dh_flag2 |= DHF_RA | FORMERR; +#endif } else if (class == HTONS(C_IN) && query_hosts(name, type, dp, pdlen)) { /* Answer to this query is in the hosts file. */ @@ -1204,7 +1276,11 @@ static int compose_reply(dns_t *dp, size_t *pdlen) if (class == HTONS(C_IN) && (qp= get_query(name, type)) != nil) { /* Answer to this query is present in the cache. */ memcpy(dp, &qp->dns, dlen= qp->size); +#ifdef __NBSD_LIBC + dp->hdr.aa = 1; +#else dp->hdr.dh_flag1 &= ~DHF_AA; +#endif (void) dns_ttl(dp, dlen, now - qp->age); if (rd) { if (qp->stale <= now) { @@ -1223,17 +1299,34 @@ static int compose_reply(dns_t *dp, size_t *pdlen) /* No real name daemon present, or this name has a repeated top level * domain sequence. Reply "no such domain". */ +#ifdef __NBSD_LIBC + dp->hdr.tc = 0; + dp->hdr.qr = 1; + dp->hdr.aa = 1; + dp->hdr.unused = 0; + dp->hdr.ra = 1; + dp->hdr.rcode = NXDOMAIN; +#else dp->hdr.dh_flag1 &= ~(DHF_TC); dp->hdr.dh_flag1 |= DHF_QR | DHF_AA; dp->hdr.dh_flag2 &= ~(DHF_UNUSED | DHF_RCODE); dp->hdr.dh_flag2 |= DHF_RA | NXDOMAIN; +#endif } else if (!rd) { /* "Recursion Desired" is off, so don't bother to relay. */ +#ifdef __NBSD_LIBC + dp->hdr.tc = 0; + dp->hdr.qr = 1; + dp->hdr.unused = 0; + dp->hdr.ra = 1; + dp->hdr.rcode = NOERROR; +#else dp->hdr.dh_flag1 &= ~(DHF_TC); dp->hdr.dh_flag1 |= DHF_QR; dp->hdr.dh_flag2 &= ~(DHF_UNUSED | DHF_RCODE); dp->hdr.dh_flag2 |= DHF_RA | NOERROR; +#endif } else { /* Caller needs to consult with a real name daemon. */ return 0; @@ -1241,8 +1334,12 @@ static int compose_reply(dns_t *dp, size_t *pdlen) /* Copy ID and RD back to answer. */ dp->hdr.dh_id= id; +#ifdef __NBSD_LIBC + dp->hdr.rd = rd; +#else dp->hdr.dh_flag1 &= ~DHF_RD; dp->hdr.dh_flag1 |= rd; +#endif *pdlen= dlen; return 1; } @@ -1295,8 +1392,22 @@ static void refresh_cache(void) dlen= cp - dns2oct(&udp.dns); udp.dns.hdr.dh_id= new_id(ID_REFRESH, my_port, ID_IPSELF); +#ifdef __NBSD_LIBC + udp.dns.hdr.qr = 0; + udp.dns.hdr.opcode = 0; + udp.dns.hdr.aa = 0; + udp.dns.hdr.tc = 0; + udp.dns.hdr.rd = 1; + + udp.dns.hdr.ra = 0; + udp.dns.hdr.unused = 0; + udp.dns.hdr.ad = 0; + udp.dns.hdr.cd = 0; + udp.dns.hdr.rcode = 0; +#else udp.dns.hdr.dh_flag1= DHF_RD; udp.dns.hdr.dh_flag2= 0; +#endif udp.dns.hdr.dh_qdcount= HTONS(1); udp.dns.hdr.dh_ancount= HTONS(0); udp.dns.hdr.dh_nscount= HTONS(0); @@ -1348,7 +1459,7 @@ static int job_read_udp(void *data, int expired) /* Restart this job no matter what. */ newjob(job_read_udp, NEVER, nil); - if (ulen < (ssize_t) (sizeof(udp_io_hdr_t) + sizeof(dns_hdr_t))) return 1; + if (ulen < (ssize_t) (sizeof(udp_io_hdr_t) + sizeof(HEADER))) return 1; if (debug >= 1) { printf("%s:%u UDP ", inet_ntoa(udp.hdr.uih_src_addr), @@ -1359,7 +1470,13 @@ static int job_read_udp(void *data, int expired) /* Check, and if necessary reinitialize my configuration. */ init_config(udp.hdr.uih_dst_addr); - if (udp.dns.hdr.dh_flag1 & DHF_QR) { + if ( +#ifdef __NBSD_LIBC + udp.dns.hdr.qr +#else + udp.dns.hdr.dh_flag1 & DHF_QR +#endif + ) { /* This is a remote named reply, not a query. */ /* Response to a query previously relayed? */ @@ -1918,8 +2035,21 @@ static void named_probe(ipaddr_t ip) * "What are the name servers for the root domain?" */ udp.dns.hdr.dh_id= new_id(ID_PROBE, my_port, ID_IPSELF); +#ifdef __NBSD_LIBC + udp.dns.hdr.qr = 0; + udp.dns.hdr.opcode = 0; + udp.dns.hdr.aa = 0; + udp.dns.hdr.tc = 0; + udp.dns.hdr.rd = 0; + udp.dns.hdr.ra = 0; + udp.dns.hdr.unused = 0; + udp.dns.hdr.ad = 0; + udp.dns.hdr.cd = 0; + udp.dns.hdr.rcode = 0; +#else udp.dns.hdr.dh_flag1= 0; udp.dns.hdr.dh_flag2= 0; +#endif udp.dns.hdr.dh_qdcount= HTONS(1); udp.dns.hdr.dh_ancount= HTONS(0); udp.dns.hdr.dh_nscount= HTONS(0); diff --git a/commands/padtext/padtext.c b/commands/padtext/padtext.c index 761c3c3e1..580b25e60 100644 --- a/commands/padtext/padtext.c +++ b/commands/padtext/padtext.c @@ -7,7 +7,11 @@ #include #include #include +#ifdef __NBSD_LIBC +#include +#else #include +#endif #include #include #include diff --git a/commands/pax/options.c b/commands/pax/options.c index 49b6fde84..8f5547abc 100644 --- a/commands/pax/options.c +++ b/commands/pax/options.c @@ -68,6 +68,10 @@ static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; * Routines which handle command line options */ +#ifdef __NBSD_LIBC +#define getline pax_getline +#endif + static char flgch[] = FLGCH; /* list of all possible flags */ static OPLIST *ophead = NULL; /* head for format specific options -x */ static OPLIST *optail = NULL; /* option tail */ diff --git a/commands/pwdauth/pwdauth.c b/commands/pwdauth/pwdauth.c index 65044b7f7..e1e047199 100644 --- a/commands/pwdauth/pwdauth.c +++ b/commands/pwdauth/pwdauth.c @@ -24,6 +24,11 @@ #include #include +#ifdef __NBSD_LIBC +#define setkey pwdauth_setkey +#define encrypt pwdauth_encrypt +#endif + #define LEN 1024 char SHADOW[] = "/etc/shadow"; diff --git a/commands/rarpd/rarpd.c b/commands/rarpd/rarpd.c index abb1872ea..d989a5ad9 100644 --- a/commands/rarpd/rarpd.c +++ b/commands/rarpd/rarpd.c @@ -40,6 +40,11 @@ Changed: Dec 11, 2000 by Kees J. Bot #define MAX_RARP_RETRIES 5 #define RARP_TIMEOUT 5 +#ifdef __NBSD_LIBC +#undef HTONS +#define HTONS htons +#endif + typedef struct rarp46 { ether_addr_t a46_dstaddr; diff --git a/commands/reboot/log.c b/commands/reboot/log.c index b54957ba9..bd3e2df8c 100644 --- a/commands/reboot/log.c +++ b/commands/reboot/log.c @@ -55,9 +55,17 @@ void write_log() fd = open(WTMP,O_APPEND|O_WRONLY,1); if (fd) { if (strcmp(prog,"reboot")) +#ifdef __NBSD_LIBC + strcpy (wtmp.ut_name, prog); +#else strcpy (wtmp.ut_user, prog); +#endif else +#ifdef __NBSD_LIBC + strcpy (wtmp.ut_name, "shutdown"); /* last ... */ +#else strcpy (wtmp.ut_user, "shutdown"); /* last ... */ +#endif strcpy (wtmp.ut_id, "~~"); strcpy (wtmp.ut_line, "~"); wtmp.ut_pid = 0; diff --git a/commands/reboot/shutdown.c b/commands/reboot/shutdown.c index 74b5770f1..5937701de 100644 --- a/commands/reboot/shutdown.c +++ b/commands/reboot/shutdown.c @@ -396,8 +396,14 @@ int crash_check() crashed = (lseek(fd, - (off_t) sizeof(last), SEEK_END) == -1 || read(fd, (void *) &last, sizeof(last)) != sizeof(last) || last.ut_line[0] != '~' +#ifdef __NBSD_LIBC + || (strncmp(last.ut_name, "shutdown", sizeof(last.ut_name)) + && strncmp(last.ut_name, "halt", sizeof(last.ut_name))) +#else || (strncmp(last.ut_user, "shutdown", sizeof(last.ut_user)) - && strncmp(last.ut_user, "halt", sizeof(last.ut_user)))); + && strncmp(last.ut_user, "halt", sizeof(last.ut_user))) +#endif + ); close(fd); return crashed; } diff --git a/commands/recwave/recwave.c b/commands/recwave/recwave.c index d93690a04..6af311904 100644 --- a/commands/recwave/recwave.c +++ b/commands/recwave/recwave.c @@ -69,7 +69,6 @@ unsigned int sign = 0; unsigned int bits = 8; unsigned int stereo = 0; unsigned int rate = 22050; -unsigned int time = 10; int old_stdin; struct termios old_tty, new_tty; diff --git a/commands/stty/stty.c b/commands/stty/stty.c index 95135eaa4..f97db69f1 100644 --- a/commands/stty/stty.c +++ b/commands/stty/stty.c @@ -19,6 +19,9 @@ #include #include #endif +#ifdef __NBSD_LIBC +#include +#endif /* Default settings, the Minix ones are defined in */ diff --git a/commands/syslogd/syslogd.c b/commands/syslogd/syslogd.c index 48d5860eb..1156aea1f 100644 --- a/commands/syslogd/syslogd.c +++ b/commands/syslogd/syslogd.c @@ -502,7 +502,11 @@ void cfline(char *line, struct filed * fLog) while (strchr(", ;", *q)) q++; /* Decode priority name */ +#ifdef __NBSD_LIBC + pri = decode(buf, prioritynames); +#else pri = decode(buf, PriNames); +#endif if (pri < 0) { sprintf(xbuf, "unknown priority name \"%s\"", buf); logerror(xbuf); @@ -520,7 +524,11 @@ void cfline(char *line, struct filed * fLog) fLog->f_pmask[ix] = pri; } } else { +#ifdef __NBSD_LIBC + ix = decode(buf, facilitynames); +#else ix = decode(buf, FacNames); +#endif if (ix < 0) { sprintf(xbuf, "unknown facility name \"%s\"", buf); logerror(xbuf); diff --git a/commands/talk/talk.c b/commands/talk/talk.c index 6450eedbf..832922f76 100644 --- a/commands/talk/talk.c +++ b/commands/talk/talk.c @@ -67,8 +67,13 @@ FILE *fp; return(-1); } fclose(fp); +#ifdef __NBSD_LIBC + strncpy(luser, utmp.ut_name, USER_SIZE < sizeof(utmp.ut_name) ? + USER_SIZE : sizeof(utmp.ut_name)); +#else strncpy(luser, utmp.ut_user, USER_SIZE < sizeof(utmp.ut_user) ? USER_SIZE : sizeof(utmp.ut_user)); +#endif luser[USER_SIZE] = '\0'; /* get local tty */ diff --git a/commands/talkd/finduser.c b/commands/talkd/finduser.c index 82049cd86..7bb0145a0 100644 --- a/commands/talkd/finduser.c +++ b/commands/talkd/finduser.c @@ -31,7 +31,11 @@ struct utmp utmp; while(read(fd, &utmp, sizeof(struct utmp)) == sizeof(struct utmp)) { if(utmp.ut_type != USER_PROCESS) continue; +#ifdef __NBSD_LIBC + if(strncmp(utmp.ut_name, name, sizeof(utmp.ut_name))) continue; +#else if(strncmp(utmp.ut_user, name, sizeof(utmp.ut_user))) continue; +#endif if(*tty && strncmp(utmp.ut_line, tty, sizeof(utmp.ut_line))) continue; strcpy(tty, utmp.ut_line); ret = SUCCESS; diff --git a/commands/tar/config.h b/commands/tar/config.h index 133b6d5bc..db48c55d6 100644 --- a/commands/tar/config.h +++ b/commands/tar/config.h @@ -728,7 +728,9 @@ /* #undef gid_t */ /* Define to `unsigned long' if does not define. */ +#ifndef __NBSD_LIBC #define id_t unsigned long +#endif /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ diff --git a/commands/uniq/uniq.c b/commands/uniq/uniq.c index e12ce4d16..e5785ca8c 100644 --- a/commands/uniq/uniq.c +++ b/commands/uniq/uniq.c @@ -24,6 +24,10 @@ int cflag = 0; int fields = 0; int chars = 0; +#ifdef __NBSD_LIBC +#define getline unix_getline +#endif + _PROTOTYPE(int main, (int argc, char **argv)); _PROTOTYPE(FILE *xfopen, (char *fn, char *mode)); _PROTOTYPE(char *skip, (char *s)); diff --git a/commands/writeisofs/writeisofs.c b/commands/writeisofs/writeisofs.c index 0a66d9d95..37409c42a 100644 --- a/commands/writeisofs/writeisofs.c +++ b/commands/writeisofs/writeisofs.c @@ -21,9 +21,11 @@ extern char *optarg; extern int optind; +#ifndef __NBSD_LIBC typedef unsigned char u_int8_t; typedef unsigned short int u_int16_t; typedef unsigned long int u_int32_t; +#endif #ifndef min #define min(a,b) ((a) < (b) ? (a) : (b)) diff --git a/common/lib/libc/arch/i386/atomic/Makefile.inc b/common/lib/libc/arch/i386/atomic/Makefile.inc index 5a7ca58bf..b88c24af5 100644 --- a/common/lib/libc/arch/i386/atomic/Makefile.inc +++ b/common/lib/libc/arch/i386/atomic/Makefile.inc @@ -1,7 +1,7 @@ # $NetBSD: Makefile.inc,v 1.7 2009/01/04 17:54:29 pooka Exp $ .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ - || ${LIB} == "rump") + || ${LIB} == "rump" || (defined(__MINIX) && ${LIB} == "sys")) SRCS+= atomic_add_64_cas.c atomic_add_64_nv_cas.c atomic_and_64_cas.c \ atomic_and_64_nv_cas.c atomic_dec_64_cas.c atomic_dec_64_nv_cas.c \ diff --git a/common/lib/libc/minix-port.patch b/common/lib/libc/minix-port.patch index cdccb5106..71b1d5037 100644 --- a/common/lib/libc/minix-port.patch +++ b/common/lib/libc/minix-port.patch @@ -1,6 +1,6 @@ -diff -ru /home/netbsd/src/common/lib/libc/Makefile.inc ./Makefile.inc ---- /home/netbsd/src/common/lib/libc/Makefile.inc 2008-10-27 03:01:48.000000000 +0000 -+++ ./Makefile.inc 2011-02-15 13:10:57.000000000 +0000 +diff -ru nbsdsrc/src/common/lib/libc/Makefile.inc common/lib/libc/Makefile.inc +--- nbsdsrc/src/common/lib/libc/Makefile.inc ++++ common/lib/libc/Makefile.inc @@ -1,7 +1,11 @@ # $NetBSD: Makefile.inc,v 1.10 2008/10/26 07:22:50 mrg Exp $ @@ -13,9 +13,21 @@ diff -ru /home/netbsd/src/common/lib/libc/Makefile.inc ./Makefile.inc COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 .if defined(COMMON_MACHINE_ARCH) && !empty(COMMON_MACHINE_ARCH) && \ -diff -ru /home/netbsd/src/common/lib/libc/arch/i386/string/strchr.S ./arch/i386/string/strchr.S ---- /home/netbsd/src/common/lib/libc/arch/i386/string/strchr.S 2009-07-18 03:01:04.000000000 +0000 -+++ ./arch/i386/string/strchr.S 2011-02-15 13:26:06.000000000 +0000 +diff -ru nbsdsrc/src/common/lib/libc/arch/i386/atomic/Makefile.inc common/lib/libc/arch/i386/atomic/Makefile.inc +--- nbsdsrc/src/common/lib/libc/arch/i386/atomic/Makefile.inc ++++ common/lib/libc/arch/i386/atomic/Makefile.inc +@@ -1,7 +1,7 @@ + # $NetBSD: Makefile.inc,v 1.7 2009/01/04 17:54:29 pooka Exp $ + + .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ +- || ${LIB} == "rump") ++ || ${LIB} == "rump" || (defined(__MINIX) && ${LIB} == "sys")) + + SRCS+= atomic_add_64_cas.c atomic_add_64_nv_cas.c atomic_and_64_cas.c \ + atomic_and_64_nv_cas.c atomic_dec_64_cas.c atomic_dec_64_nv_cas.c \ +diff -ru nbsdsrc/src/common/lib/libc/arch/i386/string/strchr.S common/lib/libc/arch/i386/string/strchr.S +--- nbsdsrc/src/common/lib/libc/arch/i386/string/strchr.S ++++ common/lib/libc/arch/i386/string/strchr.S @@ -100,4 +100,8 @@ popl %esi ret @@ -25,9 +37,9 @@ diff -ru /home/netbsd/src/common/lib/libc/arch/i386/string/strchr.S ./arch/i386/ +#else STRONG_ALIAS(index,strchr) +#endif -diff -ru /home/netbsd/src/common/lib/libc/arch/i386/string/strrchr.S ./arch/i386/string/strrchr.S ---- /home/netbsd/src/common/lib/libc/arch/i386/string/strrchr.S 2009-07-18 03:01:04.000000000 +0000 -+++ ./arch/i386/string/strrchr.S 2011-02-15 13:27:15.000000000 +0000 +diff -ru nbsdsrc/src/common/lib/libc/arch/i386/string/strrchr.S common/lib/libc/arch/i386/string/strrchr.S +--- nbsdsrc/src/common/lib/libc/arch/i386/string/strrchr.S ++++ common/lib/libc/arch/i386/string/strrchr.S @@ -93,4 +93,8 @@ popl %esi ret diff --git a/docs/UPDATING b/docs/UPDATING index a1eb1ef2f..9b19fe13d 100644 --- a/docs/UPDATING +++ b/docs/UPDATING @@ -1,4 +1,10 @@ + Populate it with new includes; you need the new install: + # cd /usr/src/commands/install + # make clean install + # cd /usr/src + # make includes + 20110228: (Next release bumped to MINIX 3.2.0.) ELF support in the base system. /usr/lib libraries diff --git a/drivers/Makefile.inc b/drivers/Makefile.inc index 7d3ec0536..4d5669aca 100644 --- a/drivers/Makefile.inc +++ b/drivers/Makefile.inc @@ -1,2 +1,8 @@ +.if (${NBSD_LIBC} != "no") +CPPFLAGS+= -D_MINIX -D_NETBSD_SOURCE +LDADD+= -lminlib -lcompat_minix +DEPEND+= ${LIBMINLIB} ${LIBCOMPAT_MINIX} +.else CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE +.endif BINDIR?=/usr/sbin diff --git a/drivers/ramdisk/Makefile b/drivers/ramdisk/Makefile index 4f648b210..f7f7ea624 100644 --- a/drivers/ramdisk/Makefile +++ b/drivers/ramdisk/Makefile @@ -107,7 +107,7 @@ newroot: ../../commands/newroot/newroot.sh sysenv: ../../commands/sysenv/sysenv install ${STRIPFLAG} ../../commands/$@/$@ $@ -../../commands/sysenv: +../../commands/sysenv/sysenv: $(MAKE) -C ../../commands/sysenv sh: ../../commands/ash/sh @@ -119,7 +119,7 @@ sh: ../../commands/ash/sh service: ../../commands/service/service install ${STRIPFLAG} ../../commands/service/$@ $@ -../../commands/service: +../../commands/service/service: $(MAKE) -C ../../commands/service mfs: ../../servers/mfs/mfs diff --git a/drivers/ramdisk/proto b/drivers/ramdisk/proto index e723ddf85..a62d4b2b7 100644 --- a/drivers/ramdisk/proto +++ b/drivers/ramdisk/proto @@ -1,5 +1,5 @@ boot -420 440 +640 440 d--755 0 0 bin d--755 0 0 cdprobe ---755 0 0 cdprobe diff --git a/drivers/random/random.c b/drivers/random/random.c index eb794a20c..fb15aeeab 100644 --- a/drivers/random/random.c +++ b/drivers/random/random.c @@ -12,7 +12,11 @@ that data into a seed for a psuedo random number generator. #include "assert.h" #include "random.h" +#ifdef __NBSD_LIBC +#include +#else #include +#endif #include "aes/rijndael.h" #define N_DERIV 16 diff --git a/kernel/Makefile b/kernel/Makefile index feb2978ac..f98e15c37 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -29,9 +29,15 @@ LDFLAGS+= -T ${.CURDIR}/arch/${ARCH}/kernel.lds .endif LDFLAGS+= -nostdlib -L${LIBDIR} CFLAGS+=-march=i386 +.if (${NBSD_LIBC} != "no") +LDADD+= -lminlib +DPADD+= ${LIBMINLIB} +CPPFLAGS+= -D_NETBSD_SOURCE +.else DPADD+= ${LIBC} LDADD+= -lgcc -lc -lgcc .endif +.endif CPPFLAGS+= -I${.CURDIR} -I${.CURDIR}/arch/${ARCH}/include -I${MINIXSRCDIR} AFLAGS+= -I${.CURDIR} -I${.CURDIR}/arch/${ARCH}/include -I${MINIXSRCDIR} diff --git a/kernel/proto.h b/kernel/proto.h index 526f7ed74..71a646e05 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -195,7 +195,7 @@ _PROTOTYPE( __dead void arch_monitor, (void) ); _PROTOTYPE( void arch_get_aout_headers, (int i, struct exec *h) ); #endif _PROTOTYPE( void restore_user_context, (struct proc * p) ); -_PROTOTYPE( void read_tsc, (unsigned long *high, unsigned long *low) ); +_PROTOTYPE( void read_tsc, (u32_t *high, u32_t *low) ); _PROTOTYPE( int arch_init_profile_clock, (u32_t freq) ); _PROTOTYPE( void arch_stop_profile_clock, (void) ); _PROTOTYPE( void arch_ack_profile_clock, (void) ); diff --git a/lib/Makefile b/lib/Makefile index aed92d42b..9a1ff4488 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,9 +1,24 @@ .include -SUBDIR= csu libc libcurses libdriver libnetdriver libedit libm libsys \ - libtimers libutil libbz2 libl libhgfs libz libfetch libarchive \ - libvtreefs libaudiodriver libmthread libexec libdevman libusb \ - libddekit +.if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no") +LIBC_DIR= nbsd_libc +LIBM_DIR= nbsd_libm +LIBCOMPAT_DIR= nbsd_libcompat_minix +LIBMINLIB_DIR= nbsd_libminlib +LIBASYN_DIR= nbsd_libasyn +.endif + +LIBC_DIR?= libc +LIBM_DIR?= libm +LIBCOMPAT_DIR?= +LIBMINLIB_DIR?= +LIBASYN_DIR?= + +SUBDIR= csu ${LIBCOMPAT_DIR} ${LIBC_DIR} libcurses libdriver libnetdriver \ + libedit ${LIBM_DIR} libsys libtimers libutil libbz2 libl libhgfs \ + libz libfetch libarchive libvtreefs libaudiodriver libmthread \ + libexec libdevman libusb ${LIBMINLIB_DIR} ${LIBASYN_DIR} \ + libddekit .if ${COMPILER_TYPE} == "ack" SUBDIR+= ack/libd ack/libe ack/libfp ack/liby @@ -32,3 +47,4 @@ clean_all: sh gnu_build.sh clean sh elf_build_base.sh clean sh elf_build.sh clean + diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 2f01bf55d..0e8137f86 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -1,2 +1,7 @@ +.if defined(NBSD_LIBC) && (${NBSD_LIBC} == "yes") +CPPFLAGS+= -D_MINIX -D_NETBSD_SOURCE +AFLAGS+= -D_MINIX +.else CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE AFLAGS+= -D_MINIX -D_POSIX_SOURCE +.endif diff --git a/lib/clang_build.sh b/lib/clang_build.sh index f29eab065..25594d710 100755 --- a/lib/clang_build.sh +++ b/lib/clang_build.sh @@ -4,5 +4,6 @@ export CC=clang export COMPILER_TYPE=gnu export PATH=$PATH:/usr/pkg/bin:/usr/gnu_cross/bin export MAKEOBJDIR=obj-elf-clang +export NBSD_LIBC=${NBSD_LIBC} make $@ diff --git a/lib/elf_build.sh b/lib/elf_build.sh index b14ac7fe3..9ced7036a 100755 --- a/lib/elf_build.sh +++ b/lib/elf_build.sh @@ -6,6 +6,7 @@ export CC=i386-pc-minix3-gcc export COMPILER_TYPE=gnu export MAKEOBJDIR=obj-elf export PATH=$PATH:/usr/gnu_cross/bin +export NBSD_LIBC=${NBSD_LIBC} if [ "$@" != clean ] then echo "$0: Unexpected arguments $@" diff --git a/lib/elf_build_base.sh b/lib/elf_build_base.sh index 6279914de..b0cf857ee 100755 --- a/lib/elf_build_base.sh +++ b/lib/elf_build_base.sh @@ -4,7 +4,9 @@ set -e export CC=clang export COMPILER_TYPE=gnu -export MAKEOBJDIR=obj-elf-base export PATH=$PATH:/usr/pkg/bin -make $@ +export MAKEOBJDIR=obj-elfbase-nbsd +make $@ NBSD_LIBC=yes +export MAKEOBJDIR=obj-elfbase +make $@ NBSD_LIBC=no diff --git a/lib/gnu_build.sh b/lib/gnu_build.sh index 108a1760c..6a70cefa5 100755 --- a/lib/gnu_build.sh +++ b/lib/gnu_build.sh @@ -1,7 +1,9 @@ #!/bin/sh export CC=gcc -export MAKEOBJDIR=obj-gnu export PATH=$PATH:/usr/pkg/bin -make $@ +export MAKEOBJDIR=obj-gnu-nbsd +make $@ NBSD_LIBC=yes +export MAKEOBJDIR=obj-gnu +make $@ NBSD_LIBC=no diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile index 6047b02bb..52de5badb 100644 --- a/lib/libarchive/Makefile +++ b/lib/libarchive/Makefile @@ -65,7 +65,11 @@ SRCS+= minix_utils.c .endif CPPFLAGS+= -DHAVE_CONFIG_H +.if (${NBSD_LIBC} != "no") +INCSDIR= /usr/netbsd/include +.else INCSDIR= /usr/include +.endif INCS= archive.h \ archive_entry.h diff --git a/lib/libarchive/config.h b/lib/libarchive/config.h index 4b35ca4c1..8de8d312e 100644 --- a/lib/libarchive/config.h +++ b/lib/libarchive/config.h @@ -710,7 +710,9 @@ #define _POSIX_1_SOURCE 2 /* Define to 1 if you need to in order for `stat' and other things to work. */ +#ifndef __NBSD_LIBC #define _POSIX_SOURCE 1 +#endif /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the @@ -728,7 +730,9 @@ /* #undef gid_t */ /* Define to `unsigned long' if does not define. */ +#ifndef __NBSD_LIBC #define id_t unsigned long +#endif /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile index 183e9821d..aee7c69d7 100644 --- a/lib/libbz2/Makefile +++ b/lib/libbz2/Makefile @@ -8,6 +8,10 @@ SRCS= bzlib.c blocksort.c compress.c crctable.c decompress.c \ huffman.c randtable.c CPPFLAGS+= -I ${BZ2DIR} INCS= bzlib.h +.if (${NBSD_LIBC} != "no") +INCSDIR= /usr/netbsd/include +.else INCSDIR= /usr/include +.endif .include diff --git a/lib/libddekit/build/ddekit/Makefile b/lib/libddekit/build/ddekit/Makefile index fcf3aae8c..97bdb5f35 100644 --- a/lib/libddekit/build/ddekit/Makefile +++ b/lib/libddekit/build/ddekit/Makefile @@ -10,6 +10,10 @@ SRCS = pci.c printf.c mem.c pgtab.c dde.c initcall.c thread.c condvar.c lock.c s CFLAGS += -Wall +.if ${NBSD_LIBC} != "no" +CFLAGS += -D_NETBSD_SOURCE +.endif + .endif .include diff --git a/lib/libddekit/src/thread.c b/lib/libddekit/src/thread.c index dcefa2757..45d292f88 100644 --- a/lib/libddekit/src/thread.c +++ b/lib/libddekit/src/thread.c @@ -474,7 +474,7 @@ PUBLIC void _ddekit_print_backtrace(ddekit_thread_t *th) bp =th->jb[0].__bp; #else /* !__ACK__ */ #include -#if defined(JB_PC) && defined(JB_SP) +#if defined(JB_BP) /* um, yikes. */ bp = (unsigned long) *((void **)(&((char *)th->jb)[JB_BP])); #else diff --git a/lib/libexec/exec_elf.c b/lib/libexec/exec_elf.c index 346ecd91a..25d67e1f2 100644 --- a/lib/libexec/exec_elf.c +++ b/lib/libexec/exec_elf.c @@ -56,7 +56,13 @@ int read_header_elf( } phdr = (const Elf_Phdr *)(exec_hdr + hdr->e_phoff); - if (!_minix_aligned(phdr, Elf_Addr)) { + if ( +#ifdef __NBSD_LIBC + rounddown((uintptr_t)phdr, sizeof(Elf_Addr)) != (uintptr_t)phdr +#else + !_minix_aligned(phdr, Elf_Addr) +#endif + ) { return ENOEXEC; } diff --git a/lib/libhgfs/inc.h b/lib/libhgfs/inc.h index 5471cd597..7d7e7ab21 100644 --- a/lib/libhgfs/inc.h +++ b/lib/libhgfs/inc.h @@ -1,6 +1,8 @@ /* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */ +#ifndef __NBSD_LIBC #define _POSIX_SOURCE 1 /* need PATH_MAX */ +#endif #define _SYSTEM 1 /* need negative error codes */ #include diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index 6e239a054..069c3ae54 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -1,4 +1,5 @@ # Makefile for libsys +.include LIB= sys @@ -128,4 +129,8 @@ SRCS= \ CPPFLAGS.sched_start.c+= -I${MINIXSRCDIR} +.if (${NBSD_LIBC} != "no") +.include "Makefile.libc.inc" +.endif + .include diff --git a/lib/libsys/Makefile.libc.inc b/lib/libsys/Makefile.libc.inc new file mode 100644 index 000000000..b2e819927 --- /dev/null +++ b/lib/libsys/Makefile.libc.inc @@ -0,0 +1,136 @@ +# +# Minimal libc for servers and drivers. +# + +LIBCSRCDIR=${MINIXSRCDIR}/lib/nbsd_libc + +.if (${NBSD_LIBC} != "no") +MACHINE_ARCH=${MACHINE} + +# +# Shared libc with userspace (/common/lib/libc) +# +.include "${MINIXSRCDIR}/common/lib/libc/Makefile.inc" +.include "${.CURDIR}/arch/${MACHINE}/Makefile.libc.inc" +.if empty(SRCS:Mbyte_swap_8.*) +SRCS+= bswap64.c +.endif + +.if (${MACHINE_ARCH} != "alpha") && \ + (${MACHINE_ARCH} != "mips64eb") && \ + (${MACHINE_ARCH} != "mips64el") && \ + (${MACHINE_ARCH} != "powerpc64") && \ + (${MACHINE_ARCH} != "sparc64") && \ + (${MACHINE_ARCH} != "x86_64") +# Quad support +SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c \ + iordi3.c lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c \ + notdi2.c qdivrem.c subdi3.c ucmpdi2.c udivdi3.c umoddi3.c \ + xordi3.c +.endif +.for i in \ + random.c strtoll.c strtoul.c strtoull.c strtoumax.c \ + memchr.c memcmp.c memcpy.c memmove.c popcount32.c popcount64.c \ + strcasecmp.c strcat.c strchr.c strcmp.c strcpy.c strlcat.c \ + strlcpy.c strlen.c strncasecmp.c strncmp.c strncpy.c strrchr.c \ + strsep.c strstr.c ptree.c rb.c sha1.c sha2.c +SRCS+= ${i} +CPPFLAGS.${i}+= -D_LIBC -I${LIBCSRCDIR}/include +.endfor +.if empty(SRCS:Mmemset2.*) +SRCS+= memset.c +.endif + +# +# Customized versions of libc functions. +# +SRCS+= calloc.c malloc.c +SRCS+= fputs.c _stdfile.c +CPPFLAGS.fputs.c+= -I${LIBCSRCDIR}/include + + +# +# Functions imported directly from the libc. +# + +# Import from stdio +.for i in sprintf.c fprintf.c perror.c vsnprintf.c snprintf.c +.PATH.c: ${LIBCSRCDIR}/stdio +CPPFLAGS.${i}= -I${LIBCSRCDIR}/stdio -I${LIBCSRCDIR}/include +SRCS+= ${i} +.endfor +# Import from stdlib +.for i in abort.c atexit.c atoi.c exit.c getenv.c \ + getopt.c ldiv.c setenv.c +.PATH.c: ${LIBCSRCDIR}/stdlib +SRCS+= ${i} +CPPFLAGS.${i}+= -I${LIBCSRCDIR}/stdlib -I${LIBCSRCDIR}/include +.endfor +# Import from gen + +errlist.c: ${LIBCSRCDIR}/gen/errlist-minix.awk \ + ${MINIXSRCDIR}/nbsd_include/sys/errno.h + ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET} + +.for i in assert.c _errno.c errno.c _env.c errlist.c \ + execle.c getprogname.c sleep.c time.c \ + ctype_.c isctype.c tolower_.c toupper_.c \ + infinityf_ieee754.c infinity_ieee754.c \ + fpclassifyf_ieee754.c fpclassifyd_ieee754.c \ + isinff_ieee754.c isinfd_ieee754.c \ + isnanf_ieee754.c isnand_ieee754.c \ + isfinitef_ieee754.c isfinited_ieee754.c \ + signbitf_ieee754.c signbitd_ieee754.c \ + nanf.c infinityl.c +.PATH.c: ${LIBCSRCDIR}/arch/${MACHINE}/gen ${LIBCSRCDIR}/gen/minix \ + ${LIBCSRCDIR}/gen ${LIBCSRCDIR} +SRCS+= ${i} +CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include +.endfor +CPPFLAGS.ctype_.c+= -I${LIBCSRCDIR}/locale +CPPFLAGS.isctype.c+= -I${LIBCSRCDIR}/locale +CPPFLAGS.tolower_.c+= -I${LIBCSRCDIR}/locale +CPPFLAGS.toupper_.c+= -I${LIBCSRCDIR}/locale +# Import from regex +.for i in regcomp.c regerror.c regexec.c regfree.c +.PATH.c: ${LIBCSRCDIR}/regex +SRCS+= ${i} +CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include +.endfor +# Import from string +.for i in strcspn.c strerror.c strerror_r.c strtol.c \ + bcmp.S bcopy.S bzero.S +.PATH.S: ${LIBCSRCDIR}/arch/${MACHINE}/string +.PATH.c: ${LIBCSRCDIR}/string +SRCS+= ${i} +CPPFLAGS.${i}+= -D_LIBC -I${LIBCSRCDIR}/include +.endfor +CPPFLAGS.strtol.c+= -I${LIBCSRCDIR}/../../common/lib/libc/stdlib +# Import from time +.for i in asctime.c localtime.c strftime.c +.PATH.c: ${LIBCSRCDIR}/time +SRCS+= ${i} +CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include +.endfor +# Import from locale +.for i in _def_time.c +.PATH.c: ${LIBCSRCDIR}/locale +SRCS+= ${i} +CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include -I${LIBCSRCDIR}/locale +.endfor +# Import from sys-minix +.for i in access.c brk.c close.c environ.c execve.c fork.c \ + getgid.c getpid.c getuid.c gettimeofday.c loadname.c \ + link.c mknod.c mmap.c nanosleep.c open.c read.c sbrk.c \ + select.c setuid.c stat.c stime.c syscall.c umask.c \ + unlink.c waitpid.c \ + brksize.S _ipc.S _senda.S +.PATH.c: ${LIBCSRCDIR}/sys-minix +.PATH.S: ${LIBCSRCDIR}/arch/${MACHINE}/sys-minix +SRCS+= ${i} +CPPFLAGS.${i}+= -I${LIBCSRCDIR}/include +.endfor + +CPPFLAGS+= -D_LIBSYS + +.endif diff --git a/lib/libsys/_stdfile.c b/lib/libsys/_stdfile.c new file mode 100644 index 000000000..0f8cc8fe4 --- /dev/null +++ b/lib/libsys/_stdfile.c @@ -0,0 +1,50 @@ +/* $NetBSD: findfp.c,v 1.25 2010/09/06 14:52:55 christos Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +#define std(flags, file) \ +/* p r w flags file bf lfbsize cookie close */ \ + { NULL, 0, 0, flags, file, { NULL, 0 }, 0, __sF + file, NULL, \ +/* read seek write ext up */ \ + NULL, NULL, NULL, { NULL, 0 }, NULL, \ +/* ur ubuf, nbuf lb blksize offset */ \ + 0, { '\0', '\0', '\0' }, { '\0' }, { NULL, 0 }, 0, (fpos_t)0 } + +FILE __sF[3] = { + std(__SRD, STDIN_FILENO), /* stdin */ + std(__SWR, STDOUT_FILENO), /* stdout */ + std(__SWR|__SNBF, STDERR_FILENO) /* stderr */ +}; diff --git a/lib/libsys/abort.c b/lib/libsys/abort.c new file mode 100644 index 000000000..1210f920e --- /dev/null +++ b/lib/libsys/abort.c @@ -0,0 +1,7 @@ +#include +#include + +void abort() +{ + panic("Abort."); +} diff --git a/lib/libsys/arch/i386/Makefile.libc.inc b/lib/libsys/arch/i386/Makefile.libc.inc new file mode 100644 index 000000000..eb3032878 --- /dev/null +++ b/lib/libsys/arch/i386/Makefile.libc.inc @@ -0,0 +1,4 @@ +SRCS+= byte_swap_2.S byte_swap_4.S ffs.S +SRCS+= memchr.S memcmp.S memcpy.S memmove.S memset.S \ + strcat.S strchr.S strcmp.S strcpy.S strlen.S \ + strncmp.S strrchr.S diff --git a/lib/libsys/assert.c b/lib/libsys/assert.c index fa2da1fd9..1c314d345 100644 --- a/lib/libsys/assert.c +++ b/lib/libsys/assert.c @@ -4,6 +4,8 @@ #include #include + +#ifndef __NBSD_LIBC #include #include #include @@ -11,3 +13,36 @@ void __bad_assertion(const char *mess) { panic("%s", mess); } + +#else /* NBSD_LIBC */ + +#include +#include + +void +__assert13(file, line, function, failedexpr) + const char *file, *function, *failedexpr; + int line; +{ + + (void)fprintf(stderr, + "assertion \"%s\" failed: file \"%s\", line %d%s%s%s\n", + failedexpr, file, line, + function ? ", function \"" : "", + function ? function : "", + function ? "\"" : ""); + abort(); + /* NOTREACHED */ +} + +void +__assert(file, line, failedexpr) + const char *file, *failedexpr; + int line; +{ + + __assert13(file, line, NULL, failedexpr); + /* NOTREACHED */ +} + +#endif /* NBSD_LIBC */ diff --git a/lib/libsys/calloc.c b/lib/libsys/calloc.c new file mode 100644 index 000000000..0c4323902 --- /dev/null +++ b/lib/libsys/calloc.c @@ -0,0 +1,28 @@ +/* $Header$ */ +#include + +/* replace undef by define */ +#define ALIGN_EIGHT_BYTES /* Use 8-byte alignment. */ + +#ifdef ALIGN_EIGHT_BYTES +#define ALIGN_SIZE 8 +#else +#define ALIGN_SIZE sizeof(size_t) +#endif + +#define ALIGN(x) (((x) + (ALIGN_SIZE - 1)) & ~(ALIGN_SIZE - 1)) + +void * +calloc(size_t nelem, size_t elsize) +{ + register char *p; + register size_t *q; + size_t size = ALIGN(nelem * elsize); + + p = malloc(size); + if (p == NULL) return NULL; + q = (size_t *) (p + size); + while ((char *) q > p) *--q = 0; + return p; +} + diff --git a/lib/libsys/errlist.c b/lib/libsys/errlist.c new file mode 100644 index 000000000..be77fba91 --- /dev/null +++ b/lib/libsys/errlist.c @@ -0,0 +1,125 @@ +/* Automatically generated file; do not edit */ +#include +__RCSID("$NetBSD: errlist.awk,v 1.4 2010/12/16 22:52:32 joerg Exp $"); +#include +static const char *const errlist[] = { + [0] = "Undefined error: 0", /* 0 - ENOERROR */ + [99] = "generic error", /* 99 - EGENERIC */ + [1] = "operation not permitted", /* 1 - EPERM */ + [2] = "no such file or directory", /* 2 - ENOENT */ + [3] = "no such process", /* 3 - ESRCH */ + [4] = "interrupted function call", /* 4 - EINTR */ + [5] = "input/output error", /* 5 - EIO */ + [6] = "no such device or address", /* 6 - ENXIO */ + [7] = "arg list too long", /* 7 - E2BIG */ + [8] = "exec format error", /* 8 - ENOEXEC */ + [9] = "bad file descriptor", /* 9 - EBADF */ + [10] = "no child process", /* 10 - ECHILD */ + [11] = "resource temporarily unavailable", /* 11 - EAGAIN */ + [12] = "not enough space", /* 12 - ENOMEM */ + [13] = "permission denied", /* 13 - EACCES */ + [14] = "bad address", /* 14 - EFAULT */ + [15] = "Extension: not a block special file", /* 15 - ENOTBLK */ + [16] = "resource busy", /* 16 - EBUSY */ + [17] = "file exists", /* 17 - EEXIST */ + [18] = "improper link", /* 18 - EXDEV */ + [19] = "no such device", /* 19 - ENODEV */ + [20] = "not a directory", /* 20 - ENOTDIR */ + [21] = "is a directory", /* 21 - EISDIR */ + [22] = "invalid argument", /* 22 - EINVAL */ + [23] = "too many open files in system", /* 23 - ENFILE */ + [24] = "too many open files", /* 24 - EMFILE */ + [25] = "inappropriate I/O control operation", /* 25 - ENOTTY */ + [26] = "no longer used", /* 26 - ETXTBSY */ + [27] = "file too large", /* 27 - EFBIG */ + [28] = "no space left on device", /* 28 - ENOSPC */ + [29] = "invalid seek", /* 29 - ESPIPE */ + [30] = "read-only file system", /* 30 - EROFS */ + [31] = "too many links", /* 31 - EMLINK */ + [32] = "broken pipe", /* 32 - EPIPE */ + [33] = "domain error (from ANSI C std )", /* 33 - EDOM */ + [34] = "result too large (from ANSI C std )", /* 34 - ERANGE */ + [35] = "resource deadlock avoided", /* 35 - EDEADLK */ + [36] = "file name too long", /* 36 - ENAMETOOLONG */ + [37] = "no locks available", /* 37 - ENOLCK */ + [38] = "function not implemented", /* 38 - ENOSYS */ + [39] = "directory not empty", /* 39 - ENOTEMPTY */ + [40] = "too many levels of symlinks detected", /* 40 - ELOOP */ + [41] = "service restarted", /* 41 - ERESTART */ + [43] = "Identifier removed", /* 43 - EIDRM */ + [44] = "illegal byte sequence", /* 44 - EILSEQ */ + [45] = "No message of desired type", /* 45 - ENOMSG */ + [46] = "Value too large to be stored in data type",/* 46 - EOVERFLOW */ + [50] = "invalid packet size for some protocol",/* 50 - EPACKSIZE */ + [51] = "not enough buffers left", /* 51 - ENOBUFS */ + [52] = "illegal ioctl for device", /* 52 - EBADIOCTL */ + [53] = "badmode in ioctl", /* 53 - EBADMODE */ + [54] = "call would block on nonblocking socket",/* 54 - EWOULDBLOCK */ + [55] = "network unreachable", /* 55 - ENETUNREACH */ + [56] = "host unreachable", /* 56 - EHOSTUNREACH */ + [57] = "already connected", /* 57 - EISCONN */ + [58] = "address in use", /* 58 - EADDRINUSE */ + [59] = "connection refused", /* 59 - ECONNREFUSED */ + [60] = "connection reset", /* 60 - ECONNRESET */ + [61] = "connection timed out", /* 61 - ETIMEDOUT */ + [62] = "urgent data present", /* 62 - EURG */ + [63] = "no urgent data present", /* 63 - ENOURG */ + [64] = "no connection (yet or anymore )", /* 64 - ENOTCONN */ + [65] = "a write call to a shutdown connection",/* 65 - ESHUTDOWN */ + [66] = "no such connection", /* 66 - ENOCONN */ + [67] = "address family not supported", /* 67 - EAFNOSUPPORT */ + [68] = "protocol not supported by AF", /* 68 - EPROTONOSUPPORT */ + [69] = "Protocol wrong type for socket", /* 69 - EPROTOTYPE */ + [70] = "Operation now in progress", /* 70 - EINPROGRESS */ + [71] = "Can't assign requested address", /* 71 - EADDRNOTAVAIL */ + [72] = "Connection already in progress", /* 72 - EALREADY */ + [73] = "Message too long", /* 73 - EMSGSIZE */ + [74] = "Socket operation on non-socket", /* 74 - ENOTSOCK */ + [75] = "Protocol not available", /* 75 - ENOPROTOOPT */ + [76] = "Operation not supported", /* 76 - EOPNOTSUPP */ + [77] = "network is down", /* 77 - ENETDOWN */ + [78] = "Protocol family not supported", /* 78 - EPFNOSUPPORT */ + [79] = "Destination address required", /* 79 - EDESTADDRREQ */ + [80] = "Host is down", /* 80 - EHOSTDOWN */ + [81] = "Network dropped connection on reset", /* 81 - ENETRESET */ + [82] = "Socket type not supported", /* 82 - ESOCKTNOSUPPORT */ + [83] = "Software caused connection abort", /* 83 - ECONNABORTED */ + [84] = "Too many references: can't splice", /* 84 - ETOOMANYREFS */ + [101] = "can't send message due to deadlock", /* 101 - ELOCKED */ + [102] = "illegal system call number", /* 102 - EBADCALL */ + [103] = "bad source or destination process", /* 103 - EBADSRCDST */ + [104] = "no permission for system call", /* 104 - ECALLDENIED */ + [105] = "source or destination is not alive", /* 105 - EDEADSRCDST */ + [106] = "source or destination is not ready", /* 106 - ENOTREADY */ + [107] = "destination cannot handle request", /* 107 - EBADREQUEST */ + [110] = "IPC trap not allowed", /* 110 - ETRAPDENIED */ + [201] = "pseudo-code: don't send a reply", /* 201 - EDONTREPLY */ + [150] = "Inappropriate file type or format", /* 150 - EFTYPE */ + [151] = "Authentication error", /* 151 - EAUTH */ + [152] = "Need authenticator", /* 152 - ENEEDAUTH */ + [153] = "Operation canceled", /* 153 - ECANCELED */ + [160] = "Stale NFS file handle", /* 160 - ESTALE */ + [161] = "Too many levels of remote in path", /* 161 - EREMOTE */ + [162] = "RPC struct is bad", /* 162 - EBADRPC */ + [163] = "RPC version wrong", /* 163 - ERPCMISMATCH */ + [164] = "RPC prog. not avail", /* 164 - EPROGUNAVAIL */ + [165] = "Program version wrong", /* 165 - EPROGMISMATCH */ + [166] = "Bad procedure for program", /* 166 - EPROCUNAVAIL */ + [170] = "Bad or Corrupt message", /* 170 - EBADMSG */ + [175] = "Too many processes", /* 175 - EPROCLIM */ + [176] = "Too many users", /* 176 - EUSERS */ + [177] = "Disc quota exceeded", /* 177 - EDQUOT */ + [180] = "Multihop attempted ", /* 180 - EMULTIHOP */ + [181] = "Link has been severed", /* 181 - ENOLINK */ + [182] = "Protocol error", /* 182 - EPROTO */ + [185] = "Attribute not found", /* 185 - ENOATTR */ + [190] = "No message available", /* 190 - ENODATA */ + [191] = "No STREAM resources", /* 191 - ENOSR */ + [192] = "Not a STREAM", /* 192 - ENOSTR */ + [193] = "STREAM ioctl timeout", /* 193 - ETIME */ + [301] = "specified endpoint is bad", /* 301 - EBADEPT */ + [302] = "specified endpoint is not alive", /* 302 - EDEADEPT */ +}; + +const int sys_nerr = sizeof(errlist) / sizeof(errlist[0]); +const char * const *sys_errlist = errlist; diff --git a/lib/libsys/fputs.c b/lib/libsys/fputs.c new file mode 100644 index 000000000..b9a66bce2 --- /dev/null +++ b/lib/libsys/fputs.c @@ -0,0 +1,15 @@ +#include +#include "namespace.h" +#include +#include + +#ifdef __weak_alias +__weak_alias(fputs, _fputs) +#endif + +int fputs(const char *s, FILE *fp) +{ + assert(fp == stdout || fp == stderr); + + puts(s); +} diff --git a/lib/libsys/malloc.c b/lib/libsys/malloc.c new file mode 100644 index 000000000..fc8028299 --- /dev/null +++ b/lib/libsys/malloc.c @@ -0,0 +1,252 @@ +/* $Header$ */ + +/* replace undef by define */ +#define ALIGN_EIGHT_BYTES /* Use 8-byte alignment. */ +#define DEBUG /* check assertions */ +#undef SLOWDEBUG /* some extra test loops (requires DEBUG) */ + +#ifndef DEBUG +#define NDEBUG +#endif + +#include +#include +#include +#include + +static int no_debug = -1; +#define CHECK_DBG(statement) + +#if _EM_WSIZE == _EM_PSIZE +#define ptrint int +#else +#define ptrint long +#endif + +#if _EM_PSIZE == 2 +#define BRKSIZE 1024 +#else +#define BRKSIZE 4096 +#endif +#ifdef ALIGN_EIGHT_BYTES +#define PTRSIZE 8 +#else +#define PTRSIZE ((int) sizeof(void *)) +#endif +#define Align(x,a) (((x) + (a - 1)) & ~(a - 1)) +#define NextSlot(p) (* (void **) ((p) - PTRSIZE)) +#define NextFree(p) (* (void **) (p)) + +/* + * A short explanation of the data structure and algorithms. + * An area returned by malloc() is called a slot. Each slot + * contains the number of bytes requested, but preceeded by + * an extra pointer to the next the slot in memory. + * '_bottom' and '_top' point to the first/last slot. + * More memory is asked for using brk() and appended to top. + * The list of free slots is maintained to keep malloc() fast. + * '_empty' points the the first free slot. Free slots are + * linked together by a pointer at the start of the + * user visable part, so just after the next-slot pointer. + * Free slots are merged together by free(). + * + * Since modern processors prefer 8-byte alignment, we now pretend + * our pointers are 8 bytes wide. + */ + +extern void *_sbrk(int); +extern int _brk(void *); +static void *_bottom, *_top, *_empty; + +static int grow(size_t len) +{ + register char *p; + + assert(NextSlot((char *)_top) == 0); + if ((char *) _top + len < (char *) _top + || (p = (char *)Align((ptrint)_top + len, BRKSIZE)) < (char *) _top ) { + errno = ENOMEM; + return(0); + } + if (_brk(p) != 0) + return(0); + NextSlot((char *)_top) = p; + NextSlot(p) = 0; + free(_top); + _top = p; + return 1; +} + +void * +malloc(const size_t size) +{ + register char *prev, *p, *next, *new; + unsigned ntries; + + if (size == 0) + return NULL; + + CHECK_DBG(return _dbg_malloc(size)); + + for (ntries = 0; ntries < 2; ntries++) { + unsigned len = Align(size, PTRSIZE) + PTRSIZE; + if (len < 2 * PTRSIZE) { + errno = ENOMEM; + return NULL; + } + if (_bottom == 0) { + if ((p = _sbrk(2 * PTRSIZE)) == (char *) -1) + return NULL; + p = (char *) Align((ptrint)p, PTRSIZE); + p += PTRSIZE; + _top = _bottom = p; + NextSlot(p) = 0; + } +#ifdef SLOWDEBUG + for (p = _bottom; (next = NextSlot(p)) != 0; p = next) + assert(next > p); + assert(p == _top); +#endif + for (prev = 0, p = _empty; p != 0; prev = p, p = NextFree(p)) { + next = NextSlot(p); + new = p + len; /* easily overflows!! */ + if (new > next || new <= p) + continue; /* too small */ + if (new + PTRSIZE < next) { /* too big, so split */ + /* + PTRSIZE avoids tiny slots on free list */ + NextSlot(new) = next; + NextSlot(p) = new; + NextFree(new) = NextFree(p); + NextFree(p) = new; + } + if (prev) + NextFree(prev) = NextFree(p); + else + _empty = NextFree(p); + return p; + } + if (grow(len) == 0) + break; + } + assert(ntries != 2); + return NULL; +} + +void * +realloc(void *oldp, size_t size) +{ + register char *prev, *p, *next, *new; + char *old = oldp; + register size_t len, n; + + if (old == 0) + return malloc(size); + if (size == 0) { + free(old); + return NULL; + } + + CHECK_DBG(return _dbg_realloc(oldp, size)); + + len = Align(size, PTRSIZE) + PTRSIZE; + next = NextSlot(old); + n = (int)(next - old); /* old length */ + /* + * extend old if there is any free space just behind it + */ + for (prev = 0, p = _empty; p != 0; prev = p, p = NextFree(p)) { + if (p > next) + break; + if (p == next) { /* 'next' is a free slot: merge */ + NextSlot(old) = NextSlot(p); + if (prev) + NextFree(prev) = NextFree(p); + else + _empty = NextFree(p); + next = NextSlot(old); + break; + } + } + new = old + len; + /* + * Can we use the old, possibly extended slot? + */ + if (new <= next && new >= old) { /* it does fit */ + if (new + PTRSIZE < next) { /* too big, so split */ + /* + PTRSIZE avoids tiny slots on free list */ + NextSlot(new) = next; + NextSlot(old) = new; + free(new); + } + return old; + } + if ((new = malloc(size)) == NULL) /* it didn't fit */ + return NULL; + memcpy(new, old, n); /* n < size */ + free(old); + return new; +} + +void +free(void *ptr) +{ + register char *prev, *next; + char *p = ptr; + + if (p == 0) + return; + + CHECK_DBG(_dbg_free(ptr); return); + +#ifdef SLOWDEBUG + { + int found; + char *curr; + + /* block must be in block list */ + assert(_bottom); + found = 0; + for (curr = _bottom; (next = NextSlot(curr)) != 0; curr = next) { + assert(next > curr); + if (curr == p) found = 1; + } + if (curr == p) found = 1; + assert(found); + + /* block must not be in free list */ + if (_empty) { + found = 0; + for (curr = _empty; (next = NextFree(curr)) != 0; curr = next) { + assert(next > curr); + if (curr == p) found = 1; + } + if (curr == p) found = 1; + assert(!found); + } + } +#endif + + assert((char *) NextSlot(p) > p); + for (prev = 0, next = _empty; next != 0; prev = next, next = NextFree(next)) + if (p < next) + break; + NextFree(p) = next; + if (prev) + NextFree(prev) = p; + else + _empty = p; + if (next) { + assert((char *) NextSlot(p) <= next); + if (NextSlot(p) == next) { /* merge p and next */ + NextSlot(p) = NextSlot(next); + NextFree(p) = NextFree(next); + } + } + if (prev) { + assert((char *) NextSlot(prev) <= p); + if (NextSlot(prev) == p) { /* merge prev and p */ + NextSlot(prev) = NextSlot(p); + NextFree(prev) = NextFree(p); + } + } +} diff --git a/lib/libsys/panic.c b/lib/libsys/panic.c index e8a06ca5e..00e281a01 100644 --- a/lib/libsys/panic.c +++ b/lib/libsys/panic.c @@ -41,8 +41,10 @@ PUBLIC void panic(const char *fmt, ...) /* Try exit */ _exit(1); +#ifndef __NBSD_LIBC /* Try to signal ourself */ abort(); +#endif /* If exiting nicely through PM fails for some reason, try to * commit suicide. E.g., message to PM might fail due to deadlock. diff --git a/lib/libsys/vprintf.c b/lib/libsys/vprintf.c index 2749e400d..2da039229 100644 --- a/lib/libsys/vprintf.c +++ b/lib/libsys/vprintf.c @@ -7,9 +7,15 @@ /* vprintf() uses kputc() to print characters. */ void kputc(int c); +#ifdef __NBSD_LIBC +#define count_kputc(c) do { charcount++; putf((c), farg); } while(0) + +int __fvprintf(void (*putf)(int, void *), const char *fmt, va_list argp, void *farg) +#else /* !NBSD_LIBC */ #define count_kputc(c) do { charcount++; kputc(c); } while(0) int vprintf(const char *fmt, va_list argp) +#endif /* NBSD_LIBC */ { int c, charcount = 0; enum { LEFT, RIGHT } adjust; @@ -167,10 +173,52 @@ int vprintf(const char *fmt, va_list argp) } /* Mark the end with a null (should be something else, like -1). */ +#ifdef __NBDS_LIBC + putf(0, farg); +#else kputc(0); +#endif return charcount; } +#ifdef __NBSD_LIBC +#include +#include +#include +#include + +__weak_alias(vprintf, _vprintf) +__weak_alias(vfprintf, _vfprintf) +__strong_alias(__vfprintf_unlocked, _vfprintf) + +static void +__xfputc(int c, void *arg) +{ + FILE *fp = (FILE *)arg; + if (fp->_flags & __SSTR) { + /* Write to a string. */ + if (fp->_w == 0) + return; + memset(fp->_p++, c, 1); + fp->_w -= 1; + return; + } + + /* Not a string. Print it. */ + kputc(c); +} + +int _vprintf(const char *fmt, va_list argp) +{ + __fvprintf(__xfputc, fmt, argp, stdout); +} + +int _vfprintf(FILE *fp, const char *fmt, va_list argp) +{ + __fvprintf(__xfputc, fmt, argp, fp); +} +#endif + /* * $PchId: kprintf.c,v 1.5 1996/04/11 06:59:05 philip Exp $ */ diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile index 5101ba878..063f80940 100644 --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -2,7 +2,11 @@ LIB= util +.if (${NBSD_LIBC} != "no") +# SHA and MD5 functions already in libc +SRCS= openpty.c efun.c +.else SRCS= openpty.c sha2.c efun.c \ sha1.c sha1hl.c sha2.c sha2hl.c md5c.c md5hl.c - +.endif .include diff --git a/lib/libvtreefs/inc.h b/lib/libvtreefs/inc.h index 2d9c65477..ac477af9c 100644 --- a/lib/libvtreefs/inc.h +++ b/lib/libvtreefs/inc.h @@ -1,5 +1,6 @@ - +#ifndef __NBSD_LIBC #define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */ +#endif #define _MINIX 1 /* tell headers to include MINIX stuff */ #define _SYSTEM 1 /* tell headers that this is the kernel */ diff --git a/lib/libz/Makefile b/lib/libz/Makefile index 0815ea22e..f87038a06 100644 --- a/lib/libz/Makefile +++ b/lib/libz/Makefile @@ -5,7 +5,12 @@ LIB= z SRCS= adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c \ gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c +.if (${NBSD_LIBC} != "no") +INCSDIR= /usr/netbsd/include +.else INCSDIR= /usr/include +.endif + INCS= zconf.h zlib.h CPPFLAGS += -DNO_VIZ=1 diff --git a/lib/nbsd_libc/Makefile b/lib/nbsd_libc/Makefile index a76051ac3..f0f530d45 100644 --- a/lib/nbsd_libc/Makefile +++ b/lib/nbsd_libc/Makefile @@ -68,9 +68,7 @@ BUILDCOLD= no .include "${.CURDIR}/citrus/Makefile.inc" .endif .include "${.CURDIR}/compat-43/Makefile.inc" -.ifndef(__MINIX) .include "${.CURDIR}/dlfcn/Makefile.inc" -.endif .include "${.CURDIR}/gdtoa/Makefile.inc" .include "${.CURDIR}/gen/Makefile.inc" .if defined(__MINIX) diff --git a/lib/nbsd_libc/Makefile.inc b/lib/nbsd_libc/Makefile.inc index de13d29b8..0b2facf8e 100644 --- a/lib/nbsd_libc/Makefile.inc +++ b/lib/nbsd_libc/Makefile.inc @@ -31,7 +31,7 @@ CITRUS?= yes WARNS=4 .if defined(__MINIX) -CPPFLAGS+= -D_LIBC -DLIBC_SCSS -DSYSLIBC_SCSS +CPPFLAGS+= -D_LIBC .else CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT .endif diff --git a/lib/nbsd_libc/citrus/Makefile.inc b/lib/nbsd_libc/citrus/Makefile.inc index abab17511..e2cf7af62 100644 --- a/lib/nbsd_libc/citrus/Makefile.inc +++ b/lib/nbsd_libc/citrus/Makefile.inc @@ -3,8 +3,8 @@ # sources .PATH: ${ARCHDIR}/citrus ${.CURDIR}/citrus -MODULE_SHLIB_MAJOR!= . ${NETBSDSRCDIR}/lib/i18n_module/shlib_version ; echo $$major -CPPFLAGS.citrus_module.c+=-DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR} +#MODULE_SHLIB_MAJOR!= . ${NETBSDSRCDIR}/lib/i18n_module/shlib_version ; echo $$major +#CPPFLAGS.citrus_module.c+=-DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR} SRCS+= citrus_bcs.c citrus_bcs_strtol.c citrus_bcs_strtoul.c \ citrus_csmapper.c citrus_ctype.c citrus_ctype_fallback.c \ citrus_db.c citrus_db_hash.c citrus_esdb.c citrus_hash.c \ diff --git a/lib/nbsd_libc/dlfcn/dlfcn_elf.c b/lib/nbsd_libc/dlfcn/dlfcn_elf.c index 1f9bb8daf..9feae96b7 100644 --- a/lib/nbsd_libc/dlfcn/dlfcn_elf.c +++ b/lib/nbsd_libc/dlfcn/dlfcn_elf.c @@ -48,7 +48,12 @@ __RCSID("$NetBSD: dlfcn_elf.c,v 1.7 2010/10/16 10:27:07 skrll Exp $"); #define dl_iterate_phdr ___dl_iterate_phdr #define ELFSIZE ARCH_ELFSIZE +#ifdef __minix +#include +#include +#else #include "rtld.h" +#endif #ifdef __weak_alias __weak_alias(dlopen,___dlopen) @@ -128,6 +133,7 @@ dlinfo(void *handle, int req, void *v) return -1; } +#ifndef __minix /*ARGSUSED*/ int dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), @@ -136,3 +142,4 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), return 0; } +#endif diff --git a/lib/nbsd_libc/gen/minix/gethostname.c b/lib/nbsd_libc/gen/minix/gethostname.c index 2df776a9c..eba3f2840 100644 --- a/lib/nbsd_libc/gen/minix/gethostname.c +++ b/lib/nbsd_libc/gen/minix/gethostname.c @@ -7,7 +7,6 @@ #include #include #include -#include #ifdef __weak_alias __weak_alias(gethostname, _gethostname) diff --git a/lib/nbsd_libc/gen/opendir.c b/lib/nbsd_libc/gen/opendir.c index 1d750470f..55e8acedb 100644 --- a/lib/nbsd_libc/gen/opendir.c +++ b/lib/nbsd_libc/gen/opendir.c @@ -103,7 +103,9 @@ __opendir_common(int fd, const char *name, int flags) DIR *dirp = NULL; int serrno; struct stat sb; +#ifndef __minix struct statvfs sfb; +#endif int error; if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) @@ -129,8 +131,6 @@ __opendir_common(int fd, const char *name, int flags) */ #ifdef __minix - if (fstatvfs(fd, &sfb) < 0) - goto error; /* MOUNT_UNION and MOUNT_NFS not supported */ flags &= ~DTF_NODUP; #else diff --git a/lib/nbsd_libc/minix-port.patch b/lib/nbsd_libc/minix-port.patch index ffe587c00..f71d57280 100644 --- a/lib/nbsd_libc/minix-port.patch +++ b/lib/nbsd_libc/minix-port.patch @@ -1,6 +1,6 @@ -diff -ru /home/netbsd/src/lib/libc/Makefile ./Makefile ---- /home/netbsd/src/lib/libc/Makefile 2010-09-05 03:00:50.000000000 +0000 -+++ ./Makefile 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/Makefile lib/nbsd_libc/Makefile +--- nbsdsrc/src/lib/libc/Makefile ++++ lib/nbsd_libc/Makefile @@ -17,6 +17,9 @@ # The Hesiod functions are always in libc. To choose that getpwent() and friends # actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below. @@ -29,13 +29,8 @@ diff -ru /home/netbsd/src/lib/libc/Makefile ./Makefile .include "${.CURDIR}/../../common/lib/libc/Makefile.inc" .include "${.CURDIR}/atomic/Makefile.inc" -@@ -61,10 +68,16 @@ - .include "${.CURDIR}/citrus/Makefile.inc" - .endif - .include "${.CURDIR}/compat-43/Makefile.inc" -+.ifndef(__MINIX) +@@ -64,7 +71,11 @@ .include "${.CURDIR}/dlfcn/Makefile.inc" -+.endif .include "${.CURDIR}/gdtoa/Makefile.inc" .include "${.CURDIR}/gen/Makefile.inc" +.if defined(__MINIX) @@ -46,7 +41,7 @@ diff -ru /home/netbsd/src/lib/libc/Makefile ./Makefile .include "${.CURDIR}/hash/Makefile.inc" .include "${.CURDIR}/iconv/Makefile.inc" .include "${.CURDIR}/inet/Makefile.inc" -@@ -84,7 +97,11 @@ +@@ -84,7 +95,11 @@ .include "${.CURDIR}/regex/Makefile.inc" .endif .include "${.CURDIR}/resolv/Makefile.inc" @@ -58,7 +53,7 @@ diff -ru /home/netbsd/src/lib/libc/Makefile ./Makefile .include "${.CURDIR}/ssp/Makefile.inc" .include "${.CURDIR}/stdio/Makefile.inc" .include "${.CURDIR}/stdlib/Makefile.inc" -@@ -92,7 +109,11 @@ +@@ -92,7 +107,11 @@ .include "${.CURDIR}/termios/Makefile.inc" .include "${.CURDIR}/thread-stub/Makefile.inc" .include "${.CURDIR}/time/Makefile.inc" @@ -70,7 +65,7 @@ diff -ru /home/netbsd/src/lib/libc/Makefile ./Makefile .include "${.CURDIR}/uuid/Makefile.inc" .if (${MKYP} != "no") .include "${.CURDIR}/yp/Makefile.inc" -@@ -121,7 +142,11 @@ +@@ -121,7 +140,11 @@ NLS= C.msg Pig.msg ca.msg cs.msg de.msg es.msg fi.msg fr.msg nl.msg \ no.msg pl.msg sk.msg sv.msg @@ -82,7 +77,7 @@ diff -ru /home/netbsd/src/lib/libc/Makefile ./Makefile tags: ${.OBJDIR}/tags ${.OBJDIR}/tags: ${SRCS} ${_MKTARGET_CREATE} -@@ -130,9 +155,11 @@ +@@ -130,9 +153,11 @@ sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \ >> ${.TARGET}; sort -o ${.TARGET} ${.TARGET} @@ -94,9 +89,9 @@ diff -ru /home/netbsd/src/lib/libc/Makefile ./Makefile # workaround for I18N stuffs: build singlebyte setlocale() for libc.a, -diff -ru /home/netbsd/src/lib/libc/Makefile.inc ./Makefile.inc ---- /home/netbsd/src/lib/libc/Makefile.inc 2010-05-31 03:02:07.000000000 +0000 -+++ ./Makefile.inc 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/Makefile.inc lib/nbsd_libc/Makefile.inc +--- nbsdsrc/src/lib/libc/Makefile.inc ++++ lib/nbsd_libc/Makefile.inc @@ -19,14 +19,22 @@ USE_FORT?= yes @@ -113,25 +108,25 @@ diff -ru /home/netbsd/src/lib/libc/Makefile.inc ./Makefile.inc WARNS=4 +.if defined(__MINIX) -+CPPFLAGS+= -D_LIBC -DLIBC_SCSS -DSYSLIBC_SCSS ++CPPFLAGS+= -D_LIBC +.else CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT +.endif .if (${USE_HESIOD} != "no") CPPFLAGS+= -DHESIOD -diff -ru /home/netbsd/src/lib/libc/arch/i386/Makefile.inc ./arch/i386/Makefile.inc ---- /home/netbsd/src/lib/libc/arch/i386/Makefile.inc 2006-06-17 18:04:23.000000000 +0000 -+++ ./arch/i386/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/arch/i386/Makefile.inc lib/nbsd_libc/arch/i386/Makefile.inc +--- nbsdsrc/src/lib/libc/arch/i386/Makefile.inc ++++ lib/nbsd_libc/arch/i386/Makefile.inc @@ -1,3 +1,5 @@ # $NetBSD: Makefile.inc,v 1.20 2006/06/17 18:04:23 uwe Exp $ +.if !defined(__MINIX) SRCS+= __sigaction14_sigtramp.c __sigtramp2.S +.endif -diff -ru /home/netbsd/src/lib/libc/arch/i386/gen/Makefile.inc ./arch/i386/gen/Makefile.inc ---- /home/netbsd/src/lib/libc/arch/i386/gen/Makefile.inc 2009-12-06 07:12:17.000000000 +0000 -+++ ./arch/i386/gen/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/arch/i386/gen/Makefile.inc lib/nbsd_libc/arch/i386/gen/Makefile.inc +--- nbsdsrc/src/lib/libc/arch/i386/gen/Makefile.inc ++++ lib/nbsd_libc/arch/i386/gen/Makefile.inc @@ -7,10 +7,18 @@ SRCS+= setjmp.S _setjmp.S sigsetjmp.S @@ -151,9 +146,9 @@ diff -ru /home/netbsd/src/lib/libc/arch/i386/gen/Makefile.inc ./arch/i386/gen/Ma # Common ieee754 constants and functions SRCS+= infinityf_ieee754.c infinity_ieee754.c -diff -ru /home/netbsd/src/lib/libc/arch/i386/gen/setjmp.S ./arch/i386/gen/setjmp.S ---- /home/netbsd/src/lib/libc/arch/i386/gen/setjmp.S 2005-09-13 01:44:08.000000000 +0000 -+++ ./arch/i386/gen/setjmp.S 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/arch/i386/gen/setjmp.S lib/nbsd_libc/arch/i386/gen/setjmp.S +--- nbsdsrc/src/lib/libc/arch/i386/gen/setjmp.S ++++ lib/nbsd_libc/arch/i386/gen/setjmp.S @@ -85,7 +85,11 @@ PIC_PROLOGUE pushl $0 @@ -166,9 +161,9 @@ diff -ru /home/netbsd/src/lib/libc/arch/i386/gen/setjmp.S ./arch/i386/gen/setjmp #ifdef PIC call PIC_PLT(_C_LABEL(__sigprocmask14)) #else -diff -ru /home/netbsd/src/lib/libc/arch/i386/gen/sigsetjmp.S ./arch/i386/gen/sigsetjmp.S ---- /home/netbsd/src/lib/libc/arch/i386/gen/sigsetjmp.S 2005-09-13 01:44:08.000000000 +0000 -+++ ./arch/i386/gen/sigsetjmp.S 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/arch/i386/gen/sigsetjmp.S lib/nbsd_libc/arch/i386/gen/sigsetjmp.S +--- nbsdsrc/src/lib/libc/arch/i386/gen/sigsetjmp.S ++++ lib/nbsd_libc/arch/i386/gen/sigsetjmp.S @@ -85,7 +85,11 @@ PIC_PROLOGUE pushl $0 @@ -181,9 +176,9 @@ diff -ru /home/netbsd/src/lib/libc/arch/i386/gen/sigsetjmp.S ./arch/i386/gen/sig #ifdef PIC call PIC_PLT(_C_LABEL(__sigprocmask14)) #else -diff -ru /home/netbsd/src/lib/libc/cdb/cdbr.c ./cdb/cdbr.c ---- /home/netbsd/src/lib/libc/cdb/cdbr.c 2010-06-04 03:06:19.000000000 +0000 -+++ ./cdb/cdbr.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/cdb/cdbr.c lib/nbsd_libc/cdb/cdbr.c +--- nbsdsrc/src/lib/libc/cdb/cdbr.c ++++ lib/nbsd_libc/cdb/cdbr.c @@ -122,7 +122,22 @@ cdbr->index_size = 4; @@ -207,9 +202,23 @@ diff -ru /home/netbsd/src/lib/libc/cdb/cdbr.c ./cdb/cdbr.c close(fd); if (cdbr->mmap_base == MAP_FAILED) { -diff -ru /home/netbsd/src/lib/libc/citrus/citrus_mmap.c ./citrus/citrus_mmap.c ---- /home/netbsd/src/lib/libc/citrus/citrus_mmap.c 2005-01-19 00:52:37.000000000 +0000 -+++ ./citrus/citrus_mmap.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/citrus/Makefile.inc lib/nbsd_libc/citrus/Makefile.inc +--- nbsdsrc/src/lib/libc/citrus/Makefile.inc ++++ lib/nbsd_libc/citrus/Makefile.inc +@@ -3,8 +3,8 @@ + # sources + .PATH: ${ARCHDIR}/citrus ${.CURDIR}/citrus + +-MODULE_SHLIB_MAJOR!= . ${NETBSDSRCDIR}/lib/i18n_module/shlib_version ; echo $$major +-CPPFLAGS.citrus_module.c+=-DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR} ++#MODULE_SHLIB_MAJOR!= . ${NETBSDSRCDIR}/lib/i18n_module/shlib_version ; echo $$major ++#CPPFLAGS.citrus_module.c+=-DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR} + SRCS+= citrus_bcs.c citrus_bcs_strtol.c citrus_bcs_strtoul.c \ + citrus_csmapper.c citrus_ctype.c citrus_ctype_fallback.c \ + citrus_db.c citrus_db_hash.c citrus_esdb.c citrus_hash.c \ +diff -ru nbsdsrc/src/lib/libc/citrus/citrus_mmap.c lib/nbsd_libc/citrus/citrus_mmap.c +--- nbsdsrc/src/lib/libc/citrus/citrus_mmap.c ++++ lib/nbsd_libc/citrus/citrus_mmap.c @@ -74,12 +74,25 @@ goto error; } @@ -236,10 +245,10 @@ diff -ru /home/netbsd/src/lib/libc/citrus/citrus_mmap.c ./citrus/citrus_mmap.c _region_init(r, head, (size_t)st.st_size); error: -diff -ru /home/netbsd/src/lib/libc/compat-43/Makefile.inc ./compat-43/Makefile.inc ---- /home/netbsd/src/lib/libc/compat-43/Makefile.inc 2006-04-24 17:15:06.000000000 +0000 -+++ ./compat-43/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 -@@ -4,12 +4,20 @@ +diff -ru nbsdsrc/src/lib/libc/compat-43/Makefile.inc lib/nbsd_libc/compat-43/Makefile.inc +--- nbsdsrc/src/lib/libc/compat-43/Makefile.inc ++++ lib/nbsd_libc/compat-43/Makefile.inc +@@ -4,11 +4,19 @@ # compat-43 sources .PATH: ${ARCHDIR}/compat-43 ${.CURDIR}/compat-43 @@ -255,14 +264,13 @@ diff -ru /home/netbsd/src/lib/libc/compat-43/Makefile.inc ./compat-43/Makefile.i setrgid.c setruid.c sigcompat.c .if !defined(AUDIT) SRCS+= getwd.c - .endif +.endif + .endif # XXX this is to get - CPPFLAGS.sigcompat.c+= -I${NETBSDSRCDIR}/sys -diff -ru /home/netbsd/src/lib/libc/db/btree/bt_open.c ./db/btree/bt_open.c ---- /home/netbsd/src/lib/libc/db/btree/bt_open.c 2008-09-11 12:58:00.000000000 +0000 -+++ ./db/btree/bt_open.c 2011-03-16 12:41:30.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/db/btree/bt_open.c lib/nbsd_libc/db/btree/bt_open.c +--- nbsdsrc/src/lib/libc/db/btree/bt_open.c ++++ lib/nbsd_libc/db/btree/bt_open.c @@ -262,7 +262,11 @@ * Don't overflow the page offset type. */ @@ -275,9 +283,9 @@ diff -ru /home/netbsd/src/lib/libc/db/btree/bt_open.c ./db/btree/bt_open.c if (b.psize < MINPSIZE) b.psize = MINPSIZE; if (b.psize > MAX_PAGE_OFFSET + 1) -diff -ru /home/netbsd/src/lib/libc/db/db/db.c ./db/db/db.c ---- /home/netbsd/src/lib/libc/db/db/db.c 2008-09-11 12:58:00.000000000 +0000 -+++ ./db/db/db.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/db/db/db.c lib/nbsd_libc/db/db/db.c +--- nbsdsrc/src/lib/libc/db/db/db.c ++++ lib/nbsd_libc/db/db/db.c @@ -57,9 +57,15 @@ { @@ -294,9 +302,9 @@ diff -ru /home/netbsd/src/lib/libc/db/db/db.c ./db/db/db.c if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) switch (type) { -diff -ru /home/netbsd/src/lib/libc/db/hash/hash.c ./db/hash/hash.c ---- /home/netbsd/src/lib/libc/db/hash/hash.c 2009-02-12 06:35:54.000000000 +0000 -+++ ./db/hash/hash.c 2011-03-16 12:35:00.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/db/hash/hash.c lib/nbsd_libc/db/hash/hash.c +--- nbsdsrc/src/lib/libc/db/hash/hash.c ++++ lib/nbsd_libc/db/hash/hash.c @@ -301,7 +301,11 @@ if (file != NULL) { if (stat(file, &statbuf)) @@ -309,9 +317,38 @@ diff -ru /home/netbsd/src/lib/libc/db/hash/hash.c ./db/hash/hash.c hashp->BSHIFT = __log2((uint32_t)hashp->BSIZE); } -diff -ru /home/netbsd/src/lib/libc/gdtoa/gdtoa_locks.c ./gdtoa/gdtoa_locks.c ---- /home/netbsd/src/lib/libc/gdtoa/gdtoa_locks.c 2006-01-25 15:36:13.000000000 +0000 -+++ ./gdtoa/gdtoa_locks.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/dlfcn/dlfcn_elf.c lib/nbsd_libc/dlfcn/dlfcn_elf.c +--- nbsdsrc/src/lib/libc/dlfcn/dlfcn_elf.c ++++ lib/nbsd_libc/dlfcn/dlfcn_elf.c +@@ -48,7 +48,12 @@ + #define dl_iterate_phdr ___dl_iterate_phdr + + #define ELFSIZE ARCH_ELFSIZE ++#ifdef __minix ++#include ++#include ++#else + #include "rtld.h" ++#endif + + #ifdef __weak_alias + __weak_alias(dlopen,___dlopen) +@@ -128,6 +133,7 @@ + return -1; + } + ++#ifndef __minix + /*ARGSUSED*/ + int + dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), +@@ -136,3 +142,4 @@ + + return 0; + } ++#endif +diff -ru nbsdsrc/src/lib/libc/gdtoa/gdtoa_locks.c lib/nbsd_libc/gdtoa/gdtoa_locks.c +--- nbsdsrc/src/lib/libc/gdtoa/gdtoa_locks.c ++++ lib/nbsd_libc/gdtoa/gdtoa_locks.c @@ -7,4 +7,6 @@ #include "gdtoaimp.h" @@ -319,10 +356,28 @@ diff -ru /home/netbsd/src/lib/libc/gdtoa/gdtoa_locks.c ./gdtoa/gdtoa_locks.c +#ifdef _REENTRANT /* !__minix */ mutex_t __gdtoa_locks[2] = { MUTEX_INITIALIZER, MUTEX_INITIALIZER }; +#endif /* _REENTRANT */ -diff -ru /home/netbsd/src/lib/libc/gen/Makefile.inc ./gen/Makefile.inc ---- /home/netbsd/src/lib/libc/gen/Makefile.inc 2010-12-13 03:52:36.000000000 +0000 -+++ ./gen/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 -@@ -2,8 +2,56 @@ +diff -ru nbsdsrc/src/lib/libc/gdtoa/gdtoaimp.h lib/nbsd_libc/gdtoa/gdtoaimp.h +--- nbsdsrc/src/lib/libc/gdtoa/gdtoaimp.h ++++ lib/nbsd_libc/gdtoa/gdtoaimp.h +@@ -1,4 +1,4 @@ +-/* $NetBSD: gdtoaimp.h,v 1.7 2009/05/07 20:31:44 christos Exp $ */ ++/* $NetBSD: gdtoaimp.h,v 1.8 2011/01/21 23:36:49 christos Exp $ */ + + /**************************************************************** + +@@ -276,7 +276,7 @@ + Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. + #endif + +-typedef union { double d; ULong L[2]; } U; ++typedef union { double d; ULong L[2]; } __attribute__((__may_alias__)) U; + + #ifdef YES_ALIAS + #define dval(x) x +diff -ru nbsdsrc/src/lib/libc/gen/Makefile.inc lib/nbsd_libc/gen/Makefile.inc +--- nbsdsrc/src/lib/libc/gen/Makefile.inc ++++ lib/nbsd_libc/gen/Makefile.inc +@@ -2,9 +2,57 @@ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -347,7 +402,7 @@ diff -ru /home/netbsd/src/lib/libc/gen/Makefile.inc ./gen/Makefile.inc +# Already in getprogname +# setprogname.c + -+SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \ + SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \ + closedir.c ctermid.c ctype_.c daemon.c \ + dehumanize_number.c dirname.c err.c errx.c \ + errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \ @@ -376,9 +431,10 @@ diff -ru /home/netbsd/src/lib/libc/gen/Makefile.inc ./gen/Makefile.inc + utmpx.c valloc.c vis.c warn.c warnx.c \ + vwarn.c vwarnx.c verr.c verrx.c wait.c waitpid.c wordexp.c +.else - SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \ ++SRCS+= _errno.c alarm.c alphasort.c arc4random.c assert.c basename.c clock.c \ closedir.c closefrom.c confstr.c ctermid.c ctype_.c daemon.c \ dehumanize_number.c devname.c dirname.c disklabel.c err.c errx.c \ + errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \ @@ -32,6 +80,7 @@ toupper_.c ualarm.c ulimit.c uname.c unvis.c usleep.c utime.c utmp.c \ utmpx.c valloc.c vis.c wait.c wait3.c waitpid.c warn.c warnx.c \ @@ -400,9 +456,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/Makefile.inc ./gen/Makefile.inc +.endif CLEANFILES+= errlist.c -diff -ru /home/netbsd/src/lib/libc/gen/_verr.c ./gen/_verr.c ---- /home/netbsd/src/lib/libc/gen/_verr.c 2005-09-13 01:44:09.000000000 +0000 -+++ ./gen/_verr.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/_verr.c lib/nbsd_libc/gen/_verr.c +--- nbsdsrc/src/lib/libc/gen/_verr.c ++++ lib/nbsd_libc/gen/_verr.c @@ -13,6 +13,9 @@ #if defined(__indr_reference) __indr_reference(_verr, verr) @@ -413,9 +469,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/_verr.c ./gen/_verr.c __dead void _verr(int, const char *, _BSD_VA_LIST_); -diff -ru /home/netbsd/src/lib/libc/gen/_verrx.c ./gen/_verrx.c ---- /home/netbsd/src/lib/libc/gen/_verrx.c 2005-09-13 01:44:09.000000000 +0000 -+++ ./gen/_verrx.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/_verrx.c lib/nbsd_libc/gen/_verrx.c +--- nbsdsrc/src/lib/libc/gen/_verrx.c ++++ lib/nbsd_libc/gen/_verrx.c @@ -13,6 +13,9 @@ #if defined(__indr_reference) __indr_reference(_verrx, verrx) @@ -426,9 +482,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/_verrx.c ./gen/_verrx.c __dead void _verrx(int, const char *, _BSD_VA_LIST_); -diff -ru /home/netbsd/src/lib/libc/gen/_vwarn.c ./gen/_vwarn.c ---- /home/netbsd/src/lib/libc/gen/_vwarn.c 2005-09-13 01:44:09.000000000 +0000 -+++ ./gen/_vwarn.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/_vwarn.c lib/nbsd_libc/gen/_vwarn.c +--- nbsdsrc/src/lib/libc/gen/_vwarn.c ++++ lib/nbsd_libc/gen/_vwarn.c @@ -13,6 +13,9 @@ #if defined(__indr_reference) __indr_reference(_vwarn, vwarn) @@ -439,9 +495,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/_vwarn.c ./gen/_vwarn.c void _vwarn(const char *, _BSD_VA_LIST_); -diff -ru /home/netbsd/src/lib/libc/gen/_vwarnx.c ./gen/_vwarnx.c ---- /home/netbsd/src/lib/libc/gen/_vwarnx.c 2005-09-13 01:44:09.000000000 +0000 -+++ ./gen/_vwarnx.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/_vwarnx.c lib/nbsd_libc/gen/_vwarnx.c +--- nbsdsrc/src/lib/libc/gen/_vwarnx.c ++++ lib/nbsd_libc/gen/_vwarnx.c @@ -13,6 +13,9 @@ #if defined(__indr_reference) __indr_reference(_vwarnx, vwarnx) @@ -452,9 +508,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/_vwarnx.c ./gen/_vwarnx.c void _vwarnx(const char *, _BSD_VA_LIST_); -diff -ru /home/netbsd/src/lib/libc/gen/_warn.c ./gen/_warn.c ---- /home/netbsd/src/lib/libc/gen/_warn.c 2005-09-13 01:44:09.000000000 +0000 -+++ ./gen/_warn.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/_warn.c lib/nbsd_libc/gen/_warn.c +--- nbsdsrc/src/lib/libc/gen/_warn.c ++++ lib/nbsd_libc/gen/_warn.c @@ -24,7 +24,11 @@ va_list ap; @@ -467,9 +523,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/_warn.c ./gen/_warn.c va_end(ap); } #endif -diff -ru /home/netbsd/src/lib/libc/gen/_warnx.c ./gen/_warnx.c ---- /home/netbsd/src/lib/libc/gen/_warnx.c 2005-09-13 01:44:09.000000000 +0000 -+++ ./gen/_warnx.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/_warnx.c lib/nbsd_libc/gen/_warnx.c +--- nbsdsrc/src/lib/libc/gen/_warnx.c ++++ lib/nbsd_libc/gen/_warnx.c @@ -24,7 +24,11 @@ va_list ap; @@ -482,9 +538,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/_warnx.c ./gen/_warnx.c va_end(ap); } -diff -ru /home/netbsd/src/lib/libc/gen/closedir.c ./gen/closedir.c ---- /home/netbsd/src/lib/libc/gen/closedir.c 2010-09-26 03:01:02.000000000 +0000 -+++ ./gen/closedir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/closedir.c lib/nbsd_libc/gen/closedir.c +--- nbsdsrc/src/lib/libc/gen/closedir.c ++++ lib/nbsd_libc/gen/closedir.c @@ -38,6 +38,11 @@ #endif #endif /* LIBC_SCCS and not lint */ @@ -497,23 +553,22 @@ diff -ru /home/netbsd/src/lib/libc/gen/closedir.c ./gen/closedir.c #include "namespace.h" #include "reentrant.h" #include "extern.h" -diff -ru /home/netbsd/src/lib/libc/gen/fts.c ./gen/fts.c ---- /home/netbsd/src/lib/libc/gen/fts.c 2009-11-02 17:17:34.000000000 +0000 -+++ ./gen/fts.c 2038-01-19 03:14:07.000000000 +0000 -@@ -56,8 +56,10 @@ +diff -ru nbsdsrc/src/lib/libc/gen/fts.c lib/nbsd_libc/gen/fts.c +--- nbsdsrc/src/lib/libc/gen/fts.c ++++ lib/nbsd_libc/gen/fts.c +@@ -56,7 +56,9 @@ #include #if ! HAVE_NBTOOL_CONFIG_H +#ifndef __minix #define HAVE_STRUCT_DIRENT_D_NAMLEN - #endif +#endif + #endif static FTSENT *fts_alloc(FTS *, const char *, size_t); - static FTSENT *fts_build(FTS *, int); -diff -ru /home/netbsd/src/lib/libc/gen/getcwd.c ./gen/getcwd.c ---- /home/netbsd/src/lib/libc/gen/getcwd.c 2011-01-20 03:02:11.000000000 +0000 -+++ ./gen/getcwd.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/getcwd.c lib/nbsd_libc/gen/getcwd.c +--- nbsdsrc/src/lib/libc/gen/getcwd.c ++++ lib/nbsd_libc/gen/getcwd.c @@ -54,8 +54,12 @@ #include "extern.h" @@ -527,9 +582,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/getcwd.c ./gen/getcwd.c __weak_alias(realpath,_realpath) #if defined(_FORTIFY_SOURCE) && !defined(__lint__) -diff -ru /home/netbsd/src/lib/libc/gen/getgrent.c ./gen/getgrent.c ---- /home/netbsd/src/lib/libc/gen/getgrent.c 2008-04-28 20:22:59.000000000 +0000 -+++ ./gen/getgrent.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/getgrent.c lib/nbsd_libc/gen/getgrent.c +--- nbsdsrc/src/lib/libc/gen/getgrent.c ++++ lib/nbsd_libc/gen/getgrent.c @@ -481,7 +481,11 @@ _files_getgrgid(void *nsrv, void *nscb, va_list ap) { @@ -662,9 +717,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/getgrent.c ./gen/getgrent.c mutex_unlock(&__grmutex); switch (rv) { case NS_SUCCESS: -diff -ru /home/netbsd/src/lib/libc/gen/getgroupmembership.c ./gen/getgroupmembership.c ---- /home/netbsd/src/lib/libc/gen/getgroupmembership.c 2008-04-28 20:22:59.000000000 +0000 -+++ ./gen/getgroupmembership.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/getgroupmembership.c lib/nbsd_libc/gen/getgroupmembership.c +--- nbsdsrc/src/lib/libc/gen/getgroupmembership.c ++++ lib/nbsd_libc/gen/getgroupmembership.c @@ -101,7 +101,11 @@ { int *result = va_arg(ap, int *); @@ -737,9 +792,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/getgroupmembership.c ./gen/getgroupmember mutex_unlock(&__grmutex); if (*groupc > maxgrp) /* too many groups found */ -diff -ru /home/netbsd/src/lib/libc/gen/getlogin.c ./gen/getlogin.c ---- /home/netbsd/src/lib/libc/gen/getlogin.c 2009-01-11 02:46:27.000000000 +0000 -+++ ./gen/getlogin.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/getlogin.c lib/nbsd_libc/gen/getlogin.c +--- nbsdsrc/src/lib/libc/gen/getlogin.c ++++ lib/nbsd_libc/gen/getlogin.c @@ -78,7 +78,9 @@ #ifdef __weak_alias __weak_alias(getlogin,_getlogin) @@ -763,9 +818,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/getlogin.c ./gen/getlogin.c return (retval); } +#endif -diff -ru /home/netbsd/src/lib/libc/gen/getpwent.c ./gen/getpwent.c ---- /home/netbsd/src/lib/libc/gen/getpwent.c 2010-03-24 03:02:14.000000000 +0000 -+++ ./gen/getpwent.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/getpwent.c lib/nbsd_libc/gen/getpwent.c +--- nbsdsrc/src/lib/libc/gen/getpwent.c ++++ lib/nbsd_libc/gen/getpwent.c @@ -671,7 +671,11 @@ _files_getpwuid(void *nsrv, void *nscb, va_list ap) { @@ -843,12 +898,12 @@ diff -ru /home/netbsd/src/lib/libc/gen/getpwent.c ./gen/getpwent.c break; case _PW_KEYBYUID: +#ifdef __minix -+ rv = nsdispatch(NULL, compatuiddtab, -+ NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis, -+ &crv, (int)uid, pw, buffer, buflen, &cpw); -+#else rv = nsdispatch(NULL, compatuiddtab, NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis, ++ &crv, (int)uid, pw, buffer, buflen, &cpw); ++#else ++ rv = nsdispatch(NULL, compatuiddtab, ++ NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis, &crv, uid, pw, buffer, buflen, &cpw); +#endif break; @@ -883,10 +938,10 @@ diff -ru /home/netbsd/src/lib/libc/gen/getpwent.c ./gen/getpwent.c mutex_lock(&_pwmutex); +#ifdef __minix -+ rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat, + rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat, + &retval, (int)uid); +#else - rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat, ++ rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat, &retval, uid); +#endif mutex_unlock(&_pwmutex); @@ -897,19 +952,244 @@ diff -ru /home/netbsd/src/lib/libc/gen/getpwent.c ./gen/getpwent.c retval = 0; mutex_lock(&_pwmutex); +#ifdef __minix -+ r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat, + r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat, + &retval, (int)uid, pwd, buffer, buflen, result); +#else - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat, ++ r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat, &retval, uid, pwd, buffer, buflen, result); +#endif + mutex_unlock(&_pwmutex); switch (r) { case NS_SUCCESS: -diff -ru /home/netbsd/src/lib/libc/gen/gr_private.h ./gen/gr_private.h ---- /home/netbsd/src/lib/libc/gen/gr_private.h 2008-04-28 20:22:59.000000000 +0000 -+++ ./gen/gr_private.h 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/glob.c lib/nbsd_libc/gen/glob.c +--- nbsdsrc/src/lib/libc/gen/glob.c ++++ lib/nbsd_libc/gen/glob.c +@@ -1,4 +1,4 @@ +-/* $NetBSD: glob.c,v 1.27 2010/09/06 14:40:25 christos Exp $ */ ++/* $NetBSD: glob.c,v 1.28 2011/01/21 23:30:31 christos Exp $ */ + + /* + * Copyright (c) 1989, 1993 +@@ -37,7 +37,7 @@ + #if 0 + static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; + #else +-__RCSID("$NetBSD: glob.c,v 1.27 2010/09/06 14:40:25 christos Exp $"); ++__RCSID("$NetBSD: glob.c,v 1.28 2011/01/21 23:30:31 christos Exp $"); + #endif + #endif /* LIBC_SCCS and not lint */ + +@@ -87,13 +87,18 @@ + #define NO_GETPW_R + #endif + +-#define GLOB_LIMIT_MALLOC 65536 +-#define GLOB_LIMIT_STAT 128 +-#define GLOB_LIMIT_READDIR 16384 ++#define GLOB_LIMIT_STRING 65536 /* number of readdirs */ ++#define GLOB_LIMIT_STAT 128 /* number of stat system calls */ ++#define GLOB_LIMIT_READDIR 16384 /* total buffer size of path strings */ ++#define GLOB_LIMIT_PATH 1024 /* number of path elements */ ++#define GLOB_LIMIT_BRACE 128 /* Number of brace calls */ + +-#define GLOB_INDEX_MALLOC 0 +-#define GLOB_INDEX_STAT 1 +-#define GLOB_INDEX_READDIR 2 ++struct glob_limit { ++ size_t l_string; ++ size_t l_stat; ++ size_t l_readdir; ++ size_t l_brace; ++}; + + /* + * XXX: For NetBSD 1.4.x compatibility. (kill me l8r) +@@ -158,17 +163,17 @@ + static DIR *g_opendir(Char *, glob_t *); + static Char *g_strchr(const Char *, int); + static int g_stat(Char *, __gl_stat_t *, glob_t *); +-static int glob0(const Char *, glob_t *, size_t *); +-static int glob1(Char *, glob_t *, size_t *); ++static int glob0(const Char *, glob_t *, struct glob_limit *); ++static int glob1(Char *, glob_t *, struct glob_limit *); + static int glob2(Char *, Char *, Char *, const Char *, glob_t *, +- size_t *); ++ struct glob_limit *); + static int glob3(Char *, Char *, Char *, const Char *, const Char *, +- const Char *, glob_t *, size_t *); +-static int globextend(const Char *, glob_t *, size_t *); ++ const Char *, glob_t *, struct glob_limit *); ++static int globextend(const Char *, glob_t *, struct glob_limit *); + static const Char *globtilde(const Char *, Char *, size_t, glob_t *); +-static int globexp1(const Char *, glob_t *, size_t *); ++static int globexp1(const Char *, glob_t *, struct glob_limit *); + static int globexp2(const Char *, const Char *, glob_t *, int *, +- size_t *); ++ struct glob_limit *); + static int match(const Char *, const Char *, const Char *); + #ifdef DEBUG + static void qprintf(const char *, Char *); +@@ -181,8 +186,7 @@ + const u_char *patnext; + int c; + Char *bufnext, *bufend, patbuf[MAXPATHLEN+1]; +- /* 0 = malloc(), 1 = stat(), 2 = readdir() */ +- size_t limit[] = { 0, 0, 0 }; ++ struct glob_limit limit = { 0, 0, 0, 0 }; + + _DIAGASSERT(pattern != NULL); + +@@ -218,9 +222,9 @@ + *bufnext = EOS; + + if (flags & GLOB_BRACE) +- return globexp1(patbuf, pglob, limit); ++ return globexp1(patbuf, pglob, &limit); + else +- return glob0(patbuf, pglob, limit); ++ return glob0(patbuf, pglob, &limit); + } + + /* +@@ -229,7 +233,7 @@ + * characters + */ + static int +-globexp1(const Char *pattern, glob_t *pglob, size_t *limit) ++globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit) + { + const Char* ptr = pattern; + int rv; +@@ -237,6 +241,12 @@ + _DIAGASSERT(pattern != NULL); + _DIAGASSERT(pglob != NULL); + ++ if ((pglob->gl_flags & GLOB_LIMIT) && ++ limit->l_brace++ >= GLOB_LIMIT_BRACE) { ++ errno = 0; ++ return GLOB_NOSPACE; ++ } ++ + /* Protect a single {}, for find(1), like csh */ + if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) + return glob0(pattern, pglob, limit); +@@ -256,7 +266,7 @@ + */ + static int + globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, +- size_t *limit) ++ struct glob_limit *limit) + { + int i; + Char *lm, *ls; +@@ -461,7 +471,7 @@ + * to find no matches. + */ + static int +-glob0(const Char *pattern, glob_t *pglob, size_t *limit) ++glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit) + { + const Char *qpatnext; + int c, error; +@@ -570,7 +580,7 @@ + } + + static int +-glob1(Char *pattern, glob_t *pglob, size_t *limit) ++glob1(Char *pattern, glob_t *pglob, struct glob_limit *limit) + { + Char pathbuf[MAXPATHLEN+1]; + +@@ -596,7 +606,7 @@ + */ + static int + glob2(Char *pathbuf, Char *pathend, Char *pathlim, const Char *pattern, +- glob_t *pglob, size_t *limit) ++ glob_t *pglob, struct glob_limit *limit) + { + __gl_stat_t sb; + const Char *p; +@@ -624,10 +634,11 @@ + return 0; + + if ((pglob->gl_flags & GLOB_LIMIT) && +- limit[GLOB_INDEX_STAT]++ >= GLOB_LIMIT_STAT) { ++ limit->l_stat++ >= GLOB_LIMIT_STAT) { + errno = 0; + *pathend++ = SEP; + *pathend = EOS; ++printf("stat limit\n"); + return GLOB_NOSPACE; + } + if (((pglob->gl_flags & GLOB_MARK) && +@@ -692,7 +703,7 @@ + static int + glob3(Char *pathbuf, Char *pathend, Char *pathlim, const Char *pattern, + const Char *restpattern, const Char *pglobstar, glob_t *pglob, +- size_t *limit) ++ struct glob_limit *limit) + { + struct dirent *dp; + DIR *dirp; +@@ -785,7 +796,7 @@ + Char *dc; + + if ((pglob->gl_flags & GLOB_LIMIT) && +- limit[GLOB_INDEX_READDIR]++ >= GLOB_LIMIT_READDIR) { ++ limit->l_readdir++ >= GLOB_LIMIT_READDIR) { + errno = 0; + *pathend++ = SEP; + *pathend = EOS; +@@ -894,7 +905,7 @@ + * gl_pathv points to (gl_offs + gl_pathc + 1) items. + */ + static int +-globextend(const Char *path, glob_t *pglob, size_t *limit) ++globextend(const Char *path, glob_t *pglob, struct glob_limit *limit) + { + char **pathv; + size_t i, newsize, len; +@@ -905,6 +916,9 @@ + _DIAGASSERT(pglob != NULL); + + newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); ++ if ((pglob->gl_flags & GLOB_LIMIT) && ++ newsize > GLOB_LIMIT_PATH * sizeof(*pathv)) ++ goto nospace; + pathv = pglob->gl_pathv ? realloc(pglob->gl_pathv, newsize) : + malloc(newsize); + if (pathv == NULL) +@@ -921,7 +935,7 @@ + for (p = path; *p++;) + continue; + len = (size_t)(p - path); +- limit[GLOB_INDEX_MALLOC] += len; ++ limit->l_string += len; + if ((copy = malloc(len)) != NULL) { + if (g_Ctoc(path, copy, len)) { + free(copy); +@@ -932,12 +946,13 @@ + pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; + + if ((pglob->gl_flags & GLOB_LIMIT) && +- (newsize + limit[GLOB_INDEX_MALLOC]) >= GLOB_LIMIT_MALLOC) { +- errno = 0; +- return GLOB_NOSPACE; +- } ++ (newsize + limit->l_string) >= GLOB_LIMIT_STRING) ++ goto nospace; + + return copy == NULL ? GLOB_NOSPACE : 0; ++nospace: ++ errno = 0; ++ return GLOB_NOSPACE; + } + + +diff -ru nbsdsrc/src/lib/libc/gen/gr_private.h lib/nbsd_libc/gen/gr_private.h +--- nbsdsrc/src/lib/libc/gen/gr_private.h ++++ lib/nbsd_libc/gen/gr_private.h @@ -40,11 +40,13 @@ #define _GROUP_COMPAT /* "group" defaults to compat, so always provide it */ @@ -924,9 +1204,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/gr_private.h ./gen/gr_private.h /* * files methods -diff -ru /home/netbsd/src/lib/libc/gen/initdir.c ./gen/initdir.c ---- /home/netbsd/src/lib/libc/gen/initdir.c 2010-09-26 02:26:59.000000000 +0000 -+++ ./gen/initdir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/initdir.c lib/nbsd_libc/gen/initdir.c +--- nbsdsrc/src/lib/libc/gen/initdir.c ++++ lib/nbsd_libc/gen/initdir.c @@ -35,6 +35,14 @@ #endif /* LIBC_SCCS and not lint */ @@ -954,9 +1234,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/initdir.c ./gen/initdir.c } free(dpv); -diff -ru /home/netbsd/src/lib/libc/gen/opendir.c ./gen/opendir.c ---- /home/netbsd/src/lib/libc/gen/opendir.c 2010-09-26 03:01:02.000000000 +0000 -+++ ./gen/opendir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/opendir.c lib/nbsd_libc/gen/opendir.c +--- nbsdsrc/src/lib/libc/gen/opendir.c ++++ lib/nbsd_libc/gen/opendir.c @@ -40,6 +40,12 @@ #include "namespace.h" @@ -970,13 +1250,21 @@ diff -ru /home/netbsd/src/lib/libc/gen/opendir.c ./gen/opendir.c #include "extern.h" #include -@@ -122,6 +128,12 @@ +@@ -97,7 +103,9 @@ + DIR *dirp = NULL; + int serrno; + struct stat sb; ++#ifndef __minix + struct statvfs sfb; ++#endif + int error; + + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) +@@ -122,6 +130,10 @@ * Tweak flags for the underlying filesystem. */ +#ifdef __minix -+ if (fstatvfs(fd, &sfb) < 0) -+ goto error; + /* MOUNT_UNION and MOUNT_NFS not supported */ + flags &= ~DTF_NODUP; +#else @@ -991,9 +1279,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/opendir.c ./gen/opendir.c dirp->dd_flags = flags; error = _initdir(dirp, fd, name); -diff -ru /home/netbsd/src/lib/libc/gen/readdir.c ./gen/readdir.c ---- /home/netbsd/src/lib/libc/gen/readdir.c 2010-09-16 03:01:30.000000000 +0000 -+++ ./gen/readdir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/readdir.c lib/nbsd_libc/gen/readdir.c +--- nbsdsrc/src/lib/libc/gen/readdir.c ++++ lib/nbsd_libc/gen/readdir.c @@ -40,6 +40,12 @@ #include "namespace.h" @@ -1018,9 +1306,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/readdir.c ./gen/readdir.c return (dp); } } -diff -ru /home/netbsd/src/lib/libc/gen/rewinddir.c ./gen/rewinddir.c ---- /home/netbsd/src/lib/libc/gen/rewinddir.c 2010-09-26 03:01:02.000000000 +0000 -+++ ./gen/rewinddir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/rewinddir.c lib/nbsd_libc/gen/rewinddir.c +--- nbsdsrc/src/lib/libc/gen/rewinddir.c ++++ lib/nbsd_libc/gen/rewinddir.c @@ -40,6 +40,11 @@ #include "namespace.h" @@ -1033,9 +1321,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/rewinddir.c ./gen/rewinddir.c #include "extern.h" #include -diff -ru /home/netbsd/src/lib/libc/gen/scandir.c ./gen/scandir.c ---- /home/netbsd/src/lib/libc/gen/scandir.c 2007-06-09 23:57:25.000000000 +0000 -+++ ./gen/scandir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/scandir.c lib/nbsd_libc/gen/scandir.c +--- nbsdsrc/src/lib/libc/gen/scandir.c ++++ lib/nbsd_libc/gen/scandir.c @@ -130,9 +130,13 @@ goto bad2; p->d_fileno = d->d_fileno; @@ -1050,9 +1338,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/scandir.c ./gen/scandir.c names[nitems++] = p; } (void)closedir(dirp); -diff -ru /home/netbsd/src/lib/libc/gen/seekdir.c ./gen/seekdir.c ---- /home/netbsd/src/lib/libc/gen/seekdir.c 2006-05-17 20:36:50.000000000 +0000 -+++ ./gen/seekdir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/seekdir.c lib/nbsd_libc/gen/seekdir.c +--- nbsdsrc/src/lib/libc/gen/seekdir.c ++++ lib/nbsd_libc/gen/seekdir.c @@ -40,6 +40,9 @@ #include "namespace.h" @@ -1063,9 +1351,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/seekdir.c ./gen/seekdir.c #include "extern.h" #include -diff -ru /home/netbsd/src/lib/libc/gen/syslog.c ./gen/syslog.c ---- /home/netbsd/src/lib/libc/gen/syslog.c 2010-05-14 04:47:24.000000000 +0000 -+++ ./gen/syslog.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/syslog.c lib/nbsd_libc/gen/syslog.c +--- nbsdsrc/src/lib/libc/gen/syslog.c ++++ lib/nbsd_libc/gen/syslog.c @@ -492,7 +492,9 @@ /* AF_UNIX address of local logger */ static const struct sockaddr_un sun = { @@ -1076,9 +1364,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/syslog.c ./gen/syslog.c .sun_path = _PATH_LOG, }; -diff -ru /home/netbsd/src/lib/libc/gen/telldir.c ./gen/telldir.c ---- /home/netbsd/src/lib/libc/gen/telldir.c 2008-05-04 18:53:26.000000000 +0000 -+++ ./gen/telldir.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/telldir.c lib/nbsd_libc/gen/telldir.c +--- nbsdsrc/src/lib/libc/gen/telldir.c ++++ lib/nbsd_libc/gen/telldir.c @@ -40,6 +40,11 @@ #include "namespace.h" @@ -1091,9 +1379,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/telldir.c ./gen/telldir.c #include "extern.h" #include -diff -ru /home/netbsd/src/lib/libc/gen/ttyname.c ./gen/ttyname.c ---- /home/netbsd/src/lib/libc/gen/ttyname.c 2008-06-25 11:47:29.000000000 +0000 -+++ ./gen/ttyname.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/ttyname.c lib/nbsd_libc/gen/ttyname.c +--- nbsdsrc/src/lib/libc/gen/ttyname.c ++++ lib/nbsd_libc/gen/ttyname.c @@ -72,7 +72,9 @@ mode_t type; dev_t dev; @@ -1132,9 +1420,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/ttyname.c ./gen/ttyname.c if (len - DEVSZ <= dlen) { /* * XXX: we return an error if *any* entry does not -diff -ru /home/netbsd/src/lib/libc/gen/ttyslot.c ./gen/ttyslot.c ---- /home/netbsd/src/lib/libc/gen/ttyslot.c 2009-01-11 02:46:27.000000000 +0000 -+++ ./gen/ttyslot.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/ttyslot.c lib/nbsd_libc/gen/ttyslot.c +--- nbsdsrc/src/lib/libc/gen/ttyslot.c ++++ lib/nbsd_libc/gen/ttyslot.c @@ -59,14 +59,20 @@ char *p; int cnt; @@ -1156,9 +1444,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/ttyslot.c ./gen/ttyslot.c ispty = 0; } else continue; -diff -ru /home/netbsd/src/lib/libc/gen/ulimit.c ./gen/ulimit.c ---- /home/netbsd/src/lib/libc/gen/ulimit.c 2008-04-28 20:22:59.000000000 +0000 -+++ ./gen/ulimit.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/ulimit.c lib/nbsd_libc/gen/ulimit.c +--- nbsdsrc/src/lib/libc/gen/ulimit.c ++++ lib/nbsd_libc/gen/ulimit.c @@ -54,12 +54,14 @@ if (getrlimit(RLIMIT_FSIZE, &rlimit) == 0) result = (long int)(rlimit.rlim_cur / 512); @@ -1174,9 +1462,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/ulimit.c ./gen/ulimit.c default: errno = EINVAL; } -diff -ru /home/netbsd/src/lib/libc/gen/utmpx.c ./gen/utmpx.c ---- /home/netbsd/src/lib/libc/gen/utmpx.c 2009-01-11 02:46:27.000000000 +0000 -+++ ./gen/utmpx.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gen/utmpx.c lib/nbsd_libc/gen/utmpx.c +--- nbsdsrc/src/lib/libc/gen/utmpx.c ++++ lib/nbsd_libc/gen/utmpx.c @@ -336,16 +336,32 @@ _DIAGASSERT(file != NULL); _DIAGASSERT(utx != NULL); @@ -1249,9 +1537,9 @@ diff -ru /home/netbsd/src/lib/libc/gen/utmpx.c ./gen/utmpx.c key.data = &uid; key.size = sizeof(uid); data.data = ll; -diff -ru /home/netbsd/src/lib/libc/gmon/gmon.c ./gmon/gmon.c ---- /home/netbsd/src/lib/libc/gmon/gmon.c 2011-01-05 03:01:31.000000000 +0000 -+++ ./gmon/gmon.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/gmon/gmon.c lib/nbsd_libc/gmon/gmon.c +--- nbsdsrc/src/lib/libc/gmon/gmon.c ++++ lib/nbsd_libc/gmon/gmon.c @@ -373,8 +373,10 @@ struct gmonparam *p = &_gmonparam; struct gmonhdr gmonhdr, *hdr; @@ -1294,9 +1582,9 @@ diff -ru /home/netbsd/src/lib/libc/gmon/gmon.c ./gmon/gmon.c return rv; } +#endif /* !__minix */ -diff -ru /home/netbsd/src/lib/libc/include/env.h ./include/env.h ---- /home/netbsd/src/lib/libc/include/env.h 2010-11-14 22:04:36.000000000 +0000 -+++ ./include/env.h 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/include/env.h lib/nbsd_libc/include/env.h +--- nbsdsrc/src/lib/libc/include/env.h ++++ lib/nbsd_libc/include/env.h @@ -56,7 +56,11 @@ } @@ -1309,9 +1597,9 @@ diff -ru /home/netbsd/src/lib/libc/include/env.h ./include/env.h { return true; } -diff -ru /home/netbsd/src/lib/libc/include/namespace.h ./include/namespace.h ---- /home/netbsd/src/lib/libc/include/namespace.h 2010-12-17 03:01:54.000000000 +0000 -+++ ./include/namespace.h 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/include/namespace.h lib/nbsd_libc/include/namespace.h +--- nbsdsrc/src/lib/libc/include/namespace.h ++++ lib/nbsd_libc/include/namespace.h @@ -47,7 +47,9 @@ #define fork _fork #define fseeko _fseeko @@ -1415,17 +1703,17 @@ diff -ru /home/netbsd/src/lib/libc/include/namespace.h ./include/namespace.h #endif /* __weak_alias */ #endif /* !__lint__ */ -diff -ru /home/netbsd/src/lib/libc/libcincludes.mk ./libcincludes.mk ---- /home/netbsd/src/lib/libc/libcincludes.mk 2008-10-26 07:28:06.000000000 +0000 -+++ ./libcincludes.mk 2038-01-19 03:14:07.000000000 +0000 -@@ -3,6 +3,24 @@ +diff -ru nbsdsrc/src/lib/libc/libcincludes.mk lib/nbsd_libc/libcincludes.mk +--- nbsdsrc/src/lib/libc/libcincludes.mk ++++ lib/nbsd_libc/libcincludes.mk +@@ -3,7 +3,25 @@ # Makefile fragment shared across several parts that want to look # inside libc's include tree. +.if defined(__MINIX) +MACHINE_ARCH= ${MACHINE} +MACHINE_CPU= ${MACHINE} -+.if defined(LIBC_MACHINE_ARCH) && \ + .if defined(LIBC_MACHINE_ARCH) && \ + exists(${MINIXSRCDIR}/lib/nbsd_libc/arch/${LIBC_MACHINE_ARCH}/SYS.h) +ARCHSUBDIR= ${LIBC_MACHINE_ARCH} +.elif exists(${MINIXSRCDIR}/lib/nbsd_libc/arch/${MACHINE_ARCH}/SYS.h) @@ -1440,17 +1728,18 @@ diff -ru /home/netbsd/src/lib/libc/libcincludes.mk ./libcincludes.mk + +ARCHDIR= ${MINIXSRCCDIR}/lib/nbsd_libc/arch/${ARCHSUBDIR} +.else - .if defined(LIBC_MACHINE_ARCH) && \ ++.if defined(LIBC_MACHINE_ARCH) && \ exists(${NETBSDSRCDIR}/lib/libc/arch/${LIBC_MACHINE_ARCH}/SYS.h) ARCHSUBDIR= ${LIBC_MACHINE_ARCH} + .elif exists(${NETBSDSRCDIR}/lib/libc/arch/${MACHINE_ARCH}/SYS.h) @@ -17,3 +35,4 @@ .endif ARCHDIR= ${NETBSDSRCDIR}/lib/libc/arch/${ARCHSUBDIR} +.endif -diff -ru /home/netbsd/src/lib/libc/locale/setlocale.c ./locale/setlocale.c ---- /home/netbsd/src/lib/libc/locale/setlocale.c 2010-06-08 03:01:34.000000000 +0000 -+++ ./locale/setlocale.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/locale/setlocale.c lib/nbsd_libc/locale/setlocale.c +--- nbsdsrc/src/lib/libc/locale/setlocale.c ++++ lib/nbsd_libc/locale/setlocale.c @@ -61,6 +61,38 @@ extern const _locale_category_t _localeio_LC_MESSAGES_desc; #endif @@ -1490,9 +1779,9 @@ diff -ru /home/netbsd/src/lib/libc/locale/setlocale.c ./locale/setlocale.c __link_set_add_data(all_categories, _generic_LC_ALL_desc); __link_set_add_data(all_categories, _dummy_LC_COLLATE_desc); #ifdef WITH_RUNE -diff -ru /home/netbsd/src/lib/libc/misc/initfini.c ./misc/initfini.c ---- /home/netbsd/src/lib/libc/misc/initfini.c 2010-11-15 03:02:00.000000000 +0000 -+++ ./misc/initfini.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/misc/initfini.c lib/nbsd_libc/misc/initfini.c +--- nbsdsrc/src/lib/libc/misc/initfini.c ++++ lib/nbsd_libc/misc/initfini.c @@ -55,8 +55,10 @@ /* Atomic operations */ __libc_atomic_init(); @@ -1504,9 +1793,9 @@ diff -ru /home/netbsd/src/lib/libc/misc/initfini.c ./misc/initfini.c /* Initialize the atexit mutexes */ __libc_atexit_init(); -diff -ru /home/netbsd/src/lib/libc/misc/stack_protector.c ./misc/stack_protector.c ---- /home/netbsd/src/lib/libc/misc/stack_protector.c 2010-12-08 03:01:48.000000000 +0000 -+++ ./misc/stack_protector.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/misc/stack_protector.c lib/nbsd_libc/misc/stack_protector.c +--- nbsdsrc/src/lib/libc/misc/stack_protector.c ++++ lib/nbsd_libc/misc/stack_protector.c @@ -56,24 +56,30 @@ void __guard_setup(void) @@ -1538,10 +1827,10 @@ diff -ru /home/netbsd/src/lib/libc/misc/stack_protector.c ./misc/stack_protector } /*ARGSUSED*/ -diff -ru /home/netbsd/src/lib/libc/net/Makefile.inc ./net/Makefile.inc ---- /home/netbsd/src/lib/libc/net/Makefile.inc 2009-10-02 02:45:29.000000000 +0000 -+++ ./net/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 -@@ -2,8 +2,22 @@ +diff -ru nbsdsrc/src/lib/libc/net/Makefile.inc lib/nbsd_libc/net/Makefile.inc +--- nbsdsrc/src/lib/libc/net/Makefile.inc ++++ lib/nbsd_libc/net/Makefile.inc +@@ -2,18 +2,33 @@ # @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 # net sources @@ -1552,19 +1841,22 @@ diff -ru /home/netbsd/src/lib/libc/net/Makefile.inc ./net/Makefile.inc +.if defined(__MINIX) +# Not supported by minix: iso_addr.c link_addr.c sockatmark.c + SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \ + getnetnamadr.c getnetent.c getpeereid.c \ + getprotobyname.c getprotobynumber.c getprotoent.c \ + getprotobyname_r.c getprotobynumber_r.c getprotoent_r.c \ + getservbyname.c getservbyport.c getservent.c \ + getservbyname_r.c getservbyport_r.c getservent_r.c \ ++ nsdispatch.c nslexer.l nsparser.y nsap_addr.c \ ++ rcmd.c recv.c send.c sethostent.c ++.else +SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \ + getnetnamadr.c getnetent.c getpeereid.c \ + getprotobyname.c getprotobynumber.c getprotoent.c \ + getprotobyname_r.c getprotobynumber_r.c getprotoent_r.c \ + getservbyname.c getservbyport.c getservent.c \ + getservbyname_r.c getservbyport_r.c getservent_r.c \ -+ nsdispatch.c nslexer.l nsparser.y nsap_addr.c \ -+ rcmd.c recv.c send.c sethostent.c -+.else - SRCS+= __cmsg_alignbytes.c base64.c ethers.c gethnamaddr.c getifaddrs.c \ - getnetnamadr.c getnetent.c getpeereid.c \ - getprotobyname.c getprotobynumber.c getprotoent.c \ -@@ -14,6 +28,7 @@ + iso_addr.c linkaddr.c \ nsdispatch.c nslexer.l nsparser.y nsap_addr.c \ rcmd.c recv.c send.c sethostent.c \ sockatmark.c @@ -1582,9 +1874,9 @@ diff -ru /home/netbsd/src/lib/libc/net/Makefile.inc ./net/Makefile.inc LPREFIX=_nsyy YPREFIX=_nsyy -diff -ru /home/netbsd/src/lib/libc/net/getaddrinfo.c ./net/getaddrinfo.c ---- /home/netbsd/src/lib/libc/net/getaddrinfo.c 2009-10-02 07:41:08.000000000 +0000 -+++ ./net/getaddrinfo.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/net/getaddrinfo.c lib/nbsd_libc/net/getaddrinfo.c +--- nbsdsrc/src/lib/libc/net/getaddrinfo.c ++++ lib/nbsd_libc/net/getaddrinfo.c @@ -855,7 +855,12 @@ ai = calloc(sizeof(struct addrinfo) + addrlen, 1); if (ai) { @@ -1598,9 +1890,9 @@ diff -ru /home/netbsd/src/lib/libc/net/getaddrinfo.c ./net/getaddrinfo.c } return ai; -diff -ru /home/netbsd/src/lib/libc/net/getnameinfo.c ./net/getnameinfo.c ---- /home/netbsd/src/lib/libc/net/getnameinfo.c 2010-06-30 03:52:09.000000000 +0000 -+++ ./net/getnameinfo.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/net/getnameinfo.c lib/nbsd_libc/net/getnameinfo.c +--- nbsdsrc/src/lib/libc/net/getnameinfo.c ++++ lib/nbsd_libc/net/getnameinfo.c @@ -54,10 +54,12 @@ #include #include @@ -1679,9 +1971,9 @@ diff -ru /home/netbsd/src/lib/libc/net/getnameinfo.c ./net/getnameinfo.c static int hexname(cp, len, host, hostlen) -diff -ru /home/netbsd/src/lib/libc/net/rcmd.c ./net/rcmd.c ---- /home/netbsd/src/lib/libc/net/rcmd.c 2007-01-03 11:46:22.000000000 +0000 -+++ ./net/rcmd.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/net/rcmd.c lib/nbsd_libc/net/rcmd.c +--- nbsdsrc/src/lib/libc/net/rcmd.c ++++ lib/nbsd_libc/net/rcmd.c @@ -48,7 +48,9 @@ #include @@ -1766,9 +2058,9 @@ diff -ru /home/netbsd/src/lib/libc/net/rcmd.c ./net/rcmd.c return (-1); } -diff -ru /home/netbsd/src/lib/libc/net/send.c ./net/send.c ---- /home/netbsd/src/lib/libc/net/send.c 2003-08-07 16:43:15.000000000 +0000 -+++ ./net/send.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/net/send.c lib/nbsd_libc/net/send.c +--- nbsdsrc/src/lib/libc/net/send.c ++++ lib/nbsd_libc/net/send.c @@ -44,9 +44,15 @@ #include @@ -1785,9 +2077,9 @@ diff -ru /home/netbsd/src/lib/libc/net/send.c ./net/send.c ssize_t send(s, msg, len, flags) -diff -ru /home/netbsd/src/lib/libc/nls/catopen.c ./nls/catopen.c ---- /home/netbsd/src/lib/libc/nls/catopen.c 2009-03-10 13:15:40.000000000 +0000 -+++ ./nls/catopen.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/nls/catopen.c lib/nbsd_libc/nls/catopen.c +--- nbsdsrc/src/lib/libc/nls/catopen.c ++++ lib/nbsd_libc/nls/catopen.c @@ -169,6 +169,19 @@ return (nl_catd)-1; } @@ -1816,9 +2108,9 @@ diff -ru /home/netbsd/src/lib/libc/nls/catopen.c ./nls/catopen.c if (ntohl((u_int32_t)((struct _nls_cat_hdr *)data)->__magic) != _NLS_MAGIC) { -diff -ru /home/netbsd/src/lib/libc/resolv/Makefile.inc ./resolv/Makefile.inc ---- /home/netbsd/src/lib/libc/resolv/Makefile.inc 2007-01-28 02:14:05.000000000 +0000 -+++ ./resolv/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/resolv/Makefile.inc lib/nbsd_libc/resolv/Makefile.inc +--- nbsdsrc/src/lib/libc/resolv/Makefile.inc ++++ lib/nbsd_libc/resolv/Makefile.inc @@ -2,7 +2,11 @@ # net sources @@ -1831,9 +2123,9 @@ diff -ru /home/netbsd/src/lib/libc/resolv/Makefile.inc ./resolv/Makefile.inc SRCS+= __dn_comp.c __res_close.c __res_send.c h_errno.c \ herror.c res_comp.c res_data.c res_debug.c \ -diff -ru /home/netbsd/src/lib/libc/resolv/res_comp.c ./resolv/res_comp.c ---- /home/netbsd/src/lib/libc/resolv/res_comp.c 2009-04-12 17:07:17.000000000 +0000 -+++ ./resolv/res_comp.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/resolv/res_comp.c lib/nbsd_libc/resolv/res_comp.c +--- nbsdsrc/src/lib/libc/resolv/res_comp.c ++++ lib/nbsd_libc/resolv/res_comp.c @@ -96,7 +96,7 @@ #ifdef __weak_alias __weak_alias(dn_expand,_dn_expand) @@ -1843,9 +2135,9 @@ diff -ru /home/netbsd/src/lib/libc/resolv/res_comp.c ./resolv/res_comp.c __weak_alias(dn_skipname,__dn_skipname) __weak_alias(res_hnok,__res_hnok) __weak_alias(res_ownok,__res_ownok) -diff -ru /home/netbsd/src/lib/libc/resolv/res_init.c ./resolv/res_init.c ---- /home/netbsd/src/lib/libc/resolv/res_init.c 2009-10-24 17:24:01.000000000 +0000 -+++ ./resolv/res_init.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/resolv/res_init.c lib/nbsd_libc/resolv/res_init.c +--- nbsdsrc/src/lib/libc/resolv/res_init.c ++++ lib/nbsd_libc/resolv/res_init.c @@ -70,6 +70,10 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ @@ -1895,19 +2187,20 @@ diff -ru /home/netbsd/src/lib/libc/resolv/res_init.c ./resolv/res_init.c } else { statp->_u._ext.ext->kq = -1; statp->_u._ext.ext->resfd = -1; -@@ -565,6 +577,12 @@ +@@ -565,7 +577,13 @@ int res_check(res_state statp, struct timespec *mtime) { +#ifdef __minix -+ /* + /* + * XXX: No update on change. + */ + return 0; +#else /* !__minix */ - /* ++ /* * If the times are equal, then we check if there * was a kevent related to resolv.conf and reload. + * If the times are not equal, then we don't bother @@ -593,6 +611,7 @@ if (mtime) *mtime = __res_conf_time; @@ -1916,9 +2209,9 @@ diff -ru /home/netbsd/src/lib/libc/resolv/res_init.c ./resolv/res_init.c } static void -diff -ru /home/netbsd/src/lib/libc/stdio/fseeko.c ./stdio/fseeko.c ---- /home/netbsd/src/lib/libc/stdio/fseeko.c 2009-01-31 00:08:05.000000000 +0000 -+++ ./stdio/fseeko.c 2011-03-16 12:40:38.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/stdio/fseeko.c lib/nbsd_libc/stdio/fseeko.c +--- nbsdsrc/src/lib/libc/stdio/fseeko.c ++++ lib/nbsd_libc/stdio/fseeko.c @@ -150,7 +150,11 @@ fp->_flags |= __SNPT; goto dumb; @@ -1931,9 +2224,9 @@ diff -ru /home/netbsd/src/lib/libc/stdio/fseeko.c ./stdio/fseeko.c fp->_flags |= __SOPT; } -diff -ru /home/netbsd/src/lib/libc/stdio/makebuf.c ./stdio/makebuf.c ---- /home/netbsd/src/lib/libc/stdio/makebuf.c 2008-03-13 15:40:00.000000000 +0000 -+++ ./stdio/makebuf.c 2011-03-16 12:44:50.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/stdio/makebuf.c lib/nbsd_libc/stdio/makebuf.c +--- nbsdsrc/src/lib/libc/stdio/makebuf.c ++++ lib/nbsd_libc/stdio/makebuf.c @@ -114,18 +114,25 @@ /* could be a tty iff it is a character device */ @@ -1960,21 +2253,21 @@ diff -ru /home/netbsd/src/lib/libc/stdio/makebuf.c ./stdio/makebuf.c return ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek ? __SOPT : __SNPT); } -diff -ru /home/netbsd/src/lib/libc/stdlib/Makefile.inc ./stdlib/Makefile.inc ---- /home/netbsd/src/lib/libc/stdlib/Makefile.inc 2010-11-15 03:02:00.000000000 +0000 -+++ ./stdlib/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 -@@ -4,6 +4,21 @@ +diff -ru nbsdsrc/src/lib/libc/stdlib/Makefile.inc lib/nbsd_libc/stdlib/Makefile.inc +--- nbsdsrc/src/lib/libc/stdlib/Makefile.inc ++++ lib/nbsd_libc/stdlib/Makefile.inc +@@ -4,18 +4,34 @@ # stdlib sources .PATH: ${ARCHDIR}/stdlib ${.CURDIR}/stdlib +.if defined(__MINIX) +# pty.c not compiled -+SRCS+= _env.c _rand48.c \ -+ a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \ -+ bsearch.c drand48.c exit.c \ -+ getenv.c getopt.c getopt_long.c getsubopt.c \ -+ hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \ -+ lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \ + SRCS+= _env.c _rand48.c \ + a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \ + bsearch.c drand48.c exit.c \ + getenv.c getopt.c getopt_long.c getsubopt.c \ + hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \ + lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \ + nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c \ + radixsort.c rand.c rand_r.c random.c remque.c \ + seed48.c setenv.c srand48.c strsuftoll.c \ @@ -1982,10 +2275,15 @@ diff -ru /home/netbsd/src/lib/libc/stdlib/Makefile.inc ./stdlib/Makefile.inc + strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \ + unsetenv.c strfmon.c +.else - SRCS+= _env.c _rand48.c \ - a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \ - bsearch.c drand48.c exit.c \ -@@ -16,6 +31,7 @@ ++SRCS+= _env.c _rand48.c \ ++ a64l.c abort.c atexit.c atof.c atoi.c atol.c atoll.c \ ++ bsearch.c drand48.c exit.c \ ++ getenv.c getopt.c getopt_long.c getsubopt.c \ ++ hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \ ++ lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \ + nrand48.c putenv.c qabs.c qdiv.c qsort.c posix_openpt.c pty.c \ + radixsort.c rand.c rand_r.c random.c remque.c \ + seed48.c setenv.c srand48.c strsuftoll.c \ strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \ strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \ unsetenv.c strfmon.c @@ -1993,9 +2291,9 @@ diff -ru /home/netbsd/src/lib/libc/stdlib/Makefile.inc ./stdlib/Makefile.inc # These are often replaced by MD .S versions SRCS+= abs.c labs.c llabs.c imaxabs.c -diff -ru /home/netbsd/src/lib/libc/stdlib/atexit.c ./stdlib/atexit.c ---- /home/netbsd/src/lib/libc/stdlib/atexit.c 2009-10-08 16:33:45.000000000 +0000 -+++ ./stdlib/atexit.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/stdlib/atexit.c lib/nbsd_libc/stdlib/atexit.c +--- nbsdsrc/src/lib/libc/stdlib/atexit.c ++++ lib/nbsd_libc/stdlib/atexit.c @@ -120,10 +120,12 @@ void __libc_atexit_init(void) @@ -2009,9 +2307,9 @@ diff -ru /home/netbsd/src/lib/libc/stdlib/atexit.c ./stdlib/atexit.c } /* -diff -ru /home/netbsd/src/lib/libc/stdlib/malloc.c ./stdlib/malloc.c ---- /home/netbsd/src/lib/libc/stdlib/malloc.c 2008-02-03 22:56:53.000000000 +0000 -+++ ./stdlib/malloc.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/stdlib/malloc.c lib/nbsd_libc/stdlib/malloc.c +--- nbsdsrc/src/lib/libc/stdlib/malloc.c ++++ lib/nbsd_libc/stdlib/malloc.c @@ -65,8 +65,10 @@ # define malloc_pageshift 12U # define malloc_minsize 16U @@ -2057,9 +2355,9 @@ diff -ru /home/netbsd/src/lib/libc/stdlib/malloc.c ./stdlib/malloc.c tail = (char *)ptr+l; -diff -ru /home/netbsd/src/lib/libc/stdlib/system.c ./stdlib/system.c ---- /home/netbsd/src/lib/libc/stdlib/system.c 2010-11-15 03:02:00.000000000 +0000 -+++ ./stdlib/system.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/stdlib/system.c lib/nbsd_libc/stdlib/system.c +--- nbsdsrc/src/lib/libc/stdlib/system.c ++++ lib/nbsd_libc/stdlib/system.c @@ -91,7 +91,11 @@ } @@ -2072,21 +2370,21 @@ diff -ru /home/netbsd/src/lib/libc/stdlib/system.c ./stdlib/system.c case -1: /* error */ (void)__unlockenv(); sigaction(SIGINT, &intsa, NULL); -diff -ru /home/netbsd/src/lib/libc/termios/Makefile.inc ./termios/Makefile.inc ---- /home/netbsd/src/lib/libc/termios/Makefile.inc 1998-02-14 20:20:44.000000000 +0000 -+++ ./termios/Makefile.inc 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/termios/Makefile.inc lib/nbsd_libc/termios/Makefile.inc +--- nbsdsrc/src/lib/libc/termios/Makefile.inc ++++ lib/nbsd_libc/termios/Makefile.inc @@ -2,9 +2,18 @@ .PATH: ${.CURDIR}/termios +.if defined(__MINIX) +# Not supported by Minix: tcgetsid.c -+SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \ -+ cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \ -+ tcsendbreak.c tcsetattr.c tcsetpgrp.c -+.else SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \ cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \ ++ tcsendbreak.c tcsetattr.c tcsetpgrp.c ++.else ++SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \ ++ cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \ tcgetsid.c tcsendbreak.c tcsetattr.c tcsetpgrp.c +.endif + @@ -2094,9 +2392,9 @@ diff -ru /home/netbsd/src/lib/libc/termios/Makefile.inc ./termios/Makefile.inc MAN+= tcgetpgrp.3 tcgetsid.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 -diff -ru /home/netbsd/src/lib/libc/termios/cfmakeraw.c ./termios/cfmakeraw.c ---- /home/netbsd/src/lib/libc/termios/cfmakeraw.c 2003-08-07 16:44:12.000000000 +0000 -+++ ./termios/cfmakeraw.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/termios/cfmakeraw.c lib/nbsd_libc/termios/cfmakeraw.c +--- nbsdsrc/src/lib/libc/termios/cfmakeraw.c ++++ lib/nbsd_libc/termios/cfmakeraw.c @@ -59,7 +59,11 @@ _DIAGASSERT(t != NULL); @@ -2109,9 +2407,9 @@ diff -ru /home/netbsd/src/lib/libc/termios/cfmakeraw.c ./termios/cfmakeraw.c t->c_oflag &= ~OPOST; t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); t->c_cflag &= ~(CSIZE|PARENB); -diff -ru /home/netbsd/src/lib/libc/termios/tcflow.c ./termios/tcflow.c ---- /home/netbsd/src/lib/libc/termios/tcflow.c 2003-08-07 16:44:13.000000000 +0000 -+++ ./termios/tcflow.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/termios/tcflow.c lib/nbsd_libc/termios/tcflow.c +--- nbsdsrc/src/lib/libc/termios/tcflow.c ++++ lib/nbsd_libc/termios/tcflow.c @@ -54,6 +54,10 @@ tcflow(fd, action) int fd, action; @@ -2129,9 +2427,9 @@ diff -ru /home/netbsd/src/lib/libc/termios/tcflow.c ./termios/tcflow.c /* NOTREACHED */ +#endif /* !__minix */ } -diff -ru /home/netbsd/src/lib/libc/termios/tcflush.c ./termios/tcflush.c ---- /home/netbsd/src/lib/libc/termios/tcflush.c 2003-08-07 16:44:13.000000000 +0000 -+++ ./termios/tcflush.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/termios/tcflush.c lib/nbsd_libc/termios/tcflush.c +--- nbsdsrc/src/lib/libc/termios/tcflush.c ++++ lib/nbsd_libc/termios/tcflush.c @@ -54,6 +54,10 @@ tcflush(fd, which) int fd, which; @@ -2149,9 +2447,9 @@ diff -ru /home/netbsd/src/lib/libc/termios/tcflush.c ./termios/tcflush.c return (ioctl(fd, TIOCFLUSH, &com)); +#endif /* !__minix */ } -diff -ru /home/netbsd/src/lib/libc/termios/tcsendbreak.c ./termios/tcsendbreak.c ---- /home/netbsd/src/lib/libc/termios/tcsendbreak.c 2003-08-07 16:44:14.000000000 +0000 -+++ ./termios/tcsendbreak.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/termios/tcsendbreak.c lib/nbsd_libc/termios/tcsendbreak.c +--- nbsdsrc/src/lib/libc/termios/tcsendbreak.c ++++ lib/nbsd_libc/termios/tcsendbreak.c @@ -41,7 +41,9 @@ #include "namespace.h" #include @@ -2179,9 +2477,9 @@ diff -ru /home/netbsd/src/lib/libc/termios/tcsendbreak.c ./termios/tcsendbreak.c return (0); +#endif /* !__minix */ } -diff -ru /home/netbsd/src/lib/libc/termios/tcsetattr.c ./termios/tcsetattr.c ---- /home/netbsd/src/lib/libc/termios/tcsetattr.c 2003-08-07 16:44:14.000000000 +0000 -+++ ./termios/tcsetattr.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/termios/tcsetattr.c lib/nbsd_libc/termios/tcsetattr.c +--- nbsdsrc/src/lib/libc/termios/tcsetattr.c ++++ lib/nbsd_libc/termios/tcsetattr.c @@ -60,11 +60,15 @@ _DIAGASSERT(fd != -1); _DIAGASSERT(t != NULL); @@ -2198,9 +2496,9 @@ diff -ru /home/netbsd/src/lib/libc/termios/tcsetattr.c ./termios/tcsetattr.c switch (opt & ~TCSASOFT) { case TCSANOW: return (ioctl(fd, TIOCSETA, t)); -diff -ru /home/netbsd/src/lib/libc/time/strftime.c ./time/strftime.c ---- /home/netbsd/src/lib/libc/time/strftime.c 2010-12-17 03:01:55.000000000 +0000 -+++ ./time/strftime.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/time/strftime.c lib/nbsd_libc/time/strftime.c +--- nbsdsrc/src/lib/libc/time/strftime.c ++++ lib/nbsd_libc/time/strftime.c @@ -553,6 +553,11 @@ pt = _conv(diff, "%04d", pt, ptlim); } @@ -2213,9 +2511,9 @@ diff -ru /home/netbsd/src/lib/libc/time/strftime.c ./time/strftime.c #if 0 case '+': pt = _fmt(sp, Locale->date_fmt, t, pt, ptlim, -diff -ru /home/netbsd/src/lib/libc/yp/yplib.c ./yp/yplib.c ---- /home/netbsd/src/lib/libc/yp/yplib.c 2006-11-03 20:18:49.000000000 +0000 -+++ ./yp/yplib.c 2038-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/lib/libc/yp/yplib.c lib/nbsd_libc/yp/yplib.c +--- nbsdsrc/src/lib/libc/yp/yplib.c ++++ lib/nbsd_libc/yp/yplib.c @@ -172,8 +172,10 @@ } (void)memset(&ysd->dom_server_addr, 0, diff --git a/lib/nbsd_libcompat_minix/Makefile b/lib/nbsd_libcompat_minix/Makefile index db9425e7c..21ec36866 100644 --- a/lib/nbsd_libcompat_minix/Makefile +++ b/lib/nbsd_libcompat_minix/Makefile @@ -2,6 +2,7 @@ LIB= compat_minix CPPFLAGS+= -D_MINIX_COMPAT +MACHINE_ARCH= ${ARCH} .PATH: ${.CURDIR} diff --git a/lib/nbsd_libcompat_minix/include/Makefile.inc b/lib/nbsd_libcompat_minix/include/Makefile.inc index d0d0e6f22..a6f0f1a1c 100644 --- a/lib/nbsd_libcompat_minix/include/Makefile.inc +++ b/lib/nbsd_libcompat_minix/include/Makefile.inc @@ -6,3 +6,5 @@ INCS+= configfile.h termcap.h INCS+= compat/a.out.h compat/regexp.h compat/syslog.h \ compat/pwd.h INCS+= net/gen/netdb.h net/gen/resolv.h net/gen/nameser.h +INCS+= sys/jmp_buf.h ${MACHINE_ARCH}/compat_jmp_buf.h +INCS+= sys/sigcontext.h diff --git a/lib/nbsd_libcompat_minix/include/i386/compat_jmp_buf.h b/lib/nbsd_libcompat_minix/include/i386/compat_jmp_buf.h new file mode 100644 index 000000000..bb5526c2c --- /dev/null +++ b/lib/nbsd_libcompat_minix/include/i386/compat_jmp_buf.h @@ -0,0 +1,16 @@ +#ifndef _COMPAT_MACHINE_JMP_BUF_H +#define _COMPAT_MACHINE_JMP_BUF_H + +/* This file is strictly dependant on the libc's + * setjmp/longjmp code! Keep it in sync! */ + +/* This is used only by libddekit's src/thread.c. + * Being incredibly fragile (not to mention hardly + * portable, it would be a good idea to replace + * that code. */ + +#define JB_PC 0 +#define JB_SP 8 +#define JB_BP 12 + +#endif /* _COMPAT_MACHINE_JMP_BUF_H */ diff --git a/lib/nbsd_libcompat_minix/include/sys/jmp_buf.h b/lib/nbsd_libcompat_minix/include/sys/jmp_buf.h new file mode 100644 index 000000000..28f137454 --- /dev/null +++ b/lib/nbsd_libcompat_minix/include/sys/jmp_buf.h @@ -0,0 +1,2 @@ +/* Stub for libddekit. Hopefully this will go away soon. */ +#include diff --git a/lib/nbsd_libcompat_minix/include/sys/sigcontext.h b/lib/nbsd_libcompat_minix/include/sys/sigcontext.h new file mode 100644 index 000000000..c27882230 --- /dev/null +++ b/lib/nbsd_libcompat_minix/include/sys/sigcontext.h @@ -0,0 +1,8 @@ +#ifndef COMPAT_SYS_SIGCONTEXT_H +#define COMPAT_SYS_SIGCONTEXT_H + +/* Minix legacy compatibility header. */ +#include +#include + +#endif diff --git a/lib/nbsd_libcompat_minix/mtab.c b/lib/nbsd_libcompat_minix/mtab.c index 69b91b823..499eae479 100644 --- a/lib/nbsd_libcompat_minix/mtab.c +++ b/lib/nbsd_libcompat_minix/mtab.c @@ -33,6 +33,7 @@ */ #include +#include #include #include #include @@ -55,7 +56,7 @@ _PROTOTYPE(int get_mtab_entry, (char *special, char *mounted_on, char *version, char *rw_flag)); _PROTOTYPE(int put_mtab_entry, (char *special, char *mounted_on, char *version, char *rw_flag)); -_PROTOTYPE(void err, (char *prog_name, char *str )); +PRIVATE _PROTOTYPE(void err, (char *prog_name, char *str )); int load_mtab(prog_name) @@ -194,7 +195,7 @@ char *rw_flag; } -void +PRIVATE void err(prog_name, str) char *prog_name, *str; { diff --git a/lib/nbsd_libm/arch/i387/.depend b/lib/nbsd_libm/arch/i387/.depend deleted file mode 100644 index 0c3366a10..000000000 --- a/lib/nbsd_libm/arch/i387/.depend +++ /dev/null @@ -1,2 +0,0 @@ - -empty.o: empty.S diff --git a/lib/nbsd_libm/minix-port.patch b/lib/nbsd_libm/minix-port.patch new file mode 100644 index 000000000..e69de29bb diff --git a/nbsd_include/arch/Makefile b/nbsd_include/arch/Makefile index 4d47046e9..058d2b9b4 100644 --- a/nbsd_include/arch/Makefile +++ b/nbsd_include/arch/Makefile @@ -55,8 +55,8 @@ SUBDIR+= xen INCSYMLINKS= ${MACHINE} /usr/netbsd/include/machine -INCSYMLINKS+= /usr/netbsd/include/machine/float.h /usr/netbsd/include/float.h \ - /usr/netbsd/include/machine/stdarg.h /usr/netbsd/include/stdarg.h +INCSYMLINKS+= machine/float.h /usr/netbsd/include/float.h \ + machine/stdarg.h /usr/netbsd/include/stdarg.h .include diff --git a/nbsd_include/arch/i386/include/cdefs.h b/nbsd_include/arch/i386/include/cdefs.h index 6fe7a7383..410cdbe2f 100644 --- a/nbsd_include/arch/i386/include/cdefs.h +++ b/nbsd_include/arch/i386/include/cdefs.h @@ -4,7 +4,9 @@ #define _I386_CDEFS_H_ #ifdef __minix +#ifndef __ELF__ #define __LEADING_UNDERSCORE +#endif #else /* !__minix */ /* No arch-specific cdefs. */ #endif diff --git a/nbsd_include/minix-port.patch b/nbsd_include/minix-port.patch index 006013d63..a40d5494a 100644 --- a/nbsd_include/minix-port.patch +++ b/nbsd_include/minix-port.patch @@ -1,16 +1,16 @@ -diff -ru /home/netbsd/src/include/Makefile ./Makefile ---- /home/netbsd/src/include/Makefile 2010-08-01 03:01:48.000000000 +0000 -+++ ./Makefile 2011-01-19 03:14:07.000000000 +0000 -@@ -7,6 +7,24 @@ +diff -ru nbsdsrc/src/include/Makefile nbsd_include/Makefile +--- nbsdsrc/src/include/Makefile ++++ nbsd_include/Makefile +@@ -7,10 +7,28 @@ # Missing: mp.h +.if defined(__MINIX) +# Avoid installing: kvm.h lwp.h sa.h (latter not installed anyway) -+INCS= a.out.h aio.h ar.h assert.h atomic.h \ -+ bitstring.h bm.h cdbr.h cdbw.h complex.h cpio.h ctype.h \ -+ db.h dirent.h disktab.h dlfcn.h err.h errno.h fenv.h fmtmsg.h fnmatch.h \ -+ fstab.h fts.h ftw.h getopt.h glob.h grp.h ifaddrs.h iconv.h \ + INCS= a.out.h aio.h ar.h assert.h atomic.h \ + bitstring.h bm.h cdbr.h cdbw.h complex.h cpio.h ctype.h \ + db.h dirent.h disktab.h dlfcn.h err.h errno.h fenv.h fmtmsg.h fnmatch.h \ + fstab.h fts.h ftw.h getopt.h glob.h grp.h ifaddrs.h iconv.h \ + inttypes.h iso646.h langinfo.h libgen.h \ + limits.h link.h link_aout.h link_elf.h locale.h \ + login_cap.h malloc.h math.h md2.h \ @@ -23,9 +23,13 @@ diff -ru /home/netbsd/src/include/Makefile ./Makefile + ttyent.h tzfile.h ucontext.h ulimit.h unistd.h util.h utime.h utmp.h \ + utmpx.h uuid.h varargs.h vis.h wchar.h wctype.h wordexp.h +.else - INCS= a.out.h aio.h ar.h assert.h atomic.h \ - bitstring.h bm.h cdbr.h cdbw.h complex.h cpio.h ctype.h \ - db.h dirent.h disktab.h dlfcn.h err.h errno.h fenv.h fmtmsg.h fnmatch.h \ ++INCS= a.out.h aio.h ar.h assert.h atomic.h \ ++ bitstring.h bm.h cdbr.h cdbw.h complex.h cpio.h ctype.h \ ++ db.h dirent.h disktab.h dlfcn.h err.h errno.h fenv.h fmtmsg.h fnmatch.h \ ++ fstab.h fts.h ftw.h getopt.h glob.h grp.h ifaddrs.h iconv.h \ + inttypes.h iso646.h kvm.h langinfo.h libgen.h \ + limits.h link.h link_aout.h link_elf.h locale.h \ + login_cap.h lwp.h malloc.h math.h md2.h \ @@ -22,6 +40,7 @@ strings.h stringlist.h struct.h sysexits.h tar.h time.h \ ttyent.h tzfile.h ucontext.h ulimit.h unistd.h util.h utime.h utmp.h \ @@ -63,9 +67,9 @@ diff -ru /home/netbsd/src/include/Makefile ./Makefile .include .include -diff -ru /home/netbsd/src/include/a.out.h ./a.out.h ---- /home/netbsd/src/include/a.out.h 2009-08-19 20:23:46.000000000 +0000 -+++ ./a.out.h 2011-04-06 05:07:37.000000000 +0000 +diff -ru nbsdsrc/src/include/a.out.h nbsd_include/a.out.h +--- nbsdsrc/src/include/a.out.h ++++ nbsd_include/a.out.h @@ -60,9 +60,14 @@ #ifndef _AOUT_H_ #define _AOUT_H_ @@ -81,9 +85,9 @@ diff -ru /home/netbsd/src/include/a.out.h ./a.out.h +#endif /* !__minix */ #endif /* !_AOUT_H_ */ -diff -ru /home/netbsd/src/include/arpa/nameser_compat.h ./arpa/nameser_compat.h ---- /home/netbsd/src/include/arpa/nameser_compat.h 2009-04-13 03:03:27.000000000 +0000 -+++ ./arpa/nameser_compat.h 2011-03-28 10:57:33.000000000 +0000 +diff -ru nbsdsrc/src/include/arpa/nameser_compat.h nbsd_include/arpa/nameser_compat.h +--- nbsdsrc/src/include/arpa/nameser_compat.h ++++ nbsd_include/arpa/nameser_compat.h @@ -133,6 +133,14 @@ unsigned arcount :16; /*%< number of resource entries */ } HEADER; @@ -99,9 +103,9 @@ diff -ru /home/netbsd/src/include/arpa/nameser_compat.h ./arpa/nameser_compat.h #define PACKETSZ NS_PACKETSZ #define MAXDNAME NS_MAXDNAME #define MAXCDNAME NS_MAXCDNAME -diff -ru /home/netbsd/src/include/dirent.h ./dirent.h ---- /home/netbsd/src/include/dirent.h 2010-09-26 03:01:02.000000000 +0000 -+++ ./dirent.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/dirent.h nbsd_include/dirent.h +--- nbsdsrc/src/include/dirent.h ++++ nbsd_include/dirent.h @@ -43,16 +43,20 @@ */ #include @@ -123,9 +127,9 @@ diff -ru /home/netbsd/src/include/dirent.h ./dirent.h /* structure describing an open directory. */ struct _dirdesc { -diff -ru /home/netbsd/src/include/fts.h ./fts.h ---- /home/netbsd/src/include/fts.h 2009-08-19 20:23:46.000000000 +0000 -+++ ./fts.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/fts.h nbsd_include/fts.h +--- nbsdsrc/src/include/fts.h ++++ nbsd_include/fts.h @@ -75,7 +75,9 @@ #define FTS_PHYSICAL 0x010 /* physical walk */ #define FTS_SEEDOT 0x020 /* return dot and dot-dot */ @@ -136,9 +140,9 @@ diff -ru /home/netbsd/src/include/fts.h ./fts.h #define FTS_OPTIONMASK 0x0ff /* valid user option mask */ #define FTS_NAMEONLY 0x100 /* (private) child names only */ -diff -ru /home/netbsd/src/include/limits.h ./limits.h ---- /home/netbsd/src/include/limits.h 2010-06-08 03:01:32.000000000 +0000 -+++ ./limits.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/limits.h nbsd_include/limits.h +--- nbsdsrc/src/include/limits.h ++++ nbsd_include/limits.h @@ -113,4 +113,9 @@ #include #include @@ -149,9 +153,9 @@ diff -ru /home/netbsd/src/include/limits.h ./limits.h +#endif + #endif /* !_LIMITS_H_ */ -diff -ru /home/netbsd/src/include/netdb.h ./netdb.h ---- /home/netbsd/src/include/netdb.h 2010-05-06 03:02:39.000000000 +0000 -+++ ./netdb.h 2011-03-23 16:09:44.000000000 +0000 +diff -ru nbsdsrc/src/include/netdb.h nbsd_include/netdb.h +--- nbsdsrc/src/include/netdb.h ++++ nbsd_include/netdb.h @@ -131,6 +131,9 @@ #ifndef _PATH_SERVICES_DB #define _PATH_SERVICES_DB "/var/db/services.db" @@ -162,9 +166,9 @@ diff -ru /home/netbsd/src/include/netdb.h ./netdb.h #endif __BEGIN_DECLS -diff -ru /home/netbsd/src/include/paths.h ./paths.h ---- /home/netbsd/src/include/paths.h 2010-12-30 03:02:34.000000000 +0000 -+++ ./paths.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/paths.h nbsd_include/paths.h +--- nbsdsrc/src/include/paths.h ++++ nbsd_include/paths.h @@ -124,5 +124,9 @@ #define _PATH_VI "/usr/bin/vi" #endif @@ -175,9 +179,9 @@ diff -ru /home/netbsd/src/include/paths.h ./paths.h + #endif /* !_PATHS_H_ */ -diff -ru /home/netbsd/src/include/pwd.h ./pwd.h ---- /home/netbsd/src/include/pwd.h 2009-01-11 03:05:43.000000000 +0000 -+++ ./pwd.h 2011-03-22 11:35:06.000000000 +0000 +diff -ru nbsdsrc/src/include/pwd.h nbsd_include/pwd.h +--- nbsdsrc/src/include/pwd.h ++++ nbsd_include/pwd.h @@ -61,6 +61,14 @@ * SUCH DAMAGE. */ @@ -193,9 +197,9 @@ diff -ru /home/netbsd/src/include/pwd.h ./pwd.h #ifndef _PWD_H_ #define _PWD_H_ -diff -ru /home/netbsd/src/include/rpc/Makefile ./rpc/Makefile ---- /home/netbsd/src/include/rpc/Makefile 2003-01-11 13:28:43.000000000 +0000 -+++ ./rpc/Makefile 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/rpc/Makefile nbsd_include/rpc/Makefile +--- nbsdsrc/src/include/rpc/Makefile ++++ nbsd_include/rpc/Makefile @@ -7,7 +7,11 @@ svc.h svc_auth.h svc_soc.h types.h xdr.h RPC_INCS= rpcb_prot.h @@ -208,9 +212,9 @@ diff -ru /home/netbsd/src/include/rpc/Makefile ./rpc/Makefile .include .include -diff -ru /home/netbsd/src/include/sched.h ./sched.h ---- /home/netbsd/src/include/sched.h 2009-01-11 03:05:43.000000000 +0000 -+++ ./sched.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/sched.h nbsd_include/sched.h +--- nbsdsrc/src/include/sched.h ++++ nbsd_include/sched.h @@ -29,6 +29,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ @@ -221,9 +225,9 @@ diff -ru /home/netbsd/src/include/sched.h ./sched.h #ifndef _SCHED_H_ #define _SCHED_H_ -diff -ru /home/netbsd/src/include/signal.h ./signal.h ---- /home/netbsd/src/include/signal.h 2010-08-28 03:00:54.000000000 +0000 -+++ ./signal.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/signal.h nbsd_include/signal.h +--- nbsdsrc/src/include/signal.h ++++ nbsd_include/signal.h @@ -62,6 +62,7 @@ int __libc_sigaction14(int, const struct sigaction * __restrict, struct sigaction * __restrict); @@ -287,9 +291,9 @@ diff -ru /home/netbsd/src/include/signal.h ./signal.h int sigblock(int); int sigsetmask(int); #endif /* _NETBSD_SOURCE */ -diff -ru /home/netbsd/src/include/stdio.h ./stdio.h ---- /home/netbsd/src/include/stdio.h 2010-09-25 03:01:11.000000000 +0000 -+++ ./stdio.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/stdio.h nbsd_include/stdio.h +--- nbsdsrc/src/include/stdio.h ++++ nbsd_include/stdio.h @@ -274,7 +274,7 @@ __printflike(2, 0); #endif @@ -299,9 +303,9 @@ diff -ru /home/netbsd/src/include/stdio.h ./stdio.h int rename (const char *, const char *) __RENAME(__posix_rename); #else int rename (const char *, const char *); -diff -ru /home/netbsd/src/include/stdlib.h ./stdlib.h ---- /home/netbsd/src/include/stdlib.h 2010-12-23 03:03:09.000000000 +0000 -+++ ./stdlib.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/stdlib.h nbsd_include/stdlib.h +--- nbsdsrc/src/include/stdlib.h ++++ nbsd_include/stdlib.h @@ -265,9 +265,11 @@ void csetexpandtc(int); @@ -324,9 +328,9 @@ diff -ru /home/netbsd/src/include/stdlib.h ./stdlib.h int getloadavg(double [], int); int getenv_r(const char *, char *, size_t); -diff -ru /home/netbsd/src/include/time.h ./time.h ---- /home/netbsd/src/include/time.h 2010-12-17 03:01:54.000000000 +0000 -+++ ./time.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/time.h nbsd_include/time.h +--- nbsdsrc/src/include/time.h ++++ nbsd_include/time.h @@ -65,12 +65,18 @@ #undef _BSD_CLOCKID_T_ #endif @@ -387,20 +391,20 @@ diff -ru /home/netbsd/src/include/time.h ./time.h #endif /* _POSIX_C_SOURCE >= 199309 || _XOPEN_SOURCE >= 500 || ... */ #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ -@@ -205,6 +221,10 @@ +@@ -204,6 +220,10 @@ + __attribute__((__format__(__strftime__, 4, 0))); #endif /* _NETBSD_SOURCE */ - ++ +#ifdef _MINIX +int stime(time_t *_top); +#endif /* _MINIX */ -+ + __END_DECLS - #endif /* !_TIME_H_ */ -diff -ru /home/netbsd/src/include/unistd.h ./unistd.h ---- /home/netbsd/src/include/unistd.h 2011-01-20 03:02:09.000000000 +0000 -+++ ./unistd.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/unistd.h nbsd_include/unistd.h +--- nbsdsrc/src/include/unistd.h ++++ nbsd_include/unistd.h @@ -88,7 +88,7 @@ int access(const char *, int); unsigned int alarm(unsigned int); @@ -548,9 +552,9 @@ diff -ru /home/netbsd/src/include/unistd.h ./unistd.h +#endif + #endif /* !_UNISTD_H_ */ -diff -ru /home/netbsd/src/include/utmp.h ./utmp.h ---- /home/netbsd/src/include/utmp.h 2009-01-11 03:05:43.000000000 +0000 -+++ ./utmp.h 2011-01-19 03:14:07.000000000 +0000 +diff -ru nbsdsrc/src/include/utmp.h nbsd_include/utmp.h +--- nbsdsrc/src/include/utmp.h ++++ nbsd_include/utmp.h @@ -39,12 +39,26 @@ #ifndef _UTMP_H_ #define _UTMP_H_ @@ -583,7 +587,7 @@ diff -ru /home/netbsd/src/include/utmp.h ./utmp.h }; +#ifdef __minix -+struct utmp { + struct utmp { + char ut_name[UT_NAMESIZE]; /* user name */ + char ut_id[4]; /* /etc/inittab ID */ + char ut_line[UT_LINESIZE]; /* terminal name */ @@ -603,7 +607,7 @@ diff -ru /home/netbsd/src/include/utmp.h ./utmp.h + +#else /* !__minix */ + - struct utmp { ++struct utmp { char ut_line[UT_LINESIZE]; char ut_name[UT_NAMESIZE]; char ut_host[UT_HOSTSIZE]; diff --git a/nbsd_include/sys/Makefile b/nbsd_include/sys/Makefile index 056ce2aac..278e843ac 100644 --- a/nbsd_include/sys/Makefile +++ b/nbsd_include/sys/Makefile @@ -11,8 +11,8 @@ INCS+= ioc_net.h statfs.h INCS+= ansi.h atomic.h \ bitops.h bswap.h \ - cdefs.h cdefs_aout.h ctype_bits.h ctype_inline.h \ - dir.h dirent.h \ + cdefs.h cdefs_aout.h cdefs_elf.h ctype_bits.h ctype_inline.h \ + dir.h dirent.h exec_elf.h \ endian.h errno.h \ fcntl.h fd_set.h featuretest.h file.h \ float_ieee754.h gcq.h gmon.h hash.h \ @@ -38,17 +38,17 @@ INCS+= ansi.h atomic.h \ wait.h INCSYMLINKS=\ - ${NETBSDINCSDIR}/sys/fcntl.h ${NETBSDINCSDIR}/fcntl.h \ - ${NETBSDINCSDIR}/sys/poll.h ${NETBSDINCSDIR}/poll.h \ - ${NETBSDINCSDIR}/sys/stdint.h ${NETBSDINCSDIR}/stdint.h \ - ${NETBSDINCSDIR}/sys/syslog.h ${NETBSDINCSDIR}/syslog.h \ - ${NETBSDINCSDIR}/sys/termios.h ${NETBSDINCSDIR}/termios.h \ - ${NETBSDINCSDIR}/sys/rmd160.h ${NETBSDINCSDIR}/rmd160.h \ - ${NETBSDINCSDIR}/sys/sha1.h ${NETBSDINCSDIR}/sha1.h \ - ${NETBSDINCSDIR}/sys/sha2.h ${NETBSDINCSDIR}/sha2.h \ - ${NETBSDINCSDIR}/sys/md4.h ${NETBSDINCSDIR}/md4.h \ - ${NETBSDINCSDIR}/sys/md5.h ${NETBSDINCSDIR}/md5.h -# sys/exec_elf.h /usr/include/elf.h \ + sys/fcntl.h ${NETBSDINCSDIR}/fcntl.h \ + sys/poll.h ${NETBSDINCSDIR}/poll.h \ + sys/stdint.h ${NETBSDINCSDIR}/stdint.h \ + sys/syslog.h ${NETBSDINCSDIR}/syslog.h \ + sys/termios.h ${NETBSDINCSDIR}/termios.h \ + sys/rmd160.h ${NETBSDINCSDIR}/rmd160.h \ + sys/sha1.h ${NETBSDINCSDIR}/sha1.h \ + sys/sha2.h ${NETBSDINCSDIR}/sha2.h \ + sys/md4.h ${NETBSDINCSDIR}/md4.h \ + sys/md5.h ${NETBSDINCSDIR}/md5.h \ + sys/exec_elf.h ${NETBSDINCSDIR}/elf.h \ #INCSYMLINKS+= ../soundcard.h ${INCSDIR}/soundcard.h diff --git a/nbsd_include/sys/cdefs_elf.h b/nbsd_include/sys/cdefs_elf.h new file mode 100644 index 000000000..e3e56a436 --- /dev/null +++ b/nbsd_include/sys/cdefs_elf.h @@ -0,0 +1,208 @@ +/* $NetBSD: cdefs_elf.h,v 1.34 2010/12/08 01:18:55 joerg Exp $ */ + +/* + * Copyright (c) 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#ifndef _SYS_CDEFS_ELF_H_ +#define _SYS_CDEFS_ELF_H_ + +#ifdef __LEADING_UNDERSCORE +#define _C_LABEL(x) __CONCAT(_,x) +#define _C_LABEL_STRING(x) "_"x +#else +#define _C_LABEL(x) x +#define _C_LABEL_STRING(x) x +#endif + +#if __STDC__ +#define ___RENAME(x) __asm(___STRING(_C_LABEL(x))) +#else +#ifdef __LEADING_UNDERSCORE +#define ___RENAME(x) ____RENAME(_/**/x) +#define ____RENAME(x) __asm(___STRING(x)) +#else +#define ___RENAME(x) __asm(___STRING(x)) +#endif +#endif + +#define __indr_reference(sym,alias) /* nada, since we do weak refs */ + +#if __STDC__ +#define __strong_alias(alias,sym) \ + __asm(".global " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); + +#define __weak_alias(alias,sym) \ + __asm(".weak " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); + +/* Do not use __weak_extern, use __weak_reference instead */ +#define __weak_extern(sym) \ + __asm(".weak " _C_LABEL_STRING(#sym)); + +#if __GNUC_PREREQ__(4, 0) && !defined(__minix) +#define __weak_reference(sym) __attribute__((__weakref__)) +#else +#define __weak_reference(sym) ; __asm(".weak " _C_LABEL_STRING(#sym)) +#endif + +#if defined(__clang__) +#define __warn_references(sym,msg) \ + static __attribute__((__used__, __section__(".gnu.warning." #sym))) \ + const char ___CONCAT(__warn_reference_##sym,__COUNTER__)[] = msg; +#else +#define __warn_references(sym,msg) \ + __asm(".pushsection .gnu.warning." #sym "\n" \ + ".ascii \"" msg "\"\n" \ + ".popsection"); +#endif + +#else /* !__STDC__ */ + +#ifdef __LEADING_UNDERSCORE +#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym) +#define ___weak_alias(alias,sym) \ + __asm(".weak alias\nalias = sym"); +#else +#define __weak_alias(alias,sym) \ + __asm(".weak alias\nalias = sym"); +#endif +#ifdef __LEADING_UNDERSCORE +#define __weak_extern(sym) ___weak_extern(_/**/sym) +#define ___weak_extern(sym) \ + __asm(".weak sym"); +#else +#define __weak_extern(sym) \ + __asm(".weak sym"); +#endif +#define __warn_references(sym,msg) \ + __asm(".pushsection .gnu.warning.sym\n" \ + ".ascii \"" msg "\"\n" \ + ".popsection"); + +#endif /* !__STDC__ */ + +#if defined(__clang__) +#define __SECTIONSTRING(_sec, _str) \ + static __attribute__((__used__, __section__(#_sec))) const char \ + ___CONCAT(__sectstr,__COUNTER__)[] = _str +#elif __STDC__ +#define __SECTIONSTRING(_sec, _str) \ + __asm(".pushsection " #_sec "\n" \ + ".asciz \"" _str "\"\n" \ + ".popsection") +#else +#define __SECTIONSTRING(_sec, _str) \ + __asm(".pushsection _sec\n" \ + ".asciz \"" _str "\"\n" \ + ".popsection") +#endif + +#define __IDSTRING(_n,_s) __SECTIONSTRING(.ident,_s) + +#define __RCSID(_s) __IDSTRING(rcsid,_s) +#define __SCCSID(_s) +#define __SCCSID2(_s) +#define __COPYRIGHT(_s) __SECTIONSTRING(.copyright,_s) + +#define __KERNEL_RCSID(_n, _s) __RCSID(_s) +#define __KERNEL_SCCSID(_n, _s) +#define __KERNEL_COPYRIGHT(_n, _s) __COPYRIGHT(_s) + +#ifndef __lint__ +#define __link_set_make_entry(set, sym) \ + static void const * const __link_set_##set##_sym_##sym \ + __section("link_set_" #set) __used = &sym +#define __link_set_make_entry2(set, sym, n) \ + static void const * const __link_set_##set##_sym_##sym##_##n \ + __section("link_set_" #set) __used = &sym[n] +#else +#define __link_set_make_entry(set, sym) \ + extern void const * const __link_set_##set##_sym_##sym +#define __link_set_make_entry2(set, sym, n) \ + extern void const * const __link_set_##set##_sym_##sym##_##n +#endif /* __lint__ */ + +#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_text2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n) + +#define __link_set_decl(set, ptype) \ + extern ptype * const __start_link_set_##set[]; \ + extern ptype * const __stop_link_set_##set[] \ + +#define __link_set_start(set) (__start_link_set_##set) +#define __link_set_end(set) (__stop_link_set_##set) + +#define __link_set_count(set) \ + (__link_set_end(set) - __link_set_start(set)) + + +#ifdef _KERNEL + +/* + * On multiprocessor systems we can gain an improvement in performance + * by being mindful of which cachelines data is placed in. + * + * __read_mostly: + * + * It makes sense to ensure that rarely modified data is not + * placed in the same cacheline as frequently modified data. + * To mitigate the phenomenon known as "false-sharing" we + * can annotate rarely modified variables with __read_mostly. + * All such variables are placed into the .data.read_mostly + * section in the kernel ELF. + * + * Prime candidates for __read_mostly annotation are variables + * which are hardly ever modified and which are used in code + * hot-paths, e.g. pmap_initialized. + * + * __cacheline_aligned: + * + * Some data structures (mainly locks) benefit from being aligned + * on a cacheline boundary, and having a cacheline to themselves. + * This way, the modification of other data items cannot adversely + * affect the lock and vice versa. + * + * Any variables annotated with __cacheline_aligned will be + * placed into the .data.cacheline_aligned ELF section. + */ +#define __read_mostly \ + __attribute__((__section__(".data.read_mostly"))) + +#define __cacheline_aligned \ + __attribute__((__aligned__(COHERENCY_UNIT) \ + __section__(".data.cacheline_aligned"))) + +#endif /* _KERNEL */ + +#endif /* !_SYS_CDEFS_ELF_H_ */ diff --git a/nbsd_include/sys/exec_elf.h b/nbsd_include/sys/exec_elf.h new file mode 100644 index 000000000..e7815a74d --- /dev/null +++ b/nbsd_include/sys/exec_elf.h @@ -0,0 +1,1090 @@ +/* $NetBSD: exec_elf.h,v 1.108 2010/12/24 12:41:43 skrll Exp $ */ + +/*- + * Copyright (c) 1994 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_EXEC_ELF_H_ +#define _SYS_EXEC_ELF_H_ + +/* + * The current ELF ABI specification is available at: + * http://www.sco.com/developers/gabi/ + * + * Current header definitions are in: + * http://www.sco.com/developers/gabi/latest/ch4.eheader.html + */ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#endif /* _KERNEL || _STANDALONE */ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif + +typedef uint8_t Elf_Byte; + +typedef uint32_t Elf32_Addr; +#define ELF32_FSZ_ADDR 4 +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_SOff; +#define ELF32_FSZ_OFF 4 +typedef int32_t Elf32_Sword; +#define ELF32_FSZ_SWORD 4 +typedef uint32_t Elf32_Word; +#define ELF32_FSZ_WORD 4 +typedef uint16_t Elf32_Half; +#define ELF32_FSZ_HALF 2 +typedef uint64_t Elf32_Lword; +#define ELF32_FSZ_LWORD 8 + +typedef uint64_t Elf64_Addr; +#define ELF64_FSZ_ADDR 8 +typedef uint64_t Elf64_Off; +typedef int64_t Elf64_SOff; +#define ELF64_FSZ_OFF 8 +typedef int32_t Elf64_Shalf; +#define ELF64_FSZ_SHALF 4 + +typedef int32_t Elf64_Sword; +#define ELF64_FSZ_SWORD 4 +typedef uint32_t Elf64_Word; +#define ELF64_FSZ_WORD 4 + +typedef int64_t Elf64_Sxword; +#define ELF64_FSZ_SXWORD 8 +typedef uint64_t Elf64_Xword; +#define ELF64_FSZ_XWORD 8 +typedef uint64_t Elf64_Lword; +#define ELF64_FSZ_LWORD 8 +typedef uint16_t Elf64_Half; +#define ELF64_FSZ_HALF 2 + +/* + * ELF Header + */ +#define ELF_NIDENT 16 + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf32_Half e_type; /* file type */ + Elf32_Half e_machine; /* machine type */ + Elf32_Word e_version; /* version number */ + Elf32_Addr e_entry; /* entry point */ + Elf32_Off e_phoff; /* Program hdr offset */ + Elf32_Off e_shoff; /* Section hdr offset */ + Elf32_Word e_flags; /* Processor flags */ + Elf32_Half e_ehsize; /* sizeof ehdr */ + Elf32_Half e_phentsize; /* Program header entry size */ + Elf32_Half e_phnum; /* Number of program headers */ + Elf32_Half e_shentsize; /* Section header entry size */ + Elf32_Half e_shnum; /* Number of section headers */ + Elf32_Half e_shstrndx; /* String table index */ +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf64_Half e_type; /* file type */ + Elf64_Half e_machine; /* machine type */ + Elf64_Word e_version; /* version number */ + Elf64_Addr e_entry; /* entry point */ + Elf64_Off e_phoff; /* Program hdr offset */ + Elf64_Off e_shoff; /* Section hdr offset */ + Elf64_Word e_flags; /* Processor flags */ + Elf64_Half e_ehsize; /* sizeof ehdr */ + Elf64_Half e_phentsize; /* Program header entry size */ + Elf64_Half e_phnum; /* Number of program headers */ + Elf64_Half e_shentsize; /* Section header entry size */ + Elf64_Half e_shnum; /* Number of section headers */ + Elf64_Half e_shstrndx; /* String table index */ +} Elf64_Ehdr; + +/* e_ident offsets */ +#define EI_MAG0 0 /* '\177' */ +#define EI_MAG1 1 /* 'E' */ +#define EI_MAG2 2 /* 'L' */ +#define EI_MAG3 3 /* 'F' */ +#define EI_CLASS 4 /* File class */ +#define EI_DATA 5 /* Data encoding */ +#define EI_VERSION 6 /* File version */ +#define EI_OSABI 7 /* Operating system/ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ +#define EI_NIDENT 16 /* First non-ident header byte */ + +/* e_ident[EI_MAG0,EI_MAG3] */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +/* e_ident[EI_CLASS] */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +/* e_ident[EI_DATA] */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement values, LSB first */ +#define ELFDATA2MSB 2 /* 2's complement values, MSB first */ + +/* e_ident[EI_VERSION] */ +#define EV_NONE 0 /* Invalid version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* e_ident[EI_OSABI] */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_LINUX 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_86OPEN 5 /* 86Open */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_MONTEREY 7 /* Monterey */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* OpenVMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +/* Unofficial OSABIs follow */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define ELFOSABI_NONE ELFOSABI_SYSV +#define ELFOSABI_AIX ELFOSABI_MONTEREY + +/* e_type */ +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 + +#define ET_LOOS 0xfe00 /* Operating system specific range */ +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 /* Processor-specific range */ +#define ET_HIPROC 0xffff + +/* e_machine */ +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS I Architecture */ +#define EM_S370 9 /* Amdahl UTS on System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ + /* 11-14 - Reserved */ +#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ +#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ +#define EM_NCUBE 16 /* NCube XXX reserved */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* 64-bit PowerPC */ + /* 22-35 - Reserved */ +#define EM_S390 22 /* System/390 XXX reserved */ +#define EM_V800 36 /* NEC V800 */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* Advanced RISC Machines ARM */ +#define EM_ALPHA 41 /* DIGITAL Alpha */ +#define EM_SH 42 /* Hitachi Super-H */ +#define EM_SPARCV9 43 /* SPARC Version 9 */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced Processor */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola MC68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Star*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ +#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */ +#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */ +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ +#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ +#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ +#define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard's machine-independent format */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */ +#define EM_NS32K 97 /* National Semiconductor 32000 series */ +#define EM_TPC 98 /* Tenor Network TPC processor */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor */ +#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller */ +#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ +#define EM_MAX 102 /* MAX processor */ +#define EM_CR 103 /* National Semiconductor CompactRISC micorprocessor */ +#define EM_F2MC16 104 /* Fujitsu F2MC16 */ +#define EM_MSP430 105 /* Texas Instruments MSP430 */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ +#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ +#define EM_SEP 108 /* Sharp embedded microprocessor */ +#define EM_ARCA 109 /* Arca RISC microprocessor */ +#define EM_UNICORE 110 /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */ + +/* Unofficial machine types follow */ +#define EM_AVR32 6317 /* used by NetBSD/avr32 */ +#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ +#define EM_NUM 36903 + +/* + * Program Header + */ +typedef struct { + Elf32_Word p_type; /* entry type */ + Elf32_Off p_offset; /* offset */ + Elf32_Addr p_vaddr; /* virtual address */ + Elf32_Addr p_paddr; /* physical address */ + Elf32_Word p_filesz; /* file size */ + Elf32_Word p_memsz; /* memory size */ + Elf32_Word p_flags; /* flags */ + Elf32_Word p_align; /* memory & file alignment */ +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; /* entry type */ + Elf64_Word p_flags; /* flags */ + Elf64_Off p_offset; /* offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory & file alignment */ +} Elf64_Phdr; + +/* p_type */ +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved, unspecified semantics */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_TLS 7 /* TLS initialisation image */ +#define PT_NUM 8 + +#define PT_LOOS 0x60000000 /* OS-specific range */ +#define PT_GNU_EH_FRAME 0x6474e550 /* GNU-specific EH frame segment */ +#define PT_HIOS 0x6fffffff +#define PT_LOPROC 0x70000000 /* Processor-specific range */ +#define PT_HIPROC 0x7fffffff + +#define PT_MIPS_REGINFO 0x70000000 + +/* p_flags */ +#define PF_R 0x4 /* Segment is readable */ +#define PF_W 0x2 /* Segment is writable */ +#define PF_X 0x1 /* Segment is executable */ + +#define PF_MASKOS 0x0ff00000 /* Operating system specific values */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ + +/* Extended program header index. */ +#define PN_XNUM 0xffff + +/* + * Section Headers + */ +typedef struct { + Elf32_Word sh_name; /* section name (.shstrtab index) */ + Elf32_Word sh_type; /* section type */ + Elf32_Word sh_flags; /* section flags */ + Elf32_Addr sh_addr; /* virtual address */ + Elf32_Off sh_offset; /* file offset */ + Elf32_Word sh_size; /* section size */ + Elf32_Word sh_link; /* link to another */ + Elf32_Word sh_info; /* misc info */ + Elf32_Word sh_addralign; /* memory alignment */ + Elf32_Word sh_entsize; /* table entry size */ +} Elf32_Shdr; + +typedef struct { + Elf64_Word sh_name; /* section name (.shstrtab index) */ + Elf64_Word sh_type; /* section type */ + Elf64_Xword sh_flags; /* section flags */ + Elf64_Addr sh_addr; /* virtual address */ + Elf64_Off sh_offset; /* file offset */ + Elf64_Xword sh_size; /* section size */ + Elf64_Word sh_link; /* link to another */ + Elf64_Word sh_info; /* misc info */ + Elf64_Xword sh_addralign; /* memory alignment */ + Elf64_Xword sh_entsize; /* table entry size */ +} Elf64_Shdr; + +/* sh_type */ +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program information */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation information w/ addend */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Auxiliary information */ +#define SHT_NOBITS 8 /* No space allocated in file image */ +#define SHT_REL 9 /* Relocation information w/o addend */ +#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ +#define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX) */ +#define SHT_NUM 19 + +#define SHT_LOOS 0x60000000 /* Operating system specific range */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ +#define SHT_GNU_verdef SHT_SUNW_verdef +#define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ +#define SHT_GNU_verneed SHT_SUNW_verneed +#define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ +#define SHT_GNU_versym SHT_SUNW_versym +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 /* Processor-specific range */ +#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 /* Application-specific range */ +#define SHT_HIUSER 0xffffffff + +/* sh_flags */ +#define SHF_WRITE 0x1 /* Section contains writable data */ +#define SHF_ALLOC 0x2 /* Section occupies memory */ +#define SHF_EXECINSTR 0x4 /* Section contains executable insns */ + +#define SHF_MASKOS 0x0f000000 /* Operating system specific values */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ + +/* + * Symbol Table + */ +typedef struct { + Elf32_Word st_name; /* Symbol name (.strtab index) */ + Elf32_Word st_value; /* value of symbol */ + Elf32_Word st_size; /* size of symbol */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf32_Half st_shndx; /* section index of symbol */ +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; /* Symbol name (.strtab index) */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf64_Half st_shndx; /* section index of symbol */ + Elf64_Addr st_value; /* value of symbol */ + Elf64_Xword st_size; /* size of symbol */ +} Elf64_Sym; + +/* Symbol Table index of the undefined symbol */ +#define ELF_SYM_UNDEFINED 0 + +#define STN_UNDEF 0 /* undefined index */ + +/* st_info: Symbol Bindings */ +#define STB_LOCAL 0 /* local symbol */ +#define STB_GLOBAL 1 /* global symbol */ +#define STB_WEAK 2 /* weakly defined global symbol */ +#define STB_NUM 3 + +#define STB_LOOS 10 /* Operating system specific range */ +#define STB_HIOS 12 +#define STB_LOPROC 13 /* Processor-specific range */ +#define STB_HIPROC 15 + +/* st_info: Symbol Types */ +#define STT_NOTYPE 0 /* Type not specified */ +#define STT_OBJECT 1 /* Associated with a data object */ +#define STT_FUNC 2 /* Associated with a function */ +#define STT_SECTION 3 /* Associated with a section */ +#define STT_FILE 4 /* Associated with a file name */ +#define STT_COMMON 5 /* Uninitialised common block */ +#define STT_TLS 6 /* Thread local data object */ +#define STT_NUM 7 + +#define STT_LOOS 10 /* Operating system specific range */ +#define STT_HIOS 12 +#define STT_LOPROC 13 /* Processor-specific range */ +#define STT_HIPROC 15 + +/* st_other: Visibility Types */ +#define STV_DEFAULT 0 /* use binding type */ +#define STV_INTERNAL 1 /* not referenced from outside */ +#define STV_HIDDEN 2 /* not visible, may be used via ptr */ +#define STV_PROTECTED 3 /* visible, not preemptible */ +#define STV_EXPORTED 4 +#define STV_SINGLETON 5 +#define STV_ELIMINATE 6 + +/* st_info/st_other utility macros */ +#define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) +#define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) +#define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ + ((type) & 0xf))) +#define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) + +/* + * Special section indexes + */ +#define SHN_UNDEF 0 /* Undefined section */ + +#define SHN_LORESERVE 0xff00 /* Reserved range */ +#define SHN_ABS 0xfff1 /* Absolute symbols */ +#define SHN_COMMON 0xfff2 /* Common symbols */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere */ +#define SHN_HIRESERVE 0xffff + +#define SHN_LOPROC 0xff00 /* Processor-specific range */ +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 /* Operating system specific range */ +#define SHN_HIOS 0xff3f + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 + +/* + * Relocation Entries + */ +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ +} Elf32_Rel; + +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ + Elf32_Sword r_addend; /* adjustment value */ +} Elf32_Rela; + +/* r_info utility macros */ +#define ELF32_R_SYM(info) ((info) >> 8) +#define ELF32_R_TYPE(info) ((info) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ +} Elf64_Rel; + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ + Elf64_Sxword r_addend; /* adjustment value */ +} Elf64_Rela; + +/* r_info utility macros */ +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xffffffff) +#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) + +/* + * Move entries + */ +typedef struct { + Elf32_Lword m_value; /* symbol value */ + Elf32_Word m_info; /* size + index */ + Elf32_Word m_poffset; /* symbol offset */ + Elf32_Half m_repeat; /* repeat count */ + Elf32_Half m_stride; /* stride info */ +} Elf32_Move; + +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) (info) & 0xff) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +typedef struct { + Elf64_Lword m_value; /* symbol value */ + Elf64_Xword m_info; /* size + index */ + Elf64_Xword m_poffset; /* symbol offset */ + Elf64_Word m_repeat; /* repeat count */ + Elf64_Word m_stride; /* stride info */ +} Elf64_Move; + +#define ELF64_M_SYM(info) ((info) >> 8) +#define ELF64_M_SIZE(info) (info) & 0xff) +#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +/* + * Hardware/software capabilities entry + */ +typedef struct { + Elf32_Word c_tag; /* entry tag value */ + union { + Elf32_Addr c_ptr; + Elf32_Word c_val; + } c_un; +} Elf32_Cap; + +typedef struct { + Elf64_Xword c_tag; /* entry tag value */ + union { + Elf64_Addr c_ptr; + Elf64_Xword c_val; + } c_un; +} Elf64_Cap; + +/* + * Dynamic Section structure array + */ +typedef struct { + Elf32_Word d_tag; /* entry tag value */ + union { + Elf32_Addr d_ptr; + Elf32_Word d_val; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Xword d_tag; /* entry tag value */ + union { + Elf64_Addr d_ptr; + Elf64_Xword d_val; + } d_un; +} Elf64_Dyn; + +/* d_tag */ +#define DT_NULL 0 /* Marks end of dynamic array */ +#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ +#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ +#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocation table */ +#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ +#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ +#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ +#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ +#define DT_INIT 12 /* Address of initialization function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ +#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ +#define DT_SYMBOLIC 16 /* Start symbol search within local object */ +#define DT_REL 17 /* Address of Rel relocation table */ +#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ +#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ +#define DT_PLTREL 20 /* Type of PLT relocation entries */ +#define DT_DEBUG 21 /* Used for debugging; unspecified */ +#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ +#define DT_JMPREL 23 /* Address of relocations associated with PLT */ +#define DT_BIND_NOW 24 /* Process all relocations at load-time */ +#define DT_INIT_ARRAY 25 /* Address of initialization function array */ +#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ +#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ +#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ +#define DT_NUM 29 + +#define DT_LOOS 0x60000000 /* Operating system specific range */ +#define DT_VERSYM 0x6ffffff0 /* Symbol versions */ +#define DT_FLAGS_1 0x6ffffffb /* ELF dynamic flags */ +#define DT_VERDEF 0x6ffffffc /* Versions defined by file */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of versions defined by file */ +#define DT_VERNEED 0x6ffffffe /* Versions needed by file */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of versions needed by file */ +#define DT_HIOS 0x6fffffff +#define DT_LOPROC 0x70000000 /* Processor-specific range */ +#define DT_HIPROC 0x7fffffff + +/* Flag values for DT_FLAGS_1 (incomplete) */ +#define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ +#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ +#define DF_1_INITFIRST 0x00000020 /* Object's init/fini take priority */ +#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ + +/* + * Auxiliary Vectors + */ +typedef struct { + Elf32_Word a_type; /* 32-bit id */ + Elf32_Word a_v; /* 32-bit id */ +} Aux32Info; + +typedef struct { + Elf64_Word a_type; /* 32-bit id */ + Elf64_Xword a_v; /* 64-bit id */ +} Aux64Info; + +/* a_type */ +#define AT_NULL 0 /* Marks end of array */ +#define AT_IGNORE 1 /* No meaning, a_un is undefined */ +#define AT_EXECFD 2 /* Open file descriptor of object file */ +#define AT_PHDR 3 /* &phdr[0] */ +#define AT_PHENT 4 /* sizeof(phdr[0]) */ +#define AT_PHNUM 5 /* # phdr entries */ +#define AT_PAGESZ 6 /* PAGESIZE */ +#define AT_BASE 7 /* Interpreter base addr */ +#define AT_FLAGS 8 /* Processor flags */ +#define AT_ENTRY 9 /* Entry address of executable */ +#define AT_DCACHEBSIZE 10 /* Data cache block size */ +#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ +#define AT_UCACHEBSIZE 12 /* Unified cache block size */ + + /* Vendor specific */ +#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ + +#define AT_EUID 2000 /* euid (solaris compatible numbers) */ +#define AT_RUID 2001 /* ruid (solaris compatible numbers) */ +#define AT_EGID 2002 /* egid (solaris compatible numbers) */ +#define AT_RGID 2003 /* rgid (solaris compatible numbers) */ + + /* Solaris kernel specific */ +#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ +#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ +#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ +#define AT_SUN_LPGSIZE 2007 /* large pagesize */ + + /* Other information */ +#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ +#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ +#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ +#define AT_SUN_CPU 2011 /* CPU name */ + /* ibcs2 emulation band aid */ +#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ +#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ + /* Executable's fully resolved name */ +#define AT_SUN_EXECNAME 2014 + +/* + * Note Headers + */ +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} Elf64_Nhdr; + +#define ELF_NOTE_TYPE_ABI_TAG 1 + +/* GNU-specific note name and description sizes */ +#define ELF_NOTE_ABI_NAMESZ 4 +#define ELF_NOTE_ABI_DESCSZ 16 +/* GNU-specific note name */ +#define ELF_NOTE_ABI_NAME "GNU\0" + +/* GNU-specific OS/version value stuff */ +#define ELF_NOTE_ABI_OS_LINUX 0 +#define ELF_NOTE_ABI_OS_HURD 1 +#define ELF_NOTE_ABI_OS_SOLARIS 2 + +/* NetBSD-specific note type: Emulation name. desc is emul name string. */ +#define ELF_NOTE_TYPE_NETBSD_TAG 1 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_NETBSD_NAMESZ 7 +#define ELF_NOTE_NETBSD_DESCSZ 4 +/* NetBSD-specific note name */ +#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" + +/* NetBSD-specific note type: Checksum. There should be 1 NOTE per PT_LOAD + section. desc is a tuple of (16),(16),. */ +#define ELF_NOTE_TYPE_CHECKSUM_TAG 2 +#define ELF_NOTE_CHECKSUM_CRC32 1 +#define ELF_NOTE_CHECKSUM_MD5 2 +#define ELF_NOTE_CHECKSUM_SHA1 3 +#define ELF_NOTE_CHECKSUM_SHA256 4 + +/* NetBSD-specific note type: PaX. There should be 1 NOTE per executable. + section. desc is a 32 bit bitmask */ +#define ELF_NOTE_TYPE_PAX_TAG 3 +#define ELF_NOTE_PAX_MPROTECT 0x01 /* Force enable Mprotect */ +#define ELF_NOTE_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ +#define ELF_NOTE_PAX_GUARD 0x04 /* Force enable Segvguard */ +#define ELF_NOTE_PAX_NOGUARD 0x08 /* Force disable Servguard */ +#define ELF_NOTE_PAX_ASLR 0x10 /* Force enable ASLR */ +#define ELF_NOTE_PAX_NOASLR 0x20 /* Force disable ASLR */ +#define ELF_NOTE_PAX_NAMESZ 4 +#define ELF_NOTE_PAX_NAME "PaX\0" +#define ELF_NOTE_PAX_DESCSZ 4 + +/* + * NetBSD-specific core file information. + * + * NetBSD ELF core files use notes to provide information about + * the process's state. The note name is "NetBSD-CORE" for + * information that is global to the process, and "NetBSD-CORE@nn", + * where "nn" is the lwpid of the LWP that the information belongs + * to (such as register state). + * + * We use the following note identifiers: + * + * ELF_NOTE_NETBSD_CORE_PROCINFO + * Note is a "netbsd_elfcore_procinfo" structure. + * + * We also use ptrace(2) request numbers (the ones that exist in + * machine-dependent space) to identify register info notes. The + * info in such notes is in the same format that ptrace(2) would + * export that information. + * + * Please try to keep the members of this structure nicely aligned, + * and if you add elements, add them to the end and bump the version. + */ + +#define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" + +#define ELF_NOTE_NETBSD_CORE_PROCINFO 1 + +#define NETBSD_ELFCORE_PROCINFO_VERSION 1 + +struct netbsd_elfcore_procinfo { + /* Version 1 fields start here. */ + uint32_t cpi_version; /* netbsd_elfcore_procinfo version */ + uint32_t cpi_cpisize; /* sizeof(netbsd_elfcore_procinfo) */ + uint32_t cpi_signo; /* killing signal */ + uint32_t cpi_sigcode; /* signal code */ + uint32_t cpi_sigpend[4]; /* pending signals */ + uint32_t cpi_sigmask[4]; /* blocked signals */ + uint32_t cpi_sigignore[4];/* blocked signals */ + uint32_t cpi_sigcatch[4];/* blocked signals */ + int32_t cpi_pid; /* process ID */ + int32_t cpi_ppid; /* parent process ID */ + int32_t cpi_pgrp; /* process group ID */ + int32_t cpi_sid; /* session ID */ + uint32_t cpi_ruid; /* real user ID */ + uint32_t cpi_euid; /* effective user ID */ + uint32_t cpi_svuid; /* saved user ID */ + uint32_t cpi_rgid; /* real group ID */ + uint32_t cpi_egid; /* effective group ID */ + uint32_t cpi_svgid; /* saved group ID */ + uint32_t cpi_nlwps; /* number of LWPs */ + int8_t cpi_name[32]; /* copy of p->p_comm */ + /* Add version 2 fields below here. */ + int32_t cpi_siglwp; /* LWP target of killing signal */ +}; + +#if !defined(ELFSIZE) && defined(ARCH_ELFSIZE) +#define ELFSIZE ARCH_ELFSIZE +#endif + +#if defined(ELFSIZE) +#define CONCAT(x,y) __CONCAT(x,y) +#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) +#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) +#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) +#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 32) +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Phdr Elf32_Phdr +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Rel Elf32_Rel +#define Elf_Rela Elf32_Rela +#define Elf_Dyn Elf32_Dyn +#define Elf_Word Elf32_Word +#define Elf_Sword Elf32_Sword +#define Elf_Half Elf32_Half +#define Elf_Addr Elf32_Addr +#define Elf_Off Elf32_Off +#define Elf_SOff Elf32_SOff +#define Elf_Nhdr Elf32_Nhdr + +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE ELF32_R_TYPE +#define ELFCLASS ELFCLASS32 + +#define AuxInfo Aux32Info +#elif defined(ELFSIZE) && (ELFSIZE == 64) +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Phdr Elf64_Phdr +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Rel Elf64_Rel +#define Elf_Rela Elf64_Rela +#define Elf_Dyn Elf64_Dyn +#define Elf_Word Elf64_Word +#define Elf_Sword Elf64_Sword +#define Elf_Half Elf64_Half +#define Elf_Addr Elf64_Addr +#define Elf_Off Elf64_Off +#define Elf_SOff Elf64_SOff +#define Elf_Nhdr Elf64_Nhdr + +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE ELF64_R_TYPE +#define ELFCLASS ELFCLASS64 + +#define AuxInfo Aux64Info +#endif + +#ifndef Elf_Symindx +#define Elf_Symindx uint32_t +#endif + +#define ELF32_ST_BIND(info) ELF_ST_BIND(info) +#define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +#define ELF64_ST_BIND(info) ELF_ST_BIND(info) +#define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +typedef struct { + Elf32_Half si_boundto; /* direct bindings - symbol bound to */ + Elf32_Half si_flags; /* per symbol flags */ +} Elf32_Syminfo; + +typedef struct { + Elf64_Word si_boundto; /* direct bindings - symbol bound to */ + Elf64_Word si_flags; /* per symbol flags */ +} Elf64_Syminfo; + +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association + to object containing definition */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be + lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to + object containing definition */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference + directly bind to this symbol */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ + +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +/* + * These constants are used for Elf32_Verdef struct's version number. + */ +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 + +/* + * These constants are used for Elf32_Verdef struct's vd_flags. + */ +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + +/* + * These are used in an Elf32_Versym field. + */ +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 + +/* + * These constants are used for Elf32_Verneed struct's version number. + */ +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 + +/* + * GNU Extension hidding symb + */ +#define VERSYM_HIDDEN 0x8000 +#define VERSYM_VERSION 0x7fff + +#define ELF_VER_CHR '@' + +/* + * These are current size independent. + */ + +typedef struct { + Elf32_Half vd_version; /* version number of structure */ + Elf32_Half vd_flags; /* flags (VER_FLG_*) */ + Elf32_Half vd_ndx; /* version index */ + Elf32_Half vd_cnt; /* number of verdaux entries */ + Elf32_Word vd_hash; /* hash of name */ + Elf32_Word vd_aux; /* offset to verdaux entries */ + Elf32_Word vd_next; /* offset to next verdef */ +} Elf32_Verdef; +typedef Elf32_Verdef Elf64_Verdef; + +typedef struct { + Elf32_Word vda_name; /* string table offset of name */ + Elf32_Word vda_next; /* offset to verdaux */ +} Elf32_Verdaux; +typedef Elf32_Verdaux Elf64_Verdaux; + +typedef struct { + Elf32_Half vn_version; /* version number of structure */ + Elf32_Half vn_cnt; /* number of vernaux entries */ + Elf32_Word vn_file; /* string table offset of library name*/ + Elf32_Word vn_aux; /* offset to vernaux entries */ + Elf32_Word vn_next; /* offset to next verneed */ +} Elf32_Verneed; +typedef Elf32_Verneed Elf64_Verneed; + +typedef struct { + Elf32_Word vna_hash; /* Hash of dependency name */ + Elf32_Half vna_flags; /* flags (VER_FLG_*) */ + Elf32_Half vna_other; /* unused */ + Elf32_Word vna_name; /* string table offset to version name*/ + Elf32_Word vna_next; /* offset to next vernaux */ +} Elf32_Vernaux; +typedef Elf32_Vernaux Elf64_Vernaux; + +typedef struct { + Elf32_Half vs_vers; +} Elf32_Versym; +typedef Elf32_Versym Elf64_Versym; + +#ifdef _KERNEL + +#define ELF_AUX_ENTRIES 14 /* Max size of aux array passed to loader */ +#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */ +#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */ + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_NO_ADDR ELF64_NO_ADDR +#define ELF_LINK_ADDR ELF64_LINK_ADDR +#elif defined(ELFSIZE) && (ELFSIZE == 32) +#define ELF_NO_ADDR ELF32_NO_ADDR +#define ELF_LINK_ADDR ELF32_LINK_ADDR +#endif + +#ifndef ELF32_EHDR_FLAGS_OK +#define ELF32_EHDR_FLAGS_OK(eh) 1 +#endif + +#ifndef ELF64_EHDR_FLAGS_OK +#define ELF64_EHDR_FLAGS_OK(eh) 1 +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh) +#else +#define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh) +#endif + +#if defined(ELFSIZE) +struct elf_args { + Elf_Addr arg_entry; /* program entry point */ + Elf_Addr arg_interp; /* Interpreter load address */ + Elf_Addr arg_phaddr; /* program header address */ + Elf_Addr arg_phentsize; /* Size of program header */ + Elf_Addr arg_phnum; /* Number of program headers */ +}; +#endif + +#ifdef _KERNEL_OPT +#include "opt_execfmt.h" +#endif + +#ifdef EXEC_ELF32 +int exec_elf32_makecmds(struct lwp *, struct exec_package *); +int elf32_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int coredump_elf32(struct lwp *, void *); +int coredump_writenote_elf32(struct proc *, void *, Elf32_Nhdr *, + const char *, void *); + +int elf32_check_header(Elf32_Ehdr *, int); +#endif + +#ifdef EXEC_ELF64 +int exec_elf64_makecmds(struct lwp *, struct exec_package *); +int elf64_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int coredump_elf64(struct lwp *, void *); +int coredump_writenote_elf64(struct proc *, void *, Elf64_Nhdr *, + const char *, void *); + +int elf64_check_header(Elf64_Ehdr *, int); +#endif + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_ELF_H_ */ diff --git a/servers/Makefile.inc b/servers/Makefile.inc index 7d3ec0536..2e67ce5b0 100644 --- a/servers/Makefile.inc +++ b/servers/Makefile.inc @@ -1,2 +1,8 @@ +.if (${NBSD_LIBC} != "no") +CPPFLAGS+= -D_MINIX -D_NETBSD_SOURCE +LDADD+= -lminlib -lcompat_minix +DPADD+= ${LIBMINLIB} ${LIBCOMPAT_MINIX} +.else CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE +.endif BINDIR?=/usr/sbin diff --git a/servers/inet/generic/rand256.c b/servers/inet/generic/rand256.c index 0a2cad23a..6d9931fe7 100644 --- a/servers/inet/generic/rand256.c +++ b/servers/inet/generic/rand256.c @@ -6,7 +6,11 @@ Created: Oct 2000 by Philip Homburg Generate 256-bit random numbers */ +#ifdef __NBSD_LIBC +#include +#else #include +#endif #include "inet.h" #include "rand256.h" diff --git a/servers/inet/inet.h b/servers/inet/inet.h index 6c4c9092d..a478417b5 100644 --- a/servers/inet/inet.h +++ b/servers/inet/inet.h @@ -53,7 +53,11 @@ typedef int ioreq_t; #include #include +#ifdef __NBSD_LIBC +#include +#else #include +#endif #include "const.h" #include "inet_config.h" diff --git a/servers/inet/inet_config.h b/servers/inet/inet_config.h index 743ab9a58..25326e369 100644 --- a/servers/inet/inet_config.h +++ b/servers/inet/inet_config.h @@ -79,12 +79,23 @@ extern struct ip_conf ip_conf[IP_PORT_MAX]; extern struct tcp_conf tcp_conf[IP_PORT_MAX]; extern struct udp_conf udp_conf[IP_PORT_MAX]; void read_conf(void); +#ifdef __NBSD_LIBC +extern void *sbrk(int); +#else extern char *sbrk(int); +#endif void *alloc(size_t size); /* Options */ extern int ip_forward_directed_bcast; +#ifdef __NBSD_LIBC +#undef HTONL +#undef HTONS +#define HTONL htonl +#define HTONS htons +#endif + #endif /* INET__INET_CONFIG_H */ /* diff --git a/servers/init/Makefile b/servers/init/Makefile index 823b16fc6..66cee87c3 100644 --- a/servers/init/Makefile +++ b/servers/init/Makefile @@ -2,9 +2,6 @@ PROG= init SRCS= init.c -DPADD+= ${LIBSYS} -LDADD+= -lsys - MAN= BINDIR?= /usr/sbin diff --git a/servers/init/init.c b/servers/init/init.c index 6a5654efd..2fe6787a0 100644 --- a/servers/init/init.c +++ b/servers/init/init.c @@ -29,11 +29,16 @@ #include #include +#ifdef __NBSD_LIBC +/* Different ttyent structure. */ +struct ttyent TT_REBOOT = { "console", "shutdown -d now CTRL-ALT_DEL", "-"}; +#else /* Command to execute as a response to the three finger salute. */ char *REBOOT_CMD[] = { "shutdown", "-d", "now", "CTRL-ALT-DEL", NULL }; /* Associated fake ttytab entry. */ struct ttyent TT_REBOOT = { "console", "-", REBOOT_CMD, NULL }; +#endif char PATH_UTMP[] = "/etc/utmp"; /* current logins */ char PATH_WTMP[] = "/usr/adm/wtmp"; /* login/logout history */ @@ -59,6 +64,9 @@ void report(int fd, char *label); void wtmp(int type, int linenr, char *line, pid_t pid); void startup(int linenr, struct ttyent *ttyp); int execute(char **cmd); +#ifdef __NBSD_LIBC +char **construct_argv(char *cmd); +#endif void onhup(int sig); void onterm(int sig); void onabrt(int sig); @@ -183,7 +191,13 @@ int main(void) if ((ttyp = getttyent()) == NULL) break; if (ttyp->ty_getty != NULL +#ifdef __NBSD_LIBC + /* ty_getty is a string, and TTY_ON is + * the way to check for enabled ternimanls. */ + && (ttyp->ty_status & TTY_ON) +#else && ttyp->ty_getty[0] != NULL +#endif && slotp->pid == NO_PID && slotp->errct < ERRCT_DISABLE) { @@ -224,6 +238,9 @@ void startup(int linenr, struct ttyent *ttyp) int err[2]; /* error reporting pipe */ char line[32]; /* tty device name */ int status; +#ifdef __NBSD_LIBC + char **ty_getty_argv; +#endif slotp = &slots[linenr]; @@ -256,6 +273,9 @@ void startup(int linenr, struct ttyent *ttyp) _exit(1); } +#ifdef __NBSD_LIBC + /* ty_init not present. */ +#else if (ttyp->ty_init != NULL && ttyp->ty_init[0] != NULL) { /* Execute a command to initialize the terminal line. */ @@ -285,16 +305,31 @@ void startup(int linenr, struct ttyent *ttyp) _exit(1); } } +#endif /* Redirect standard error too. */ dup2(0, 2); +#ifdef __NBSD_LIBC + /* Construct argv for execute() */ + ty_getty_argv = construct_argv(ttyp->ty_getty); + if (ty_getty_argv == NULL) + report(2, "construct_argv"); + + /* Execute the getty process. */ + execute(ty_getty_argv); +#else /* Execute the getty process. */ execute(ttyp->ty_getty); +#endif /* Oops, disaster strikes. */ fcntl(2, F_SETFL, fcntl(2, F_GETFL) | O_NONBLOCK); +#ifdef __NBSD_LIBC + if (linenr != 0) report(2, ty_getty_argv[0]); +#else if (linenr != 0) report(2, ttyp->ty_getty[0]); +#endif write(err[1], &errno, sizeof(errno)); _exit(1); } @@ -448,6 +483,25 @@ pid_t pid; /* pid of process */ } } +char ** +construct_argv(char *cmd) +{ + int argc = 0; + static const char sep[] = " \t"; + char **argv = malloc(((strlen(cmd) + 1) / 2 + 1) * sizeof (char *)); + + if (argv == NULL) + return NULL; + + if ((argv[argc++] = strtok(cmd, sep)) == 0) { + free(argv); + return NULL; + } + while ((argv[argc++] = strtok(NULL, sep)) != NULL) + continue; + return argv; +} + void tell(fd, s) int fd; char *s; diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index 89156face..e15f58cd9 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -2,6 +2,9 @@ #include #include #include +#ifdef __NBSD_LIBC +#include +#endif #include "buf.h" PRIVATE char getdents_buf[GETDENTS_BUFSIZ]; diff --git a/servers/mfs/Makefile b/servers/mfs/Makefile index 37846138f..88bc62ac2 100644 --- a/servers/mfs/Makefile +++ b/servers/mfs/Makefile @@ -5,8 +5,8 @@ SRCS= cache.c device.c link.c \ stadir.c stats.c table.c time.c utility.c \ write.c inode.c main.c path.c super.c -DPADD+= ${LIBSYS} -LDADD+= -lsys +DPADD+= ${LIBM} ${LIBSYS} +LDADD+= -lm -lsys MAN= diff --git a/servers/pfs/inc.h b/servers/pfs/inc.h index 0bba827f6..f8a0eb915 100644 --- a/servers/pfs/inc.h +++ b/servers/pfs/inc.h @@ -4,7 +4,11 @@ #define VERBOSE 0 /* display diagnostics */ +#ifdef __NBSD_LIBC +#include +#else #include +#endif #include #include diff --git a/servers/pm/misc.c b/servers/pm/misc.c index aa620f5b6..3549eb3af 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -543,7 +543,11 @@ PUBLIC int do_svrctl() extern char *_brksize; PUBLIC int brk(brk_addr) +#ifdef __NBSD_LIBC +void *brk_addr; +#else char *brk_addr; +#endif { int r; /* PM wants to call brk() itself. */ diff --git a/servers/procfs/proto.h b/servers/procfs/proto.h index 01b62d24f..56e84533e 100644 --- a/servers/procfs/proto.h +++ b/servers/procfs/proto.h @@ -18,6 +18,6 @@ _PROTOTYPE( int rdlink_hook, (struct inode *inode, char *ptr, size_t max, cbdata_t cbdata) ); /* util.c */ -_PROTOTYPE( int procfs_getloadavg, (double *loadavg, int nelem) ); +_PROTOTYPE( int procfs_getloadavg, (struct load *loadavg, int nelem) ); #endif /* _PROCFS_PROTO_H */ diff --git a/servers/procfs/root.c b/servers/procfs/root.c index 2b70b993e..9b07437a1 100644 --- a/servers/procfs/root.c +++ b/servers/procfs/root.c @@ -40,12 +40,19 @@ PRIVATE void root_loadavg(void) { /* Print load averages. */ - double avg[3]; + struct load loads[3]; + ldiv_t avg[3]; - if (procfs_getloadavg(avg, 3) != 3) + if (procfs_getloadavg(loads, 3) != 3) return; - buf_printf("%.2lf %.2lf %.2lf\n", avg[0], avg[1], avg[2]); + avg[0] = ldiv(100L * loads[0].proc_load / loads[0].ticks, 100); + avg[1] = ldiv(100L * loads[1].proc_load / loads[1].ticks, 100); + avg[2] = ldiv(100L * loads[2].proc_load / loads[2].ticks, 100); + + buf_printf("%ld.%0.2ld %ld.%02ld %ld.%02ld\n", + avg[0].quot, avg[0].rem, avg[1].quot, avg[1].rem, + avg[2].quot, avg[2].rem); } /*===========================================================================* @@ -56,11 +63,13 @@ PRIVATE void root_uptime(void) /* Print the current uptime. */ clock_t ticks; + ldiv_t division; if (getuptime(&ticks) != OK) return; + division = ldiv(100L * ticks / sys_hz(), 100L); - buf_printf("%.2lf\n", (double) ticks / (double) sys_hz()); + buf_printf("%ld.%0.2ld\n", division.quot, division.rem); } /*===========================================================================* diff --git a/servers/procfs/type.h b/servers/procfs/type.h index 202551f94..d2f72acd5 100644 --- a/servers/procfs/type.h +++ b/servers/procfs/type.h @@ -3,6 +3,11 @@ typedef void *data_t; /* abstract data type; can hold pointer */ +struct load { + clock_t ticks; /* in this umber of ticks: */ + long proc_load; /* .. the CPU had this load */ +}; + /* ProcFS supports two groups of files: dynamic files, which are created within * process-specific (PID) directories, and static files, which are global. For * both, the following structure is used to construct the files. diff --git a/servers/procfs/util.c b/servers/procfs/util.c index 703af706a..eda7aba27 100644 --- a/servers/procfs/util.c +++ b/servers/procfs/util.c @@ -5,7 +5,7 @@ /*===========================================================================* * procfs_getloadavg * *===========================================================================*/ -PUBLIC int procfs_getloadavg(double *loadavg, int nelem) +PUBLIC int procfs_getloadavg(struct load *loadavg, int nelem) { /* Retrieve system load average information. */ @@ -34,9 +34,9 @@ PUBLIC int procfs_getloadavg(double *loadavg, int nelem) for(p = 0; p < nelem; p++) { int h, slots; - double l = 0.0; int latest = loadinfo.proc_last_slot; slots = minutes[p] * 60 / _LOAD_UNIT_SECS; + loadavg[p].proc_load = 0; /* Add up the total number of process ticks for this number * of minutes (minutes[p]). Start with the newest slot, which @@ -48,6 +48,8 @@ PUBLIC int procfs_getloadavg(double *loadavg, int nelem) for(h = 0; h < slots; h++) { int slot; slot = (latest - h + _LOAD_HISTORY) % _LOAD_HISTORY; + loadavg[p].proc_load += + loadinfo.proc_load_history[slot]; l += (double) loadinfo.proc_load_history[slot]; } @@ -56,7 +58,7 @@ PUBLIC int procfs_getloadavg(double *loadavg, int nelem) * counting the number of ticks the last slot hasn't been * around yet. */ - loadavg[p] = l / (slots * ticks_per_slot - unfilled_ticks); + loadavg[p].ticks = slots * ticks_per_slot - unfilled_ticks; } return nelem; diff --git a/servers/vfs/select.c b/servers/vfs/select.c index 664629120..705030785 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -535,7 +535,11 @@ PRIVATE int copy_fdsets(struct selectentry *se, int nfds, int direction) panic("select copy_fdsets: nfds wrong: %d", nfds); /* Only copy back as many bits as the user expects. */ +#ifdef __NBSD_LIBC + fd_setsize = (size_t) (howmany(nfds, __NFDBITS) * sizeof(__fd_mask)); +#else fd_setsize = (size_t) (_FDSETWORDS(nfds) * _FDSETBITSPERWORD/8); +#endif /* Set source and destination endpoints */ src_e = (direction == FROM_PROC) ? se->req_endpt : SELF; diff --git a/servers/vm/alloc.c b/servers/vm/alloc.c index 62e736f0c..2aa5f4972 100644 --- a/servers/vm/alloc.c +++ b/servers/vm/alloc.c @@ -800,8 +800,8 @@ void printmemstats(void) int nodes, pages, largest; memstats(&nodes, &pages, &largest); printf("%d blocks, %d pages (%lukB) free, largest %d pages (%lukB)\n", - nodes, pages, (u32_t) pages * (VM_PAGE_SIZE/1024), - largest, (u32_t) largest * (VM_PAGE_SIZE/1024)); + nodes, pages, (unsigned long) pages * (VM_PAGE_SIZE/1024), + largest, (unsigned long) largest * (VM_PAGE_SIZE/1024)); } diff --git a/servers/vm/arch/i386/pagetable.c b/servers/vm/arch/i386/pagetable.c index f26e02bec..bbd2183e9 100644 --- a/servers/vm/arch/i386/pagetable.c +++ b/servers/vm/arch/i386/pagetable.c @@ -56,7 +56,7 @@ struct vmproc *vmprocess = &vmproc[VM_PROC_NR]; int missing_spares = SPAREPAGES; PRIVATE struct { void *page; - u32_t phys; + phys_bytes phys; } sparepages[SPAREPAGES]; #define MAX_KERNMAPPINGS 10 @@ -86,7 +86,8 @@ int kernmappings = 0; #define CLICK2PAGE(c) ((c) / CLICKSPERPAGE) /* Page table that contains pointers to all page directories. */ -u32_t page_directories_phys, *page_directories = NULL; +phys_bytes page_directories_phys; +u32_t *page_directories = NULL; #define STATIC_SPAREPAGES 10 @@ -225,7 +226,7 @@ PRIVATE void vm_freepages(vir_bytes vir, vir_bytes phys, int pages, int reason) /*===========================================================================* * vm_getsparepage * *===========================================================================*/ -PRIVATE void *vm_getsparepage(u32_t *phys) +PRIVATE void *vm_getsparepage(phys_bytes *phys) { int s; assert(missing_spares >= 0 && missing_spares <= SPAREPAGES); @@ -428,7 +429,7 @@ PRIVATE int pt_ptalloc(pt_t *pt, int pde, u32_t flags) { /* Allocate a page table and write its address into the page directory. */ int i; - u32_t pt_phys; + phys_bytes pt_phys; /* Argument must make sense. */ assert(pde >= 0 && pde < I386_VM_DIR_ENTRIES); @@ -737,7 +738,8 @@ PUBLIC int pt_writemap(struct vmproc * vmp, printf("pt_writemap: mismatch: "); if((entry & I386_VM_ADDR_MASK) != (maskedentry & I386_VM_ADDR_MASK)) { - printf("pt_writemap: physaddr mismatch (0x%lx, 0x%lx); ", entry, maskedentry); + printf("pt_writemap: physaddr mismatch (0x%lx, 0x%lx); ", + (long)entry, (long)maskedentry); } else printf("phys ok; "); printf(" flags: found %s; ", ptestr(pt->pt_pt[pde][pte])); @@ -832,7 +834,7 @@ PUBLIC int pt_new(pt_t *pt) * the page directories (the page_directories data). */ if(!pt->pt_dir && - !(pt->pt_dir = vm_allocpage(&pt->pt_dir_phys, VMP_PAGEDIR))) { + !(pt->pt_dir = vm_allocpage((phys_bytes *)&pt->pt_dir_phys, VMP_PAGEDIR))) { return ENOMEM; } @@ -1071,9 +1073,12 @@ PUBLIC void pt_init_mem() * shared with the kernel and VM's page tables are mapped above the stack, * so that we can easily transfer existing mappings for new VM instances. */ - u32_t new_page_directories_phys, *new_page_directories; - u32_t new_pt_dir_phys, *new_pt_dir; - u32_t new_pt_phys, *new_pt; + phys_bytes new_page_directories_phys; + u32_t *new_page_directories; + phys_bytes new_pt_dir_phys; + u32_t *new_pt_dir; + phys_bytes new_pt_phys; + u32_t *new_pt; pt_t *vmpt; int i; diff --git a/servers/vm/pagefaults.c b/servers/vm/pagefaults.c index 5bce5f5c6..fae6373a9 100644 --- a/servers/vm/pagefaults.c +++ b/servers/vm/pagefaults.c @@ -39,7 +39,7 @@ char *pf_errstr(u32_t err) { static char buf[100]; - sprintf(buf, "err 0x%lx ", err); + sprintf(buf, "err 0x%lx ", (long)err); if(PFERR_NOPAGE(err)) strcat(buf, "nopage "); if(PFERR_PROT(err)) strcat(buf, "protection "); if(PFERR_WRITE(err)) strcat(buf, "write"); diff --git a/share/Makefile b/share/Makefile index 8ae65e740..edb1205a6 100644 --- a/share/Makefile +++ b/share/Makefile @@ -1,5 +1,8 @@ .include -SUBDIR= mk zoneinfo +SUBDIR= mk +.if (${NBSD_LIBC} == "no") +SUBDIR+= zoneinfo +.endif .include diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 5d5e6a802..cccc74201 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -195,6 +195,12 @@ _LDADD.${_P}= ${LDADD} ${LDADD.${_P}} _LDFLAGS.${_P}= ${LDFLAGS} ${LDFLAGS.${_P}} _LDSTATIC.${_P}= ${LDSTATIC} ${LDSTATIC.${_P}} +.if defined(NBSD_LIBC) && (${NBSD_LIBC} == "yes") && \ + !empty(_LDADD.${_P}:M-lsys) +# defined(USE_LIBSYS) && (${USE_LIBSYS} == "yes") +_LDADD.${_P}+= -nodefaultlibs -lgcc -lsys -lgcc +.endif + ##### Build and install rules .if !empty(_APPEND_SRCS:M[Yy][Ee][Ss]) SRCS+= ${SRCS.${_P}} # For bsd.dep.mk diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 69aaf2077..d6c27a74c 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -66,7 +66,7 @@ HAS_SSP= yes .endif .if defined(NBSD_LIBC) && (${NBSD_LIBC} != "no") -CPPFLAGS+= -nostdinc -D__NBSD_LIBC -I /usr/netbsd/include +CPPFLAGS+= -nostdinc -D__NBSD_LIBC -isystem /usr/netbsd/include LDFLAGS+= -L /usr/netbsd/lib .endif diff --git a/tools/Makefile b/tools/Makefile index bdc8ecbe2..11c812220 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,4 +1,6 @@ # Makefile for the kernel image. +.include +.include "nbsd.config" u=/usr MDEC= /usr/mdec @@ -34,6 +36,8 @@ usage: @echo " make hdboot # Make image, and install to hard disk" >&2 @echo " make fdboot # Make image, and install to floppy disk" >&2 @echo " make bootable # Make hard disk bootable" >&2 + @echo " make nbsd_fetch # Download current NetBSD reference sources" >&2 + @echo " make nbsd_diff # Update minix-port.patch in NetBSD sources" >&2 @echo " make clean # Remove all compiler results, except libs" >&2 @echo " " >&2 @echo "To create a fresh MINIX configuration, try:" >&2 @@ -100,6 +104,16 @@ fdboot: image install: includes services hdboot +# download and update NetBSD reference sources. +nbsd_fetch: + cd ${MINIXSRCDIR} && awk '{print $$2;}' < tools/nbsd_ports \ + | xargs -t cvs -d ${NBSD_CVSROOT} co -N -d nbsdsrc ${NBSD_REF} + +nbsd_diff: + cd ${MINIXSRCDIR} && awk '{ system("sh tools/nbsd_diff.sh " \ + "nbsdsrc/"$$2" "$$1" "$$1"/minix-port.patch");}' < tools/nbsd_ports + + # clean up compile results clean: $(MAKE) -C ../kernel $@ diff --git a/tools/nbsd.config b/tools/nbsd.config new file mode 100644 index 000000000..ea1c240f8 --- /dev/null +++ b/tools/nbsd.config @@ -0,0 +1,3 @@ +NBSD_CVSROOT= anoncvs@anoncvs.netbsd.org:/cvsroot + +NBSD_REF= "-D 2011-01-22" # The date (or tag) of ported NetBSD sources. diff --git a/tools/nbsd_diff.sh b/tools/nbsd_diff.sh new file mode 100644 index 000000000..11cfbea7f --- /dev/null +++ b/tools/nbsd_diff.sh @@ -0,0 +1,6 @@ +#!/bin/sh +echo "Updating $3" +diff -ru $1 $2 | \ + sed /"^Only in"/d | \ + sed -e 's/^\(---.*\)\t.*/\1/' | \ + sed -e 's/^\(\+\+\+.*\)\t.*/\1/' > $3 diff --git a/tools/nbsd_ports b/tools/nbsd_ports new file mode 100644 index 000000000..0c4ac6bb4 --- /dev/null +++ b/tools/nbsd_ports @@ -0,0 +1,4 @@ +common/lib/libc src/common/lib/libc +lib/nbsd_libc src/lib/libc +lib/nbsd_libm src/lib/libm +nbsd_include src/include -- 2.44.0