From nobody Tue Oct 7 06:57:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551386175389156.0780802022938; Thu, 28 Feb 2019 12:36:15 -0800 (PST) Received: from localhost ([127.0.0.1]:46131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzSPb-00089I-B3 for importer@patchew.org; Thu, 28 Feb 2019 15:36:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzSFb-0000VS-CG for qemu-devel@nongnu.org; Thu, 28 Feb 2019 15:25:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzSFa-0007PO-Bj for qemu-devel@nongnu.org; Thu, 28 Feb 2019 15:25:51 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzSFa-0007Oe-31 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 15:25:50 -0500 Received: by mail-wr1-x443.google.com with SMTP id w2so23414163wrt.11 for ; Thu, 28 Feb 2019 12:25:50 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a8sm7401392wmh.26.2019.02.28.12.25.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 12:25:45 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E47681FF8E; Thu, 28 Feb 2019 20:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IhmDA8Paz4xh5btvDJbvSxpnzxmgwJBv6Kvn01RZQX4=; b=MjRKO5wQFy1j2r9a3RgaJnu11c4bG1dcQi6FDMqTJOIMwaPypVh6UOFBfbRQmC4glI 8DdtC3Eh7P9v+EzNvVDuDgGN0PCPZEfwdeGqUNBYk6B4L5w4Yb6AxYvEjpMhbP/Slq/S dkD0K+P73bn/CSUOCQKZwzPJTdp/120HMqY9+sR+DOgYpmF/764OwELczSLXYZTdY0c0 3aVZrRVZrVs/Z2xKbDRjYjtCWS4CKQPK17KElbCwP84pevQhpx2WlkJruK2Syg4YoDto xMdRmOmPPkg/HCJh29rucka9oMI5hqS94pmf8g674/0dtoKCRtSlvo3EwBSceN9tHH+D P0Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IhmDA8Paz4xh5btvDJbvSxpnzxmgwJBv6Kvn01RZQX4=; b=QsofyXcEKfBYrsBrpJ0MY0B8FA6+DJoRPr2GcV/WJJWSlhFMcm214nNWYSuSX3zNF+ BeH7Sd69jPRaEPW8kvH9/WnzRlPSKz0FIixGLjsCW7n0/wQmdtDeV6pIufkibpK/HXtL L7PGD5KOkO+L+e2euBoDGkk0B0NPmak4BlZrUP4o/baC7bwMNMq0mZoPk1x031WYcB6H r6NiapSz2n4hu6E3wkISViQYGdsyf9RF0YHqrX/naFvrmb1uhYch5OU38WxBMidwRBfh l0UpNsAaYdvDUCJUpHsjZnxt8wtvd0V3eBnrsqYgB8LzZyqc099ECocZc5x2dUK7Nel1 NziA== X-Gm-Message-State: APjAAAXN1IVON2jaoMNo+h2lrRKpxTEjCypcL3RPpAEskHEMmUtcLyCH +TWwgULJgXbtqacOQ6PFqJyyew== X-Google-Smtp-Source: APXvYqzFueHOX+pc4F22w0XZbqznzUh/rJXwIxTkx453hupmTN+QgryFLYNsPSEmo4CA/heD8guI1g== X-Received: by 2002:a5d:4945:: with SMTP id r5mr779762wrs.295.1551385549123; Thu, 28 Feb 2019 12:25:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 28 Feb 2019 20:25:32 +0000 Message-Id: <20190228202537.4638-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190228202537.4638-1-alex.bennee@linaro.org> References: <20190228202537.4638-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v2 11/16] tests/tcg/cris: cleanup sys.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edgar.iglesias@gmail.com, qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , jcmvbkbc@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This is a mini library which provides helper functions to the tests which are all currently written in assembly. A bunch of minor changes: - removed libc related headers (fedora-cris-cross is a system compile= r) - re-organised the functions to avoid forward declarations - cleaned up brace usage - restored exit for _fail case - removed tabs and fixed indentation Signed-off-by: Alex Benn=C3=A9e --- tests/tcg/cris/bare/sys.c | 96 +++++++++++++++++++-------------------- tests/tcg/cris/libc/sys.c | 23 ++++++---- 2 files changed, 62 insertions(+), 57 deletions(-) diff --git a/tests/tcg/cris/bare/sys.c b/tests/tcg/cris/bare/sys.c index 21f08c0747..aa342335d6 100644 --- a/tests/tcg/cris/bare/sys.c +++ b/tests/tcg/cris/bare/sys.c @@ -1,59 +1,59 @@ -#include -#include -#include - -static inline int mystrlen(char *s) { - int i =3D 0; - while (s[i]) - i++; - return i; +/* + * Helper functions for CRIS system tests + * + * There is no libc and only a limited set of headers. + */ + +#include + +void exit(int status) +{ + register unsigned int callno asm ("r9") =3D 1; /* NR_exit */ + + asm volatile ("break 13\n" + : /* no outputs */ + : "r" (callno) + : "memory" ); + while(1); } =20 -void pass(void) { - char s[] =3D "passed.\n"; - write (1, s, sizeof (s) - 1); - exit (0); -} +size_t write(int fd, const void *buf, size_t count) +{ + register unsigned int callno asm ("r9") =3D 4; /* NR_write */ + register unsigned int r10 asm ("r10") =3D fd; + register const void *r11 asm ("r11") =3D buf; + register size_t r12 asm ("r12") =3D count; + register unsigned int r asm ("r10"); =20 -void _fail(char *reason) { - char s[] =3D "\nfailed: "; - int len =3D mystrlen(reason); - write (1, s, sizeof (s) - 1); - write (1, reason, len); - write (1, "\n", 1); -// exit (1); -} + asm volatile ("break 13\n" + : "=3Dr" (r) + : "r" (callno), "0" (r10), "r" (r11), "r" (r12) + : "memory"); =20 -void *memset (void *s, int c, size_t n) { - char *p =3D s; - int i; - for (i =3D 0; i < n; i++) - p[i] =3D c; - return p; + return r; } =20 -void exit (int status) { - register unsigned int callno asm ("r9") =3D 1; /* NR_exit */ - - asm volatile ("break 13\n" - : - : "r" (callno) - : "memory" ); - while(1) - ; +static inline int mystrlen(char *s) +{ + int i =3D 0; + while (s[i]) { + i++; + } + return i; } =20 -ssize_t write (int fd, const void *buf, size_t count) { - register unsigned int callno asm ("r9") =3D 4; /* NR_write */ - register unsigned int r10 asm ("r10") =3D fd; - register const void *r11 asm ("r11") =3D buf; - register size_t r12 asm ("r12") =3D count; - register unsigned int r asm ("r10"); =20 - asm volatile ("break 13\n" - : "=3Dr" (r) - : "r" (callno), "0" (r10), "r" (r11), "r" (r12) - : "memory"); +void pass(void) { + char s[] =3D "passed.\n"; + write(1, s, sizeof (s) - 1); + exit(0); +} =20 - return r; +void _fail(char *reason) { + char s[] =3D "\nfailed: "; + int len =3D mystrlen(reason); + write(1, s, sizeof (s) - 1); + write(1, reason, len); + write(1, "\n", 1); + exit(1); } diff --git a/tests/tcg/cris/libc/sys.c b/tests/tcg/cris/libc/sys.c index b8e759eee3..6ec4e77b22 100644 --- a/tests/tcg/cris/libc/sys.c +++ b/tests/tcg/cris/libc/sys.c @@ -3,16 +3,18 @@ */ =20 =20 -void exit (int status) { +void exit(int status) +{ register unsigned int callno asm ("r9") =3D 1; /* NR_exit */ asm volatile ("break 13\n" : : "r" (callno) - : "memory" ); + : "memory"); while(1); } =20 -ssize_t write (int fd, const void *buf, size_t count) { +ssize_t write(int fd, const void *buf, size_t count) +{ register unsigned int callno asm ("r9") =3D 4; /* NR_write */ register unsigned int r10 asm ("r10") =3D fd; register const void *r11 asm ("r11") =3D buf; @@ -27,29 +29,32 @@ ssize_t write (int fd, const void *buf, size_t count) { return r; } =20 -static inline int mystrlen(char *s) { +static inline int mystrlen(char *s) +{ int i =3D 0; while (s[i]) i++; return i; } =20 -void pass(void) { +void pass(void) +{ char s[] =3D "passed.\n"; - write (1, s, sizeof (s) - 1); + write (1, s, sizeof(s) - 1); exit (0); } =20 -void _fail(char *reason) { +void _fail(char *reason) +{ char s[] =3D "\nfailed: "; int len =3D mystrlen(reason); write (1, s, sizeof (s) - 1); write (1, reason, len); write (1, "\n", 1); -// exit (1); } =20 -void *memset (void *s, int c, size_t n) { +void *memset(void *s, int c, size_t n) +{ char *p =3D s; int i; for (i =3D 0; i < n; i++) --=20 2.20.1