From dea2a1fa20fc8e843cd85e5920a67b9054d00b2e Mon Sep 17 00:00:00 2001 From: Woodpecker CI Date: Sun, 24 May 2026 15:40:32 +0000 Subject: Woodpecker CI ef5bfeb93345a5a681d88e99775622bf28defd8d [SKIP CI] --- repos/core/musl/.checksum | 11 - repos/core/musl/.files | 258 --------- repos/core/musl/abuild | 43 -- repos/core/musl/cdefs.h | 26 - repos/core/musl/default-locpath.patch | 14 - repos/core/musl/elfutils-0.190-relr.patch | 73 --- repos/core/musl/getconf.1 | 94 ---- repos/core/musl/getconf.c | 338 ------------ repos/core/musl/getent.1 | 145 ----- repos/core/musl/getent.c | 437 --------------- repos/core/musl/iconv.c | 110 ---- repos/core/musl/queue.h | 846 ------------------------------ repos/core/musl/tree.h | 761 --------------------------- 13 files changed, 3156 deletions(-) delete mode 100644 repos/core/musl/.checksum delete mode 100644 repos/core/musl/.files delete mode 100644 repos/core/musl/abuild delete mode 100644 repos/core/musl/cdefs.h delete mode 100644 repos/core/musl/default-locpath.patch delete mode 100644 repos/core/musl/elfutils-0.190-relr.patch delete mode 100644 repos/core/musl/getconf.1 delete mode 100644 repos/core/musl/getconf.c delete mode 100644 repos/core/musl/getent.1 delete mode 100644 repos/core/musl/getent.c delete mode 100644 repos/core/musl/iconv.c delete mode 100644 repos/core/musl/queue.h delete mode 100644 repos/core/musl/tree.h (limited to 'repos/core/musl') diff --git a/repos/core/musl/.checksum b/repos/core/musl/.checksum deleted file mode 100644 index 4116dc7a..00000000 --- a/repos/core/musl/.checksum +++ /dev/null @@ -1,11 +0,0 @@ -936eb5830af322af38a1d08d02cc1d31ae95efdbc2e381b0e5fa6e91eebe693e cdefs.h -bfb4a93ede1bacfa7c7c78aaaf80372223effcea7bbc52aeffca655dd0922159 default-locpath.patch -ae7b2598293d87cff4fc4e8bed5faabe486615ad7484a08d6dfea807786af895 elfutils-0.190-relr.patch -676213e6d717200470f5f8b2c30c171e47e20eebfa669891afe43c514e1b72b5 getconf.1 -9949f50c6d3b639a65986fd8a0cd44e9b9ea886ae137ba53e300f20545ee3118 getconf.c -3f72e9edab77c36cf5f4c38f469b11f5186c229b3b9265d7abcdff9c66f3292b getent.1 -3e6180af36c59edb15c254c05ef7dd0a22a4531227e4a30c4f17c0c4b7b0cbac getent.c -6614a2c2ad98779913e56e6afe855ddc82155085cd0c7b50c5f75f36fdd86bd7 iconv.c -260127b07a6cb72b70264fceafbc509e7da0cfde8e701a1fb44247859bc489a5 musl-1.2.6.tar.gz -619fd80e4d195caa65ee96b4338a1e68ed16bdc41cbe90ac15730c359bca8209 queue.h -c712195c178941f6c90ab09c99639a06e49c240c932c632189033d961af05279 tree.h diff --git a/repos/core/musl/.files b/repos/core/musl/.files deleted file mode 100644 index 69b65def..00000000 --- a/repos/core/musl/.files +++ /dev/null @@ -1,258 +0,0 @@ -drwxr-xr-x root/root lib/ -lrwxrwxrwx root/root lib/ld-musl-x86_64.so.1 -> /usr/lib/libc.so -drwxr-xr-x root/root sbin/ --rwxr-xr-x root/root sbin/ldconfig -drwxr-xr-x root/root usr/ -drwxr-xr-x root/root usr/bin/ --rwxr-xr-x root/root usr/bin/getconf --rwxr-xr-x root/root usr/bin/getent --rwxr-xr-x root/root usr/bin/iconv -lrwxrwxrwx root/root usr/bin/ldd -> ../lib/libc.so -drwxr-xr-x root/root usr/include/ --rw-r--r-- root/root usr/include/aio.h --rw-r--r-- root/root usr/include/alloca.h --rw-r--r-- root/root usr/include/ar.h -drwxr-xr-x root/root usr/include/arpa/ --rw-r--r-- root/root usr/include/arpa/ftp.h --rw-r--r-- root/root usr/include/arpa/inet.h --rw-r--r-- root/root usr/include/arpa/nameser.h --rw-r--r-- root/root usr/include/arpa/nameser_compat.h --rw-r--r-- root/root usr/include/arpa/telnet.h --rw-r--r-- root/root usr/include/arpa/tftp.h --rw-r--r-- root/root usr/include/assert.h -drwxr-xr-x root/root usr/include/bits/ --rw-r--r-- root/root usr/include/bits/alltypes.h --rw-r--r-- root/root usr/include/bits/dirent.h --rw-r--r-- root/root usr/include/bits/errno.h --rw-r--r-- root/root usr/include/bits/fcntl.h --rw-r--r-- root/root usr/include/bits/fenv.h --rw-r--r-- root/root usr/include/bits/float.h --rw-r--r-- root/root usr/include/bits/hwcap.h --rw-r--r-- root/root usr/include/bits/io.h --rw-r--r-- root/root usr/include/bits/ioctl.h --rw-r--r-- root/root usr/include/bits/ioctl_fix.h --rw-r--r-- root/root usr/include/bits/ipc.h --rw-r--r-- root/root usr/include/bits/ipcstat.h --rw-r--r-- root/root usr/include/bits/kd.h --rw-r--r-- root/root usr/include/bits/limits.h --rw-r--r-- root/root usr/include/bits/link.h --rw-r--r-- root/root usr/include/bits/mman.h --rw-r--r-- root/root usr/include/bits/msg.h --rw-r--r-- root/root usr/include/bits/poll.h --rw-r--r-- root/root usr/include/bits/ptrace.h --rw-r--r-- root/root usr/include/bits/reg.h --rw-r--r-- root/root usr/include/bits/resource.h --rw-r--r-- root/root usr/include/bits/sem.h --rw-r--r-- root/root usr/include/bits/setjmp.h --rw-r--r-- root/root usr/include/bits/shm.h --rw-r--r-- root/root usr/include/bits/signal.h --rw-r--r-- root/root usr/include/bits/socket.h --rw-r--r-- root/root usr/include/bits/soundcard.h --rw-r--r-- root/root usr/include/bits/stat.h --rw-r--r-- root/root usr/include/bits/statfs.h --rw-r--r-- root/root usr/include/bits/stdint.h --rw-r--r-- root/root usr/include/bits/syscall.h --rw-r--r-- root/root usr/include/bits/termios.h --rw-r--r-- root/root usr/include/bits/user.h --rw-r--r-- root/root usr/include/bits/vt.h --rw-r--r-- root/root usr/include/byteswap.h --rw-r--r-- root/root usr/include/complex.h --rw-r--r-- root/root usr/include/cpio.h --rw-r--r-- root/root usr/include/crypt.h --rw-r--r-- root/root usr/include/ctype.h --rw-r--r-- root/root usr/include/dirent.h --rw-r--r-- root/root usr/include/dlfcn.h --rw-r--r-- root/root usr/include/elf.h --rw-r--r-- root/root usr/include/endian.h --rw-r--r-- root/root usr/include/err.h --rw-r--r-- root/root usr/include/errno.h --rw-r--r-- root/root usr/include/fcntl.h --rw-r--r-- root/root usr/include/features.h --rw-r--r-- root/root usr/include/fenv.h --rw-r--r-- root/root usr/include/float.h --rw-r--r-- root/root usr/include/fmtmsg.h --rw-r--r-- root/root usr/include/fnmatch.h --rw-r--r-- root/root usr/include/ftw.h --rw-r--r-- root/root usr/include/getopt.h --rw-r--r-- root/root usr/include/glob.h --rw-r--r-- root/root usr/include/grp.h --rw-r--r-- root/root usr/include/iconv.h --rw-r--r-- root/root usr/include/ifaddrs.h --rw-r--r-- root/root usr/include/inttypes.h --rw-r--r-- root/root usr/include/iso646.h --rw-r--r-- root/root usr/include/langinfo.h --rw-r--r-- root/root usr/include/lastlog.h --rw-r--r-- root/root usr/include/libgen.h --rw-r--r-- root/root usr/include/libintl.h --rw-r--r-- root/root usr/include/limits.h --rw-r--r-- root/root usr/include/link.h --rw-r--r-- root/root usr/include/locale.h --rw-r--r-- root/root usr/include/malloc.h --rw-r--r-- root/root usr/include/math.h --rw-r--r-- root/root usr/include/memory.h --rw-r--r-- root/root usr/include/mntent.h --rw-r--r-- root/root usr/include/monetary.h --rw-r--r-- root/root usr/include/mqueue.h -drwxr-xr-x root/root usr/include/net/ --rw-r--r-- root/root usr/include/net/ethernet.h --rw-r--r-- root/root usr/include/net/if.h --rw-r--r-- root/root usr/include/net/if_arp.h --rw-r--r-- root/root usr/include/net/route.h --rw-r--r-- root/root usr/include/netdb.h -drwxr-xr-x root/root usr/include/netinet/ --rw-r--r-- root/root usr/include/netinet/ether.h --rw-r--r-- root/root usr/include/netinet/icmp6.h --rw-r--r-- root/root usr/include/netinet/if_ether.h --rw-r--r-- root/root usr/include/netinet/igmp.h --rw-r--r-- root/root usr/include/netinet/in.h --rw-r--r-- root/root usr/include/netinet/in_systm.h --rw-r--r-- root/root usr/include/netinet/ip.h --rw-r--r-- root/root usr/include/netinet/ip6.h --rw-r--r-- root/root usr/include/netinet/ip_icmp.h --rw-r--r-- root/root usr/include/netinet/tcp.h --rw-r--r-- root/root usr/include/netinet/udp.h -drwxr-xr-x root/root usr/include/netpacket/ --rw-r--r-- root/root usr/include/netpacket/packet.h --rw-r--r-- root/root usr/include/nl_types.h --rw-r--r-- root/root usr/include/paths.h --rw-r--r-- root/root usr/include/poll.h --rw-r--r-- root/root usr/include/pthread.h --rw-r--r-- root/root usr/include/pty.h --rw-r--r-- root/root usr/include/pwd.h --rw-r--r-- root/root usr/include/regex.h --rw-r--r-- root/root usr/include/resolv.h --rw-r--r-- root/root usr/include/sched.h -drwxr-xr-x root/root usr/include/scsi/ --rw-r--r-- root/root usr/include/scsi/scsi.h --rw-r--r-- root/root usr/include/scsi/scsi_ioctl.h --rw-r--r-- root/root usr/include/scsi/sg.h --rw-r--r-- root/root usr/include/search.h --rw-r--r-- root/root usr/include/semaphore.h --rw-r--r-- root/root usr/include/setjmp.h --rw-r--r-- root/root usr/include/shadow.h --rw-r--r-- root/root usr/include/signal.h --rw-r--r-- root/root usr/include/spawn.h --rw-r--r-- root/root usr/include/stdalign.h --rw-r--r-- root/root usr/include/stdarg.h --rw-r--r-- root/root usr/include/stdbool.h --rw-r--r-- root/root usr/include/stdc-predef.h --rw-r--r-- root/root usr/include/stddef.h --rw-r--r-- root/root usr/include/stdint.h --rw-r--r-- root/root usr/include/stdio.h --rw-r--r-- root/root usr/include/stdio_ext.h --rw-r--r-- root/root usr/include/stdlib.h --rw-r--r-- root/root usr/include/stdnoreturn.h --rw-r--r-- root/root usr/include/string.h --rw-r--r-- root/root usr/include/strings.h --rw-r--r-- root/root usr/include/stropts.h -drwxr-xr-x root/root usr/include/sys/ --rw-r--r-- root/root usr/include/sys/acct.h --rw-r--r-- root/root usr/include/sys/auxv.h --rw-r--r-- root/root usr/include/sys/cachectl.h --rwxr-xr-x root/root usr/include/sys/cdefs.h --rw-r--r-- root/root usr/include/sys/dir.h --rw-r--r-- root/root usr/include/sys/epoll.h --rw-r--r-- root/root usr/include/sys/errno.h --rw-r--r-- root/root usr/include/sys/eventfd.h --rw-r--r-- root/root usr/include/sys/fanotify.h --rw-r--r-- root/root usr/include/sys/fcntl.h --rw-r--r-- root/root usr/include/sys/file.h --rw-r--r-- root/root usr/include/sys/fsuid.h --rw-r--r-- root/root usr/include/sys/inotify.h --rw-r--r-- root/root usr/include/sys/io.h --rw-r--r-- root/root usr/include/sys/ioctl.h --rw-r--r-- root/root usr/include/sys/ipc.h --rw-r--r-- root/root usr/include/sys/kd.h --rw-r--r-- root/root usr/include/sys/klog.h --rw-r--r-- root/root usr/include/sys/membarrier.h --rw-r--r-- root/root usr/include/sys/mman.h --rw-r--r-- root/root usr/include/sys/mount.h --rw-r--r-- root/root usr/include/sys/msg.h --rw-r--r-- root/root usr/include/sys/mtio.h --rw-r--r-- root/root usr/include/sys/param.h --rw-r--r-- root/root usr/include/sys/personality.h --rw-r--r-- root/root usr/include/sys/poll.h --rw-r--r-- root/root usr/include/sys/prctl.h --rw-r--r-- root/root usr/include/sys/procfs.h --rw-r--r-- root/root usr/include/sys/ptrace.h --rwxr-xr-x root/root usr/include/sys/queue.h --rw-r--r-- root/root usr/include/sys/quota.h --rw-r--r-- root/root usr/include/sys/random.h --rw-r--r-- root/root usr/include/sys/reboot.h --rw-r--r-- root/root usr/include/sys/reg.h --rw-r--r-- root/root usr/include/sys/resource.h --rw-r--r-- root/root usr/include/sys/select.h --rw-r--r-- root/root usr/include/sys/sem.h --rw-r--r-- root/root usr/include/sys/sendfile.h --rw-r--r-- root/root usr/include/sys/shm.h --rw-r--r-- root/root usr/include/sys/signal.h --rw-r--r-- root/root usr/include/sys/signalfd.h --rw-r--r-- root/root usr/include/sys/socket.h --rw-r--r-- root/root usr/include/sys/soundcard.h --rw-r--r-- root/root usr/include/sys/stat.h --rw-r--r-- root/root usr/include/sys/statfs.h --rw-r--r-- root/root usr/include/sys/statvfs.h --rw-r--r-- root/root usr/include/sys/stropts.h --rw-r--r-- root/root usr/include/sys/swap.h --rw-r--r-- root/root usr/include/sys/syscall.h --rw-r--r-- root/root usr/include/sys/sysinfo.h --rw-r--r-- root/root usr/include/sys/syslog.h --rw-r--r-- root/root usr/include/sys/sysmacros.h --rw-r--r-- root/root usr/include/sys/termios.h --rw-r--r-- root/root usr/include/sys/time.h --rw-r--r-- root/root usr/include/sys/timeb.h --rw-r--r-- root/root usr/include/sys/timerfd.h --rw-r--r-- root/root usr/include/sys/times.h --rw-r--r-- root/root usr/include/sys/timex.h --rwxr-xr-x root/root usr/include/sys/tree.h --rw-r--r-- root/root usr/include/sys/ttydefaults.h --rw-r--r-- root/root usr/include/sys/types.h --rw-r--r-- root/root usr/include/sys/ucontext.h --rw-r--r-- root/root usr/include/sys/uio.h --rw-r--r-- root/root usr/include/sys/un.h --rw-r--r-- root/root usr/include/sys/user.h --rw-r--r-- root/root usr/include/sys/utsname.h --rw-r--r-- root/root usr/include/sys/vfs.h --rw-r--r-- root/root usr/include/sys/vt.h --rw-r--r-- root/root usr/include/sys/wait.h --rw-r--r-- root/root usr/include/sys/xattr.h --rw-r--r-- root/root usr/include/syscall.h --rw-r--r-- root/root usr/include/sysexits.h --rw-r--r-- root/root usr/include/syslog.h --rw-r--r-- root/root usr/include/tar.h --rw-r--r-- root/root usr/include/termios.h --rw-r--r-- root/root usr/include/tgmath.h --rw-r--r-- root/root usr/include/threads.h --rw-r--r-- root/root usr/include/time.h --rw-r--r-- root/root usr/include/uchar.h --rw-r--r-- root/root usr/include/ucontext.h --rw-r--r-- root/root usr/include/ulimit.h --rw-r--r-- root/root usr/include/unistd.h --rw-r--r-- root/root usr/include/utime.h --rw-r--r-- root/root usr/include/utmp.h --rw-r--r-- root/root usr/include/utmpx.h --rw-r--r-- root/root usr/include/values.h --rw-r--r-- root/root usr/include/wait.h --rw-r--r-- root/root usr/include/wchar.h --rw-r--r-- root/root usr/include/wctype.h --rw-r--r-- root/root usr/include/wordexp.h -drwxr-xr-x root/root usr/lib/ --rw-r--r-- root/root usr/lib/Scrt1.o --rw-r--r-- root/root usr/lib/crt1.o --rw-r--r-- root/root usr/lib/crti.o --rw-r--r-- root/root usr/lib/crtn.o --rw-r--r-- root/root usr/lib/libc.a --rwxr-xr-x root/root usr/lib/libc.so --rw-r--r-- root/root usr/lib/libcrypt.a --rw-r--r-- root/root usr/lib/libdl.a --rw-r--r-- root/root usr/lib/libm.a --rw-r--r-- root/root usr/lib/libpthread.a --rw-r--r-- root/root usr/lib/libresolv.a --rw-r--r-- root/root usr/lib/librt.a --rw-r--r-- root/root usr/lib/libutil.a --rw-r--r-- root/root usr/lib/libxnet.a --rw-r--r-- root/root usr/lib/rcrt1.o -drwxr-xr-x root/root usr/share/ -drwxr-xr-x root/root usr/share/man/ -drwxr-xr-x root/root usr/share/man/man1/ --rw-r--r-- root/root usr/share/man/man1/getconf.1.gz diff --git a/repos/core/musl/abuild b/repos/core/musl/abuild deleted file mode 100644 index 3f229dbf..00000000 --- a/repos/core/musl/abuild +++ /dev/null @@ -1,43 +0,0 @@ -name=musl -version=1.2.6 -release=2 -source="https://www.musl-libc.org/releases/musl-$version.tar.gz - getconf.c - getconf.1 - getent.c - getent.1 - iconv.c - tree.h - queue.h - cdefs.h - elfutils-0.190-relr.patch - default-locpath.patch" -keep_static=1 - -build() { - ./configure \ - --prefix=/usr #\ - #--syslibdir=/usr/lib - make - make DESTDIR=$PKG install - - mkdir -p $PKG/usr/bin - ln -sf ../lib/libc.so $PKG/usr/bin/ldd - mkdir -p $PKG/sbin - echo "#!/bin/sh - /bin/true" > $PKG/sbin/ldconfig - chmod +x $PKG/sbin/ldconfig - - for i in getent getconf iconv; do - ${CC:-gcc} $CFLAGS $LDFLAGS -fpie $SRC/$i.c -o $PKG/usr/bin/$i - done - - mkdir -p $PKG/usr/share/man/man1 - install -m644 $SRC/getconf.1 $PKG/usr/share/man/man1 - #install -m644 $SRC/getent.1 $PKG/usr/share/man/man1 - - # bsdcompat headers - for h in tree.h queue.h cdefs.h; do - install -D $SRC/$h $PKG/usr/include/sys/ - done -} diff --git a/repos/core/musl/cdefs.h b/repos/core/musl/cdefs.h deleted file mode 100644 index 209a623c..00000000 --- a/repos/core/musl/cdefs.h +++ /dev/null @@ -1,26 +0,0 @@ -#warning usage of non-standard #include is deprecated - -#undef __P -#undef __PMT - -#define __P(args) args -#define __PMT(args) args - -#define __CONCAT(x,y) x ## y -#define __STRING(x) #x - -#ifdef __cplusplus -# define __BEGIN_DECLS extern "C" { -# define __END_DECLS } -#else -# define __BEGIN_DECLS -# define __END_DECLS -#endif - -#if defined(__GNUC__) && !defined(__cplusplus) -# define __THROW __attribute__ ((__nothrow__)) -# define __NTH(fct) __attribute__ ((__nothrow__)) fct -#else -# define __THROW -# define __NTH(fct) fct -#endif diff --git a/repos/core/musl/default-locpath.patch b/repos/core/musl/default-locpath.patch deleted file mode 100644 index a6080d44..00000000 --- a/repos/core/musl/default-locpath.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/src/locale/locale_map.c 2024-05-12 20:33:15.000000000 +0100 -+++ b/src/locale/locale_map.c 2024-05-20 22:53:02.685916344 +0100 -@@ -64,7 +64,10 @@ - if (!strcmp(val, p->name)) return p; - - if (!libc.secure) path = getenv("MUSL_LOCPATH"); -- /* FIXME: add a default path? */ -+ if (!path) { -+ // Provided by musl-locales -+ path = "/usr/share/i18n/locales/musl"; -+ } - - if (path) for (; *path; path=z+!!*z) { - z = __strchrnul(path, ':'); diff --git a/repos/core/musl/elfutils-0.190-relr.patch b/repos/core/musl/elfutils-0.190-relr.patch deleted file mode 100644 index e5eaf46f..00000000 --- a/repos/core/musl/elfutils-0.190-relr.patch +++ /dev/null @@ -1,73 +0,0 @@ -https://www.openwall.com/lists/musl/2023/11/06/3 -https://inbox.vuxu.org/musl/20231106113336.3664-2-ncopa@alpinelinux.org/T/#u -https://sourceware.org/bugzilla/show_bug.cgi?id=31034 -https://bugs.gentoo.org/916857 - -From mboxrd@z Thu Jan 1 00:00:00 1970 -X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org -X-Spam-Level: -X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, - MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, - RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham - autolearn_force=no version=3.4.4 -Received: (qmail 5179 invoked from network); 6 Nov 2023 11:46:34 -0000 -Received: from second.openwall.net (193.110.157.125) - by inbox.vuxu.org with ESMTPUTF8; 6 Nov 2023 11:46:34 -0000 -Received: (qmail 30570 invoked by uid 550); 6 Nov 2023 11:46:29 -0000 -Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm -Precedence: bulk -List-Post: -List-Help: -List-Unsubscribe: -List-Subscribe: -List-ID: -Reply-To: musl@lists.openwall.com -Received: (qmail 30538 invoked from network); 6 Nov 2023 11:46:29 -0000 -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alpinelinux.org; - s=smtp; t=1699271177; - h=from:from:reply-to:subject:subject:date:date:message-id:message-id: - to:to:cc:cc:mime-version:mime-version: - content-transfer-encoding:content-transfer-encoding; - bh=73HDLjg72r1JGckDGbEyPxYrYL7dC7MB3gMwy/yp7hc=; - b=pSGCs/DrFDbs9eEA89un578pZbyzpmTw81QGH7xK4ZAAkYiXx1ysaXlsllwxGd076F+plw - kE1QbGVndutc+ieeUOiHomF4O8IP4AqO/8xCy52LlYmnhMTcxgoXD/GWHfVcXmIgFb+8Uc - jvgM9nXFOXceFSlHLLOwJBQFE2dyBrU= -From: Natanael Copa -To: musl@lists.openwall.com -Cc: Natanael Copa -Date: Mon, 6 Nov 2023 12:33:37 +0100 -Message-ID: <20231106113336.3664-2-ncopa@alpinelinux.org> -X-Mailer: git-send-email 2.42.1 -MIME-Version: 1.0 -Content-Transfer-Encoding: 8bit -Subject: [musl] [PATCH] elf.h: add typedefs for Elf*_Relr - -Add typedefs for Elf32_Relr and Elf64_Relr as a follow-up to commit -d32dadd60efb (ldso: support DT_RELR relative relocation format) - ---- -This fixes build of iproute2 with elfutils 0.190, which assumes that -Elf*_Relr are typedef'ed when SHT_RELR is defined. - -ref: https://sourceware.org/git/?p=elfutils.git;a=commit;h=39f2c500542f69c2f1a13fd0ae4eaa5778d2ed8d -ref: https://sourceware.org/bugzilla/show_bug.cgi?id=31034 - - include/elf.h | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/include/elf.h b/include/elf.h -index 23f2c4bc..aa186d9d 100644 ---- a/include/elf.h -+++ b/include/elf.h -@@ -32,6 +32,9 @@ typedef uint16_t Elf64_Section; - typedef Elf32_Half Elf32_Versym; - typedef Elf64_Half Elf64_Versym; - -+typedef Elf32_Word Elf32_Relr; -+typedef Elf64_Xword Elf64_Relr; -+ - #define EI_NIDENT (16) - - typedef struct { --- -2.42.1 diff --git a/repos/core/musl/getconf.1 b/repos/core/musl/getconf.1 deleted file mode 100644 index 520a688b..00000000 --- a/repos/core/musl/getconf.1 +++ /dev/null @@ -1,94 +0,0 @@ -.\" $NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $ -.\" -.\" Copyright (c) 1996 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by J.T. Conklin. -.\" -.\" 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. -.\" -.Dd August 9, 2011 -.Dt GETCONF 1 -.Os -.Sh NAME -.Nm getconf -.Nd get configuration values -.Sh SYNOPSIS -.Nm -.Ar system_var -.Nm -.Fl a -.Nm -.Ar path_var -.Ar pathname -.Nm -.Fl a -.Ar pathname -.Sh DESCRIPTION -The -.Nm -utility writes the current value of a configurable system limit or -option variable to the standard output. -.Pp -The -.Ar system_var -argument specifies the system variable to be queried. -The names of the system variables are from -.Xr sysconf 3 -with the leading -.Dq Li _SC_ -removed. -.Pp -The -.Ar path_var -argument specifies the pathname variable to be queried for the specified -.Ar pathname -argument. -The names of the pathname variables are from -.Xr pathconf 2 -with the leading -.Dq Li _PC_ -removed. -.Pp -When invoked with the option -.Fl a , -.Nm -writes a list of all applicable variables and their values to the -standard output, in the format -.Do -.Va name -= -.Va value -.Dc . -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Xr pathconf 2 , -.Xr confstr 3 , -.Xr limits 3 , -.Xr sysconf 3 -.Sh STANDARDS -The -.Nm -utility conforms to -.St -p1003.2-92 . diff --git a/repos/core/musl/getconf.c b/repos/core/musl/getconf.c deleted file mode 100644 index c4235242..00000000 --- a/repos/core/musl/getconf.c +++ /dev/null @@ -1,338 +0,0 @@ -/*- - * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Mostly rewritten to be used in Alpine Linux (with musl c-library) - * by Timo Teräs. - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct conf_variable { - const char *name; - enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT, UCONSTANT, NUM_TYPES } type; - long value; -}; - -static const struct conf_variable conf_table[] = { -{ "PATH", CONFSTR, _CS_PATH }, - -/* Utility Limit Minimum Values */ -{ "POSIX2_BC_BASE_MAX", CONSTANT, _POSIX2_BC_BASE_MAX }, -{ "POSIX2_BC_DIM_MAX", CONSTANT, _POSIX2_BC_DIM_MAX }, -{ "POSIX2_BC_SCALE_MAX", CONSTANT, _POSIX2_BC_SCALE_MAX }, -{ "POSIX2_BC_STRING_MAX", CONSTANT, _POSIX2_BC_STRING_MAX }, -{ "POSIX2_COLL_WEIGHTS_MAX", CONSTANT, _POSIX2_COLL_WEIGHTS_MAX }, -{ "POSIX2_EXPR_NEST_MAX", CONSTANT, _POSIX2_EXPR_NEST_MAX }, -{ "POSIX2_LINE_MAX", CONSTANT, _POSIX2_LINE_MAX }, -{ "POSIX2_RE_DUP_MAX", CONSTANT, _POSIX2_RE_DUP_MAX }, -{ "POSIX2_VERSION", CONSTANT, _POSIX2_VERSION }, - -/* POSIX.1 Minimum Values */ -{ "_POSIX_AIO_LISTIO_MAX", CONSTANT, _POSIX_AIO_LISTIO_MAX }, -{ "_POSIX_AIO_MAX", CONSTANT, _POSIX_AIO_MAX }, -{ "_POSIX_ARG_MAX", CONSTANT, _POSIX_ARG_MAX }, -{ "_POSIX_CHILD_MAX", CONSTANT, _POSIX_CHILD_MAX }, -{ "_POSIX_LINK_MAX", CONSTANT, _POSIX_LINK_MAX }, -{ "_POSIX_MAX_CANON", CONSTANT, _POSIX_MAX_CANON }, -{ "_POSIX_MAX_INPUT", CONSTANT, _POSIX_MAX_INPUT }, -{ "_POSIX_MQ_OPEN_MAX", CONSTANT, _POSIX_MQ_OPEN_MAX }, -{ "_POSIX_MQ_PRIO_MAX", CONSTANT, _POSIX_MQ_PRIO_MAX }, -{ "_POSIX_NAME_MAX", CONSTANT, _POSIX_NAME_MAX }, -{ "_POSIX_NGROUPS_MAX", CONSTANT, _POSIX_NGROUPS_MAX }, -{ "_POSIX_OPEN_MAX", CONSTANT, _POSIX_OPEN_MAX }, -{ "_POSIX_PATH_MAX", CONSTANT, _POSIX_PATH_MAX }, -{ "_POSIX_PIPE_BUF", CONSTANT, _POSIX_PIPE_BUF }, -{ "_POSIX_SSIZE_MAX", CONSTANT, _POSIX_SSIZE_MAX }, -{ "_POSIX_STREAM_MAX", CONSTANT, _POSIX_STREAM_MAX }, -{ "_POSIX_TZNAME_MAX", CONSTANT, _POSIX_TZNAME_MAX }, - -/* Symbolic Utility Limits */ -{ "BC_BASE_MAX", SYSCONF, _SC_BC_BASE_MAX }, -{ "BC_DIM_MAX", SYSCONF, _SC_BC_DIM_MAX }, -{ "BC_SCALE_MAX", SYSCONF, _SC_BC_SCALE_MAX }, -{ "BC_STRING_MAX", SYSCONF, _SC_BC_STRING_MAX }, -{ "COLL_WEIGHTS_MAX", SYSCONF, _SC_COLL_WEIGHTS_MAX }, -{ "EXPR_NEST_MAX", SYSCONF, _SC_EXPR_NEST_MAX }, -{ "LINE_MAX", SYSCONF, _SC_LINE_MAX }, -{ "RE_DUP_MAX", SYSCONF, _SC_RE_DUP_MAX }, - -/* Optional Facility Configuration Values */ -{ "_POSIX2_C_BIND", SYSCONF, _SC_2_C_BIND }, -{ "POSIX2_C_DEV", SYSCONF, _SC_2_C_DEV }, -{ "POSIX2_CHAR_TERM", SYSCONF, _SC_2_CHAR_TERM }, -{ "POSIX2_FORT_DEV", SYSCONF, _SC_2_FORT_DEV }, -{ "POSIX2_FORT_RUN", SYSCONF, _SC_2_FORT_RUN }, -{ "POSIX2_LOCALEDEF", SYSCONF, _SC_2_LOCALEDEF }, -{ "POSIX2_SW_DEV", SYSCONF, _SC_2_SW_DEV }, -{ "POSIX2_UPE", SYSCONF, _SC_2_UPE }, - -/* POSIX.1 Configurable System Variables */ -{ "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX }, -{ "AIO_MAX", SYSCONF, _SC_AIO_MAX }, -{ "ARG_MAX", SYSCONF, _SC_ARG_MAX }, -{ "CHILD_MAX", SYSCONF, _SC_CHILD_MAX }, -{ "CLK_TCK", SYSCONF, _SC_CLK_TCK }, -{ "MQ_OPEN_MAX", SYSCONF, _SC_MQ_OPEN_MAX }, -{ "MQ_PRIO_MAX", SYSCONF, _SC_MQ_PRIO_MAX }, -{ "NGROUPS_MAX", SYSCONF, _SC_NGROUPS_MAX }, -{ "OPEN_MAX", SYSCONF, _SC_OPEN_MAX }, -{ "STREAM_MAX", SYSCONF, _SC_STREAM_MAX }, -{ "TZNAME_MAX", SYSCONF, _SC_TZNAME_MAX }, -{ "_POSIX_JOB_CONTROL", SYSCONF, _SC_JOB_CONTROL }, -{ "_POSIX_SAVED_IDS", SYSCONF, _SC_SAVED_IDS }, -{ "_POSIX_VERSION", SYSCONF, _SC_VERSION }, - -{ "LINK_MAX", PATHCONF, _PC_LINK_MAX }, -{ "MAX_CANON", PATHCONF, _PC_MAX_CANON }, -{ "MAX_INPUT", PATHCONF, _PC_MAX_INPUT }, -{ "NAME_MAX", PATHCONF, _PC_NAME_MAX }, -{ "PATH_MAX", PATHCONF, _PC_PATH_MAX }, -{ "PIPE_BUF", PATHCONF, _PC_PIPE_BUF }, -{ "_POSIX_CHOWN_RESTRICTED", PATHCONF, _PC_CHOWN_RESTRICTED }, -{ "_POSIX_NO_TRUNC", PATHCONF, _PC_NO_TRUNC }, -{ "_POSIX_VDISABLE", PATHCONF, _PC_VDISABLE }, - -/* POSIX.1b Configurable System Variables */ -{ "PAGESIZE", SYSCONF, _SC_PAGESIZE }, -{ "_POSIX_ASYNCHRONOUS_IO", SYSCONF, _SC_ASYNCHRONOUS_IO }, -{ "_POSIX_FSYNC", SYSCONF, _SC_FSYNC }, -{ "_POSIX_MAPPED_FILES", SYSCONF, _SC_MAPPED_FILES }, -{ "_POSIX_MEMLOCK", SYSCONF, _SC_MEMLOCK }, -{ "_POSIX_MEMLOCK_RANGE", SYSCONF, _SC_MEMLOCK_RANGE }, -{ "_POSIX_MEMORY_PROTECTION", SYSCONF, _SC_MEMORY_PROTECTION }, -{ "_POSIX_MESSAGE_PASSING", SYSCONF, _SC_MESSAGE_PASSING }, -{ "_POSIX_MONOTONIC_CLOCK", SYSCONF, _SC_MONOTONIC_CLOCK }, -{ "_POSIX_PRIORITY_SCHEDULING", SYSCONF, _SC_PRIORITY_SCHEDULING }, -{ "_POSIX_SEMAPHORES", SYSCONF, _SC_SEMAPHORES }, -{ "_POSIX_SHARED_MEMORY_OBJECTS", SYSCONF, _SC_SHARED_MEMORY_OBJECTS }, -{ "_POSIX_SYNCHRONIZED_IO", SYSCONF, _SC_SYNCHRONIZED_IO }, -{ "_POSIX_TIMERS", SYSCONF, _SC_TIMERS }, - -{ "_POSIX_SYNC_IO", PATHCONF, _PC_SYNC_IO }, - -/* POSIX.1c Configurable System Variables */ -{ "LOGIN_NAME_MAX", SYSCONF, _SC_LOGIN_NAME_MAX }, -{ "_POSIX_THREADS", SYSCONF, _SC_THREADS }, - -/* POSIX.1j Configurable System Variables */ -{ "_POSIX_BARRIERS", SYSCONF, _SC_BARRIERS }, -{ "_POSIX_READER_WRITER_LOCKS", SYSCONF, _SC_READER_WRITER_LOCKS }, -{ "_POSIX_SPIN_LOCKS", SYSCONF, _SC_SPIN_LOCKS }, - -/* XPG4.2 Configurable System Variables */ -{ "IOV_MAX", SYSCONF, _SC_IOV_MAX }, -{ "PAGE_SIZE", SYSCONF, _SC_PAGE_SIZE }, -{ "_XOPEN_SHM", SYSCONF, _SC_XOPEN_SHM }, - -/* X/Open CAE Spec. Issue 5 Version 2 Configurable System Variables */ -{ "FILESIZEBITS", PATHCONF, _PC_FILESIZEBITS }, - -/* POSIX.1-2001 XSI Option Group Configurable System Variables */ -{ "ATEXIT_MAX", SYSCONF, _SC_ATEXIT_MAX }, - -/* POSIX.1-2001 TSF Configurable System Variables */ -{ "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX }, -{ "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX }, - -/* Commonly provided extensions */ -{ "_PHYS_PAGES", SYSCONF, _SC_PHYS_PAGES }, -{ "_AVPHYS_PAGES", SYSCONF, _SC_AVPHYS_PAGES }, -{ "_NPROCESSORS_CONF", SYSCONF, _SC_NPROCESSORS_CONF }, -{ "_NPROCESSORS_ONLN", SYSCONF, _SC_NPROCESSORS_ONLN }, - -/* Data type related extensions */ -{ "CHAR_BIT", CONSTANT, CHAR_BIT }, -{ "CHAR_MAX", CONSTANT, CHAR_MAX }, -{ "CHAR_MIN", CONSTANT, CHAR_MIN }, -{ "INT_MAX", CONSTANT, INT_MAX }, -{ "INT_MIN", CONSTANT, INT_MIN }, -{ "LONG_BIT", CONSTANT, LONG_BIT }, -{ "LONG_MAX", CONSTANT, LONG_MAX }, -{ "LONG_MIN", CONSTANT, LONG_MIN }, -{ "SCHAR_MAX", CONSTANT, SCHAR_MAX }, -{ "SCHAR_MIN", CONSTANT, SCHAR_MIN }, -{ "SHRT_MAX", CONSTANT, SHRT_MAX }, -{ "SHRT_MIN", CONSTANT, SHRT_MIN }, -{ "SSIZE_MAX", CONSTANT, SSIZE_MAX }, -{ "UCHAR_MAX", UCONSTANT, (long) UCHAR_MAX }, -{ "UINT_MAX", UCONSTANT, (long) UINT_MAX }, -{ "ULONG_MAX", UCONSTANT, (long) ULONG_MAX }, -{ "USHRT_MAX", UCONSTANT, (long) USHRT_MAX }, -{ "WORD_BIT", CONSTANT, WORD_BIT }, - -{ NULL, CONSTANT, 0L } -}; - -static int all = 0; - -static void usage(const char *p) -{ - (void)fprintf(stderr, "Usage: %s system_var\n\t%s -a\n" - "\t%s path_var pathname\n\t%s -a pathname\n", p, p, p, p); - exit(EXIT_FAILURE); -} - -static void print_long(const char *name, long val) -{ - if (all) printf("%s = %ld\n", name, val); - else printf("%ld\n", val); -} - -static void print_ulong(const char *name, unsigned long val) -{ - if (all) printf("%s = %lu\n", name, val); - else printf("%lu\n", val); -} - -static void print_string(const char *name, const char *val) -{ - if (all) printf("%s = %s\n", name, val); - else printf("%s\n", val); -} - -static int print_constant(const struct conf_variable *cp, const char *pathname) -{ - print_long(cp->name, cp->value); - return 0; -} - -static int print_uconstant(const struct conf_variable *cp, const char *pathname) -{ - print_ulong(cp->name, (unsigned long) cp->value); - return 0; -} - -static int print_sysconf(const struct conf_variable *cp, const char *pathname) -{ - long val; - - errno = 0; - if ((val = sysconf((int)cp->value)) == -1) { - if (errno != 0) err(EXIT_FAILURE, "sysconf(%ld)", cp->value); - return -1; - } - print_long(cp->name, val); - return 0; -} - -static int print_confstr(const struct conf_variable *cp, const char *pathname) -{ - size_t len; - char *val; - - errno = 0; - if ((len = confstr((int)cp->value, NULL, 0)) == 0) goto error; - if ((val = malloc(len)) == NULL) err(EXIT_FAILURE, "Can't allocate %zu bytes", len); - errno = 0; - if (confstr((int)cp->value, val, len) == 0) goto error; - print_string(cp->name, val); - free(val); - return 0; -error: - if (errno != EINVAL) err(EXIT_FAILURE, "confstr(%ld)", cp->value); - return -1; -} - -static int print_pathconf(const struct conf_variable *cp, const char *pathname) -{ - long val; - - errno = 0; - if ((val = pathconf(pathname, (int)cp->value)) == -1) { - if (all && errno == EINVAL) return 0; - if (errno != 0) err(EXIT_FAILURE, "pathconf(%s, %ld)", pathname, cp->value); - return -1; - } - print_long(cp->name, val); - return 0; -} - -typedef int (*handler_t)(const struct conf_variable *cp, const char *pathname); -static const handler_t type_handlers[NUM_TYPES] = { - [SYSCONF] = print_sysconf, - [CONFSTR] = print_confstr, - [PATHCONF] = print_pathconf, - [CONSTANT] = print_constant, - [UCONSTANT] = print_uconstant, -}; - -int main(int argc, char **argv) -{ - const char *progname = argv[0]; - const struct conf_variable *cp; - const char *varname, *pathname; - int ch, found = 0; - - (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "a")) != -1) { - switch (ch) { - case 'a': - all = 1; - break; - case '?': - default: - usage(progname); - } - } - argc -= optind; - argv += optind; - - if (!all) { - if (argc == 0) - usage(progname); - varname = argv[0]; - argc--; - argv++; - } else - varname = NULL; - - if (argc > 1) - usage(progname); - pathname = argv[0]; /* may be NULL */ - - for (cp = conf_table; cp->name != NULL; cp++) { - if (!all && strcmp(varname, cp->name) != 0) continue; - if ((cp->type == PATHCONF) == (pathname != NULL)) { - if (type_handlers[cp->type](cp, pathname) < 0) - print_string(cp->name, "undefined"); - found = 1; - } else if (!all) - errx(EXIT_FAILURE, "%s: invalid variable type", cp->name); - } - if (!all && !found) errx(EXIT_FAILURE, "%s: unknown variable", varname); - (void)fflush(stdout); - return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS; -} diff --git a/repos/core/musl/getent.1 b/repos/core/musl/getent.1 deleted file mode 100644 index 0e07058e..00000000 --- a/repos/core/musl/getent.1 +++ /dev/null @@ -1,145 +0,0 @@ -.\" $NetBSD: getent.1,v 1.23 2011/10/11 20:39:40 wiz Exp $ -.\" -.\" Copyright (c) 2004 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Luke Mewburn. -.\" -.\" 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. -.\" -.Dd October 11, 2011 -.Dt GETENT 1 -.Os -.Sh NAME -.Nm getent -.Nd get entries from administrative databases -.Sh SYNOPSIS -.Nm getent -.Ar database -.Op Ar key ... -.Nm getcap -.Ar database -.Op Ar key ... -.Sh DESCRIPTION -The -.Nm -program retrieves and displays entries from the administrative -database specified by -.Ar database , -using the lookup order specified in -.Xr nsswitch.conf 5 . -The display format for a given -.Ar database -is as per the -.Dq traditional -file format for that database. -.Pp -.Ar database -may be one of: -.Bl -column "protocols" "user:passwd:uid:gid:gecos:home_dir:shell" -offset indent -compact -.It Sy Database Ta Sy Display format -.It disktab Ta entry -.It ethers Ta address name -.It gettytab Ta entry -.It group Ta group:passwd:gid:[member[,member]...] -.It hosts Ta address name [alias ...] -.It netgroup Ta (host,user,domain) [...] -.It networks Ta name network [alias ...] -.It passwd Ta user:passwd:uid:gid:gecos:home_dir:shell -.It printcap Ta entry -.It protocols Ta name protocol [alias ...] -.It rpc Ta name number [alias ...] -.It services Ta name port/protocol [alias ...] -.It shells Ta /path/to/shell -.El -.Pp -If one or more -.Ar key -arguments are provided, they will be looked up in -.Ar database -using the appropriate function. -For example, -.Sy passwd -supports a numeric UID or user name; -.Sy hosts -supports an IPv4 address, IPv6 address, or host name; -and -.Sy services -supports a service name, service name/protocol name, numeric port, or -numeric port/protocol name. -.Pp -If no -.Ar key -is provided and -.Ar database -supports enumeration, all entries for -.Ar database -will be retrieved using the appropriate enumeration function and printed. -.Pp -For -.Xr cgetcap 3 -style databases -.Sy ( disktab , -.Sy printcap ) -specifying a key, lists the entry for that key, and specifying more arguments -after the key are used as fields in that key, and only the values of the keys -are returned. -For boolean keys -.Dv true -is returned if the key is found. -If a key is not found, then -.Dv false -is always -returned. -.Sh DIAGNOSTICS -.Nm -exits 0 on success, -1 if there was an error in the command syntax, -2 if one of the specified key names was not found in -.Ar database , -or 3 if there is no support for enumeration on -.Ar database . -.Sh SEE ALSO -.Xr cgetcap 3 , -.Xr disktab 5 , -.Xr ethers 5 , -.Xr gettytab 5 , -.Xr group 5 , -.Xr hosts 5 , -.Xr networks 5 , -.Xr nsswitch.conf 5 , -.Xr passwd 5 , -.Xr printcap 5 , -.Xr protocols 5 , -.Xr rpc 5 , -.Xr services 5 , -.Xr shells 5 -.Sh HISTORY -A -.Nm -command appeared in -.Nx 3.0 . -It was based on the command of the same name in -.Tn Solaris -and -.Tn Linux . diff --git a/repos/core/musl/getent.c b/repos/core/musl/getent.c deleted file mode 100644 index 939b46c0..00000000 --- a/repos/core/musl/getent.c +++ /dev/null @@ -1,437 +0,0 @@ -/*- - * Copyright (c) 2004-2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * Timo Teräs cleaned up the code for use in Alpine Linux with musl libc. - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -enum { - RV_OK = 0, - RV_USAGE = 1, - RV_NOTFOUND = 2, - RV_NOENUM = 3 -}; - -static int usage(const char *); - -static int parsenum(const char *word, unsigned long *result) -{ - unsigned long num; - char *ep; - - if (!isdigit((unsigned char)word[0])) - return 0; - errno = 0; - num = strtoul(word, &ep, 10); - if (num == ULONG_MAX && errno == ERANGE) - return 0; - if (*ep != '\0') - return 0; - *result = num; - return 1; -} - -/* - * printfmtstrings -- - * vprintf(format, ...), - * then the aliases (beginning with prefix, separated by sep), - * then a newline - */ -__attribute__ ((format (printf, 4, 5))) -static void printfmtstrings(char *strings[], const char *prefix, const char *sep, - const char *fmt, ...) -{ - va_list ap; - const char *curpref; - size_t i; - - va_start(ap, fmt); - (void)vprintf(fmt, ap); - va_end(ap); - - curpref = prefix; - for (i = 0; strings[i] != NULL; i++) { - (void)printf("%s%s", curpref, strings[i]); - curpref = sep; - } - (void)printf("\n"); -} - -static int ethers(int argc, char *argv[]) -{ - char hostname[MAXHOSTNAMELEN + 1], *hp; - struct ether_addr ea, *eap; - int i, rv; - - if (argc == 2) { - warnx("Enumeration not supported on ethers"); - return RV_NOENUM; - } - - rv = RV_OK; - for (i = 2; i < argc; i++) { - if ((eap = ether_aton(argv[i])) == NULL) { - eap = &ea; - hp = argv[i]; - if (ether_hostton(hp, eap) != 0) { - rv = RV_NOTFOUND; - break; - } - } else { - hp = hostname; - if (ether_ntohost(hp, eap) != 0) { - rv = RV_NOTFOUND; - break; - } - } - (void)printf("%-17s %s\n", ether_ntoa(eap), hp); - } - return rv; -} - -static void groupprint(const struct group *gr) -{ - printfmtstrings(gr->gr_mem, ":", ",", "%s:%s:%u", - gr->gr_name, gr->gr_passwd, gr->gr_gid); -} - -static int group(int argc, char *argv[]) -{ - struct group *gr; - unsigned long id; - int i, rv; - - rv = RV_OK; - if (argc == 2) { - while ((gr = getgrent()) != NULL) - groupprint(gr); - } else { - for (i = 2; i < argc; i++) { - if (parsenum(argv[i], &id)) - gr = getgrgid((gid_t)id); - else - gr = getgrnam(argv[i]); - if (gr == NULL) { - rv = RV_NOTFOUND; - break; - } - groupprint(gr); - } - } - endgrent(); - return rv; -} - -static void hostsprint(const struct hostent *he) -{ - char buf[INET6_ADDRSTRLEN]; - - if (inet_ntop(he->h_addrtype, he->h_addr, buf, sizeof(buf)) == NULL) - (void)strlcpy(buf, "# unknown", sizeof(buf)); - printfmtstrings(he->h_aliases, " ", " ", "%-16s %s", buf, he->h_name); -} - -static int hosts(int argc, char *argv[]) -{ - struct hostent *he; - char addr[IN6ADDRSZ]; - int i, rv; - - sethostent(1); - rv = RV_OK; - if (argc == 2) { - while ((he = gethostent()) != NULL) - hostsprint(he); - } else { - for (i = 2; i < argc; i++) { - if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0) - he = gethostbyaddr(addr, IN6ADDRSZ, AF_INET6); - else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0) - he = gethostbyaddr(addr, INADDRSZ, AF_INET); - else - he = gethostbyname(argv[i]); - if (he == NULL) { - rv = RV_NOTFOUND; - break; - } - hostsprint(he); - } - } - endhostent(); - return rv; -} - -static void networksprint(const struct netent *ne) -{ - char buf[INET6_ADDRSTRLEN]; - struct in_addr ianet; - - ianet = inet_makeaddr(ne->n_net, 0); - if (inet_ntop(ne->n_addrtype, &ianet, buf, sizeof(buf)) == NULL) - (void)strlcpy(buf, "# unknown", sizeof(buf)); - printfmtstrings(ne->n_aliases, " ", " ", "%-16s %s", ne->n_name, buf); -} - -static int networks(int argc, char *argv[]) -{ - struct netent *ne; - in_addr_t net; - int i, rv; - - setnetent(1); - rv = RV_OK; - if (argc == 2) { - while ((ne = getnetent()) != NULL) - networksprint(ne); - } else { - for (i = 2; i < argc; i++) { - net = inet_network(argv[i]); - if (net != INADDR_NONE) - ne = getnetbyaddr(net, AF_INET); - else - ne = getnetbyname(argv[i]); - if (ne == NULL) { - rv = RV_NOTFOUND; - break; - } - networksprint(ne); - } - } - endnetent(); - return rv; -} - -static void passwdprint(struct passwd *pw) -{ - (void)printf("%s:%s:%u:%u:%s:%s:%s\n", - pw->pw_name, pw->pw_passwd, pw->pw_uid, - pw->pw_gid, pw->pw_gecos, pw->pw_dir, pw->pw_shell); -} - -static int passwd(int argc, char *argv[]) -{ - struct passwd *pw; - unsigned long id; - int i, rv; - - rv = RV_OK; - if (argc == 2) { - while ((pw = getpwent()) != NULL) - passwdprint(pw); - } else { - for (i = 2; i < argc; i++) { - if (parsenum(argv[i], &id)) - pw = getpwuid((uid_t)id); - else - pw = getpwnam(argv[i]); - if (pw == NULL) { - rv = RV_NOTFOUND; - break; - } - passwdprint(pw); - } - } - endpwent(); - return rv; -} - -static void protocolsprint(struct protoent *pe) -{ - printfmtstrings(pe->p_aliases, " ", " ", - "%-16s %5d", pe->p_name, pe->p_proto); -} - -static int protocols(int argc, char *argv[]) -{ - struct protoent *pe; - unsigned long id; - int i, rv; - - setprotoent(1); - rv = RV_OK; - if (argc == 2) { - while ((pe = getprotoent()) != NULL) - protocolsprint(pe); - } else { - for (i = 2; i < argc; i++) { - if (parsenum(argv[i], &id)) - pe = getprotobynumber((int)id); - else - pe = getprotobyname(argv[i]); - if (pe == NULL) { - rv = RV_NOTFOUND; - break; - } - protocolsprint(pe); - } - } - endprotoent(); - return rv; -} - -static void servicesprint(struct servent *se) -{ - printfmtstrings(se->s_aliases, " ", " ", - "%-16s %5d/%s", - se->s_name, ntohs(se->s_port), se->s_proto); - -} - -static int services(int argc, char *argv[]) -{ - struct servent *se; - unsigned long id; - char *proto; - int i, rv; - - setservent(1); - rv = RV_OK; - if (argc == 2) { - while ((se = getservent()) != NULL) - servicesprint(se); - } else { - for (i = 2; i < argc; i++) { - proto = strchr(argv[i], '/'); - if (proto != NULL) - *proto++ = '\0'; - if (parsenum(argv[i], &id)) - se = getservbyport(htons(id), proto); - else - se = getservbyname(argv[i], proto); - if (se == NULL) { - rv = RV_NOTFOUND; - break; - } - servicesprint(se); - } - } - endservent(); - return rv; -} - -static int shells(int argc, char *argv[]) -{ - const char *sh; - int i, rv; - - setusershell(); - rv = RV_OK; - if (argc == 2) { - while ((sh = getusershell()) != NULL) - (void)printf("%s\n", sh); - } else { - for (i = 2; i < argc; i++) { - setusershell(); - while ((sh = getusershell()) != NULL) { - if (strcmp(sh, argv[i]) == 0) { - (void)printf("%s\n", sh); - break; - } - } - if (sh == NULL) { - rv = RV_NOTFOUND; - break; - } - } - } - endusershell(); - return rv; -} - -static struct getentdb { - const char *name; - int (*callback)(int, char *[]); -} databases[] = { - { "ethers", ethers, }, - { "group", group, }, - { "hosts", hosts, }, - { "networks", networks, }, - { "passwd", passwd, }, - { "protocols", protocols, }, - { "services", services, }, - { "shells", shells, }, - - { NULL, NULL, }, -}; - -static int usage(const char *arg0) -{ - struct getentdb *curdb; - size_t i; - - (void)fprintf(stderr, "Usage: %s database [key ...]\n", arg0); - (void)fprintf(stderr, "\tdatabase may be one of:"); - for (i = 0, curdb = databases; curdb->name != NULL; curdb++, i++) { - if (i % 7 == 0) - (void)fputs("\n\t\t", stderr); - (void)fprintf(stderr, "%s%s", i % 7 == 0 ? "" : " ", - curdb->name); - } - (void)fprintf(stderr, "\n"); - exit(RV_USAGE); - /* NOTREACHED */ -} - -int -main(int argc, char *argv[]) -{ - struct getentdb *curdb; - - if (argc < 2) - usage(argv[0]); - for (curdb = databases; curdb->name != NULL; curdb++) - if (strcmp(curdb->name, argv[1]) == 0) - return (*curdb->callback)(argc, argv); - - warn("Unknown database `%s'", argv[1]); - usage(argv[0]); - /* NOTREACHED */ -} diff --git a/repos/core/musl/iconv.c b/repos/core/musl/iconv.c deleted file mode 100644 index f5d5ce2a..00000000 --- a/repos/core/musl/iconv.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * iconv.c - * Implementation of SUSv4 XCU iconv utility - * Copyright © 2011 Rich Felker - * Licensed under the terms of the GNU General Public License, v2 or later - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - const char *from=0, *to=0; - int b; - iconv_t cd; - char buf[BUFSIZ]; - char outbuf[BUFSIZ*4]; - char *in, *out; - size_t inb; - size_t l; - size_t unitsize=0; - int err=0; - FILE *f; - - while ((b = getopt(argc, argv, "f:t:csl")) != EOF) switch(b) { - case 'l': - puts("UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF32-LE, UCS-2BE, UCS-2LE, WCHAR_T,\n" - "US_ASCII, ISO8859-1, ISO8859-2, ISO8859-3, ISO8859-4, ISO8859-5,\n" - "ISO8859-6, ISO8859-7, ..."); - exit(0); - case 'c': case 's': break; - case 'f': from=optarg; break; - case 't': to=optarg; break; - default: exit(1); - } - - if (!from || !to) { - setlocale(LC_CTYPE, ""); - if (!to) to = nl_langinfo(CODESET); - if (!from) from = nl_langinfo(CODESET); - } - cd = iconv_open(to, from); - if (cd == (iconv_t)-1) { - if (iconv_open(to, "WCHAR_T") == (iconv_t)-1) - fprintf(stderr, "iconv: destination charset %s: ", to); - else - fprintf(stderr, "iconv: source charset %s: ", from); - perror(""); - exit(1); - } - if (optind == argc) argv[argc++] = "-"; - - for (; optind < argc; optind++) { - if (argv[optind][0]=='-' && !argv[optind][1]) { - f = stdin; - argv[optind] = "(stdin)"; - } else if (!(f = fopen(argv[optind], "rb"))) { - fprintf(stderr, "iconv: %s: ", argv[optind]); - perror(""); - err = 1; - continue; - } - inb = 0; - for (;;) { - in = buf; - out = outbuf; - l = fread(buf+inb, 1, sizeof(buf)-inb, f); - inb += l; - if (!inb) break; - if (iconv(cd, &in, &inb, &out, (size_t [1]){sizeof outbuf})==-1 - && errno == EILSEQ) { - if (!unitsize) { - wchar_t wc='0'; - char dummy[4], *dummyp=dummy; - iconv_t cd2 = iconv_open(from, "WCHAR_T"); - if (cd == (iconv_t)-1) { - unitsize = 1; - } else { - iconv(cd2, - (char *[1]){(char *)&wc}, - (size_t[1]){1}, - &dummyp, (size_t[1]){4}); - unitsize = dummyp-dummy; - if (!unitsize) unitsize=1; - } - } - inb-=unitsize; - in+=unitsize; - } - if (inb && !l && errno==EINVAL) break; - if (out>outbuf && !fwrite(outbuf, out-outbuf, 1, stdout)) { - perror("iconv: write error"); - exit(1); - } - if (inb) memmove(buf, in, inb); - } - if (ferror(f)) { - fprintf(stderr, "iconv: %s: ", argv[optind]); - perror(""); - err = 1; - } - } - return err; -} diff --git a/repos/core/musl/queue.h b/repos/core/musl/queue.h deleted file mode 100644 index a38499a2..00000000 --- a/repos/core/musl/queue.h +++ /dev/null @@ -1,846 +0,0 @@ -/* $NetBSD: queue.h,v 1.70 2015/11/02 15:21:23 christos Exp $ */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - */ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -/* - * This file defines five types of data structures: singly-linked lists, - * lists, simple queues, tail queues, and circular queues. - * - * A singly-linked list is headed by a single forward pointer. The - * elements are singly linked for minimum space and pointer manipulation - * overhead at the expense of O(n) removal for arbitrary elements. New - * elements can be added to the list after an existing element or at the - * head of the list. Elements being removed from the head of the list - * should use the explicit macro for this purpose for optimum - * efficiency. A singly-linked list may only be traversed in the forward - * direction. Singly-linked lists are ideal for applications with large - * datasets and few or no removals or for implementing a LIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A simple queue is headed by a pair of pointers, one the head of the - * list and the other to the tail of the list. The elements are singly - * linked to save space, so elements can only be removed from the - * head of the list. New elements can be added to the list after - * an existing element, at the head of the list, or at the end of the - * list. A simple queue may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * A circle queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or after - * an existing element, at the head of the list, or at the end of the list. - * A circle queue may be traversed in either direction, but has a more - * complex end of list detection. - * - * For details on the use of these macros, see the queue(3) manual page. - */ - -/* - * Include the definition of NULL only on NetBSD because sys/null.h - * is not available elsewhere. This conditional makes the header - * portable and it can simply be dropped verbatim into any system. - * The caveat is that on other systems some other header - * must provide NULL before the macros can be used. - */ -#ifdef __NetBSD__ -#include -#endif - -#if defined(QUEUEDEBUG) -# if defined(_KERNEL) -# define QUEUEDEBUG_ABORT(...) panic(__VA_ARGS__) -# else -# include -# define QUEUEDEBUG_ABORT(...) err(1, __VA_ARGS__) -# endif -#endif - -/* - * Singly-linked List definitions. - */ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List access methods. - */ -#define SLIST_FIRST(head) ((head)->slh_first) -#define SLIST_END(head) NULL -#define SLIST_EMPTY(head) ((head)->slh_first == NULL) -#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) - -#define SLIST_FOREACH(var, head, field) \ - for((var) = (head)->slh_first; \ - (var) != SLIST_END(head); \ - (var) = (var)->field.sle_next) - -#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) != SLIST_END(head) && \ - ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -/* - * Singly-linked List functions. - */ -#define SLIST_INIT(head) do { \ - (head)->slh_first = SLIST_END(head); \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE_AFTER(slistelm, field) do { \ - (slistelm)->field.sle_next = \ - SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (/*CONSTCOND*/0) - -#define SLIST_REMOVE(head, elm, type, field) do { \ - if ((head)->slh_first == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - struct type *curelm = (head)->slh_first; \ - while(curelm->field.sle_next != (elm)) \ - curelm = curelm->field.sle_next; \ - curelm->field.sle_next = \ - curelm->field.sle_next->field.sle_next; \ - } \ -} while (/*CONSTCOND*/0) - - -/* - * List definitions. - */ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define LIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List access methods. - */ -#define LIST_FIRST(head) ((head)->lh_first) -#define LIST_END(head) NULL -#define LIST_EMPTY(head) ((head)->lh_first == LIST_END(head)) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) - -#define LIST_FOREACH(var, head, field) \ - for ((var) = ((head)->lh_first); \ - (var) != LIST_END(head); \ - (var) = ((var)->field.le_next)) - -#define LIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) != LIST_END(head) && \ - ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_MOVE(head1, head2) do { \ - LIST_INIT((head2)); \ - if (!LIST_EMPTY((head1))) { \ - (head2)->lh_first = (head1)->lh_first; \ - LIST_INIT((head1)); \ - } \ -} while (/*CONSTCOND*/0) - -/* - * List functions. - */ -#if defined(QUEUEDEBUG) -#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ - if ((head)->lh_first && \ - (head)->lh_first->field.le_prev != &(head)->lh_first) \ - QUEUEDEBUG_ABORT("LIST_INSERT_HEAD %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_LIST_OP(elm, field) \ - if ((elm)->field.le_next && \ - (elm)->field.le_next->field.le_prev != \ - &(elm)->field.le_next) \ - QUEUEDEBUG_ABORT("LIST_* forw %p %s:%d", (elm), \ - __FILE__, __LINE__); \ - if (*(elm)->field.le_prev != (elm)) \ - QUEUEDEBUG_ABORT("LIST_* back %p %s:%d", (elm), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ - (elm)->field.le_next = (void *)1L; \ - (elm)->field.le_prev = (void *)1L; -#else -#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) -#define QUEUEDEBUG_LIST_OP(elm, field) -#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) -#endif - -#define LIST_INIT(head) do { \ - (head)->lh_first = LIST_END(head); \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ - QUEUEDEBUG_LIST_OP((listelm), field) \ - if (((elm)->field.le_next = (listelm)->field.le_next) != \ - LIST_END(head)) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ - QUEUEDEBUG_LIST_OP((listelm), field) \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define LIST_INSERT_HEAD(head, elm, field) do { \ - QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ - if (((elm)->field.le_next = (head)->lh_first) != LIST_END(head))\ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (/*CONSTCOND*/0) - -#define LIST_REMOVE(elm, field) do { \ - QUEUEDEBUG_LIST_OP((elm), field) \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ - QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ -} while (/*CONSTCOND*/0) - -#define LIST_REPLACE(elm, elm2, field) do { \ - if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ - (elm2)->field.le_next->field.le_prev = \ - &(elm2)->field.le_next; \ - (elm2)->field.le_prev = (elm)->field.le_prev; \ - *(elm2)->field.le_prev = (elm2); \ - QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ -} while (/*CONSTCOND*/0) - -/* - * Simple queue definitions. - */ -#define SIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define SIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define SIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue access methods. - */ -#define SIMPLEQ_FIRST(head) ((head)->sqh_first) -#define SIMPLEQ_END(head) NULL -#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head)) -#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - -#define SIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var) != SIMPLEQ_END(head); \ - (var) = ((var)->field.sqe_next)) - -#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->sqh_first); \ - (var) != SIMPLEQ_END(head) && \ - ((next = ((var)->field.sqe_next)), 1); \ - (var) = (next)) - -/* - * Simple queue functions. - */ -#define SIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ - if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ - == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - SIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_CONCAT(head1, head2) do { \ - if (!SIMPLEQ_EMPTY((head2))) { \ - *(head1)->sqh_last = (head2)->sqh_first; \ - (head1)->sqh_last = (head2)->sqh_last; \ - SIMPLEQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define SIMPLEQ_LAST(head, type, field) \ - (SIMPLEQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->sqh_last) - offsetof(struct type, field)))) - -/* - * Tail queue definitions. - */ -#define _TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last; /* addr of last next element */ \ -} -#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) - -#define TAILQ_HEAD_INITIALIZER(head) \ - { TAILQ_END(head), &(head).tqh_first } - -#define _TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ -} -#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) - -/* - * Tail queue access methods. - */ -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_END(head) (NULL) -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_LAST(head, headname) \ - (*(((struct headname *)(void *)((head)->tqh_last))->tqh_last)) -#define TAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)(void *)((elm)->field.tqe_prev))->tqh_last)) -#define TAILQ_EMPTY(head) (TAILQ_FIRST(head) == TAILQ_END(head)) - - -#define TAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->tqh_first); \ - (var) != TAILQ_END(head); \ - (var) = ((var)->field.tqe_next)) - -#define TAILQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->tqh_first); \ - (var) != TAILQ_END(head) && \ - ((next) = TAILQ_NEXT(var, field), 1); (var) = (next)) - -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) != TAILQ_END(head); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) != TAILQ_END(head) && \ - ((prev) = TAILQ_PREV((var), headname, field), 1); (var) = (prev)) - -/* - * Tail queue functions. - */ -#if defined(QUEUEDEBUG) -#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ - if ((head)->tqh_first && \ - (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ - QUEUEDEBUG_ABORT("TAILQ_INSERT_HEAD %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ - if (*(head)->tqh_last != NULL) \ - QUEUEDEBUG_ABORT("TAILQ_INSERT_TAIL %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_OP(elm, field) \ - if ((elm)->field.tqe_next && \ - (elm)->field.tqe_next->field.tqe_prev != \ - &(elm)->field.tqe_next) \ - QUEUEDEBUG_ABORT("TAILQ_* forw %p %s:%d", (elm), \ - __FILE__, __LINE__); \ - if (*(elm)->field.tqe_prev != (elm)) \ - QUEUEDEBUG_ABORT("TAILQ_* back %p %s:%d", (elm), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ - if ((elm)->field.tqe_next == NULL && \ - (head)->tqh_last != &(elm)->field.tqe_next) \ - QUEUEDEBUG_ABORT("TAILQ_PREREMOVE head %p elm %p %s:%d",\ - (head), (elm), __FILE__, __LINE__); -#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ - (elm)->field.tqe_next = (void *)1L; \ - (elm)->field.tqe_prev = (void *)1L; -#else -#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) -#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) -#define QUEUEDEBUG_TAILQ_OP(elm, field) -#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) -#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) -#endif - -#define TAILQ_INIT(head) do { \ - (head)->tqh_first = TAILQ_END(head); \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ - QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ - if (((elm)->field.tqe_next = (head)->tqh_first) != TAILQ_END(head))\ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ - QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ - (elm)->field.tqe_next = TAILQ_END(head); \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - QUEUEDEBUG_TAILQ_OP((listelm), field) \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != \ - TAILQ_END(head)) \ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - QUEUEDEBUG_TAILQ_OP((listelm), field) \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define TAILQ_REMOVE(head, elm, field) do { \ - QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ - QUEUEDEBUG_TAILQ_OP((elm), field) \ - if (((elm)->field.tqe_next) != TAILQ_END(head)) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ - QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ -} while (/*CONSTCOND*/0) - -#define TAILQ_REPLACE(head, elm, elm2, field) do { \ - if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != \ - TAILQ_END(head)) \ - (elm2)->field.tqe_next->field.tqe_prev = \ - &(elm2)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm2)->field.tqe_next; \ - (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ - *(elm2)->field.tqe_prev = (elm2); \ - QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ -} while (/*CONSTCOND*/0) - -#define TAILQ_CONCAT(head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -/* - * Singly-linked Tail queue declarations. - */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first; /* first element */ \ - struct type **stqh_last; /* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -/* - * Singly-linked Tail queue access methods. - */ -#define STAILQ_FIRST(head) ((head)->stqh_first) -#define STAILQ_END(head) NULL -#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) -#define STAILQ_EMPTY(head) (STAILQ_FIRST(head) == STAILQ_END(head)) - -/* - * Singly-linked Tail queue functions. - */ -#define STAILQ_INIT(head) do { \ - (head)->stqh_first = NULL; \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (head)->stqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.stqe_next = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &(elm)->field.stqe_next; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (listelm)->field.stqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ - (head)->stqh_last = &(head)->stqh_first; \ -} while (/*CONSTCOND*/0) - -#define STAILQ_REMOVE(head, elm, type, field) do { \ - if ((head)->stqh_first == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->stqh_first; \ - while (curelm->field.stqe_next != (elm)) \ - curelm = curelm->field.stqe_next; \ - if ((curelm->field.stqe_next = \ - curelm->field.stqe_next->field.stqe_next) == NULL) \ - (head)->stqh_last = &(curelm)->field.stqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define STAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->stqh_first); \ - (var); \ - (var) = ((var)->field.stqe_next)) - -#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_CONCAT(head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define STAILQ_LAST(head, type, field) \ - (STAILQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->stqh_last) - offsetof(struct type, field)))) - - -#ifndef _KERNEL -/* - * Circular queue definitions. Do not use. We still keep the macros - * for compatibility but because of pointer aliasing issues their use - * is discouraged! - */ - -/* - * __launder_type(): We use this ugly hack to work around the the compiler - * noticing that two types may not alias each other and elide tests in code. - * We hit this in the CIRCLEQ macros when comparing 'struct name *' and - * 'struct type *' (see CIRCLEQ_HEAD()). Modern compilers (such as GCC - * 4.8) declare these comparisons as always false, causing the code to - * not run as designed. - * - * This hack is only to be used for comparisons and thus can be fully const. - * Do not use for assignment. - * - * If we ever choose to change the ABI of the CIRCLEQ macros, we could fix - * this by changing the head/tail sentinal values, but see the note above - * this one. - */ -static __inline const void * __launder_type(const void *); -static __inline const void * -__launder_type(const void *__x) -{ - __asm __volatile("" : "+r" (__x)); - return __x; -} - -#if defined(QUEUEDEBUG) -#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \ - if ((head)->cqh_first != CIRCLEQ_ENDC(head) && \ - (head)->cqh_first->field.cqe_prev != CIRCLEQ_ENDC(head)) \ - QUEUEDEBUG_ABORT("CIRCLEQ head forw %p %s:%d", (head), \ - __FILE__, __LINE__); \ - if ((head)->cqh_last != CIRCLEQ_ENDC(head) && \ - (head)->cqh_last->field.cqe_next != CIRCLEQ_ENDC(head)) \ - QUEUEDEBUG_ABORT("CIRCLEQ head back %p %s:%d", (head), \ - __FILE__, __LINE__); -#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \ - if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) { \ - if ((head)->cqh_last != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm last %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } else { \ - if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm forw %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } \ - if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) { \ - if ((head)->cqh_first != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm first %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } else { \ - if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \ - QUEUEDEBUG_ABORT("CIRCLEQ elm prev %p %s:%d", \ - (elm), __FILE__, __LINE__); \ - } -#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \ - (elm)->field.cqe_next = (void *)1L; \ - (elm)->field.cqe_prev = (void *)1L; -#else -#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) -#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) -#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) -#endif - -#define CIRCLEQ_HEAD(name, type) \ -struct name { \ - struct type *cqh_first; /* first element */ \ - struct type *cqh_last; /* last element */ \ -} - -#define CIRCLEQ_HEAD_INITIALIZER(head) \ - { CIRCLEQ_END(&head), CIRCLEQ_END(&head) } - -#define CIRCLEQ_ENTRY(type) \ -struct { \ - struct type *cqe_next; /* next element */ \ - struct type *cqe_prev; /* previous element */ \ -} - -/* - * Circular queue functions. - */ -#define CIRCLEQ_INIT(head) do { \ - (head)->cqh_first = CIRCLEQ_END(head); \ - (head)->cqh_last = CIRCLEQ_END(head); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ - (elm)->field.cqe_next = (listelm)->field.cqe_next; \ - (elm)->field.cqe_prev = (listelm); \ - if ((listelm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ - (head)->cqh_last = (elm); \ - else \ - (listelm)->field.cqe_next->field.cqe_prev = (elm); \ - (listelm)->field.cqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ - (elm)->field.cqe_next = (listelm); \ - (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ - if ((listelm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ - (head)->cqh_first = (elm); \ - else \ - (listelm)->field.cqe_prev->field.cqe_next = (elm); \ - (listelm)->field.cqe_prev = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - (elm)->field.cqe_next = (head)->cqh_first; \ - (elm)->field.cqe_prev = CIRCLEQ_END(head); \ - if ((head)->cqh_last == CIRCLEQ_ENDC(head)) \ - (head)->cqh_last = (elm); \ - else \ - (head)->cqh_first->field.cqe_prev = (elm); \ - (head)->cqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - (elm)->field.cqe_next = CIRCLEQ_END(head); \ - (elm)->field.cqe_prev = (head)->cqh_last; \ - if ((head)->cqh_first == CIRCLEQ_ENDC(head)) \ - (head)->cqh_first = (elm); \ - else \ - (head)->cqh_last->field.cqe_next = (elm); \ - (head)->cqh_last = (elm); \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_REMOVE(head, elm, field) do { \ - QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ - QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \ - if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ - (head)->cqh_last = (elm)->field.cqe_prev; \ - else \ - (elm)->field.cqe_next->field.cqe_prev = \ - (elm)->field.cqe_prev; \ - if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ - (head)->cqh_first = (elm)->field.cqe_next; \ - else \ - (elm)->field.cqe_prev->field.cqe_next = \ - (elm)->field.cqe_next; \ - QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \ -} while (/*CONSTCOND*/0) - -#define CIRCLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->cqh_first); \ - (var) != CIRCLEQ_ENDC(head); \ - (var) = ((var)->field.cqe_next)) - -#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ - for ((var) = ((head)->cqh_last); \ - (var) != CIRCLEQ_ENDC(head); \ - (var) = ((var)->field.cqe_prev)) - -/* - * Circular queue access methods. - */ -#define CIRCLEQ_FIRST(head) ((head)->cqh_first) -#define CIRCLEQ_LAST(head) ((head)->cqh_last) -/* For comparisons */ -#define CIRCLEQ_ENDC(head) (__launder_type(head)) -/* For assignments */ -#define CIRCLEQ_END(head) ((void *)(head)) -#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) -#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) -#define CIRCLEQ_EMPTY(head) \ - (CIRCLEQ_FIRST(head) == CIRCLEQ_ENDC(head)) - -#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ - (((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) \ - ? ((head)->cqh_first) \ - : (elm->field.cqe_next)) -#define CIRCLEQ_LOOP_PREV(head, elm, field) \ - (((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) \ - ? ((head)->cqh_last) \ - : (elm->field.cqe_prev)) -#endif /* !_KERNEL */ - -#endif /* !_SYS_QUEUE_H_ */ diff --git a/repos/core/musl/tree.h b/repos/core/musl/tree.h deleted file mode 100644 index eaea56aa..00000000 --- a/repos/core/musl/tree.h +++ /dev/null @@ -1,761 +0,0 @@ -/* $NetBSD: tree.h,v 1.20 2013/09/14 13:20:45 joerg Exp $ */ -/* $OpenBSD: tree.h,v 1.13 2011/07/09 00:19:45 pirofti Exp $ */ -/* - * Copyright 2002 Niels Provos - * All rights reserved. - * - * 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 AUTHOR ``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 AUTHOR 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_TREE_H_ -#define _SYS_TREE_H_ - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline __unused struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __unused __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ -\ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ - __left = __right = &__node; \ -\ - while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ -\ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ - __left = __right = &__node; \ -\ - while (1) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-black tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) do {} while (/*CONSTCOND*/ 0) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static) -#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ -attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ -attr struct type *name##_RB_INSERT(struct name *, struct type *); \ -attr struct type *name##_RB_FIND(struct name *, struct type *); \ -attr struct type *name##_RB_NFIND(struct name *, struct type *); \ -attr struct type *name##_RB_NEXT(struct type *); \ -attr struct type *name##_RB_PREV(struct type *); \ -attr struct type *name##_RB_MINMAX(struct name *, int); \ - \ - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp,) -#define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static) -#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) != NULL && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field);\ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field);\ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} \ - \ -attr void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)) \ - != NULL) \ - RB_COLOR(oleft, field) = RB_BLACK;\ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field);\ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)) \ - != NULL) \ - RB_COLOR(oright, field) = RB_BLACK;\ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field);\ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} \ - \ -attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field)) != NULL) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old)\ - RB_LEFT(RB_PARENT(old, field), field) = elm;\ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm;\ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field)) != NULL); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - \ -/* Inserts a node into the RB tree */ \ -attr struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} \ - \ -/* Finds the node with the same key as elm */ \ -attr struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} \ - \ -/* Finds the first node greater than or equal to the search key */ \ -attr struct type * \ -name##_RB_NFIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *res = NULL; \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) { \ - res = tmp; \ - tmp = RB_LEFT(tmp, field); \ - } \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (res); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_PREV(struct type *elm) \ -{ \ - if (RB_LEFT(elm, field)) { \ - elm = RB_LEFT(elm, field); \ - while (RB_RIGHT(elm, field)) \ - elm = RB_RIGHT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -attr struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_PREV(name, x, y) name##_RB_PREV(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#define RB_FOREACH_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_SAFE(x, name, head, y) \ - for ((x) = RB_MIN(name, head); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE(x, name, head) \ - for ((x) = RB_MAX(name, head); \ - (x) != NULL; \ - (x) = name##_RB_PREV(x)) - -#define RB_FOREACH_REVERSE_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ - for ((x) = RB_MAX(name, head); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#endif /* _SYS_TREE_H_ */ -- cgit v1.2.3