Module Name: src Committed By: martin Date: Fri Aug 23 18:32:37 UTC 2024
Modified Files: src/distrib/sets/lists/debug [netbsd-9]: mi src/distrib/sets/lists/tests [netbsd-9]: mi src/etc/mtree [netbsd-9]: NetBSD.dist.tests src/external/gpl3/gcc/dist/libstdc++-v3/config/io [netbsd-9]: basic_file_stdio.cc Added Files: src/tests/lib/libstdc++ [netbsd-9]: Makefile h_cin_nosync.cc t_sync_with_stdio.sh Log Message: Pull up following revision(s) (requested by riastradh in ticket #1877): tests/lib/libstdc++/h_cin_nosync.cc: revision 1.1 tests/lib/libstdc++/t_sync_with_stdio.sh: revision 1.1 tests/lib/libstdc++/t_sync_with_stdio.sh: revision 1.2 etc/mtree/NetBSD.dist.tests: revision 1.204 distrib/sets/lists/tests/mi: revision 1.1313 (patch) tests/lib/libstdc++/Makefile: revision 1.1 distrib/sets/lists/debug/mi: revision 1.433 external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc: revision 1.2 libstdc++: Add test for PR lib/58206, sync_with_stdio busted. libstdc++: Don't try to fflush stdin. It doesn't work. It's undefined behaviour. On NetBSD, it will fail with EBADF, if fd 0 isn't open for write, or if fd 0 is open for write, it will write heap garbage to fd 0. If stream points to an output stream or an update stream in which the most recent operation was not input, the fflush function causes any unwritten data for that stream to be delivered to the host environment to be written to the file; otherwise, the behavior is undefined. (ISO C11 and ISO C17, Sec. 7.21.5.2 `The fflush function') PR lib/58206 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114879 To generate a diff of this commit: cvs rdiff -u -r1.285.2.8 -r1.285.2.9 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.818.2.6 -r1.818.2.7 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.158 -r1.158.2.1 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.1.1.7 -r1.1.1.7.2.1 \ src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc cvs rdiff -u -r0 -r1.1.6.2 src/tests/lib/libstdc++/Makefile \ src/tests/lib/libstdc++/h_cin_nosync.cc cvs rdiff -u -r0 -r1.2.6.2 src/tests/lib/libstdc++/t_sync_with_stdio.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.285.2.8 src/distrib/sets/lists/debug/mi:1.285.2.9 --- src/distrib/sets/lists/debug/mi:1.285.2.8 Fri Aug 23 16:59:52 2024 +++ src/distrib/sets/lists/debug/mi Fri Aug 23 18:32:36 2024 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.285.2.8 2024/08/23 16:59:52 martin Exp $ +# $NetBSD: mi,v 1.285.2.9 2024/08/23 18:32:36 martin Exp $ ./etc/mtree/set.debug comp-sys-root ./usr/lib comp-sys-usr compatdir ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile @@ -2298,6 +2298,7 @@ ./usr/libdata/debug/usr/tests/lib/librumphijack/h_netget.debug tests-lib-debug debug,atf,rump ./usr/libdata/debug/usr/tests/lib/libskey/t_algorithms.debug tests-lib-debug debug,atf,skey,compattestfile ./usr/libdata/debug/usr/tests/lib/libsljit/h_sljit.debug tests-lib-debug debug,atf,sljit,compattestfile +./usr/libdata/debug/usr/tests/lib/libstdc++/h_cin_nosync.debug tests-lib-tests compattestfile,atf ./usr/libdata/debug/usr/tests/lib/libtre/h_regex_att.debug tests-obsolete obsolete,compattestfile ./usr/libdata/debug/usr/tests/lib/libtre/t_exhaust.debug tests-lib-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/lib/libtre/t_regex_att.debug tests-lib-debug debug,atf,compattestfile Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.818.2.6 src/distrib/sets/lists/tests/mi:1.818.2.7 --- src/distrib/sets/lists/tests/mi:1.818.2.6 Fri Aug 23 16:59:53 2024 +++ src/distrib/sets/lists/tests/mi Fri Aug 23 18:32:36 2024 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.818.2.6 2024/08/23 16:59:53 martin Exp $ +# $NetBSD: mi,v 1.818.2.7 2024/08/23 18:32:36 martin Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -143,6 +143,7 @@ ./usr/libdata/debug/usr/tests/lib/librumphijack tests-lib-debug compattestfile,atf ./usr/libdata/debug/usr/tests/lib/libskey tests-lib-debug compattestfile,atf ./usr/libdata/debug/usr/tests/lib/libsljit tests-lib-debug compattestfile,atf +./usr/libdata/debug/usr/tests/lib/libstdc++ tests-lib-debug compattestfile,atf ./usr/libdata/debug/usr/tests/lib/libtre tests-lib-debug compattestfile,atf ./usr/libdata/debug/usr/tests/lib/libusbhid tests-lib-debug compattestfile,atf ./usr/libdata/debug/usr/tests/lib/libutil tests-lib-debug compattestfile,atf @@ -3327,6 +3328,11 @@ ./usr/tests/lib/libsljit/Kyuafile tests-lib-tests compattestfile,atf,sljit,kyua ./usr/tests/lib/libsljit/h_sljit tests-lib-tests compattestfile,atf,sljit ./usr/tests/lib/libsljit/t_sljit tests-lib-tests compattestfile,atf,sljit +./usr/tests/lib/libstdc++ tests-lib-tests compattestfile,atf +./usr/tests/lib/libstdc++/Atffile tests-lib-tests compattestfile,atf +./usr/tests/lib/libstdc++/Kyuafile tests-lib-tests compattestfile,atf,kyua +./usr/tests/lib/libstdc++/h_cin_nosync tests-lib-tests compattestfile,atf +./usr/tests/lib/libstdc++/t_sync_with_stdio tests-lib-tests compattestfile,atf ./usr/tests/lib/libtre tests-lib-tests compattestfile,atf ./usr/tests/lib/libtre/Atffile tests-lib-tests compattestfile,atf ./usr/tests/lib/libtre/Kyuafile tests-lib-tests compattestfile,atf,kyua Index: src/etc/mtree/NetBSD.dist.tests diff -u src/etc/mtree/NetBSD.dist.tests:1.158 src/etc/mtree/NetBSD.dist.tests:1.158.2.1 --- src/etc/mtree/NetBSD.dist.tests:1.158 Thu Apr 4 19:50:47 2019 +++ src/etc/mtree/NetBSD.dist.tests Fri Aug 23 18:32:36 2024 @@ -1,4 +1,4 @@ -# $NetBSD: NetBSD.dist.tests,v 1.158 2019/04/04 19:50:47 kamil Exp $ +# $NetBSD: NetBSD.dist.tests,v 1.158.2.1 2024/08/23 18:32:36 martin Exp $ ./usr/libdata/debug/usr/tests ./usr/libdata/debug/usr/tests/atf @@ -125,6 +125,7 @@ ./usr/libdata/debug/usr/tests/lib/librumphijack ./usr/libdata/debug/usr/tests/lib/libskey ./usr/libdata/debug/usr/tests/lib/libsljit +./usr/libdata/debug/usr/tests/lib/libstdc++ ./usr/libdata/debug/usr/tests/lib/libtre ./usr/libdata/debug/usr/tests/lib/libusbhid ./usr/libdata/debug/usr/tests/lib/libutil @@ -316,6 +317,7 @@ ./usr/tests/lib/librumphijack ./usr/tests/lib/libskey ./usr/tests/lib/libsljit +./usr/tests/lib/libstdc++ ./usr/tests/lib/libtre ./usr/tests/lib/libtre/data ./usr/tests/lib/libusbhid Index: src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc diff -u src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.1.1.7 src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.1.1.7.2.1 --- src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc:1.1.1.7 Sat Jan 19 10:14:12 2019 +++ src/external/gpl3/gcc/dist/libstdc++-v3/config/io/basic_file_stdio.cc Fri Aug 23 18:32:37 2024 @@ -190,7 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { this->close(); } __basic_file<char>* - __basic_file<char>::sys_open(__c_file* __file, ios_base::openmode) + __basic_file<char>::sys_open(__c_file* __file, ios_base::openmode __mode) { __basic_file* __ret = NULL; if (!this->is_open() && __file) @@ -199,7 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // POSIX guarantees that fflush sets errno on error, but C doesn't. errno = 0; do - __err = fflush(__file); + __err = (__mode == std::ios_base::in ? 0 : fflush(__file)); while (__err && errno == EINTR); errno = __save_errno; if (!__err) Added files: Index: src/tests/lib/libstdc++/Makefile diff -u /dev/null src/tests/lib/libstdc++/Makefile:1.1.6.2 --- /dev/null Fri Aug 23 18:32:37 2024 +++ src/tests/lib/libstdc++/Makefile Fri Aug 23 18:32:36 2024 @@ -0,0 +1,12 @@ +# $NetBSD: Makefile,v 1.1.6.2 2024/08/23 18:32:36 martin Exp $ +# + +NOMAN= # defined + +TESTSDIR= ${TESTSBASE}/lib/libstdc++ +BINDIR= ${TESTSDIR} + +TESTS_SH+= t_sync_with_stdio +PROG_CXX+= h_cin_nosync + +.include <bsd.test.mk> Index: src/tests/lib/libstdc++/h_cin_nosync.cc diff -u /dev/null src/tests/lib/libstdc++/h_cin_nosync.cc:1.1.6.2 --- /dev/null Fri Aug 23 18:32:37 2024 +++ src/tests/lib/libstdc++/h_cin_nosync.cc Fri Aug 23 18:32:35 2024 @@ -0,0 +1,40 @@ +/* $NetBSD: h_cin_nosync.cc,v 1.1.6.2 2024/08/23 18:32:35 martin Exp $ */ + +/*- + * Copyright (c) 2024 The NetBSD Foundation, Inc. + * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <iostream> + +int +main(void) +{ + char buf[128]; + + std::ios::sync_with_stdio(false); + std::cin.read(buf, sizeof(buf)); + std::cout << std::cin.gcount() << std::endl; + return 0; +} Index: src/tests/lib/libstdc++/t_sync_with_stdio.sh diff -u /dev/null src/tests/lib/libstdc++/t_sync_with_stdio.sh:1.2.6.2 --- /dev/null Fri Aug 23 18:32:37 2024 +++ src/tests/lib/libstdc++/t_sync_with_stdio.sh Fri Aug 23 18:32:36 2024 @@ -0,0 +1,41 @@ +# $NetBSD: t_sync_with_stdio.sh,v 1.2.6.2 2024/08/23 18:32:36 martin Exp $ +# +# Copyright (c) 2024 The NetBSD Foundation, Inc. +# 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +cin_nosync_head() +{ + atf_set descr "Check cin works after std::ios::sync_with_stdio(false)" +} +cin_nosync_body() +{ + echo hello >in + atf_check -o inline:'6\n' "$(atf_get_srcdir)"/h_cin_nosync <in +} + +atf_init_test_cases() +{ + atf_add_test_case cin_nosync +}