From nobody Tue Feb 10 00:39:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544456492685970.9909697388163; Mon, 10 Dec 2018 07:41:32 -0800 (PST) Received: from localhost ([::1]:33404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWNgS-000279-S7 for importer@patchew.org; Mon, 10 Dec 2018 10:41:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWNU9-00089R-S0 for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:28:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWNU8-0000Xd-DW for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:28:41 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:40912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gWNU8-0000XE-45 for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:28:40 -0500 Received: by mail-wr1-x444.google.com with SMTP id p4so10896736wrt.7 for ; Mon, 10 Dec 2018 07:28:40 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b131sm12508911wma.21.2018.12.10.07.28.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Dec 2018 07:28:34 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A42473E06D8; Mon, 10 Dec 2018 15:28:30 +0000 (GMT) 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=/U1pyU+stUfvYOAsG/d5zAnLuBxRcYUDLgZPKFsVVuE=; b=FQ0WyCulaRM/4qSsbOKUoGrN6RS2W7kfQtLRvDC95FojmanAUmrhSRpxcKFA96514y B3tx4NcEsBYz9NdxIB4t3vqGelCUxptxUIOcsl9H8n+doHQ40eq5hR7SNLYNWAhXqZ9Q h7Df3G3n1dnoe3Lh+uH+jIPOFn1Jjhvu4ufmY= 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=/U1pyU+stUfvYOAsG/d5zAnLuBxRcYUDLgZPKFsVVuE=; b=J29lGt+QuGO+vPhSQhw26LoJbus8tDPwp28EqL4Cy9ImAWgHUmrJXhc5pBbYE2ET2I qD+NrGI3TjCUkWCjXGO9i45wB38SH0CTnrctq7S5Y5SzK/6OCh390tJl1Ouj9m5tlEg/ qtloRyETVXGdZsV/fx0Sbpn7e/WwbkDWxsGwcYi4eaJbY2HTIr9rFM4O35wruBOaBOgS 3Bh0IxfWCfoXeteq4yLb3M4QUc6igqo1YkBKtD8EPFtatzQ1mTEbZUVepWdNTPtUyu4R xIKS/kJemYffmqEgowk3dJkAA6seUJm8pT5zofEO0uQt8Vx28rWSA7dJogSp6leUXmkC 3EFw== X-Gm-Message-State: AA+aEWZrl70xUt1xRLXequs4Ipni41SDd1/XXpsz33/jtg5Sf1di753m QjZYfTtOwVAYzue1P+zELy32xg== X-Google-Smtp-Source: AFSGD/V2iEf/9D2KM4EYYpzwr84o3Vz5o/DkqvxhAtzAOz73219DpptcZybHNHmvcXiMLHlyxfjezA== X-Received: by 2002:adf:f8d2:: with SMTP id f18mr10319637wrq.265.1544455719029; Mon, 10 Dec 2018 07:28:39 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Mon, 10 Dec 2018 15:28:26 +0000 Message-Id: <20181210152829.29271-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181210152829.29271-1-alex.bennee@linaro.org> References: <20181210152829.29271-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::444 Subject: [Qemu-devel] [RFC PATCH 10/13] 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: jcmvbkbc@gmail.com, michael@walle.cc, amarkovic@wavecomp.com, edgar.iglesias@gmail.com, shorne@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , aurelien@aurel32.net 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/system/sys.c | 96 ++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/tests/tcg/cris/system/sys.c b/tests/tcg/cris/system/sys.c index 21f08c0747..aa342335d6 100644 --- a/tests/tcg/cris/system/sys.c +++ b/tests/tcg/cris/system/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); } --=20 2.17.1