aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING.NEWLIB29
-rw-r--r--libgloss/arm/crt0.S2
-rw-r--r--libgloss/arm/redboot-crt0.S2
-rw-r--r--newlib/Makefile.in97
-rw-r--r--newlib/libc/include/complex.h13
-rw-r--r--newlib/libc/include/stdatomic.h17
-rw-r--r--newlib/libc/include/sys/_default_fcntl.h5
-rw-r--r--newlib/libc/include/sys/resource.h3
-rw-r--r--newlib/libc/include/sys/tree.h864
-rw-r--r--newlib/libc/machine/arm/aeabi_memmove-thumb2.S1
-rw-r--r--newlib/libc/machine/arm/aeabi_memset-thumb2.S1
-rw-r--r--newlib/libc/machine/arm/memchr.S1
-rw-r--r--newlib/libc/machine/arm/memcpy-armv7m.S1
-rw-r--r--newlib/libc/machine/arm/setjmp.S1
-rw-r--r--newlib/libc/machine/arm/strlen-armv7.S1
-rw-r--r--newlib/libc/machine/arm/strlen-thumb2-Os.S1
-rw-r--r--newlib/libc/sys/arm/crt0.S2
-rw-r--r--newlib/libc/sys/sh/creat.c7
-rw-r--r--newlib/libc/sys/sh/ftruncate.c2
-rw-r--r--newlib/libc/sys/sh/syscalls.c40
-rw-r--r--newlib/libc/sys/sh/truncate.c2
-rw-r--r--newlib/libm/ld/math_private.h53
-rw-r--r--newlib/libm/ld128/Makefile.inc3
-rw-r--r--newlib/libm/ld128/k_cospil.h42
-rw-r--r--newlib/libm/ld128/k_sinpil.h42
-rw-r--r--newlib/libm/ld128/k_tanl.c114
-rw-r--r--newlib/libm/ld128/s_cospil.c108
-rw-r--r--newlib/libm/ld128/s_sinpil.c111
-rw-r--r--newlib/libm/ld80/Makefile.inc4
-rw-r--r--newlib/libm/ld80/k_tanl.c119
-rw-r--r--newlib/libm/machine/arm/s_fma_arm.c2
-rw-r--r--newlib/libm/machine/arm/sf_fma_arm.c2
-rw-r--r--winsup/cygwin/devices.cc4
-rw-r--r--winsup/cygwin/devices.in4
-rw-r--r--winsup/cygwin/exceptions.cc3
-rw-r--r--winsup/cygwin/fhandler/console.cc162
-rw-r--r--winsup/cygwin/fhandler/dsp.cc26
-rw-r--r--winsup/cygwin/fhandler/proc.cc50
-rw-r--r--winsup/cygwin/fhandler/pty.cc25
-rw-r--r--winsup/cygwin/local_includes/fhandler.h20
-rw-r--r--winsup/cygwin/local_includes/shared_info.h3
-rw-r--r--winsup/cygwin/local_includes/tty.h5
-rw-r--r--winsup/cygwin/release/3.5.47
43 files changed, 999 insertions, 1002 deletions
diff --git a/COPYING.NEWLIB b/COPYING.NEWLIB
index 176b3a4..39a03bc 100644
--- a/COPYING.NEWLIB
+++ b/COPYING.NEWLIB
@@ -1541,3 +1541,32 @@ conflicts with the conditions of the GPLv2, you may retroactively and
prospectively choose to deem waived or otherwise exclude such Section(s) of
the License, but only in their entirety and only with respect to the Combined
Software.
+
+(57) Steven G. Kargl - libm ld128 functions
+
+/*-
+ * Copyright (c) 2017-2023 Steven G. Kargl
+ * 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 unmodified, 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.
+ */
+
diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S
index cd1a20d..9ff0e63 100644
--- a/libgloss/arm/crt0.S
+++ b/libgloss/arm/crt0.S
@@ -48,6 +48,7 @@
.thumb
.macro FUNC_START name
.global \name
+ .type \name, %function
.thumb_func
\name:
.endm
@@ -55,6 +56,7 @@
.code 32
.macro FUNC_START name
.global \name
+ .type \name, %function
\name:
.endm
#endif
diff --git a/libgloss/arm/redboot-crt0.S b/libgloss/arm/redboot-crt0.S
index 0e3a9b4..c9f3440 100644
--- a/libgloss/arm/redboot-crt0.S
+++ b/libgloss/arm/redboot-crt0.S
@@ -17,6 +17,7 @@
#ifdef PREFER_THUMB
.macro FUNC_START name
.global \name
+ .type \name, %function
.thumb_func
\name:
.endm
@@ -24,6 +25,7 @@
#else
.macro FUNC_START name
.global \name
+ .type \name, %function
\name:
.endm
.code 32
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index b45c42c..a051c27 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -3244,7 +3244,10 @@ am__objects_159 = libm/fenv/libm_a-feclearexcept.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-invtrig.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-e_lgammal_r.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-k_cosl.$(OBJEXT) \
-@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-k_sinl.$(OBJEXT)
+@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-k_sinl.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-k_tanl.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-s_sinpil.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_AARCH64_FALSE@@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/libm_a-s_cospil.$(OBJEXT)
@HAVE_LIBM_MACHINE_AARCH64_TRUE@am__objects_162 = libm/ld128/libm_a-e_powl.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-s_erfl.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-s_exp2l.$(OBJEXT) \
@@ -3254,7 +3257,10 @@ am__objects_159 = libm/fenv/libm_a-feclearexcept.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-invtrig.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-e_lgammal_r.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-k_cosl.$(OBJEXT) \
-@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-k_sinl.$(OBJEXT)
+@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-k_sinl.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-k_tanl.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-s_sinpil.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/libm_a-s_cospil.$(OBJEXT)
@HAVE_LIBM_MACHINE_AARCH64_TRUE@@HAVE_LONG_DOUBLE_TRUE@am__objects_163 = $(am__objects_162)
@HAVE_LIBM_MACHINE_AMDGCN_TRUE@am__objects_164 = libm/machine/amdgcn/libm_a-v64_mathcnst.$(OBJEXT) \
@HAVE_LIBM_MACHINE_AMDGCN_TRUE@ libm/machine/amdgcn/libm_a-v64_reent.$(OBJEXT) \
@@ -3426,7 +3432,8 @@ am__objects_159 = libm/fenv/libm_a-feclearexcept.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_FALSE@@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/libm_a-invtrig.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_FALSE@@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/libm_a-e_lgammal_r.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_FALSE@@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/libm_a-k_cosl.$(OBJEXT) \
-@HAVE_LIBM_MACHINE_I386_FALSE@@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/libm_a-k_sinl.$(OBJEXT)
+@HAVE_LIBM_MACHINE_I386_FALSE@@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/libm_a-k_sinl.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_I386_FALSE@@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/libm_a-k_tanl.$(OBJEXT)
@HAVE_LIBM_MACHINE_I386_TRUE@am__objects_170 = libm/ld80/libm_a-b_tgammal.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-e_powl.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-s_erfl.$(OBJEXT) \
@@ -3438,7 +3445,8 @@ am__objects_159 = libm/fenv/libm_a-feclearexcept.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-invtrig.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-e_lgammal_r.$(OBJEXT) \
@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-k_cosl.$(OBJEXT) \
-@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-k_sinl.$(OBJEXT)
+@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-k_sinl.$(OBJEXT) \
+@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/libm_a-k_tanl.$(OBJEXT)
@HAVE_LIBM_MACHINE_I386_TRUE@@HAVE_LONG_DOUBLE_TRUE@am__objects_171 = $(am__objects_170)
@HAVE_LIBM_MACHINE_MIPS_TRUE@am__objects_172 = libm/machine/mips/libm_a-feclearexcept.$(OBJEXT) \
@HAVE_LIBM_MACHINE_MIPS_TRUE@ libm/machine/mips/libm_a-fegetenv.$(OBJEXT) \
@@ -3971,7 +3979,6 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
-runstatedir = @runstatedir@
sbindir = @sbindir@
shared_machine_dir = @shared_machine_dir@
sharedstatedir = @sharedstatedir@
@@ -5066,12 +5073,14 @@ libm_test_test_LDADD = $(CRT0) libm.a libc.a
@HAVE_LIBM_MACHINE_AARCH64_TRUE@libm_ld128_lsrc = \
@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/e_powl.c libm/ld128/s_erfl.c libm/ld128/s_exp2l.c libm/ld128/s_expl.c \
@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/s_logl.c libm/ld128/b_tgammal.c libm/ld128/invtrig.c \
-@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/e_lgammal_r.c libm/ld128/k_cosl.c libm/ld128/k_sinl.c
+@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/e_lgammal_r.c libm/ld128/k_cosl.c libm/ld128/k_sinl.c \
+@HAVE_LIBM_MACHINE_AARCH64_TRUE@ libm/ld128/k_tanl.c libm/ld128/s_sinpil.c libm/ld128/s_cospil.c
@HAVE_LIBM_MACHINE_RISCV_TRUE@libm_ld128_lsrc = \
@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/e_powl.c libm/ld128/s_erfl.c libm/ld128/s_exp2l.c libm/ld128/s_expl.c \
@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/s_logl.c libm/ld128/b_tgammal.c libm/ld128/invtrig.c \
-@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/e_lgammal_r.c libm/ld128/k_cosl.c libm/ld128/k_sinl.c
+@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/e_lgammal_r.c libm/ld128/k_cosl.c libm/ld128/k_sinl.c \
+@HAVE_LIBM_MACHINE_RISCV_TRUE@ libm/ld128/k_tanl.c libm/ld128/s_sinpil.c libm/ld128/s_cospil.c
@HAVE_LIBM_MACHINE_AARCH64_TRUE@libm_a_CFLAGS_libm_ld128 = -fbuiltin -fno-math-errno
@HAVE_LIBM_MACHINE_RISCV_TRUE@libm_a_CFLAGS_libm_ld128 = -fbuiltin -fno-math-errno
@@ -5212,12 +5221,14 @@ libm_test_test_LDADD = $(CRT0) libm.a libc.a
@HAVE_LIBM_MACHINE_I386_TRUE@libm_ld80_lsrc = \
@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/b_tgammal.c libm/ld80/e_powl.c libm/ld80/s_erfl.c libm/ld80/s_exp2l.c \
@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/s_expl.c libm/ld80/s_logl.c libm/ld80/s_sinpil.c libm/ld80/s_cospil.c \
-@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/invtrig.c libm/ld80/e_lgammal_r.c libm/ld80/k_cosl.c libm/ld80/k_sinl.c
+@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/invtrig.c libm/ld80/e_lgammal_r.c libm/ld80/k_cosl.c libm/ld80/k_sinl.c \
+@HAVE_LIBM_MACHINE_I386_TRUE@ libm/ld80/k_tanl.c
@HAVE_LIBM_MACHINE_X86_64_TRUE@libm_ld80_lsrc = \
@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/b_tgammal.c libm/ld80/e_powl.c libm/ld80/s_erfl.c libm/ld80/s_exp2l.c \
@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/s_expl.c libm/ld80/s_logl.c libm/ld80/s_sinpil.c libm/ld80/s_cospil.c \
-@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/invtrig.c libm/ld80/e_lgammal_r.c libm/ld80/k_cosl.c libm/ld80/k_sinl.c
+@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/invtrig.c libm/ld80/e_lgammal_r.c libm/ld80/k_cosl.c libm/ld80/k_sinl.c \
+@HAVE_LIBM_MACHINE_X86_64_TRUE@ libm/ld80/k_tanl.c
@HAVE_LIBM_MACHINE_I386_TRUE@libm_a_CFLAGS_libm_ld80 = -fbuiltin -fno-math-errno
@HAVE_LIBM_MACHINE_X86_64_TRUE@libm_a_CFLAGS_libm_ld80 = -fbuiltin -fno-math-errno
@@ -11059,6 +11070,12 @@ libm/ld128/libm_a-k_cosl.$(OBJEXT): libm/ld128/$(am__dirstamp) \
libm/ld128/$(DEPDIR)/$(am__dirstamp)
libm/ld128/libm_a-k_sinl.$(OBJEXT): libm/ld128/$(am__dirstamp) \
libm/ld128/$(DEPDIR)/$(am__dirstamp)
+libm/ld128/libm_a-k_tanl.$(OBJEXT): libm/ld128/$(am__dirstamp) \
+ libm/ld128/$(DEPDIR)/$(am__dirstamp)
+libm/ld128/libm_a-s_sinpil.$(OBJEXT): libm/ld128/$(am__dirstamp) \
+ libm/ld128/$(DEPDIR)/$(am__dirstamp)
+libm/ld128/libm_a-s_cospil.$(OBJEXT): libm/ld128/$(am__dirstamp) \
+ libm/ld128/$(DEPDIR)/$(am__dirstamp)
libm/machine/amdgcn/$(am__dirstamp):
@$(MKDIR_P) libm/machine/amdgcn
@: > libm/machine/amdgcn/$(am__dirstamp)
@@ -11575,6 +11592,8 @@ libm/ld80/libm_a-k_cosl.$(OBJEXT): libm/ld80/$(am__dirstamp) \
libm/ld80/$(DEPDIR)/$(am__dirstamp)
libm/ld80/libm_a-k_sinl.$(OBJEXT): libm/ld80/$(am__dirstamp) \
libm/ld80/$(DEPDIR)/$(am__dirstamp)
+libm/ld80/libm_a-k_tanl.$(OBJEXT): libm/ld80/$(am__dirstamp) \
+ libm/ld80/$(DEPDIR)/$(am__dirstamp)
libm/machine/mips/$(am__dirstamp):
@$(MKDIR_P) libm/machine/mips
@: > libm/machine/mips/$(am__dirstamp)
@@ -14427,16 +14446,20 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-invtrig.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-k_cosl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-k_sinl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-k_tanl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-s_cospil.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-s_erfl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-s_exp2l.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-s_expl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-s_logl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libm/ld128/$(DEPDIR)/libm_a-s_sinpil.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-b_tgammal.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-e_lgammal_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-e_powl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-invtrig.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-k_cosl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-k_sinl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-k_tanl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-s_cospil.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-s_erfl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@libm/ld80/$(DEPDIR)/libm_a-s_exp2l.Po@am__quote@
@@ -44350,6 +44373,48 @@ libm/ld128/libm_a-k_sinl.obj: libm/ld128/k_sinl.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld128/libm_a-k_sinl.obj `if test -f 'libm/ld128/k_sinl.c'; then $(CYGPATH_W) 'libm/ld128/k_sinl.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld128/k_sinl.c'; fi`
+libm/ld128/libm_a-k_tanl.o: libm/ld128/k_tanl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld128/libm_a-k_tanl.o -MD -MP -MF libm/ld128/$(DEPDIR)/libm_a-k_tanl.Tpo -c -o libm/ld128/libm_a-k_tanl.o `test -f 'libm/ld128/k_tanl.c' || echo '$(srcdir)/'`libm/ld128/k_tanl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld128/$(DEPDIR)/libm_a-k_tanl.Tpo libm/ld128/$(DEPDIR)/libm_a-k_tanl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld128/k_tanl.c' object='libm/ld128/libm_a-k_tanl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld128/libm_a-k_tanl.o `test -f 'libm/ld128/k_tanl.c' || echo '$(srcdir)/'`libm/ld128/k_tanl.c
+
+libm/ld128/libm_a-k_tanl.obj: libm/ld128/k_tanl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld128/libm_a-k_tanl.obj -MD -MP -MF libm/ld128/$(DEPDIR)/libm_a-k_tanl.Tpo -c -o libm/ld128/libm_a-k_tanl.obj `if test -f 'libm/ld128/k_tanl.c'; then $(CYGPATH_W) 'libm/ld128/k_tanl.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld128/k_tanl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld128/$(DEPDIR)/libm_a-k_tanl.Tpo libm/ld128/$(DEPDIR)/libm_a-k_tanl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld128/k_tanl.c' object='libm/ld128/libm_a-k_tanl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld128/libm_a-k_tanl.obj `if test -f 'libm/ld128/k_tanl.c'; then $(CYGPATH_W) 'libm/ld128/k_tanl.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld128/k_tanl.c'; fi`
+
+libm/ld128/libm_a-s_sinpil.o: libm/ld128/s_sinpil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld128/libm_a-s_sinpil.o -MD -MP -MF libm/ld128/$(DEPDIR)/libm_a-s_sinpil.Tpo -c -o libm/ld128/libm_a-s_sinpil.o `test -f 'libm/ld128/s_sinpil.c' || echo '$(srcdir)/'`libm/ld128/s_sinpil.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld128/$(DEPDIR)/libm_a-s_sinpil.Tpo libm/ld128/$(DEPDIR)/libm_a-s_sinpil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld128/s_sinpil.c' object='libm/ld128/libm_a-s_sinpil.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld128/libm_a-s_sinpil.o `test -f 'libm/ld128/s_sinpil.c' || echo '$(srcdir)/'`libm/ld128/s_sinpil.c
+
+libm/ld128/libm_a-s_sinpil.obj: libm/ld128/s_sinpil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld128/libm_a-s_sinpil.obj -MD -MP -MF libm/ld128/$(DEPDIR)/libm_a-s_sinpil.Tpo -c -o libm/ld128/libm_a-s_sinpil.obj `if test -f 'libm/ld128/s_sinpil.c'; then $(CYGPATH_W) 'libm/ld128/s_sinpil.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld128/s_sinpil.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld128/$(DEPDIR)/libm_a-s_sinpil.Tpo libm/ld128/$(DEPDIR)/libm_a-s_sinpil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld128/s_sinpil.c' object='libm/ld128/libm_a-s_sinpil.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld128/libm_a-s_sinpil.obj `if test -f 'libm/ld128/s_sinpil.c'; then $(CYGPATH_W) 'libm/ld128/s_sinpil.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld128/s_sinpil.c'; fi`
+
+libm/ld128/libm_a-s_cospil.o: libm/ld128/s_cospil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld128/libm_a-s_cospil.o -MD -MP -MF libm/ld128/$(DEPDIR)/libm_a-s_cospil.Tpo -c -o libm/ld128/libm_a-s_cospil.o `test -f 'libm/ld128/s_cospil.c' || echo '$(srcdir)/'`libm/ld128/s_cospil.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld128/$(DEPDIR)/libm_a-s_cospil.Tpo libm/ld128/$(DEPDIR)/libm_a-s_cospil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld128/s_cospil.c' object='libm/ld128/libm_a-s_cospil.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld128/libm_a-s_cospil.o `test -f 'libm/ld128/s_cospil.c' || echo '$(srcdir)/'`libm/ld128/s_cospil.c
+
+libm/ld128/libm_a-s_cospil.obj: libm/ld128/s_cospil.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld128/libm_a-s_cospil.obj -MD -MP -MF libm/ld128/$(DEPDIR)/libm_a-s_cospil.Tpo -c -o libm/ld128/libm_a-s_cospil.obj `if test -f 'libm/ld128/s_cospil.c'; then $(CYGPATH_W) 'libm/ld128/s_cospil.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld128/s_cospil.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld128/$(DEPDIR)/libm_a-s_cospil.Tpo libm/ld128/$(DEPDIR)/libm_a-s_cospil.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld128/s_cospil.c' object='libm/ld128/libm_a-s_cospil.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld128/libm_a-s_cospil.obj `if test -f 'libm/ld128/s_cospil.c'; then $(CYGPATH_W) 'libm/ld128/s_cospil.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld128/s_cospil.c'; fi`
+
libm/machine/amdgcn/libm_a-v64_mathcnst.o: libm/machine/amdgcn/v64_mathcnst.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/machine/amdgcn/libm_a-v64_mathcnst.o -MD -MP -MF libm/machine/amdgcn/$(DEPDIR)/libm_a-v64_mathcnst.Tpo -c -o libm/machine/amdgcn/libm_a-v64_mathcnst.o `test -f 'libm/machine/amdgcn/v64_mathcnst.c' || echo '$(srcdir)/'`libm/machine/amdgcn/v64_mathcnst.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/machine/amdgcn/$(DEPDIR)/libm_a-v64_mathcnst.Tpo libm/machine/amdgcn/$(DEPDIR)/libm_a-v64_mathcnst.Po
@@ -46534,6 +46599,20 @@ libm/ld80/libm_a-k_sinl.obj: libm/ld80/k_sinl.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld80/libm_a-k_sinl.obj `if test -f 'libm/ld80/k_sinl.c'; then $(CYGPATH_W) 'libm/ld80/k_sinl.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld80/k_sinl.c'; fi`
+libm/ld80/libm_a-k_tanl.o: libm/ld80/k_tanl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld80/libm_a-k_tanl.o -MD -MP -MF libm/ld80/$(DEPDIR)/libm_a-k_tanl.Tpo -c -o libm/ld80/libm_a-k_tanl.o `test -f 'libm/ld80/k_tanl.c' || echo '$(srcdir)/'`libm/ld80/k_tanl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld80/$(DEPDIR)/libm_a-k_tanl.Tpo libm/ld80/$(DEPDIR)/libm_a-k_tanl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld80/k_tanl.c' object='libm/ld80/libm_a-k_tanl.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld80/libm_a-k_tanl.o `test -f 'libm/ld80/k_tanl.c' || echo '$(srcdir)/'`libm/ld80/k_tanl.c
+
+libm/ld80/libm_a-k_tanl.obj: libm/ld80/k_tanl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/ld80/libm_a-k_tanl.obj -MD -MP -MF libm/ld80/$(DEPDIR)/libm_a-k_tanl.Tpo -c -o libm/ld80/libm_a-k_tanl.obj `if test -f 'libm/ld80/k_tanl.c'; then $(CYGPATH_W) 'libm/ld80/k_tanl.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld80/k_tanl.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/ld80/$(DEPDIR)/libm_a-k_tanl.Tpo libm/ld80/$(DEPDIR)/libm_a-k_tanl.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libm/ld80/k_tanl.c' object='libm/ld80/libm_a-k_tanl.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -c -o libm/ld80/libm_a-k_tanl.obj `if test -f 'libm/ld80/k_tanl.c'; then $(CYGPATH_W) 'libm/ld80/k_tanl.c'; else $(CYGPATH_W) '$(srcdir)/libm/ld80/k_tanl.c'; fi`
+
libm/machine/mips/libm_a-feclearexcept.o: libm/machine/mips/feclearexcept.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libm_a_CPPFLAGS) $(CPPFLAGS) $(libm_a_CFLAGS) $(CFLAGS) -MT libm/machine/mips/libm_a-feclearexcept.o -MD -MP -MF libm/machine/mips/$(DEPDIR)/libm_a-feclearexcept.Tpo -c -o libm/machine/mips/libm_a-feclearexcept.o `test -f 'libm/machine/mips/feclearexcept.c' || echo '$(srcdir)/'`libm/machine/mips/feclearexcept.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libm/machine/mips/$(DEPDIR)/libm_a-feclearexcept.Tpo libm/machine/mips/$(DEPDIR)/libm_a-feclearexcept.Po
diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h
index ad3028e..dbabdf6 100644
--- a/newlib/libc/include/complex.h
+++ b/newlib/libc/include/complex.h
@@ -16,6 +16,19 @@
__BEGIN_DECLS
+/* Implementation from FreeBSD */
+#if __ISO_C_VISIBLE >= 2011
+#ifdef __clang__
+#define CMPLX(x, y) ((double complex){ x, y })
+#define CMPLXF(x, y) ((float complex){ x, y })
+#define CMPLXL(x, y) ((long double complex){ x, y })
+#elif __GNUC_PREREQ__(4, 7)
+#define CMPLX(x, y) __builtin_complex((double)(x), (double)(y))
+#define CMPLXF(x, y) __builtin_complex((float)(x), (float)(y))
+#define CMPLXL(x, y) __builtin_complex((long double)(x), (long double)(y))
+#endif
+#endif /* __ISO_C_VISIBLE >= 2011 */
+
/* 7.3.5 Trigonometric functions */
/* 7.3.5.1 The cacos functions */
double complex cacos(double complex);
diff --git a/newlib/libc/include/stdatomic.h b/newlib/libc/include/stdatomic.h
index d58e795..13d1e17 100644
--- a/newlib/libc/include/stdatomic.h
+++ b/newlib/libc/include/stdatomic.h
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
* Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
* David Chisnall <theraven@FreeBSD.org>
* All rights reserved.
@@ -23,8 +25,6 @@
* 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.
- *
- * $FreeBSD$
*/
#ifndef _STDATOMIC_H_
@@ -33,7 +33,8 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
-#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
+#if (__has_extension(c_atomic) || __has_extension(cxx_atomic)) && \
+ defined(__clang__)
#define __CLANG_ATOMICS
#elif __GNUC_PREREQ__(4, 7)
#define __GNUC_ATOMICS
@@ -161,6 +162,11 @@ atomic_signal_fence(memory_order __order __unused)
#endif
}
+#if defined(__cplusplus) && !defined(_Bool)
+#define _Bool bool
+#define __bool_locally_defined
+#endif
+
/*
* 7.17.5 Lock-free property.
*/
@@ -406,4 +412,9 @@ atomic_flag_clear(volatile atomic_flag *__object)
}
#endif /* !_KERNEL */
+#ifdef __bool_locally_defined
+#undef _Bool
+#undef __bool_locally_defined
+#endif
+
#endif /* !_STDATOMIC_H_ */
diff --git a/newlib/libc/include/sys/_default_fcntl.h b/newlib/libc/include/sys/_default_fcntl.h
index ce721fa..148e97d 100644
--- a/newlib/libc/include/sys/_default_fcntl.h
+++ b/newlib/libc/include/sys/_default_fcntl.h
@@ -71,11 +71,12 @@ extern "C" {
#define O_DIRECT _FDIRECT
#endif
+#define O_DSYNC _FSYNC
+#define O_RSYNC _FSYNC
+
#if defined (__CYGWIN__)
#define O_BINARY _FBINARY
#define O_TEXT _FTEXT
-#define O_DSYNC _FSYNC
-#define O_RSYNC _FSYNC
/* Linux-specific flags */
#if __GNU_VISIBLE
diff --git a/newlib/libc/include/sys/resource.h b/newlib/libc/include/sys/resource.h
index c0a0d20..e653d08 100644
--- a/newlib/libc/include/sys/resource.h
+++ b/newlib/libc/include/sys/resource.h
@@ -9,6 +9,9 @@ extern "C" {
#define RUSAGE_SELF 0 /* calling process */
#define RUSAGE_CHILDREN -1 /* terminated child processes */
+#if __GNU_VISIBLE
+#define RUSAGE_THREAD 1
+#endif
struct rusage {
struct timeval ru_utime; /* user time used */
diff --git a/newlib/libc/include/sys/tree.h b/newlib/libc/include/sys/tree.h
deleted file mode 100644
index 2d3cec0..0000000
--- a/newlib/libc/include/sys/tree.h
+++ /dev/null
@@ -1,864 +0,0 @@
-/* $NetBSD: tree.h,v 1.8 2004/03/28 19:38:30 provos Exp $ */
-/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */
-/* $FreeBSD: head/sys/sys/tree.h 347360 2019-05-08 18:47:00Z trasz $ */
-
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright 2002 Niels Provos <provos@citi.umich.edu>
- * 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_
-
-#include <sys/cdefs.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 __unused __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 __unused __inline 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_ISRED(elm, field) ((elm) != NULL && RB_COLOR(elm, field) == RB_RED)
-#define RB_ROOT(head) (head)->rbh_root
-#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
-
-#define RB_SET_PARENT(dst, src, field) do { \
- RB_PARENT(dst, field) = src; \
-} while (/*CONSTCOND*/ 0)
-
-#define RB_SET(elm, parent, field) do { \
- RB_SET_PARENT(elm, parent, field); \
- 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)
-
-/*
- * Something to be invoked in a loop at the root of every modified subtree,
- * from the bottom up to the root, to update augmented node data.
- */
-#ifndef RB_AUGMENT
-#define RB_AUGMENT(x) break
-#endif
-
-#define RB_SWAP_CHILD(head, out, in, field) do { \
- if (RB_PARENT(out, field) == NULL) \
- RB_ROOT(head) = (in); \
- else if ((out) == RB_LEFT(RB_PARENT(out, field), field)) \
- RB_LEFT(RB_PARENT(out, field), field) = (in); \
- else \
- RB_RIGHT(RB_PARENT(out, field), field) = (in); \
-} while (/*CONSTCOND*/ 0)
-
-#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_SET_PARENT(RB_RIGHT(elm, field), elm, field); \
- } \
- RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \
- RB_SWAP_CHILD(head, elm, tmp, field); \
- RB_LEFT(tmp, field) = (elm); \
- RB_SET_PARENT(elm, tmp, field); \
- RB_AUGMENT(elm); \
-} 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_SET_PARENT(RB_LEFT(elm, field), elm, field); \
- } \
- RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \
- RB_SWAP_CHILD(head, elm, tmp, field); \
- RB_RIGHT(tmp, field) = (elm); \
- RB_SET_PARENT(elm, tmp, field); \
- RB_AUGMENT(elm); \
-} while (/*CONSTCOND*/ 0)
-
-/*
- * The RB_PARENT_ROTATE_LEFT() and RB_PARENT_ROTATE_RIGHT() rotations are
- * specialized versions of RB_ROTATE_LEFT() and RB_ROTATE_RIGHT() which may be
- * used if the parent node exists and the direction of the child element is
- * known.
- */
-
-#define RB_PARENT_ROTATE_LEFT(parent, left, tmp, field) do { \
- (tmp) = RB_RIGHT(left, field); \
- if ((RB_RIGHT(left, field) = RB_LEFT(tmp, field)) != NULL) { \
- RB_SET_PARENT(RB_RIGHT(left, field), left, field); \
- } \
- RB_SET_PARENT(tmp, parent, field); \
- RB_LEFT(parent, field) = (tmp); \
- RB_LEFT(tmp, field) = (left); \
- RB_SET_PARENT(left, tmp, field); \
- RB_AUGMENT(left); \
-} while (/*CONSTCOND*/ 0)
-
-#define RB_PARENT_ROTATE_RIGHT(parent, right, tmp, field) do { \
- (tmp) = RB_LEFT(right, field); \
- if ((RB_LEFT(right, field) = RB_RIGHT(tmp, field)) != NULL) { \
- RB_SET_PARENT(RB_LEFT(right, field), right, field); \
- } \
- RB_SET_PARENT(tmp, parent, field); \
- RB_RIGHT(parent, field) = (tmp); \
- RB_RIGHT(tmp, field) = (right); \
- RB_SET_PARENT(right, tmp, field); \
- RB_AUGMENT(right); \
-} while (/*CONSTCOND*/ 0)
-
-/*
- * The RB_RED_ROTATE_LEFT() and RB_RED_ROTATE_RIGHT() rotations are specialized
- * versions of RB_ROTATE_LEFT() and RB_ROTATE_RIGHT() which may be used if we
- * rotate an element with a red child which has a black sibling. Such a red
- * node must have at least two child nodes so that the following red-black tree
- * invariant is fulfilled:
- *
- * Every path from a given node to any of its descendant NULL nodes goes
- * through the same number of black nodes.
- *
- * elm (could be the root)
- * / \
- * BLACK RED (left or right child)
- * / \
- * BLACK BLACK
- */
-
-#define RB_RED_ROTATE_LEFT(head, elm, tmp, field) do { \
- (tmp) = RB_RIGHT(elm, field); \
- RB_RIGHT(elm, field) = RB_LEFT(tmp, field); \
- RB_SET_PARENT(RB_RIGHT(elm, field), elm, field); \
- RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \
- RB_SWAP_CHILD(head, elm, tmp, field); \
- RB_LEFT(tmp, field) = (elm); \
- RB_SET_PARENT(elm, tmp, field); \
- RB_AUGMENT(elm); \
-} while (/*CONSTCOND*/ 0)
-
-#define RB_RED_ROTATE_RIGHT(head, elm, tmp, field) do { \
- (tmp) = RB_LEFT(elm, field); \
- RB_LEFT(elm, field) = RB_RIGHT(tmp, field); \
- RB_SET_PARENT(RB_LEFT(elm, field), elm, field); \
- RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \
- RB_SWAP_CHILD(head, elm, tmp, field); \
- RB_RIGHT(tmp, field) = (elm); \
- RB_SET_PARENT(elm, tmp, field); \
- RB_AUGMENT(elm); \
-} 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) \
- RB_PROTOTYPE_INSERT_COLOR(name, type, attr); \
- RB_PROTOTYPE_REMOVE_COLOR(name, type, attr); \
- RB_PROTOTYPE_INSERT(name, type, attr); \
- RB_PROTOTYPE_REMOVE(name, type, attr); \
- RB_PROTOTYPE_FIND(name, type, attr); \
- RB_PROTOTYPE_NFIND(name, type, attr); \
- RB_PROTOTYPE_NEXT(name, type, attr); \
- RB_PROTOTYPE_PREV(name, type, attr); \
- RB_PROTOTYPE_MINMAX(name, type, attr); \
- RB_PROTOTYPE_REINSERT(name, type, attr);
-#define RB_PROTOTYPE_INSERT_COLOR(name, type, attr) \
- attr void name##_RB_INSERT_COLOR(struct name *, struct type *)
-#define RB_PROTOTYPE_REMOVE_COLOR(name, type, attr) \
- attr void name##_RB_REMOVE_COLOR(struct name *, struct type *)
-#define RB_PROTOTYPE_REMOVE(name, type, attr) \
- attr struct type *name##_RB_REMOVE(struct name *, struct type *)
-#define RB_PROTOTYPE_INSERT(name, type, attr) \
- attr struct type *name##_RB_INSERT(struct name *, struct type *)
-#define RB_PROTOTYPE_FIND(name, type, attr) \
- attr struct type *name##_RB_FIND(struct name *, struct type *)
-#define RB_PROTOTYPE_NFIND(name, type, attr) \
- attr struct type *name##_RB_NFIND(struct name *, struct type *)
-#define RB_PROTOTYPE_NEXT(name, type, attr) \
- attr struct type *name##_RB_NEXT(struct type *)
-#define RB_PROTOTYPE_PREV(name, type, attr) \
- attr struct type *name##_RB_PREV(struct type *)
-#define RB_PROTOTYPE_MINMAX(name, type, attr) \
- attr struct type *name##_RB_MINMAX(struct name *, int)
-#define RB_PROTOTYPE_REINSERT(name, type, attr) \
- attr struct type *name##_RB_REINSERT(struct name *, struct type *)
-
-/* 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) \
- RB_GENERATE_INSERT_COLOR(name, type, field, attr) \
- RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \
- RB_GENERATE_INSERT(name, type, field, cmp, attr) \
- RB_GENERATE_REMOVE(name, type, field, attr) \
- RB_GENERATE_FIND(name, type, field, cmp, attr) \
- RB_GENERATE_NFIND(name, type, field, cmp, attr) \
- RB_GENERATE_NEXT(name, type, field, attr) \
- RB_GENERATE_PREV(name, type, field, attr) \
- RB_GENERATE_MINMAX(name, type, field, attr) \
- RB_GENERATE_REINSERT(name, type, field, cmp, attr)
-
-
-#define RB_GENERATE_INSERT_COLOR(name, type, field, attr) \
-attr void \
-name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
-{ \
- struct type *parent, *gparent, *tmp; \
- while (RB_ISRED((parent = RB_PARENT(elm, field)), field)) { \
- gparent = RB_PARENT(parent, field); \
- if (parent == RB_LEFT(gparent, field)) { \
- tmp = RB_RIGHT(gparent, field); \
- if (RB_ISRED(tmp, field)) { \
- RB_COLOR(tmp, field) = RB_BLACK; \
- RB_SET_BLACKRED(parent, gparent, field);\
- elm = gparent; \
- continue; \
- } \
- if (RB_RIGHT(parent, field) == elm) { \
- RB_PARENT_ROTATE_LEFT(gparent, 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 (RB_ISRED(tmp, field)) { \
- RB_COLOR(tmp, field) = RB_BLACK; \
- RB_SET_BLACKRED(parent, gparent, field);\
- elm = gparent; \
- continue; \
- } \
- if (RB_LEFT(parent, field) == elm) { \
- RB_PARENT_ROTATE_RIGHT(gparent, 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; \
-}
-
-#define RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \
-attr void \
-name##_RB_REMOVE_COLOR(struct name *head, struct type *parent) \
-{ \
- struct type *elm, *tmp; \
- elm = NULL; \
- do { \
- 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_RED_ROTATE_LEFT(head, parent, tmp, field); \
- tmp = RB_RIGHT(parent, field); \
- } \
- if (RB_ISRED(RB_RIGHT(tmp, field), field)) \
- RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \
- else if (RB_ISRED(RB_LEFT(tmp, field), field)) { \
- struct type *oleft; \
- RB_PARENT_ROTATE_RIGHT(parent, tmp, \
- oleft, field); \
- RB_COLOR(oleft, field) = RB_BLACK; \
- tmp = oleft; \
- } else { \
- RB_COLOR(tmp, field) = RB_RED; \
- elm = parent; \
- parent = RB_PARENT(elm, field); \
- continue; \
- } \
- RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
- RB_COLOR(parent, 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_RED_ROTATE_RIGHT(head, parent, tmp, field); \
- tmp = RB_LEFT(parent, field); \
- } \
- if (RB_ISRED(RB_LEFT(tmp, field), field)) \
- RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \
- else if (RB_ISRED(RB_RIGHT(tmp, field), field)) { \
- struct type *oright; \
- RB_PARENT_ROTATE_LEFT(parent, tmp, \
- oright, field); \
- RB_COLOR(oright, field) = RB_BLACK; \
- tmp = oright; \
- } else { \
- RB_COLOR(tmp, field) = RB_RED; \
- elm = parent; \
- parent = RB_PARENT(elm, field); \
- continue; \
- } \
- RB_COLOR(tmp, field) = RB_COLOR(parent, field); \
- RB_COLOR(parent, field) = RB_BLACK; \
- RB_ROTATE_RIGHT(head, parent, tmp, field); \
- elm = RB_ROOT(head); \
- break; \
- } \
- } while (RB_COLOR(elm, field) == RB_BLACK && parent != NULL); \
- RB_COLOR(elm, field) = RB_BLACK; \
-}
-
-#define RB_GENERATE_REMOVE(name, type, field, attr) \
-attr struct type * \
-name##_RB_REMOVE(struct name *head, struct type *elm) \
-{ \
- struct type *child, *old, *parent, *right; \
- int color; \
- \
- old = elm; \
- parent = RB_PARENT(elm, field); \
- right = RB_RIGHT(elm, field); \
- color = RB_COLOR(elm, field); \
- if (RB_LEFT(elm, field) == NULL) \
- elm = child = right; \
- else if (right == NULL) \
- elm = child = RB_LEFT(elm, field); \
- else { \
- if ((child = RB_LEFT(right, field)) == NULL) { \
- child = RB_RIGHT(right, field); \
- RB_RIGHT(old, field) = child; \
- parent = elm = right; \
- } else { \
- do \
- elm = child; \
- while ((child = RB_LEFT(elm, field)) != NULL); \
- child = RB_RIGHT(elm, field); \
- parent = RB_PARENT(elm, field); \
- RB_LEFT(parent, field) = child; \
- RB_SET_PARENT(RB_RIGHT(old, field), elm, field); \
- } \
- RB_SET_PARENT(RB_LEFT(old, field), elm, field); \
- color = RB_COLOR(elm, field); \
- elm->field = old->field; \
- } \
- RB_SWAP_CHILD(head, old, elm, field); \
- if (child != NULL) { \
- RB_SET_PARENT(child, parent, field); \
- RB_COLOR(child, field) = RB_BLACK; \
- } else if (color != RB_RED && parent != NULL) \
- name##_RB_REMOVE_COLOR(head, parent); \
- while (parent != NULL) { \
- RB_AUGMENT(parent); \
- parent = RB_PARENT(parent, field); \
- } \
- return (old); \
-}
-
-#define RB_GENERATE_INSERT(name, type, field, cmp, attr) \
-/* 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; \
- } else \
- RB_ROOT(head) = elm; \
- name##_RB_INSERT_COLOR(head, elm); \
- while (elm != NULL) { \
- RB_AUGMENT(elm); \
- elm = RB_PARENT(elm, field); \
- } \
- return (NULL); \
-}
-
-#define RB_GENERATE_FIND(name, type, field, cmp, attr) \
-/* 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); \
-}
-
-#define RB_GENERATE_NFIND(name, type, field, cmp, attr) \
-/* 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); \
-}
-
-#define RB_GENERATE_NEXT(name, type, field, attr) \
-/* 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); \
-}
-
-#define RB_GENERATE_PREV(name, type, field, attr) \
-/* 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); \
-}
-
-#define RB_GENERATE_MINMAX(name, type, field, attr) \
-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_GENERATE_REINSERT(name, type, field, cmp, attr) \
-attr struct type * \
-name##_RB_REINSERT(struct name *head, struct type *elm) \
-{ \
- struct type *cmpelm; \
- if (((cmpelm = RB_PREV(name, head, elm)) != NULL && \
- cmp(cmpelm, elm) >= 0) || \
- ((cmpelm = RB_NEXT(name, head, elm)) != NULL && \
- cmp(elm, cmpelm) >= 0)) { \
- /* XXXLAS: Remove/insert is heavy handed. */ \
- RB_REMOVE(name, head, elm); \
- return (RB_INSERT(name, head, elm)); \
- } \
- return (NULL); \
-} \
-
-#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_REINSERT(name, x, y) name##_RB_REINSERT(x, y)
-
-#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_ */
diff --git a/newlib/libc/machine/arm/aeabi_memmove-thumb2.S b/newlib/libc/machine/arm/aeabi_memmove-thumb2.S
index 20ca993..3018e74 100644
--- a/newlib/libc/machine/arm/aeabi_memmove-thumb2.S
+++ b/newlib/libc/machine/arm/aeabi_memmove-thumb2.S
@@ -36,6 +36,7 @@
ASM_ALIAS __aeabi_memmove8 __aeabi_memmove
__aeabi_memmove:
.fnstart
+ .cfi_sections .debug_frame
.cfi_startproc
prologue 4
cmp r0, r1
diff --git a/newlib/libc/machine/arm/aeabi_memset-thumb2.S b/newlib/libc/machine/arm/aeabi_memset-thumb2.S
index 6b77d38..a1b8f05 100644
--- a/newlib/libc/machine/arm/aeabi_memset-thumb2.S
+++ b/newlib/libc/machine/arm/aeabi_memset-thumb2.S
@@ -33,6 +33,7 @@
.global __aeabi_memset
.type __aeabi_memset, %function
.fnstart
+ .cfi_sections .debug_frame
.cfi_startproc
ASM_ALIAS __aeabi_memset4 __aeabi_memset
ASM_ALIAS __aeabi_memset8 __aeabi_memset
diff --git a/newlib/libc/machine/arm/memchr.S b/newlib/libc/machine/arm/memchr.S
index d13ef8d..f0b3650 100644
--- a/newlib/libc/machine/arm/memchr.S
+++ b/newlib/libc/machine/arm/memchr.S
@@ -293,6 +293,7 @@ memchr:
.global memchr
.type memchr,%function
.fnstart
+ .cfi_sections .debug_frame
.cfi_startproc
memchr:
@ r0 = start of memory to scan
diff --git a/newlib/libc/machine/arm/memcpy-armv7m.S b/newlib/libc/machine/arm/memcpy-armv7m.S
index ec1ad64..13ffdb3 100644
--- a/newlib/libc/machine/arm/memcpy-armv7m.S
+++ b/newlib/libc/machine/arm/memcpy-armv7m.S
@@ -88,6 +88,7 @@
.thumb
.thumb_func
.fnstart
+ .cfi_sections .debug_frame
.cfi_startproc
.type memcpy, %function
memcpy:
diff --git a/newlib/libc/machine/arm/setjmp.S b/newlib/libc/machine/arm/setjmp.S
index 5e59522..0070f17 100644
--- a/newlib/libc/machine/arm/setjmp.S
+++ b/newlib/libc/machine/arm/setjmp.S
@@ -183,6 +183,7 @@ SYM (.arm_start_of.\name):
MODE
.globl SYM (\name)
.fnstart
+ .cfi_sections .debug_frame
.cfi_startproc
TYPE (\name)
SYM (\name):
diff --git a/newlib/libc/machine/arm/strlen-armv7.S b/newlib/libc/machine/arm/strlen-armv7.S
index 6aa122c..1c2b5c5 100644
--- a/newlib/libc/machine/arm/strlen-armv7.S
+++ b/newlib/libc/machine/arm/strlen-armv7.S
@@ -106,6 +106,7 @@
def_fn strlen p2align=6
.fnstart
+ .cfi_sections .debug_frame
.cfi_startproc
prologue 4 5 push_ip=HAVE_PAC_LEAF
pld [srcin, #0]
diff --git a/newlib/libc/machine/arm/strlen-thumb2-Os.S b/newlib/libc/machine/arm/strlen-thumb2-Os.S
index 4adbc61..b8a615a 100644
--- a/newlib/libc/machine/arm/strlen-thumb2-Os.S
+++ b/newlib/libc/machine/arm/strlen-thumb2-Os.S
@@ -47,6 +47,7 @@
def_fn strlen p2align=1
.fnstart
+ .cfi_sections .debug_frame
.cfi_startproc
prologue
mov r3, r0
diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S
index 90d5be3..dae0f04 100644
--- a/newlib/libc/sys/arm/crt0.S
+++ b/newlib/libc/sys/arm/crt0.S
@@ -48,6 +48,7 @@
.thumb
.macro FUNC_START name
.global \name
+ .type \name, %function
.thumb_func
\name:
.endm
@@ -55,6 +56,7 @@
.code 32
.macro FUNC_START name
.global \name
+ .type \name, %function
\name:
.endm
#endif
diff --git a/newlib/libc/sys/sh/creat.c b/newlib/libc/sys/sh/creat.c
index 62ec5ea..5cce6d0 100644
--- a/newlib/libc/sys/sh/creat.c
+++ b/newlib/libc/sys/sh/creat.c
@@ -1,7 +1,8 @@
+extern int
+_creat (const char *path, int mode);
+
int
-creat(path, mode)
- const char *path;
- int mode;
+creat (const char *path, int mode)
{
return _creat (path, mode);
}
diff --git a/newlib/libc/sys/sh/ftruncate.c b/newlib/libc/sys/sh/ftruncate.c
index 660377b..c358eb1 100644
--- a/newlib/libc/sys/sh/ftruncate.c
+++ b/newlib/libc/sys/sh/ftruncate.c
@@ -2,6 +2,8 @@
#include <sys/types.h>
#include "sys/syscall.h"
+extern int __trap34 (int function, ...);
+
int
ftruncate (int file, off_t length)
{
diff --git a/newlib/libc/sys/sh/syscalls.c b/newlib/libc/sys/sh/syscalls.c
index 614b67e..3c41ece 100644
--- a/newlib/libc/sys/sh/syscalls.c
+++ b/newlib/libc/sys/sh/syscalls.c
@@ -3,11 +3,19 @@
#include <sys/stat.h>
#include <sys/time.h>
#include "sys/syscall.h"
-int errno;
+#include <errno.h>
+#undef errno
+extern int errno;
+
+void abort (void) __attribute__((__noreturn__));
+
+extern int __trap34 (int function, ...);
/* This is used by _sbrk. */
register char *stack_ptr asm ("r15");
+extern int main (int, char**);
+
int
_read (int file,
char *ptr,
@@ -93,34 +101,38 @@ _unlink ()
return -1;
}
-isatty (fd)
- int fd;
+int
+isatty (int fd)
{
return 1;
}
-_isatty (fd)
- int fd;
+int
+_isatty (int fd)
{
return 1;
}
-
-_exit (n)
+_ATTRIBUTE ((__noreturn__)) void
+_exit (int n)
{
- return __trap34 (SYS_exit, n, 0, 0);
+ __trap34 (SYS_exit, n, 0, 0);
}
-_kill (n, m)
+int
+_kill (int pid,
+ int sig)
{
return __trap34 (SYS_exit, 0xdead, 0, 0);
}
-_getpid (n)
+int
+_getpid ()
{
return 1;
}
+void
_raise ()
{
}
@@ -145,9 +157,8 @@ _chown (const char *path, short owner, short group)
}
int
-_utime (path, times)
- const char *path;
- char *times;
+_utime (const char *path,
+ char *times)
{
return __trap34 (SYS_utime, path, times);
}
@@ -159,8 +170,7 @@ _fork ()
}
int
-_wait (statusp)
- int *statusp;
+_wait (int *statusp)
{
return __trap34 (SYS_wait);
}
diff --git a/newlib/libc/sys/sh/truncate.c b/newlib/libc/sys/sh/truncate.c
index 5ca48d3..47a4c06 100644
--- a/newlib/libc/sys/sh/truncate.c
+++ b/newlib/libc/sys/sh/truncate.c
@@ -2,6 +2,8 @@
#include <sys/types.h>
#include "sys/syscall.h"
+extern int __trap34 (int function, ...);
+
int
truncate (const char *path, off_t length)
{
diff --git a/newlib/libm/ld/math_private.h b/newlib/libm/ld/math_private.h
index c5b88f6..6d0183e 100644
--- a/newlib/libm/ld/math_private.h
+++ b/newlib/libm/ld/math_private.h
@@ -705,6 +705,59 @@ irintl(long double x)
}
#endif
+/*
+ * The following are fast floor macros for 0 <= |x| < 0x1p(N-1), where
+ * N is the precision of the type of x. These macros are used in the
+ * half-cycle trignometric functions (e.g., sinpi(x)).
+ */
+#define FFLOORF(x, j0, ix) do { \
+ (j0) = (((ix) >> 23) & 0xff) - 0x7f; \
+ (ix) &= ~(0x007fffff >> (j0)); \
+ SET_FLOAT_WORD((x), (ix)); \
+} while (0)
+
+#define FFLOOR(x, j0, ix, lx) do { \
+ (j0) = (((ix) >> 20) & 0x7ff) - 0x3ff; \
+ if ((j0) < 20) { \
+ (ix) &= ~(0x000fffff >> (j0)); \
+ (lx) = 0; \
+ } else { \
+ (lx) &= ~((uint32_t)0xffffffff >> ((j0) - 20)); \
+ } \
+ INSERT_WORDS((x), (ix), (lx)); \
+} while (0)
+
+#define FFLOORL80(x, j0, ix, lx) do { \
+ j0 = ix - 0x3fff + 1; \
+ if ((j0) < 32) { \
+ (lx) = ((lx) >> 32) << 32; \
+ (lx) &= ~((((lx) << 32)-1) >> (j0)); \
+ } else { \
+ uint64_t _m; \
+ _m = (uint64_t)-1 >> (j0); \
+ if ((lx) & _m) (lx) &= ~_m; \
+ } \
+ INSERT_LDBL80_WORDS((x), (ix), (lx)); \
+} while (0)
+
+#define FFLOORL128(x, ai, ar) do { \
+ union IEEEl2bits u; \
+ uint64_t m; \
+ int e; \
+ u.e = (x); \
+ e = u.bits.exp - 16383; \
+ if (e < 48) { \
+ m = ((1llu << 49) - 1) >> (e + 1); \
+ u.bits.manh &= ~m; \
+ u.bits.manl = 0; \
+ } else { \
+ m = (uint64_t)-1 >> (e - 48); \
+ u.bits.manl &= ~m; \
+ } \
+ (ai) = u.e; \
+ (ar) = (x) - (ai); \
+} while (0)
+
#ifdef DEBUG
#if defined(__amd64__) || defined(__i386__)
#define breakpoint() asm("int $3")
diff --git a/newlib/libm/ld128/Makefile.inc b/newlib/libm/ld128/Makefile.inc
index 337284d..3a04b99 100644
--- a/newlib/libm/ld128/Makefile.inc
+++ b/newlib/libm/ld128/Makefile.inc
@@ -1,7 +1,8 @@
%C%_lsrc = \
%D%/e_powl.c %D%/s_erfl.c %D%/s_exp2l.c %D%/s_expl.c \
%D%/s_logl.c %D%/b_tgammal.c %D%/invtrig.c \
- %D%/e_lgammal_r.c %D%/k_cosl.c %D%/k_sinl.c
+ %D%/e_lgammal_r.c %D%/k_cosl.c %D%/k_sinl.c \
+ %D%/k_tanl.c %D%/s_sinpil.c %D%/s_cospil.c
libm_a_CFLAGS_%C% = -fbuiltin -fno-math-errno
diff --git a/newlib/libm/ld128/k_cospil.h b/newlib/libm/ld128/k_cospil.h
new file mode 100644
index 0000000..592f192
--- /dev/null
+++ b/newlib/libm/ld128/k_cospil.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2017 Steven G. Kargl
+ * 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 unmodified, 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.
+ */
+
+/*
+ * See ../src/k_cospi.c for implementation details.
+ */
+
+static inline long double
+__kernel_cospil(long double x)
+{
+ long double hi, lo;
+
+ hi = (double)x;
+ lo = x - hi;
+ lo = lo * (pi_lo + pi_hi) + hi * pi_lo;
+ hi *= pi_hi;
+ _2sumF(hi, lo);
+ return (__kernel_cosl(hi, lo));
+}
diff --git a/newlib/libm/ld128/k_sinpil.h b/newlib/libm/ld128/k_sinpil.h
new file mode 100644
index 0000000..fa4e7d6
--- /dev/null
+++ b/newlib/libm/ld128/k_sinpil.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2017 Steven G. Kargl
+ * 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 unmodified, 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.
+ */
+
+/*
+ * See ../src/k_sinpi.c for implementation details.
+ */
+
+static inline long double
+__kernel_sinpil(long double x)
+{
+ long double hi, lo;
+
+ hi = (double)x;
+ lo = x - hi;
+ lo = lo * (pi_lo + pi_hi) + hi * pi_lo;
+ hi *= pi_hi;
+ _2sumF(hi, lo);
+ return (__kernel_sinl(hi, lo, 1));
+}
diff --git a/newlib/libm/ld128/k_tanl.c b/newlib/libm/ld128/k_tanl.c
new file mode 100644
index 0000000..9a58cd2
--- /dev/null
+++ b/newlib/libm/ld128/k_tanl.c
@@ -0,0 +1,114 @@
+/*
+ * ====================================================
+ * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * ld128 version of k_tan.c. See ../src/k_tan.c for most comments.
+ */
+
+#include "math.h"
+#include "../ld/math_private.h"
+
+/*
+ * Domain [-0.67434, 0.67434], range ~[-3.37e-36, 1.982e-37]
+ * |tan(x)/x - t(x)| < 2**-117.8 (XXX should be ~1e-37)
+ *
+ * See ../ld80/k_cosl.c for more details about the polynomial.
+ */
+static const long double
+T3 = 0x1.5555555555555555555555555553p-2L,
+T5 = 0x1.1111111111111111111111111eb5p-3L,
+T7 = 0x1.ba1ba1ba1ba1ba1ba1ba1b694cd6p-5L,
+T9 = 0x1.664f4882c10f9f32d6bbe09d8bcdp-6L,
+T11 = 0x1.226e355e6c23c8f5b4f5762322eep-7L,
+T13 = 0x1.d6d3d0e157ddfb5fed8e84e27b37p-9L,
+T15 = 0x1.7da36452b75e2b5fce9ee7c2c92ep-10L,
+T17 = 0x1.355824803674477dfcf726649efep-11L,
+T19 = 0x1.f57d7734d1656e0aceb716f614c2p-13L,
+T21 = 0x1.967e18afcb180ed942dfdc518d6cp-14L,
+T23 = 0x1.497d8eea21e95bc7e2aa79b9f2cdp-15L,
+T25 = 0x1.0b132d39f055c81be49eff7afd50p-16L,
+T27 = 0x1.b0f72d33eff7bfa2fbc1059d90b6p-18L,
+T29 = 0x1.5ef2daf21d1113df38d0fbc00267p-19L,
+T31 = 0x1.1c77d6eac0234988cdaa04c96626p-20L,
+T33 = 0x1.cd2a5a292b180e0bdd701057dfe3p-22L,
+T35 = 0x1.75c7357d0298c01a31d0a6f7d518p-23L,
+T37 = 0x1.2f3190f4718a9a520f98f50081fcp-24L,
+pio4 = 0x1.921fb54442d18469898cc51701b8p-1L,
+pio4lo = 0x1.cd129024e088a67cc74020bbea60p-116L;
+
+static const double
+T39 = 0.000000028443389121318352, /* 0x1e8a7592977938.0p-78 */
+T41 = 0.000000011981013102001973, /* 0x19baa1b1223219.0p-79 */
+T43 = 0.0000000038303578044958070, /* 0x107385dfb24529.0p-80 */
+T45 = 0.0000000034664378216909893, /* 0x1dc6c702a05262.0p-81 */
+T47 = -0.0000000015090641701997785, /* -0x19ecef3569ebb6.0p-82 */
+T49 = 0.0000000029449552300483952, /* 0x194c0668da786a.0p-81 */
+T51 = -0.0000000022006995706097711, /* -0x12e763b8845268.0p-81 */
+T53 = 0.0000000015468200913196612, /* 0x1a92fc98c29554.0p-82 */
+T55 = -0.00000000061311613386849674, /* -0x151106cbc779a9.0p-83 */
+T57 = 1.4912469681508012e-10; /* 0x147edbdba6f43a.0p-85 */
+
+long double
+__kernel_tanl(long double x, long double y, int iy) {
+ long double z, r, v, w, s;
+ long double osign;
+ int i;
+
+ iy = (iy == 1 ? -1 : 1); /* XXX recover original interface */
+ osign = (x >= 0 ? 1.0 : -1.0); /* XXX slow, probably wrong for -0 */
+ if (fabsl(x) >= 0.67434) {
+ if (x < 0) {
+ x = -x;
+ y = -y;
+ }
+ z = pio4 - x;
+ w = pio4lo - y;
+ x = z + w;
+ y = 0.0;
+ i = 1;
+ } else
+ i = 0;
+ z = x * x;
+ w = z * z;
+ r = T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 +
+ w * (T25 + w * (T29 + w * (T33 +
+ w * (T37 + w * (T41 + w * (T45 + w * (T49 + w * (T53 +
+ w * T57))))))))))));
+ v = z * (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 +
+ w * (T27 + w * (T31 + w * (T35 +
+ w * (T39 + w * (T43 + w * (T47 + w * (T51 + w * T55))))))))))));
+ s = z * x;
+ r = y + z * (s * (r + v) + y);
+ r += T3 * s;
+ w = x + r;
+ if (i == 1) {
+ v = (long double) iy;
+ return osign *
+ (v - 2.0 * (x - (w * w / (w + v) - r)));
+ }
+ if (iy == 1)
+ return w;
+ else {
+ /*
+ * if allow error up to 2 ulp, simply return
+ * -1.0 / (x+r) here
+ */
+ /* compute -1.0 / (x+r) accurately */
+ long double a, t;
+ z = w;
+ z = z + 0x1p32 - 0x1p32;
+ v = r - (z - x); /* z+v = r+x */
+ t = a = -1.0 / w; /* a = -1.0/w */
+ t = t + 0x1p32 - 0x1p32;
+ s = 1.0 + t * z;
+ return t + a * (s + t * v);
+ }
+}
diff --git a/newlib/libm/ld128/s_cospil.c b/newlib/libm/ld128/s_cospil.c
new file mode 100644
index 0000000..0ef3177
--- /dev/null
+++ b/newlib/libm/ld128/s_cospil.c
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2017-2023 Steven G. Kargl
+ * 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 unmodified, 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.
+ */
+
+/*
+ * See ../src/s_cospi.c for implementation details.
+ */
+
+#include "../ld/fpmath.h"
+#include "math.h"
+#include "../ld/math_private.h"
+
+/*
+ * pi_hi contains the leading 56 bits of a 169 bit approximation for pi.
+ */
+static const long double
+pi_hi = 3.14159265358979322702026593105983920e+00L,
+pi_lo = 1.14423774522196636802434264184180742e-17L;
+
+#include "k_cospil.h"
+#include "k_sinpil.h"
+
+volatile static const double vzero = 0;
+
+long double
+cospil(long double x)
+{
+ long double ai, ar, ax, c;
+
+ ax = fabsl(x);
+
+ if (ax <= 1) {
+ if (ax < 0.25) {
+ if (ax < 0x1p-60) {
+ if ((int)x == 0)
+ return (1);
+ }
+ return (__kernel_cospil(ax));
+ }
+
+ if (ax < 0.5)
+ c = __kernel_sinpil(0.5 - ax);
+ else if (ax < 0.75) {
+ if (ax == 0.5)
+ return (0);
+ c = -__kernel_sinpil(ax - 0.5);
+ } else
+ c = -__kernel_cospil(1 - ax);
+ return (c);
+ }
+
+ if (ax < 0x1p112) {
+ /* Split ax = ai + ar with 0 <= ar < 1. */
+ FFLOORL128(ax, ai, ar);
+
+ if (ar < 0.5) {
+ if (ar < 0.25)
+ c = ar == 0 ? 1 : __kernel_cospil(ar);
+ else
+ c = __kernel_sinpil(0.5 - ar);
+ } else {
+ if (ar < 0.75) {
+ if (ar == 0.5)
+ return (0);
+ c = -__kernel_sinpil(ar - 0.5);
+ } else
+ c = -__kernel_cospil(1 - ar);
+ }
+ return (fmodl(ai, 2.L) == 0 ? c : -c);
+ }
+
+ if (isinf(x) || isnan(x))
+ return (vzero / vzero);
+
+ /*
+ * For |x| >= 0x1p113, it is always an even integer, so return 1.
+ */
+ if (ax >= 0x1p113)
+ return (1);
+ /*
+ * For 0x1p112 <= |x| < 0x1p113 need to determine if x is an even
+ * or odd integer to return 1 or -1.
+ */
+
+ return (fmodl(ax, 2.L) == 0 ? 1 : -1);
+}
diff --git a/newlib/libm/ld128/s_sinpil.c b/newlib/libm/ld128/s_sinpil.c
new file mode 100644
index 0000000..30d1881
--- /dev/null
+++ b/newlib/libm/ld128/s_sinpil.c
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 2017-2023 Steven G. Kargl
+ * 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 unmodified, 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.
+ */
+
+/*
+ * See ../src/s_sinpi.c for implementation details.
+ */
+
+#include "../ld/fpmath.h"
+#include "math.h"
+#include "../ld/math_private.h"
+
+/*
+ * pi_hi contains the leading 56 bits of a 169 bit approximation for pi.
+ */
+static const long double
+pi_hi = 3.14159265358979322702026593105983920e+00L,
+pi_lo = 1.14423774522196636802434264184180742e-17L;
+
+#include "k_cospil.h"
+#include "k_sinpil.h"
+
+volatile static const double vzero = 0;
+
+long double
+sinpil(long double x)
+{
+ long double ai, ar, ax, hi, lo, s, xhi, xlo;
+
+ ax = fabsl(x);
+
+ if (ax < 1) {
+ if (ax < 0.25) {
+ if (ax < 0x1p-60) {
+ if (x == 0)
+ return (x);
+ hi = (double)x;
+ hi *= 0x1p113L;
+ lo = x * 0x1p113L - hi;
+ s = (pi_lo + pi_hi) * lo + pi_lo * lo +
+ pi_hi * hi;
+ return (s * 0x1p-113L);
+ }
+
+ s = __kernel_sinpil(ax);
+ return (x < 0 ? -s : s);
+ }
+
+ if (ax < 0.5)
+ s = __kernel_cospil(0.5 - ax);
+ else if (ax < 0.75)
+ s = __kernel_cospil(ax - 0.5);
+ else
+ s = __kernel_sinpil(1 - ax);
+ return (x < 0 ? -s : s);
+ }
+
+ if (ax < 0x1p112) {
+ /* Split ax = ai + ar with 0 <= ar < 1. */
+ FFLOORL128(ax, ai, ar);
+
+ if (ar == 0) {
+ s = 0;
+ } else {
+ if (ar < 0.5) {
+ if (ar <= 0.25)
+ s = __kernel_sinpil(ar);
+ else
+ s = __kernel_cospil(0.5 - ar);
+ } else {
+ if (ar < 0.75)
+ s = __kernel_cospil(ar - 0.5);
+ else
+ s = __kernel_sinpil(1 - ar);
+ }
+
+ s = fmodl(ai, 2.L) == 0 ? s : -s;
+ }
+ return (x < 0 ? -s : s);
+ }
+
+ if (isinf(x) || isnan(x))
+ return (vzero / vzero);
+
+ /*
+ * |x| >= 0x1p112 is always an integer, so return +-0.
+ */
+ return (copysignl(0, x));
+}
diff --git a/newlib/libm/ld80/Makefile.inc b/newlib/libm/ld80/Makefile.inc
index 97fbacd..7bb20f7 100644
--- a/newlib/libm/ld80/Makefile.inc
+++ b/newlib/libm/ld80/Makefile.inc
@@ -1,8 +1,8 @@
%C%_lsrc = \
%D%/b_tgammal.c %D%/e_powl.c %D%/s_erfl.c %D%/s_exp2l.c \
%D%/s_expl.c %D%/s_logl.c %D%/s_sinpil.c %D%/s_cospil.c \
- %D%/invtrig.c %D%/e_lgammal_r.c %D%/k_cosl.c %D%/k_sinl.c
-
+ %D%/invtrig.c %D%/e_lgammal_r.c %D%/k_cosl.c %D%/k_sinl.c \
+ %D%/k_tanl.c
libm_a_CFLAGS_%C% = -fbuiltin -fno-math-errno
diff --git a/newlib/libm/ld80/k_tanl.c b/newlib/libm/ld80/k_tanl.c
new file mode 100644
index 0000000..c55303f
--- /dev/null
+++ b/newlib/libm/ld80/k_tanl.c
@@ -0,0 +1,119 @@
+/*
+ * ====================================================
+ * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * ld80 version of k_tan.c. See ../src/k_tan.c for most comments.
+ */
+
+#include "math.h"
+#include "../ld/math_private.h"
+
+/*
+ * Domain [-0.67434, 0.67434], range ~[-2.25e-22, 1.921e-22]
+ * |tan(x)/x - t(x)| < 2**-71.9
+ *
+ * See k_cosl.c for more details about the polynomial.
+ */
+#if defined(__amd64__) || defined(__i386__)
+/* Long double constants are slow on these arches, and broken on i386. */
+static const volatile double
+T3hi = 0.33333333333333331, /* 0x15555555555555.0p-54 */
+T3lo = 1.8350121769317163e-17, /* 0x15280000000000.0p-108 */
+T5hi = 0.13333333333333336, /* 0x11111111111112.0p-55 */
+T5lo = 1.3051083651294260e-17, /* 0x1e180000000000.0p-109 */
+T7hi = 0.053968253968250494, /* 0x1ba1ba1ba1b827.0p-57 */
+T7lo = 3.1509625637859973e-18, /* 0x1d100000000000.0p-111 */
+pio4_hi = 0.78539816339744828, /* 0x1921fb54442d18.0p-53 */
+pio4_lo = 3.0628711372715500e-17, /* 0x11a80000000000.0p-107 */
+pio4lo_hi = -1.2541394031670831e-20, /* -0x1d9cceba3f91f2.0p-119 */
+pio4lo_lo = 6.1493048227390915e-37; /* 0x1a280000000000.0p-173 */
+#define T3 ((long double)T3hi + T3lo)
+#define T5 ((long double)T5hi + T5lo)
+#define T7 ((long double)T7hi + T7lo)
+#define pio4 ((long double)pio4_hi + pio4_lo)
+#define pio4lo ((long double)pio4lo_hi + pio4lo_lo)
+#else
+static const long double
+T3 = 0.333333333333333333180L, /* 0xaaaaaaaaaaaaaaa5.0p-65 */
+T5 = 0.133333333333333372290L, /* 0x88888888888893c3.0p-66 */
+T7 = 0.0539682539682504975744L, /* 0xdd0dd0dd0dc13ba2.0p-68 */
+pio4 = 0.785398163397448309628L, /* 0xc90fdaa22168c235.0p-64 */
+pio4lo = -1.25413940316708300586e-20L; /* -0xece675d1fc8f8cbb.0p-130 */
+#endif
+
+static const double
+T9 = 0.021869488536312216, /* 0x1664f4882cc1c2.0p-58 */
+T11 = 0.0088632355256619590, /* 0x1226e355c17612.0p-59 */
+T13 = 0.0035921281113786528, /* 0x1d6d3d185d7ff8.0p-61 */
+T15 = 0.0014558334756312418, /* 0x17da354aa3f96b.0p-62 */
+T17 = 0.00059003538700862256, /* 0x13559358685b83.0p-63 */
+T19 = 0.00023907843576635544, /* 0x1f56242026b5be.0p-65 */
+T21 = 0.000097154625656538905, /* 0x1977efc26806f4.0p-66 */
+T23 = 0.000038440165747303162, /* 0x14275a09b3ceac.0p-67 */
+T25 = 0.000018082171885432524, /* 0x12f5e563e5487e.0p-68 */
+T27 = 0.0000024196006108814377, /* 0x144c0d80cc6896.0p-71 */
+T29 = 0.0000078293456938132840, /* 0x106b59141a6cb3.0p-69 */
+T31 = -0.0000032609076735050182, /* -0x1b5abef3ba4b59.0p-71 */
+T33 = 0.0000023261313142559411; /* 0x13835436c0c87f.0p-71 */
+
+long double
+__kernel_tanl(long double x, long double y, int iy) {
+ long double z, r, v, w, s;
+ long double osign;
+ int i;
+
+ iy = (iy == 1 ? -1 : 1); /* XXX recover original interface */
+ osign = (x >= 0 ? 1.0 : -1.0); /* XXX slow, probably wrong for -0 */
+ if (fabsl(x) >= 0.67434) {
+ if (x < 0) {
+ x = -x;
+ y = -y;
+ }
+ z = pio4 - x;
+ w = pio4lo - y;
+ x = z + w;
+ y = 0.0;
+ i = 1;
+ } else
+ i = 0;
+ z = x * x;
+ w = z * z;
+ r = T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 +
+ w * (T25 + w * (T29 + w * T33))))));
+ v = z * (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 +
+ w * (T27 + w * T31))))));
+ s = z * x;
+ r = y + z * (s * (r + v) + y);
+ r += T3 * s;
+ w = x + r;
+ if (i == 1) {
+ v = (long double) iy;
+ return osign *
+ (v - 2.0 * (x - (w * w / (w + v) - r)));
+ }
+ if (iy == 1)
+ return w;
+ else {
+ /*
+ * if allow error up to 2 ulp, simply return
+ * -1.0 / (x+r) here
+ */
+ /* compute -1.0 / (x+r) accurately */
+ long double a, t;
+ z = w;
+ z = z + 0x1p32 - 0x1p32;
+ v = r - (z - x); /* z+v = r+x */
+ t = a = -1.0 / w; /* a = -1.0/w */
+ t = t + 0x1p32 - 0x1p32;
+ s = 1.0 + t * z;
+ return t + a * (s + t * v);
+ }
+}
diff --git a/newlib/libm/machine/arm/s_fma_arm.c b/newlib/libm/machine/arm/s_fma_arm.c
index f945419..6a2b403 100644
--- a/newlib/libm/machine/arm/s_fma_arm.c
+++ b/newlib/libm/machine/arm/s_fma_arm.c
@@ -41,7 +41,7 @@
double
fma (double x, double y, double z)
{
- asm ("vfma.f64 %P0, %P1, %P2" : "=w" (z) : "w" (x), "w" (y));
+ asm ("vfma.f64 %P0, %P1, %P2" : "+w" (z) : "w" (x), "w" (y));
return z;
}
diff --git a/newlib/libm/machine/arm/sf_fma_arm.c b/newlib/libm/machine/arm/sf_fma_arm.c
index 4befd90..8d1b63d 100644
--- a/newlib/libm/machine/arm/sf_fma_arm.c
+++ b/newlib/libm/machine/arm/sf_fma_arm.c
@@ -41,7 +41,7 @@
float
fmaf (float x, float y, float z)
{
- asm ("vfma.f32 %0, %1, %2" : "=t" (z) : "t" (x), "t" (y));
+ asm ("vfma.f32 %0, %1, %2" : "+t" (z) : "t" (x), "t" (y));
return z;
}
diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc
index d4c003b..6eb6a41 100644
--- a/winsup/cygwin/devices.cc
+++ b/winsup/cygwin/devices.cc
@@ -83,8 +83,8 @@ exists_console (const device& dev)
default:
if (dev.get_minor () < MAX_CONS_DEV)
{
- unsigned long bitmask = fhandler_console::console_unit (CONS_LIST_USED);
- return !!(bitmask & (1UL << dev.get_minor ()));
+ int n = fhandler_console::console_unit (dev.get_minor ());
+ return (n == dev.get_minor ());
}
return false;
}
diff --git a/winsup/cygwin/devices.in b/winsup/cygwin/devices.in
index a86e501..ea9a70e 100644
--- a/winsup/cygwin/devices.in
+++ b/winsup/cygwin/devices.in
@@ -79,8 +79,8 @@ exists_console (const device& dev)
default:
if (dev.get_minor () < MAX_CONS_DEV)
{
- unsigned long bitmask = fhandler_console::console_unit (CONS_LIST_USED);
- return !!(bitmask & (1UL << dev.get_minor ()));
+ int n = fhandler_console::console_unit (dev.get_minor ());
+ return (n == dev.get_minor ());
}
return false;
}
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index a2a6f9d..28d0431 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1717,7 +1717,10 @@ _cygtls::call_signal_handler ()
context, unwind to the caller and in case we're called
from sigdelayed, fix the instruction pointer accordingly. */
context.uc_mcontext.ctxflags = CONTEXT_FULL;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
RtlCaptureContext ((PCONTEXT) &context.uc_mcontext);
+#pragma GCC diagnostic pop
__unwind_single_frame ((PCONTEXT) &context.uc_mcontext);
if (stackptr > stack)
{
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index 1c0d5c8..d4c3f10 100644
--- a/winsup/cygwin/fhandler/console.cc
+++ b/winsup/cygwin/fhandler/console.cc
@@ -33,6 +33,7 @@ details. */
#include "child_info.h"
#include "cygwait.h"
#include "winf.h"
+#include "psapi.h"
/* Don't make this bigger than NT_MAX_PATH as long as the temporary buffer
is allocated using tmp_pathbuf!!! */
@@ -48,6 +49,9 @@ details. */
con.b.srWindow.Top + con.scroll_region.Bottom)
#define con_is_legacy (shared_console_info[unit] && con.is_legacy)
+static HANDLE NO_COPY shared_info_mutex;
+static int NO_COPY shared_info_state[MAX_CONS_DEV];
+
#define CONS_THREAD_SYNC "cygcons.thread_sync"
static bool NO_COPY master_thread_started = false;
@@ -224,44 +228,52 @@ fhandler_console::open_shared_console (HWND hw, HANDLE& h, bool& created)
return res;
}
-BOOL CALLBACK
-fhandler_console::enum_windows (HWND hw, LPARAM lp)
+fhandler_console::console_unit::console_unit (int n0, HANDLE *input_mutex) :
+ n (-1)
{
- console_unit *this1 = (console_unit *) lp;
- HANDLE h = NULL;
- fhandler_console::console_state *cs;
- if ((cs = fhandler_console::open_shared_console (hw, h)))
+ char buf[MAX_PATH];
+ for (int i = max(0, n0); i < MAX_CONS_DEV; i++)
{
- CloseHandle (h);
- if (major (cs->tty_min_state.getntty ()) == DEV_CONS_MAJOR)
- this1->bitmask |= 1UL << minor (cs->tty_min_state.getntty ());
- if (this1->n == minor (cs->tty_min_state.getntty ()))
+ shared_name (buf, "cygcons.input.mutex", i);
+ SetLastError (ERROR_SUCCESS);
+ HANDLE input_mutex0 = CreateMutex (&sec_none, FALSE, buf);
+ DWORD err = GetLastError ();
+ if (err == ERROR_ALREADY_EXISTS || err == ERROR_ACCESS_DENIED)
{
- this1->shared_console_info = cs;
- return FALSE;
+ if (n0 >= 0)
+ n = i;
}
- UnmapViewOfFile ((void *) cs);
+ else if (n0 == CONS_SCAN_UNUSED)
+ {
+ n = i;
+ if (input_mutex)
+ *input_mutex = input_mutex0;
+ break;
+ }
+ if (input_mutex0)
+ CloseHandle (input_mutex0);
+ if (n0 >= 0)
+ break;
}
- else
- { /* Only for ConEmu */
- char class_hw[32];
- if (19 == GetClassName (hw, class_hw, sizeof (class_hw))
- && 0 == strcmp (class_hw, "VirtualConsoleClass"))
- EnumChildWindows (hw, fhandler_console::enum_windows, lp);
+ if (n0 == CONS_SCAN_UNUSED && n < 0)
+ {
+ __small_sprintf (buf, "console device allocation failure - "
+ "too many consoles in use, max consoles is %d",
+ MAX_CONS_DEV);
+ api_fatal (buf);
}
- return TRUE;
}
-fhandler_console::console_unit::console_unit (int n0):
- n (n0), bitmask (0), shared_console_info (NULL)
+fhandler_console::console_unit::operator console_state * () const
{
- EnumWindows (fhandler_console::enum_windows, (LPARAM) this);
- if (n0 == CONS_SCAN_UNUSED && (n = ffsl (~bitmask) - 1) < 0)
- api_fatal (sizeof (bitmask) == 8 ?
- "console device allocation failure - "
- "too many consoles in use, max consoles is 64" :
- "console device allocation failure - "
- "too many consoles in use, max consoles is 32");
+ if (n < 0 || n >= MAX_CONS_DEV)
+ return NULL;
+ HANDLE h = NULL;
+ fhandler_console::console_state *cs;
+ HWND hw = cygwin_shared->cons_hwnd[n];
+ if ((cs = fhandler_console::open_shared_console (hw, h)))
+ CloseHandle (h);
+ return cs;
}
static DWORD
@@ -272,17 +284,23 @@ cons_master_thread (VOID *arg)
fhandler_console::handle_set_t handle_set;
fh->get_duplicated_handle_set (&handle_set);
HANDLE thread_sync_event;
- DuplicateHandle (GetCurrentProcess (), fh->thread_sync_event,
- GetCurrentProcess (), &thread_sync_event,
- 0, FALSE, DUPLICATE_SAME_ACCESS);
- SetEvent (thread_sync_event);
- master_thread_started = true;
- /* Do not touch class members after here because the class instance
- may have been destroyed. */
- fhandler_console::cons_master_thread (&handle_set, ttyp);
- fhandler_console::close_handle_set (&handle_set);
- SetEvent (thread_sync_event);
- CloseHandle (thread_sync_event);
+ if (DuplicateHandle (GetCurrentProcess (), fh->thread_sync_event,
+ GetCurrentProcess (), &thread_sync_event,
+ 0, FALSE, DUPLICATE_SAME_ACCESS))
+ {
+ SetEvent (thread_sync_event);
+ master_thread_started = true;
+ /* Do not touch class members after here because the class instance
+ may have been destroyed. */
+ fhandler_console::cons_master_thread (&handle_set, ttyp);
+ fhandler_console::close_handle_set (&handle_set);
+ SetEvent (thread_sync_event);
+ CloseHandle (thread_sync_event);
+ master_thread_started = false;
+ }
+ else
+ debug_printf ("cons_master_thread not started because thread_sync_event "
+ "could not be duplicated %08x", GetLastError ());
return 0;
}
@@ -451,6 +469,8 @@ fhandler_console::cons_master_thread (handle_set_t *p, tty *ttyp)
case WAIT_CANCELED:
break;
default: /* Error */
+ free (input_rec);
+ free (input_tmp);
ReleaseMutex (p->input_mutex);
return;
}
@@ -650,6 +670,11 @@ fhandler_console::set_unit ()
else if (myself->ctty != CTTY_UNINITIALIZED)
unit = device::minor (myself->ctty);
+ if (!shared_info_mutex)
+ shared_info_mutex = CreateMutex (&sec_none_nih, FALSE, NULL);
+
+ WaitForSingleObject (shared_info_mutex, INFINITE);
+
if (shared_console_info[unit])
; /* Do nothing */
else if (generic_console
@@ -658,7 +683,10 @@ fhandler_console::set_unit ()
else
{
if (!generic_console && (dev_t) myself->ctty != get_device ())
- shared_console_info[unit] = console_unit (unit);
+ {
+ shared_console_info[unit] = console_unit (unit);
+ shared_info_state[unit]++;
+ }
if (generic_console || !shared_console_info[unit])
{
me = GetConsoleWindow ();
@@ -669,10 +697,12 @@ fhandler_console::set_unit ()
created = true;
fhandler_console::console_state *cs =
open_shared_console (me, cygheap->console_h, created);
+ shared_info_state[unit]++;
ProtectHandleINH (cygheap->console_h);
if (created)
{
- unit = console_unit (CONS_SCAN_UNUSED);
+ unit = console_unit (CONS_SCAN_UNUSED, &input_mutex);
+ cygwin_shared->cons_hwnd[unit] = me;
cs->tty_min_state.setntty (DEV_CONS_MAJOR, unit);
}
else
@@ -683,6 +713,8 @@ fhandler_console::set_unit ()
}
}
}
+ ReleaseMutex (shared_info_mutex);
+
if (shared_console_info[unit])
{
devset = (fh_devices) shared_console_info[unit]->tty_min_state.getntty ();
@@ -1847,9 +1879,15 @@ fhandler_console::open (int flags, mode_t)
char name[MAX_PATH];
shared_name (name, CONS_THREAD_SYNC, get_minor ());
thread_sync_event = CreateEvent(NULL, FALSE, FALSE, name);
- new cygthread (::cons_master_thread, this, "consm");
- WaitForSingleObject (thread_sync_event, INFINITE);
- CloseHandle (thread_sync_event);
+ if (thread_sync_event)
+ {
+ new cygthread (::cons_master_thread, this, "consm");
+ WaitForSingleObject (thread_sync_event, INFINITE);
+ CloseHandle (thread_sync_event);
+ }
+ else
+ debug_printf ("Failed to create thread_sync_event %08x",
+ GetLastError ());
}
return 1;
}
@@ -1910,9 +1948,15 @@ fhandler_console::close ()
char name[MAX_PATH];
shared_name (name, CONS_THREAD_SYNC, get_minor ());
thread_sync_event = OpenEvent (MAXIMUM_ALLOWED, FALSE, name);
- con.owner = MAX_PID + 1;
- WaitForSingleObject (thread_sync_event, INFINITE);
- CloseHandle (thread_sync_event);
+ if (thread_sync_event)
+ {
+ con.owner = MAX_PID + 1;
+ WaitForSingleObject (thread_sync_event, INFINITE);
+ CloseHandle (thread_sync_event);
+ }
+ else
+ debug_printf ("Failed to open thread_sync_event %08x",
+ GetLastError ());
}
con.owner = 0;
}
@@ -1927,7 +1971,23 @@ fhandler_console::close ()
if (!have_execed && !invisible_console
&& (!CTTY_IS_VALID (myself->ctty)
|| get_device () == (dev_t) myself->ctty))
- free_console ();
+ {
+ /* ConEmu hack. Detach from ConEmu to unhook console APIs. */
+ HMODULE h = GetModuleHandle ("ConEmuHk64.dll");
+ if (h)
+ {
+ MODULEINFO mi;
+ if (GetModuleInformation (GetCurrentProcess (), h, &mi, sizeof (mi)))
+ {
+ BOOL (*DllMain)(HINSTANCE, DWORD, LPVOID) =
+ (BOOL (*)(HINSTANCE, DWORD, LPVOID)) mi.EntryPoint;
+ DllMain (h, DLL_PROCESS_DETACH, NULL);
+ }
+ }
+
+ /* Freeing console to detach the process from the console. */
+ free_console ();
+ }
release_output_mutex ();
@@ -1936,11 +1996,13 @@ fhandler_console::close ()
CloseHandle (output_mutex);
output_mutex = NULL;
- if (shared_console_info[unit] && myself->ctty != tc ()->ntty)
+ WaitForSingleObject (shared_info_mutex, INFINITE);
+ if (--shared_info_state[unit] == 0 && shared_console_info[unit])
{
UnmapViewOfFile ((void *) shared_console_info[unit]);
shared_console_info[unit] = NULL;
}
+ ReleaseMutex (shared_info_mutex);
return 0;
}
diff --git a/winsup/cygwin/fhandler/dsp.cc b/winsup/cygwin/fhandler/dsp.cc
index 59c11ac..605a048 100644
--- a/winsup/cygwin/fhandler/dsp.cc
+++ b/winsup/cygwin/fhandler/dsp.cc
@@ -1026,19 +1026,19 @@ fhandler_dev_dsp::fhandler_dev_dsp ():
ssize_t
fhandler_dev_dsp::write (const void *ptr, size_t len)
{
- return base ()->_write (ptr, len);
+ return base ()->_write (ptr, len, this);
}
void
fhandler_dev_dsp::read (void *ptr, size_t& len)
{
- base ()->_read (ptr, len);
+ base ()->_read (ptr, len, this);
}
int
fhandler_dev_dsp::ioctl (unsigned int cmd, void *buf)
{
- return base ()->_ioctl (cmd, buf);
+ return base ()->_ioctl (cmd, buf, this);
}
int
@@ -1065,7 +1065,6 @@ fhandler_dev_dsp::open (int flags, mode_t mode)
{
int ret = -1, err = 0;
UINT num_in = 0, num_out = 0;
- set_flags ((flags & ~O_TEXT) | O_BINARY);
// Work out initial sample format & frequency, /dev/dsp defaults
audioformat_ = AFMT_U8;
audiofreq_ = 8000;
@@ -1105,11 +1104,11 @@ fhandler_dev_dsp::open (int flags, mode_t mode)
return ret;
}
-#define IS_WRITE() ((get_flags() & O_ACCMODE) != O_RDONLY)
-#define IS_READ() ((get_flags() & O_ACCMODE) != O_WRONLY)
+#define IS_WRITE() ((fh->get_flags() & O_ACCMODE) != O_RDONLY)
+#define IS_READ() ((fh->get_flags() & O_ACCMODE) != O_WRONLY)
ssize_t
-fhandler_dev_dsp::_write (const void *ptr, size_t len)
+fhandler_dev_dsp::_write (const void *ptr, size_t len, fhandler_dev_dsp *fh)
{
debug_printf ("ptr=%p len=%ld", ptr, len);
int len_s = len;
@@ -1168,7 +1167,7 @@ fhandler_dev_dsp::_write (const void *ptr, size_t len)
}
void
-fhandler_dev_dsp::_read (void *ptr, size_t& len)
+fhandler_dev_dsp::_read (void *ptr, size_t& len, fhandler_dev_dsp *fh)
{
debug_printf ("ptr=%p len=%ld", ptr, len);
@@ -1244,7 +1243,7 @@ fhandler_dev_dsp::close ()
}
int
-fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
+fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf, fhandler_dev_dsp *fh)
{
debug_printf ("audio_in=%p audio_out=%p", audio_in_, audio_out_);
int *intbuf = (int *) buf;
@@ -1349,7 +1348,7 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
CASE (SNDCTL_DSP_STEREO)
{
int nChannels = *intbuf + 1;
- int res = _ioctl (SNDCTL_DSP_CHANNELS, &nChannels);
+ int res = _ioctl (SNDCTL_DSP_CHANNELS, &nChannels, fh);
*intbuf = nChannels - 1;
return res;
}
@@ -1547,3 +1546,10 @@ fhandler_dev_dsp::read_ready ()
{
return base ()->_read_ready ();
}
+
+bool
+fhandler_dev_dsp::open_setup (int flags)
+{
+ set_flags ((flags & ~O_TEXT) | O_BINARY);
+ return fhandler_base::open_setup (flags);
+}
diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc
index baf0cae..8c7a4ab 100644
--- a/winsup/cygwin/fhandler/proc.cc
+++ b/winsup/cygwin/fhandler/proc.cc
@@ -1021,14 +1021,14 @@ format_proc_cpuinfo (void *, char *&destbuf)
ftcprint (features1, 9, "apic"); /* APIC enabled */
ftcprint (features1, 11, "sep"); /* sysenter/sysexit */
ftcprint (features1, 12, "mtrr"); /* memory type range registers */
- ftcprint (features1, 13, "pge"); /* page global extension */
+ ftcprint (features1, 13, "pge"); /* page global enable */
ftcprint (features1, 14, "mca"); /* machine check architecture */
ftcprint (features1, 15, "cmov"); /* conditional move */
ftcprint (features1, 16, "pat"); /* page attribute table */
ftcprint (features1, 17, "pse36");/* 36 bit page size extensions */
ftcprint (features1, 18, "pn"); /* processor serial number */
ftcprint (features1, 19, "clflush"); /* clflush instruction */
- ftcprint (features1, 21, "dts"); /* debug store */
+ ftcprint (features1, 21, "ds"); /* debug store */
ftcprint (features1, 22, "acpi"); /* ACPI via MSR */
ftcprint (features1, 23, "mmx"); /* multimedia extensions */
ftcprint (features1, 24, "fxsr"); /* fxsave/fxrstor */
@@ -1326,13 +1326,6 @@ format_proc_cpuinfo (void *, char *&destbuf)
ftcprint (features1, 3, "epb"); /* energy perf bias */
}
- /* cpuid 0x00000007:1 ebx */
- if (maxf >= 0x00000007)
- {
- cpuid (&unused, &features1, &unused, &unused, 0x00000007, 1);
-
- ftcprint (features1, 0, "intel_ppin"); /* Prot Proc Id No */
- }
/* cpuid 0x00000010 ebx */
if (maxf >= 0x00000010)
{
@@ -1360,6 +1353,13 @@ format_proc_cpuinfo (void *, char *&destbuf)
/* ftcprint (features1, 11, "pti");*//* Page Table Isolation reqd with Meltdown */
+ /* cpuid 0x00000007:1 ebx */
+ if (maxf >= 0x00000007)
+ {
+ cpuid (&unused, &features1, &unused, &unused, 0x00000007, 1);
+
+ ftcprint (features1, 0, "intel_ppin"); /* Prot Proc Id No */
+ }
/* cpuid 0x00000010:2 ecx */
if (maxf >= 0x00000010)
{
@@ -1406,8 +1406,8 @@ format_proc_cpuinfo (void *, char *&destbuf)
/* ftcprint (features1, 4, "rdpru"); *//* user level rd proc reg */
/* ftcprint (features1, 6, "mba"); *//* memory BW alloc */
/* ftcprint (features1, 9, "wbnoinvd"); *//* wbnoinvd instruction */
- ftcprint (features1, 12, "ibpb"); /* ind br pred barrier */
ftcprint (features1, 14, "ibrs"); /* ind br restricted spec */
+ ftcprint (features1, 12, "ibpb"); /* ind br pred barrier */
ftcprint (features1, 15, "stibp"); /* 1 thread ind br pred */
ftcprint (features1, 16, "ibrs_enhanced"); /* ibrs_enhanced IBRS always on */
/* ftcprint (features1, 17, "stibp_always_on"); */ /* stibp always on */
@@ -1442,14 +1442,14 @@ format_proc_cpuinfo (void *, char *&destbuf)
ftcprint (features1, 3, "bmi1"); /* bit manip ext group 1 */
ftcprint (features1, 4, "hle"); /* hardware lock elision */
ftcprint (features1, 5, "avx2"); /* AVX ext instructions */
-/* ftcprint (features1, 6, "fpdx"); */ /* "" FP data ptr upd on exc */
+/* ftcprint (features1, 6, "fdp_excptn_only"); *//* FP data ptr upd on exc */
ftcprint (features1, 7, "smep"); /* super mode exec prot */
ftcprint (features1, 8, "bmi2"); /* bit manip ext group 2 */
ftcprint (features1, 9, "erms"); /* enh rep movsb/stosb */
ftcprint (features1, 10, "invpcid"); /* inv proc context id */
ftcprint (features1, 11, "rtm"); /* restricted txnal mem */
ftcprint (features1, 12, "cqm"); /* cache QoS monitoring */
-/* ftcprint (features1, 13, "fpcsdsz"); */ /* "" zero FP cs/ds */
+/* ftcprint (features1, 13, "zero_fcs_fds");*//* zero FP CS/DS */
ftcprint (features1, 14, "mpx"); /* mem prot ext */
ftcprint (features1, 15, "rdt_a"); /* rsrc dir tech alloc */
ftcprint (features1, 16, "avx512f"); /* vec foundation */
@@ -1541,11 +1541,11 @@ format_proc_cpuinfo (void *, char *&destbuf)
ftcprint (features1, 4, "rdpru"); /* user level rd proc reg */
/* ftcprint (features1, 6, "mba"); */ /* memory BW alloc */
ftcprint (features1, 9, "wbnoinvd"); /* wbnoinvd instruction */
-/* ftcprint (features1, 12, "ibpb" ); */ /* ind br pred barrier */
-/* ftcprint (features1, 14, "ibrs" ); */ /* ind br restricted spec */
-/* ftcprint (features1, 15, "stibp"); */ /* 1 thread ind br pred */
-/* ftcprint (features1, 16, "ibrs_enhanced"); */ /* ibrs_enhanced IBRS always on */
-/* ftcprint (features1, 17, "stibp_always_on"); */ /* stibp always on */
+/* ftcprint (features1, 12, "amd_ibpb" ); */ /* ind br pred barrier */
+/* ftcprint (features1, 14, "amd_ibrs" ); */ /* ind br restricted spec */
+/* ftcprint (features1, 15, "amd_stibp"); */ /* 1 thread ind br pred */
+/* ftcprint (features1, 16, "ibrs_enhanced");*//* ibrs_enhanced IBRS always on */
+/* ftcprint (features1, 17, "amd_stibp_always_on");*//* stibp always on */
/* ftcprint (features1, 18, "ibrs_pref"); */ /* ibrs_pref IBRS preferred */
ftcprint (features1, 23, "amd_ppin"); /* protected proc id no */
/* ftcprint (features1, 24, "ssbd"); */ /* spec store byp dis */
@@ -1572,6 +1572,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
ftcprint (features1, 9, "hwp_act_window"); /* HWP activity window */
ftcprint (features1, 10, "hwp_epp"); /* HWP energy perf pref */
ftcprint (features1, 11, "hwp_pkg_req"); /* HWP package level req */
+/* ftcprint (features1, 15, "hwp_highest_perf_change");*//* HWP highest perf change */
ftcprint (features1, 19, "hfi"); /* Hardware Feedback Interface */
}
@@ -1593,6 +1594,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
ftcprint (features1, 13, "avic"); /* virt int control */
ftcprint (features1, 15, "v_vmsave_vmload"); /* virt vmsave vmload */
ftcprint (features1, 16, "vgif"); /* virt glb int flag */
+ ftcprint (features1, 18, "x2avic"); /* virt x2apic */
ftcprint (features1, 20, "v_spec_ctrl"); /* virt spec ctrl support */
ftcprint (features1, 25, "vnmi"); /* virt NMI */
/* ftcprint (features1, 28, "svme_addr_chk"); *//* secure vmexit addr check */
@@ -1687,6 +1689,13 @@ format_proc_cpuinfo (void *, char *&destbuf)
/* ftcprint (features2, 16, "vte"); *//* virtual transparent encryption */
}
+ /* cpuid 0x80000022 eax */
+ if (is_amd && maxe >= 0x80000022)
+ {
+ cpuid (&features1, &unused, &unused, &unused, 0x80000022);
+ ftcprint (features1, 2, "amd_lbr_pmc_freeze ");/* AMD LBR & PMC Freeze */
+ }
+
print ("\n");
bufptr += __small_sprintf (bufptr, "bogomips\t: %d.00\n",
@@ -1744,16 +1753,17 @@ format_proc_cpuinfo (void *, char *&destbuf)
ftcprint (features1, 12, "acc_power"); /* core power reporting */
/* ftcprint (features1, 13, "connstby"); */ /* connected standby */
/* ftcprint (features1, 14, "rapl"); */ /* running average power limit */
+
+ print ("\n");
}
+ print ("\n");
+
if (orig_affinity_mask != 0)
SetThreadGroupAffinity (GetCurrentThread (), &orig_group_affinity,
NULL);
- print ("\n");
}
- print ("\n");
-
destbuf = (char *) crealloc_abort (destbuf, bufptr - buf);
memcpy (destbuf, buf, bufptr - buf);
return bufptr - buf;
diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index 9d7ef3c..fa6bf10 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -3118,8 +3118,22 @@ fhandler_pty_common::process_opost_output (HANDLE h, const void *ptr,
return res; /* Discard write data */
while (towrite)
{
+ ssize_t space = towrite;
if (!is_echo)
{
+ IO_STATUS_BLOCK iosb = {{0}, 0};
+ FILE_PIPE_LOCAL_INFORMATION fpli = {0};
+ NTSTATUS status;
+
+ status = NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
+ FilePipeLocalInformation);
+ if (!NT_SUCCESS (status))
+ {
+ if (towrite < len)
+ break;
+ len = -1;
+ return FALSE;
+ }
if (ttyp->output_stopped && is_nonblocking)
{
if (towrite < len)
@@ -3131,13 +3145,18 @@ fhandler_pty_common::process_opost_output (HANDLE h, const void *ptr,
return TRUE;
}
}
- while (ttyp->output_stopped)
- cygwait (10);
+ if (ttyp->output_stopped || fpli.WriteQuotaAvailable == 0)
+ {
+ cygwait (1);
+ continue;
+ }
+ space = fpli.WriteQuotaAvailable;
}
if (!(ttyp->ti.c_oflag & OPOST)) // raw output mode
{
DWORD n = MIN (OUT_BUFFER_SIZE, towrite);
+ n = MIN (n, space);
res = WriteFile (h, ptr, n, &n, NULL);
if (!res)
break;
@@ -3150,7 +3169,7 @@ fhandler_pty_common::process_opost_output (HANDLE h, const void *ptr,
char *buf = (char *)ptr;
DWORD n = 0;
ssize_t rc = 0;
- while (n < OUT_BUFFER_SIZE && rc < towrite)
+ while (n < OUT_BUFFER_SIZE && n < space && rc < towrite)
{
switch (buf[rc])
{
diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h
index 978d3e5..8b02a2b 100644
--- a/winsup/cygwin/local_includes/fhandler.h
+++ b/winsup/cygwin/local_includes/fhandler.h
@@ -2191,10 +2191,6 @@ class dev_console
friend class fhandler_console;
};
-#define MAX_CONS_DEV (sizeof (unsigned long) * 8)
-#define CONS_SCAN_UNUSED (-1)
-#define CONS_LIST_USED (-2)
-
/* This is a input and output console handle */
class fhandler_console: public fhandler_termios
{
@@ -2387,13 +2383,10 @@ private:
class console_unit
{
int n;
- unsigned long bitmask;
- console_state *shared_console_info;
public:
- operator console_state * () const {return shared_console_info;}
- operator unsigned long () const {return n == CONS_LIST_USED ? bitmask : n;}
- console_unit (int);
- friend BOOL CALLBACK fhandler_console::enum_windows (HWND, LPARAM);
+ operator console_state * () const;
+ operator int () const { return n; }
+ console_unit (int, HANDLE *input_mutex = NULL);
};
friend tty_min * tty_list::get_cttyp ();
@@ -2881,11 +2874,12 @@ class fhandler_dev_dsp: public fhandler_base
int close ();
void fixup_after_fork (HANDLE);
void fixup_after_exec ();
+ bool open_setup (int);
private:
- ssize_t _write (const void *, size_t);
- void _read (void *, size_t&);
- int _ioctl (unsigned int, void *);
+ ssize_t _write (const void *, size_t, fhandler_dev_dsp *);
+ void _read (void *, size_t&, fhandler_dev_dsp *);
+ int _ioctl (unsigned int, void *, fhandler_dev_dsp *);
int _fcntl (int cmd, intptr_t);
void _fixup_after_fork (HANDLE);
void _fixup_after_exec ();
diff --git a/winsup/cygwin/local_includes/shared_info.h b/winsup/cygwin/local_includes/shared_info.h
index cbe55a2..4316717 100644
--- a/winsup/cygwin/local_includes/shared_info.h
+++ b/winsup/cygwin/local_includes/shared_info.h
@@ -33,7 +33,7 @@ public:
/* Data accessible to all tasks */
-#define CURR_SHARED_MAGIC 0x9f33cc5dU
+#define CURR_SHARED_MAGIC 0x205f4579U
#define USER_VERSION 1
@@ -46,6 +46,7 @@ class shared_info
DWORD cb;
public:
tty_list tty;
+ HWND cons_hwnd[MAX_CONS_DEV];
LONG last_used_bindresvport;
DWORD obcaseinsensitive;
mtinfo mt;
diff --git a/winsup/cygwin/local_includes/tty.h b/winsup/cygwin/local_includes/tty.h
index df3bf60..53fa26b 100644
--- a/winsup/cygwin/local_includes/tty.h
+++ b/winsup/cygwin/local_includes/tty.h
@@ -211,4 +211,9 @@ public:
};
extern "C" int ttyslot (void);
+
+/* Console stuff */
+#define MAX_CONS_DEV 128
+#define CONS_SCAN_UNUSED (-1)
+
#endif /*_TTY_H*/
diff --git a/winsup/cygwin/release/3.5.4 b/winsup/cygwin/release/3.5.4
index 2a5f2b1..c95ef46 100644
--- a/winsup/cygwin/release/3.5.4
+++ b/winsup/cygwin/release/3.5.4
@@ -15,3 +15,10 @@ Fixes:
- Fix a problem that ldd command against cygwin DLLs sometimes hangs.
Addresses: https://cygwin.com/pipermail/cygwin/2024-May/255991.html
+
+- Fix a problem that pty slave hangs on writing when pty master stops
+ to read.
+ Addresses: https://cygwin.com/pipermail/cygwin/2024-June/256178.html
+
+- Fix conflict on shared name in console between sessions.
+ Addresses: https://cygwin.com/pipermail/cygwin/2024-April/255893.html