From patchwork Mon Jun 18 15:23:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139004 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4085381lji; Mon, 18 Jun 2018 08:27:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKgEWb4jH2C8e6DTIZsrAH4ySyvuv+VjDgs/9l0UpxRjHOWRhLOezWOjT4GRYMslkzIAmC7 X-Received: by 2002:a50:9385:: with SMTP id o5-v6mr11346752eda.291.1529335644770; Mon, 18 Jun 2018 08:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335644; cv=none; d=google.com; s=arc-20160816; b=n2CtTx5Y9ucWZJmjSTHV1hdV5WAy5uWbSyp9Tn5W7GTMAs9PDtDhLlJRSiYvm8vlyl k9P1g3lTaRsm7ThWlHrVHmMYZ9c0atmjVkkJmxGk8Ing4mTFtxwgoEOVi2lVigVe+Ojs 2LSYQ5UfGe6dV/xX6aN8lEYHJEBRXWRYmAX12sNbBi9cxm0lWE91fvhiew7UCrYnY0U5 Ao2rkbHiq0msGc+uNm+MtOGKSuOZmFqvnKig9blEkLbhKNfc6SWuj4sdmN8GlkTRcoH4 l1H7Q5nKWxs7yMHisLqK5PucgBlry/GFuVv4KvWhyKUFJSjSfL/c8iz/vlbsnXOHN52n 1lRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=L0ihwtCF/3NORMewIdNCs5UfSNERzRsZ7h9rYNOh56Y=; b=TaoUOWP4g4VHQjp1lI3QJvX2nxZr3f14DYP/oDdqhDUyngUMevwjY3UV/zDA+aL7sZ 4DKtsB5yidSBxrloFYxbNj70CT4jMLNOsZvWlMUCY2SXfRDYHlrTipe7ImhX1R7c3pSB nIPLBUNX9+gVgYN1MDOCyHygjsdSeBY5JXSxzz3izdvDwNTOJ3cwWZxBR3xg6XCCm+hJ eXM8EJwsPNSC1uvhYWCqhvAKk+X2cVJRfSsyzOTlAEVwfY8xKYEH1FeLRcHEkpbjlagy XaU14nDfWBuwjWX6BuEyiAzUC9MQ61Tu7RxFLKPQ8ch0bMyu7qtoAysrFtRkZydQskqc OYTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id b11-v6si5399929edd.235.2018.06.18.08.27.24; Mon, 18 Jun 2018 08:27:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 4766DC21E63; Mon, 18 Jun 2018 15:26:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4671AC21F5B; Mon, 18 Jun 2018 15:23:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C9A4DC21DFA; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id E7001C21DED for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4D1C1AF7D; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:09 +0200 Message-Id: <20180618152315.34233-16-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 15/21] sandbox: Fix setjmp/longjmp X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In sandbox, longjmp returns to itself in an endless loop. Cut this through by calling the real OS function. Setjmp on the other hand must not return. So here we have to call the OS setjmp function straight from the code where the setjmp call happens. Signed-off-by: Alexander Graf --- arch/sandbox/cpu/cpu.c | 5 ----- arch/sandbox/cpu/os.c | 20 ++------------------ arch/sandbox/include/asm/setjmp.h | 4 +++- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 29dac8dfda..9087026d71 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -167,11 +167,6 @@ ulong timer_get_boot_us(void) return (count - base_count) / 1000; } -int setjmp(jmp_buf jmp) -{ - return os_setjmp((ulong *)jmp, sizeof(*jmp)); -} - void longjmp(jmp_buf jmp, int ret) { os_longjmp((ulong *)jmp, ret); diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 5839932b00..9cfdc9f31f 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -630,24 +630,8 @@ void os_localtime(struct rtc_time *rt) rt->tm_isdst = tm->tm_isdst; } -int os_setjmp(ulong *jmp, int size) -{ - jmp_buf dummy; - - /* - * We cannot rely on the struct name that jmp_buf uses, so use a - * local variable here - */ - if (size < sizeof(dummy)) { - printf("setjmp: jmpbuf is too small (%d bytes, need %d)\n", - size, sizeof(jmp_buf)); - return -ENOSPC; - } - - return setjmp((struct __jmp_buf_tag *)jmp); -} - void os_longjmp(ulong *jmp, int ret) { - longjmp((struct __jmp_buf_tag *)jmp, ret); + /* Call the OS longjmp function directly */ + _longjmp((struct __jmp_buf_tag *)jmp, ret); } diff --git a/arch/sandbox/include/asm/setjmp.h b/arch/sandbox/include/asm/setjmp.h index 1fe37c91cc..e103d170e0 100644 --- a/arch/sandbox/include/asm/setjmp.h +++ b/arch/sandbox/include/asm/setjmp.h @@ -24,7 +24,9 @@ struct jmp_buf_data { typedef struct jmp_buf_data jmp_buf[1]; -int setjmp(jmp_buf jmp); +/* Call the OS setjmp function directly, so that we don't introduce returns */ +#define setjmp _setjmp +int _setjmp(jmp_buf jmp); __noreturn void longjmp(jmp_buf jmp, int ret); #endif /* _SETJMP_H_ */