From patchwork Fri Jun 15 12:42:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138693 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp808429lji; Fri, 15 Jun 2018 05:53:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJp7pa9/5f227jY6rvuw6D+kAwjCtONGX9XUBppd0rcenCPSif5Um5fiFkANt5KtwTo6v0L X-Received: by 2002:a50:ba1d:: with SMTP id g29-v6mr1775233edc.85.1529067235494; Fri, 15 Jun 2018 05:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067235; cv=none; d=google.com; s=arc-20160816; b=ldQdnXNvOd7pondSbcKc44M6tEeToz2g4Hmw/2xTi4tSFzSpHea/neZIJBgLwsg1Vr UgbvmrWHJd4Eu41Ipimhr6M4yB9fQMxPMif8HZz3AFO1BZiyvMYOFiP8IMLHdJGyjCuw aJnlCTqtWP55ZlHwcF02zX80/bg/GWsKMnnnAgJTz3g8Nus9dZXqTANpv8dbD6EulnWS h4NetRCOMFRmi5ffA+3EnWDeNZWlDl6PRjc0Z+avYeDZmtb0ntUm9PLF4h0YHIMCx6+6 qeRE3oq0jRt4elemnvMMNBFUPo5F05TAQl5s+lqIWNVLgKk86IBVq/RxMKwhO9AdVbgf M2/w== 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=l1RfSfAAY2W8/Ya+juobNRpPAC13vmBsWenVP9s3uJM=; b=c9Vqqy4q6Z48djrDGJuPR0fERwqCuVS/WmP0bIgTH3he5ekmNhYMG9vG+NObsuJoNs TTLMQnIcmrfb3GbLulZ2LMgKkTkpiG8EqNaeHVUv9I9GezE0TJsH0ch+QFPUTuOEKegh GMCmJ2MBwvk6qocy9oGLmFOHzGCAKR9mS+2gcrv2At9ihmvy9lLt9s3dxRNZb1ih8Hs5 p9pS71GU4ZtwBZctjTMSLqn36BUOhCPH0PcsnER1oS69xEcbYX0bOOTp/IXNpBDivPPB wo1NnYFiEkG98IB8TyFP6vxGfEyalOuipTNNH5c3rRp3VEAmAJl9O/gYDQ6IIZnUaUm4 VgDQ== 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 j30-v6si1462407edc.86.2018.06.15.05.53.55; Fri, 15 Jun 2018 05:53:55 -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 18A3BC21E62; Fri, 15 Jun 2018 12:47:36 +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 1E955C21DAF; Fri, 15 Jun 2018 12:42:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D3343C21E96; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 259D2C21EB4 for ; Fri, 15 Jun 2018 12:42:32 +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 61F63AF96; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:29 +0200 Message-Id: <20180615124229.35310-18-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 17/17] 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 944f104899..1d9f10df98 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -151,11 +151,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 81206ba0d2..4ef4040103 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -653,24 +653,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_ */