From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 6C7DE38582B3; Wed, 10 Jan 2024 09:47:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C7DE38582B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1704880033; bh=JafePTtH7My4MWl8LxLjaUAD+FIfS+7BkuTS6x/zqIo=; h=From:To:Subject:Date:From; b=xciUsoUZlM39vlV5jqxMFHOeg513G7CcbETrJEgZ2pLqKZxxbdXM7hONqiMUmM8UD 1ER806TvYRvicFHZpm73rsQhronZ+6FEWbMZ6QUdLW0U1LCYizGJUlENdDS0OB9qqK uBFk3j4j6QzLtvCC4Co/6g3YtercqGoJOCjhA/6c= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] RISC-V: fix setting up std streams in init_semihosting() X-Act-Checkin: newlib-cygwin X-Git-Author: Venkata Ramanaiah Nalamothu X-Git-Refname: refs/heads/main X-Git-Oldrev: 9a863f713af24a3b18c165c640c936a4c0b707ea X-Git-Newrev: c419bbb341528a97d2de88539caf200c9dec1ffb Message-Id: <20240110094713.6C7DE38582B3@sourceware.org> Date: Wed, 10 Jan 2024 09:47:13 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dc419bbb3415= 28a97d2de88539caf200c9dec1ffb commit c419bbb341528a97d2de88539caf200c9dec1ffb Author: Venkata Ramanaiah Nalamothu AuthorDate: Wed Jan 3 12:22:16 2024 +0530 Commit: Corinna Vinschen CommitDate: Wed Jan 10 10:46:56 2024 +0100 RISC-V: fix setting up std streams in init_semihosting() =20 Currently init_semihosting() assumes the return value from _open() call as the file descriptor handle and that is incorrect. =20 The semihost _open() call returns the fdtable index returned by the __add_fdentry() for the file opened. Diff: --- libgloss/riscv/semihost-sys_fdtable.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libgloss/riscv/semihost-sys_fdtable.c b/libgloss/riscv/semihos= t-sys_fdtable.c index 152c92d1513b..d62e3f9708fe 100644 --- a/libgloss/riscv/semihost-sys_fdtable.c +++ b/libgloss/riscv/semihost-sys_fdtable.c @@ -24,25 +24,26 @@ static struct fdentry fdtable[RISCV_MAX_OPEN_FILES]; void __attribute__ ((constructor)) init_semihosting () { - int handle; + int i; =20 - for (int i=3D0; i