From patchwork Thu Aug 1 10:13:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Fedotov X-Patchwork-Id: 170366 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5213720ile; Thu, 1 Aug 2019 03:14:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAd4YAHZxJ1MYGxXnZ1kHl9fP/vpMvhvqLlTiME2iWbMpDPFWVSeqIATKehrFe3BiWMGJc X-Received: by 2002:a65:6108:: with SMTP id z8mr86883560pgu.289.1564654445173; Thu, 01 Aug 2019 03:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564654445; cv=none; d=google.com; s=arc-20160816; b=jB0vbrGA9RT+7KJoO6Y1alALy/kdk9m7bt24BqZsbFgetyjoDVrwgJ0KUgvDfuDeKV 3xyaQ/rJtOnVxfUljrID+WSeEKAZzIMHtQ7AxNGdItZnGcBrIB90GD4wdVxJPYTVkSze KypSqm27vDqjkl15CVgND9VOx3a7q9syEOObkQRyFxBCM4tOLV1niJ8wT0WMkoPWjNTm i6t6V8v62lLTxdAn7O6YhcgQSKKy72ZixqE+ZLhsN3awvqzdKDvWgcYQbbkYfPhSjlWF oPPHYzY6ls9v7nqJCk/7ZfTLWELeyE1xt2jhQDI/+IQ8xMF505tn0mO5toUu3S0WHH1A 5j2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=PIb7SHWSIrhJzY/85PiSWPovoMW2DqrriSQVm7Rbpsk=; b=ZD3BX8kdKQPW+UKmq8eoftum+IwlfUokPxTghL7y5O1ORDqmkuxyq7k92TYMbcyIxk cRZwNxpIRVQ8OjgGRfQF2yWRyB6FBe703eg0vOIgirzlQt9HA16hmhoMLCsDQrIfht5C aqp8bQlt/KDmzJ5IvyspjB3BuEw17GHvQebWJ8z4k1SYWpqmAdxy16G2umBUQSWgeaO9 /ALaiKCgOnzvg0IGlU6qSUAg3i1DU5deiBtIB5zkZ2zEx6tt8vmhiMBPXSchPtZd0Jom xxJtWXtHdMbgmt5BTgpctDFufrylaolVhkxnAtwBqKxtedXLQdKy9VizQrjPGQTqt8P8 z8rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IGYJoVHI; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uJwTLJPD; spf=pass (google.com: domain of newlib-return-17108-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17108-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s14si36835914pgj.347.2019.08.01.03.14.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 03:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-17108-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=IGYJoVHI; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uJwTLJPD; spf=pass (google.com: domain of newlib-return-17108-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17108-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=L2OLOxU/QbplGf2E/jb69JbgUiI5zwOYWeTof+3CM1EgYLwF7ka+P 9KhDdfI1RH7xXNCmPOhPHkYZoOfymumYve0DgaaARUoz4cful3m2MxKGy6MuzFfS fwr3Qrq5og2ZeV0+Lhv2IK5PEEL2VYyCQxI5OK8rHplEta03gY5SXs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=HLNnC32auI8hAI64AdP9Gyr16Qs=; b=IGYJoVHIheF9r9887HlQoRwHwR1e qqjApLyRp6jbrhvPcLOMoHlR2X1oE8xwo/iftdtqwHGA0lLuMnYEPnlZhSJn1tqj PMa1wdd0K3f52l9Eon8Ne1/C6MtfRTm//UNDla1jplMZGynuHj859LUW2M+f3gJ6 Zwwp2t4RWQY4iZI= Received: (qmail 94497 invoked by alias); 1 Aug 2019 10:13:48 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 94428 invoked by uid 89); 1 Aug 2019 10:13:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Space X-HELO: mail-lf1-f65.google.com Received: from mail-lf1-f65.google.com (HELO mail-lf1-f65.google.com) (209.85.167.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Aug 2019 10:13:47 +0000 Received: by mail-lf1-f65.google.com with SMTP id x3so49923773lfc.0 for ; Thu, 01 Aug 2019 03:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PIb7SHWSIrhJzY/85PiSWPovoMW2DqrriSQVm7Rbpsk=; b=uJwTLJPDemLz76ilTG+IyBusHkA2a/4r6cUPqHCQdOvcBDgEkrLmfecNC0V63MFxio aHOlp8GULCCdn7KTsjKRD+RVfPjOXcNxe833OhBRnITRaRF+IDl6cXDQhGKbIHbfScOr gKwYWX1SRlcCIYfKWOoh/NN4AGj3fZC1MsrZYIeMyw8pnJCWmqUNWHpuLRT+Z16qdFYZ sdcTOECnrf74EhYXVr+PBU8wBDMbnD58iMxjxGXaJ+bevU2sW0Lwu5qUizMMD3aF/qX6 6EZf7bS8Mr3JTSS3MLEjwhLDkIW8UHnviwqFLmyL7mHJkyq9BafaFjXPzsZclwiO81T3 KosA== Return-Path: Received: from af-ubuntu18-hyperv.cmtknet.ru (relay.cmtk.ru. [195.5.145.226]) by smtp.gmail.com with ESMTPSA id n1sm12221136lfk.19.2019.08.01.03.13.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 03:13:44 -0700 (PDT) From: Alexander Fedotov To: newlib@sourceware.org, Richard.Earnshaw@arm.com Cc: Alexander Fedotov Subject: [PATCH v1 1/4] Alignment libgloss/arm and newlib/libc/sys/arm: reflect commit 9b11672 Date: Thu, 1 Aug 2019 05:13:31 -0500 Message-Id: <20190801101334.6213-1-alfedotov@gmail.com> --- newlib/libc/sys/arm/crt0.S | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S index 9c262428d..40bbc3d69 100644 --- a/newlib/libc/sys/arm/crt0.S +++ b/newlib/libc/sys/arm/crt0.S @@ -393,13 +393,14 @@ __change_mode: movs r1, r0 #else movs r0, #AngelSWI_Reason_GetCmdLine - adr r1, .LC30 /* Space for command line. */ + ldr r1, .LC30 /* Space for command line. */ #ifdef THUMB_VXM bkpt AngelSWI #else AngelSWIAsm AngelSWI #endif ldr r1, .LC30 + ldr r1, [r1] #endif /* Parse string at r1. */ movs r0, #0 /* Count of arguments so far. */ @@ -586,8 +587,7 @@ change_back: #endif #ifdef ARM_RDI_MONITOR .LC30: - .word CommandLine - .word 255 + .word AngelSWIArgs .LC31: .word __end__ @@ -600,6 +600,9 @@ HeapLimit: .word 0 __stack_base__: .word 0 StackLimit: .word 0 CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */ +AngelSWIArgs: + .word CommandLine + .word 255 #endif #ifdef __pe__ From patchwork Thu Aug 1 10:13:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Fedotov X-Patchwork-Id: 170367 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5213906ile; Thu, 1 Aug 2019 03:14:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTd1KRMRyqz/t/1+HAQ6yMmt5kVlegWuiJ54llesdws1FmV6vApvduS+q84Tcr/DIk/u5D X-Received: by 2002:a17:90a:374a:: with SMTP id u68mr7772910pjb.4.1564654454057; Thu, 01 Aug 2019 03:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564654454; cv=none; d=google.com; s=arc-20160816; b=GJLPErK+N5Hiv0OCZ+BoMQl74YF15BBUV9kQm0fpy4/vYjWQc66760A/2uXDV0AO5F DCw48Q6vqDk9SLi4xDpdosozBSeU+OHaXXczz/Jh9ijosU01T+gZrlau6boLxNiEjXj/ nZTsRiOgm+ievcATAm0B0uawi23jrUO2cQzffGGIp7ozrchGxkjkb8uQujG4XBb/v18P 1WqKAJGh5FC8D4Rrg+r8Q9WgKV7zq650xEsi3IX3H0RczlpP6xDMvVpFVpC6bSd2WRQR YlrfBW7vn4jkED3YdiAKTGmdxRfrhPxklpLns25exr1X9ZYZYamAqwt8r954wsdP2VAo 5hWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=WQWSz+VZ0TRVn4xK5UIuderZYlwmT7d85FvRdA2eCLA=; b=XRv+n0xiLtJ4JgME9MV4xIkXhWnfrNQWm4EgM8El0Bc/CA8B20bJ4QjF+IDPe4EdSJ 1l+SPva3C0NX1kJKMO5D7/Dk3/b1DAck+N3N7F8MNQLDyeKj9fAkJ+m73XJP9OFIJlGz lTW66ceor6Wi4SDqDW0L8F1E7BnuDB09/kxmzoqQOWnBf4b9hagjU25gZTqUflEpZU4o 4WOPeDDVKLytgHbsVinUX76oJiIcJCjHwggrUT+MIHXbkhoPQqvcx8pd0RMGyq6il+3K P7MDQUzYFnOetfzeAtakUdrfZupt6LPPO2WTR3H/ZlwbtVW5LcDdcJo6ShsZ4IXT2X+j yvMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=XuCGKsm5; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gZsh9q7S; spf=pass (google.com: domain of newlib-return-17109-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17109-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q85si34578999pfc.85.2019.08.01.03.14.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 03:14:14 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-17109-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=XuCGKsm5; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gZsh9q7S; spf=pass (google.com: domain of newlib-return-17109-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17109-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=br0MLQX5b2iIuuG8W2YHi1S4ODnR3MW BT2cykj1tNHim5UAK/+iVbta74n00JLbeC6qUJZmbMlGW5Pe4DN8nCeP+JVzORMX Zb8e4tuZhoPHB1tqr+8cFMR4M8bQBvzdpffxqCxFlPSSYRofbop3gaHtnWn5CBaW 4drheicCWjL8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=Feaga8j2MKSOlTqi0FlhDUFvT/4=; b=XuCGK sm5YmVDeBc2eVojB/YVg8JAeiP9wNWJg7q4nDu9GT3IKgvkj/9xWV+TBTvxuqPlF Eo7sS5T5DpC6mumP5K/zB6wtxati7kkbj9a3+zSeU7yeyBPfNk9IGIFWz9gioGN5 aKXQBKyj7o+zRRdyGmrB0fAnSM5LYc61otnU7k= Received: (qmail 94745 invoked by alias); 1 Aug 2019 10:13:50 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 94671 invoked by uid 89); 1 Aug 2019 10:13:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:sk:2019080, H*i:sk:2019080 X-HELO: mail-lf1-f68.google.com Received: from mail-lf1-f68.google.com (HELO mail-lf1-f68.google.com) (209.85.167.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Aug 2019 10:13:48 +0000 Received: by mail-lf1-f68.google.com with SMTP id s19so49815266lfb.9 for ; Thu, 01 Aug 2019 03:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WQWSz+VZ0TRVn4xK5UIuderZYlwmT7d85FvRdA2eCLA=; b=gZsh9q7SuPfKt0/V03GA8CXvFCJjGjuDuL+A28fy6eOANNmcg+9N1sOa93pWWfT6/j u/KOgAVECv9zFcmWPAFcJFD98l+KOfvRl5lIfmYYBP/LRO5T8zUMbT1HJxrTHctm8rVw /Vp1vMQJ93iEwlyLHR8Cz+OKQpANhYQPR//WszzCxoXYKoeO9QCbuKU1YBeF0pqYTqzp yxRVlGC2YmqlgrLsnMqROEXAxb55Xfkldiak6WytbBk87cDnb4bX7H39/4klEuQ18nPk shLQ74hYS9Azy2e5Z4cfC/DSeGvu2QTntW4vXpIhv+Od6zU9hrl4SN5YFS/xXd33M+IK hyQw== Return-Path: Received: from af-ubuntu18-hyperv.cmtknet.ru (relay.cmtk.ru. [195.5.145.226]) by smtp.gmail.com with ESMTPSA id n1sm12221136lfk.19.2019.08.01.03.13.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 03:13:45 -0700 (PDT) From: Alexander Fedotov To: newlib@sourceware.org, Richard.Earnshaw@arm.com Cc: Alexander Fedotov Subject: [PATCH v1 2/4] Alignment libgloss/arm and newlib/libc/sys/arm: reflect commits 8d98f95, 5c9403e Date: Thu, 1 Aug 2019 05:13:32 -0500 Message-Id: <20190801101334.6213-2-alfedotov@gmail.com> In-Reply-To: <20190801101334.6213-1-alfedotov@gmail.com> References: <20190801101334.6213-1-alfedotov@gmail.com> --- libgloss/arm/syscalls.c | 12 ++++++------ newlib/libc/sys/arm/crt0.S | 7 +++++++ newlib/libc/sys/arm/syscalls.c | 9 +++++++-- 3 files changed, 20 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index dacd1a9d3..3605e0fd0 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -707,15 +707,15 @@ uint __heap_limit = 0xcafedead; void * __attribute__((weak)) _sbrk (ptrdiff_t incr) { - extern char end asm ("end"); /* Defined by the linker. */ + extern char end asm ("end"); /* Defined by the linker. */ static char * heap_end; - char * prev_heap_end; + char * prev_heap_end; if (heap_end == NULL) heap_end = & end; - + prev_heap_end = heap_end; - + if ((heap_end + incr > stack_ptr) /* Honour heap limit if it's valid. */ || (__heap_limit != 0xcafedead && heap_end + incr > (char *)__heap_limit)) @@ -726,14 +726,14 @@ _sbrk (ptrdiff_t incr) extern void abort (void); _write (1, "_sbrk: Heap and stack collision\n", 32); - + abort (); #else errno = ENOMEM; return (void *) -1; #endif } - + heap_end += incr; return (void *) prev_heap_end; diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S index 40bbc3d69..a55aa365b 100644 --- a/newlib/libc/sys/arm/crt0.S +++ b/newlib/libc/sys/arm/crt0.S @@ -282,6 +282,13 @@ #endif ldr r0, .LC0 /* Point at values read. */ + /* Set __heap_limit. */ + ldr r1, [r0, #4] + cmp r1, #0 + beq .LC33 + ldr r2, =__heap_limit + str r1, [r2] +.LC33: ldr r1, [r0, #0] cmp r1, #0 bne .LC32 diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c index b52107491..a2997b44c 100644 --- a/newlib/libc/sys/arm/syscalls.c +++ b/newlib/libc/sys/arm/syscalls.c @@ -487,10 +487,13 @@ _getpid (void) return (pid_t)1; } +/* Heap limit returned from SYS_HEAPINFO Angel semihost call. */ +uint __heap_limit = 0xcafedead; + void * __attribute__((weak)) _sbrk (ptrdiff_t incr) { - extern char end asm ("end"); /* Defined by the linker. */ + extern char end asm ("end"); /* Defined by the linker. */ static char * heap_end; char * prev_heap_end; @@ -499,7 +502,9 @@ _sbrk (ptrdiff_t incr) prev_heap_end = heap_end; - if (heap_end + incr > stack_ptr) + if ((heap_end + incr > stack_ptr) + /* Honour heap limit if it's valid. */ + || (__heap_limit != 0xcafedead && heap_end + incr > (char *)__heap_limit)) { /* Some of the libstdc++-v3 tests rely upon detecting out of memory errors, so do not abort here. */ From patchwork Thu Aug 1 10:13:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Fedotov X-Patchwork-Id: 170368 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5214105ile; Thu, 1 Aug 2019 03:14:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiFNrdaA0bS7MSlyEij3AQF177s5YvY6yUqAhzdwaTWitgcS4eNZvG+rfeZGKs/RDKUe2b X-Received: by 2002:a17:90a:8c06:: with SMTP id a6mr7972142pjo.45.1564654462595; Thu, 01 Aug 2019 03:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564654462; cv=none; d=google.com; s=arc-20160816; b=fxIqKUuAOhLZVE6EwZx/uvPGCebzcOY11B+GcTJroz8ehYo89P3wE+kPXlU4MOoJ6N d/jb5gSeAG1Vjg4OsmttcEqTrRYWiSvUP3ozqspwzJvd8EbVdz+/ScSLHsgCoIrNCtcQ 5B9GgIk04pYt7aJwsrydEqSyWJydBeLLV89E5TD8Oje5uodb5CFAOOJM/6TVhFa20++B fo+7ZnLZ4IGSRQpFYHtH5+Vl+jLtLKAgjBeHgD8l/fNvWdlD8psr0h7hRLZ72uH7gBAK +1BsXcL7Uh6Z0R9yRiqotQBwEpIkjzP9+Cxk5inSl73+GPz5ybHUpMdk732rt+pCzy7F p/2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=SO6nCUY6/ihAUyyRWtH74/pBtcGKX84BNcFboYthc7A=; b=mzBUjvx814ECjUq1oEoh2Y7Vjzfk4icu6H8lNbrSuAUCDnKzON3obad4Vh+7FyDZkj IRiwVuZ1kaM8w04+avvoqINysUEVXXiWXgEHyW7YUfTZV9j26Tdk797Fh/vzLbxtn3Hx 5MqWG9tbDystMQ/lmcOB34yJiYbZISuERVboNlST/ze61ccRD6W38XgKA5tQqS7idENV rBmv8uYq3XNO//lPFhEJ0HNFPEQbHvrSZeafvwyWdwX0bEC2DLZi77U/UcYYwq8dx7YI vTIqxtRxqIHvq/TEuAP2YGSshaswa6lOimVg7xDxQPxaL3IiJVg71M/XwuQT3i/xJcE/ RU8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NUE4L9yl; dkim=pass header.i=@gmail.com header.s=20161025 header.b=blsIZb56; spf=pass (google.com: domain of newlib-return-17110-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17110-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 131si33608550pfu.165.2019.08.01.03.14.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 03:14:22 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-17110-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NUE4L9yl; dkim=pass header.i=@gmail.com header.s=20161025 header.b=blsIZb56; spf=pass (google.com: domain of newlib-return-17110-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17110-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=dWdEuJRezf0vtEU2LXF7fK4uzE8a5uY 8ITxDPHvR2Be2HB6eXdpaaQcjQZEGAbbbdUgBI6FNgmdAMUyW5RWVz7Y/tJ368Pp sP/RfPn1iaa7wHf/YXfPUkkHhxRiXHnOvJcNt6JOZi/ahP8eb0XAt7WeFljy/SrH FDmQjW0L8OXs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=MHaX9RpnNgFi0G95+X8EZ0WBas0=; b=NUE4L 9yl+bCTYXSmnBDdYfHJ3GBbPCJm9L94ISRwOQwk4q/r5XvRjfp8SMnYp1pbr+nqT tLSAcWNaA53y8KiZTK8Kybrf0T4C/EtDW6YJ3rE670efLhBbekuYuaYTUjxKI78l cncyoY4udUo2HDaDUI5H8LWoxtoBzHbBGkrT7A= Received: (qmail 94837 invoked by alias); 1 Aug 2019 10:13:50 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 94747 invoked by uid 89); 1 Aug 2019 10:13:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:sk:2019080, H*i:sk:2019080 X-HELO: mail-lf1-f45.google.com Received: from mail-lf1-f45.google.com (HELO mail-lf1-f45.google.com) (209.85.167.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Aug 2019 10:13:48 +0000 Received: by mail-lf1-f45.google.com with SMTP id c9so49765169lfh.4 for ; Thu, 01 Aug 2019 03:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SO6nCUY6/ihAUyyRWtH74/pBtcGKX84BNcFboYthc7A=; b=blsIZb56BcDDOG2pkpC3kXybV5+FtFareZFR/qEuMBtfH11cKKNxCbO9wyPIYNJc1y zeIQ/1Dgixw2D+g4zpQyFxhL/BE9lRoN7AHpZZSog135h6MFADJ9E48u49AY6Upcuz80 Hxjjw07visgFm8yCozUYtz1YzwLbo8MbwCIGyhGDn4oxw+9XfLojQuoETeG3fRSbRNk0 MIHVBKdK/qQqX3NlxvwHtznxchn5t22i5AF3Y4dyXIOQnAlQnWZQ4xpOlg581sOgw97+ l89CT2jD/q5tW42bcAngThRb/Ls3nq7NfIVGUqxsBrgJQr4MO3ANyMYO1jKLNHPGS7eW HxhA== Return-Path: Received: from af-ubuntu18-hyperv.cmtknet.ru (relay.cmtk.ru. [195.5.145.226]) by smtp.gmail.com with ESMTPSA id n1sm12221136lfk.19.2019.08.01.03.13.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 03:13:45 -0700 (PDT) From: Alexander Fedotov To: newlib@sourceware.org, Richard.Earnshaw@arm.com Cc: Alexander Fedotov Subject: [PATCH v1 3/4] Alignment libgloss/arm and newlib/libc/sys/arm: reflect commit 2404223 Date: Thu, 1 Aug 2019 05:13:33 -0500 Message-Id: <20190801101334.6213-3-alfedotov@gmail.com> In-Reply-To: <20190801101334.6213-1-alfedotov@gmail.com> References: <20190801101334.6213-1-alfedotov@gmail.com> --- newlib/libc/sys/arm/crt0.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.17.1 diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S index a55aa365b..5e677a23c 100644 --- a/newlib/libc/sys/arm/crt0.S +++ b/newlib/libc/sys/arm/crt0.S @@ -518,8 +518,17 @@ __change_mode: for _fini to be called at program exit. */ movs r4, r0 movs r5, r1 +#ifdef _LITE_EXIT + /* Make reference to atexit weak to avoid unconditionally pulling in + support code. Refer to comments in __atexit.c for more details. */ + .weak FUNCTION(atexit) + ldr r0, .Latexit + cmp r0, #0 + beq .Lweak_atexit +#endif ldr r0, .Lfini bl FUNCTION (atexit) +.Lweak_atexit: bl FUNCTION (_init) movs r0, r4 movs r1, r5 @@ -589,6 +598,13 @@ change_back: .LC2: .word __bss_end__ #ifdef __USES_INITFINI__ +#ifdef _LITE_EXIT +.Latexit: + .word FUNCTION(atexit) + + /* Weak reference _fini in case of lite exit. */ + .weak FUNCTION(_fini) +#endif .Lfini: .word FUNCTION(_fini) #endif From patchwork Thu Aug 1 10:13:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Fedotov X-Patchwork-Id: 170369 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5214292ile; Thu, 1 Aug 2019 03:14:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2yNTDZQq1HJnBS8rRMIUn26TydTYxi8TniO6HwOd6Hf9luyg8pgxzGltZ99dDtIugyeEu X-Received: by 2002:aa7:9217:: with SMTP id 23mr53324782pfo.239.1564654471468; Thu, 01 Aug 2019 03:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564654471; cv=none; d=google.com; s=arc-20160816; b=KXpJZOMOsNG6BM54amt0a6uW7UP50EAwz2u76m8sOaxAEaKmyA2SlFFc+xWeuyef/w xBEdyPDWrF2EQ6lIDkjEInnAjQcqkCk0lIOEB2Xm+d0KwBGMXleor9kCRaFb/iFj8ssA Dr++oz+Q6bVybSzmxQGNll7lM57KELvQOxrU4sw6mpr+7LC35qEEQHrHshgZ/99A2/eH zjez49NAqNnXp8vwZu04LQw6k5kLXvZ6hyc4t0TbXfPD5PJRXcx7BTu3sgX0ttYhg9wp U3nd+wUXOwmf9VMkdKGLPKamtWqcEuAsnVnpXfLdgcOGBcQICWb+9fr03lOKAuw+JVmD MHnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=zf8DTyzgoE5H9rFIy8QeU1jb01b5yeCVnpXDYlHox+Q=; b=iMTl08pu68WbY7mHr6DWC6p+ISksjorR6p/qXlkDGTK+5gB7MxMbb1UsKRmuo7tTwk CX55SJ1REnjEtGSHnAHlloWFph71fIGXnqgoJXFBQUtf98l+TtAZATcqfSQx/vrJibmy cA7wnGd+XKiHosqair09twc7un7+JjuWnIoNfhCxTN0eaRoO9msMBA3JxCKaUirnaRhj oK/xRyB9XKb1YTKqnCdnGDwaqLPy7aJT3dRL38nnJjWTw7G9crIgdVLg3anW0IZJLdAa xSzCoVzw2uM02BBKZT/Odc+5VaYCr7ysN6DmaHfjDfCaOSheI2K8BFm9CpCNDZVFr0cu gtSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=VspSuMOF; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pKvslaM+; spf=pass (google.com: domain of newlib-return-17111-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17111-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j192si37482659pge.393.2019.08.01.03.14.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 03:14:31 -0700 (PDT) Received-SPF: pass (google.com: domain of newlib-return-17111-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=VspSuMOF; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pKvslaM+; spf=pass (google.com: domain of newlib-return-17111-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="newlib-return-17111-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=ilJogfJv9XxQlvynU+CjqqUiqevkntZ mkN2IzovprePbRpkUo/h6hDFjp0DEyFXxETGQUekMvIrmtmJkgBcihKK+zECHjhB jZXgGFhLCmWUlYGRZMIY3mkazhqR95ychyoooj8WCUv24iJ0wUyuTeWIgQsKSk+v KuVnmeOZWY18= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=rG0ENFvHcIIYzf/hnlKaTDaGq8c=; b=VspSu MOFgaLBvqVbMij+o7YY2N+cYtajx9JmdNOm7Gxdu88S7n49NGZv/34HsSMUg/A0n tyLx7GgTyhZYR7jTyWzWFhB6WVLlMieSIDsWVfI7xYOjX43+mk8oPI9Ak0PRr7gf x7iMYWxik3ZuyIXV7lpoFuAFtnOz4Nq/kKu/cs= Received: (qmail 95310 invoked by alias); 1 Aug 2019 10:13:53 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 95229 invoked by uid 89); 1 Aug 2019 10:13:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=write-only, 4417 X-HELO: mail-lf1-f67.google.com Received: from mail-lf1-f67.google.com (HELO mail-lf1-f67.google.com) (209.85.167.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Aug 2019 10:13:50 +0000 Received: by mail-lf1-f67.google.com with SMTP id h28so49780674lfj.5 for ; Thu, 01 Aug 2019 03:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zf8DTyzgoE5H9rFIy8QeU1jb01b5yeCVnpXDYlHox+Q=; b=pKvslaM+VRu9/jRw5CiPOrV6crOdbP6pjUW41TOD3Sw2UDFsa848WJU3OndtbWyrMx cidz0JFDnM6RdVA2QIKkt4WPnpprOMOhMCXB0E5pvpk3Sk1rU7djkgJyHTIcbkORZBNf 7RQ7EzLEHY452q02pCw2rpQE/NK6QlQs+dM0HUGyNC9bF19kA227H7jp90yNLN++wlmL /E1wI/0OnBv2/UKDF/bci2LQryq0HqMraVvPsCqrhKo2/IOPYcVRyYgEJJqmRZSqlLGR E1sIAmRSp6dbfpZ7Gv45vLQwqPaQXpD0TVZidZoZ2Cme2xloiDtI6LLn9EeTDI5OsooY 933Q== Return-Path: Received: from af-ubuntu18-hyperv.cmtknet.ru (relay.cmtk.ru. [195.5.145.226]) by smtp.gmail.com with ESMTPSA id n1sm12221136lfk.19.2019.08.01.03.13.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 03:13:46 -0700 (PDT) From: Alexander Fedotov To: newlib@sourceware.org, Richard.Earnshaw@arm.com Cc: Alexander Fedotov Subject: [PATCH v1 4/4] Alignment libgloss/arm and newlib/libc/sys/arm: minor fixes, alignments and cleanup Date: Thu, 1 Aug 2019 05:13:34 -0500 Message-Id: <20190801101334.6213-4-alfedotov@gmail.com> In-Reply-To: <20190801101334.6213-1-alfedotov@gmail.com> References: <20190801101334.6213-1-alfedotov@gmail.com> --- libgloss/arm/crt0.S | 2 +- libgloss/arm/syscalls.c | 106 ++++++++++++++------------------- newlib/libc/sys/arm/arm.h | 2 +- newlib/libc/sys/arm/syscalls.c | 50 +++++++++++----- 4 files changed, 82 insertions(+), 78 deletions(-) -- 2.17.1 diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S index 3e740c654..8490bde2f 100644 --- a/libgloss/arm/crt0.S +++ b/libgloss/arm/crt0.S @@ -440,7 +440,7 @@ __change_mode: beq .LC10 /* See whether we are scanning a string. */ - cmp r3, #'"' + cmp r3, #'\"' #ifdef __thumb__ beq .LC20 cmp r3, #'\'' diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index 3605e0fd0..fc394f94b 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -18,30 +18,30 @@ #include "swi.h" /* Forward prototypes. */ -int _system (const char *); -int _rename (const char *, const char *); -int _isatty (int); +int _system (const char *); +int _rename (const char *, const char *); +int _isatty (int); clock_t _times (struct tms *); -int _gettimeofday (struct timeval *, void *); -int _unlink (const char *); -int _link (const char *, const char *); -int _stat (const char *, struct stat *); -int _fstat (int, struct stat *); +int _gettimeofday (struct timeval *, void *); +int _unlink (const char *); +int _link (const char *, const char *); +int _stat (const char *, struct stat *); +int _fstat (int, struct stat *); int _swistat (int fd, struct stat * st); -void * _sbrk (ptrdiff_t); -pid_t _getpid (void); -int _close (int); -clock_t _clock (void); -int _swiclose (int); -int _open (const char *, int, ...); -int _swiopen (const char *, int); -int _write (int, const void *, size_t); -int _swiwrite (int, const void *, size_t); -_off_t _lseek (int, _off_t, int); -_off_t _swilseek (int, _off_t, int); -int _read (int, void *, size_t); -int _swiread (int, void *, size_t); -void initialise_monitor_handles (void); +void * _sbrk (ptrdiff_t); +pid_t _getpid (void); +int _close (int); +clock_t _clock (void); +int _swiclose (int); +int _open (const char *, int, ...); +int _swiopen (const char *, int); +int _write (int, const void *, size_t); +int _swiwrite (int, const void *, size_t); +_off_t _lseek (int, _off_t, int); +_off_t _swilseek (int, _off_t, int); +int _read (int, void *, size_t); +int _swiread (int, void *, size_t); +void initialise_monitor_handles (void); static int checkerror (int); static int error (int); @@ -143,7 +143,7 @@ initialise_monitor_handles (void) int i; /* Open the standard file descriptors by opening the special - * teletype device, ":tt", read-only to obtain a descritpor for + * teletype device, ":tt", read-only to obtain a descriptor for * standard input and write-only to obtain a descriptor for standard * output. Finally, open ":tt" in append mode to obtain a descriptor * for standard error. Since this is a write mode, most kernels will @@ -154,7 +154,7 @@ initialise_monitor_handles (void) #ifdef ARM_RDI_MONITOR int volatile block[3]; - + block[0] = (int) ":tt"; block[2] = 3; /* length of filename */ block[1] = 0; /* mode "r" */ @@ -351,17 +351,15 @@ checkerror (int result) len, is the length in bytes to read. Returns the number of bytes *not* written. */ int -_swiread (int fh, - void * ptr, - size_t len) +_swiread (int fh, void * ptr, size_t len) { #ifdef ARM_RDI_MONITOR int block[3]; - + block[0] = fh; block[1] = (int) ptr; block[2] = (int) len; - + return checkerror (do_AngelSWI (AngelSWI_Reason_Read, block)); #else register int r0 asm("r0"); @@ -381,9 +379,7 @@ _swiread (int fh, Translates the return of _swiread into bytes read. */ int __attribute__((weak)) -_read (int fd, - void * ptr, - size_t len) +_read (int fd, void * ptr, size_t len) { int res; struct fdent *pfd; @@ -409,9 +405,7 @@ _read (int fd, /* fd, is a user file descriptor. */ off_t -_swilseek (int fd, - off_t ptr, - int dir) +_swilseek (int fd, off_t ptr, int dir) { off_t res; struct fdent *pfd; @@ -447,7 +441,7 @@ _swilseek (int fd, } dir = SEEK_SET; } - + #ifdef ARM_RDI_MONITOR int block[2]; if (dir == SEEK_END) @@ -458,7 +452,7 @@ _swilseek (int fd, return -1; ptr += res; } - + /* This code only does absolute seeks. */ block[0] = pfd->handle; block[1] = (int) ptr; @@ -494,9 +488,7 @@ _swilseek (int fd, } off_t -_lseek (int fd, - off_t ptr, - int dir) +_lseek (int fd, off_t ptr, int dir) { return _swilseek (fd, ptr, dir); } @@ -504,18 +496,15 @@ _lseek (int fd, /* fh, is a valid internal file handle. Returns the number of bytes *not* written. */ int -_swiwrite ( - int fh, - const void * ptr, - size_t len) +_swiwrite (int fh, const void * ptr, size_t len) { #ifdef ARM_RDI_MONITOR int block[3]; - + block[0] = fh; block[1] = (int) ptr; block[2] = (int) len; - + return checkerror (do_AngelSWI (AngelSWI_Reason_Write, block)); #else register int r0 asm("r0"); @@ -533,9 +522,7 @@ _swiwrite ( /* fd, is a user file descriptor. */ int __attribute__((weak)) -_write (int fd, - const void * ptr, - size_t len) +_write (int fd, const void * ptr, size_t len) { int res; struct fdent *pfd; @@ -593,7 +580,7 @@ _swiopen (const char * path, int flags) } } - /* The flags are Unix-style, so we need to convert them. */ + /* The flags are Unix-style, so we need to convert them. */ #ifdef O_BINARY if (flags & O_BINARY) aflags |= 1; @@ -611,25 +598,24 @@ _swiopen (const char * path, int flags) if (flags & O_APPEND) { - /* Can't ask for w AND a; means just 'a'. */ - aflags &= ~4; + aflags &= ~4; /* Can't ask for w AND a; means just 'a'. */ aflags |= 8; } - + #ifdef ARM_RDI_MONITOR block[0] = (int) path; block[2] = strlen (path); block[1] = aflags; - + fh = do_AngelSWI (AngelSWI_Reason_Open, block); - + #else asm ("mov r0,%2; mov r1, %3; swi %a1; mov %0, r0" : "=r"(fh) : "i" (SWI_Open),"r"(path),"r"(aflags) : "r0","r1"); #endif - + /* Return a user file descriptor or an error. */ if (fh >= 0) { @@ -784,13 +770,13 @@ _stat (const char *fname, struct stat *st) { int fd, res; memset (st, 0, sizeof (* st)); - /* The best we can do is try to open the file readonly. - If it exists, then we can guess a few things about it. */ + /* The best we can do is try to open the file readonly. If it exists, + then we can guess a few things about it. */ if ((fd = _open (fname, O_RDONLY)) == -1) return -1; st->st_mode |= S_IFREG | S_IREAD; res = _swistat (fd, st); - /* Not interested in the error. */ + /* Not interested in the error. */ _close (fd); return res; } @@ -880,7 +866,7 @@ _times (struct tms * tp) tp->tms_cutime = 0; /* user time, children */ tp->tms_cstime = 0; /* system time, children */ } - + return timeval; }; diff --git a/newlib/libc/sys/arm/arm.h b/newlib/libc/sys/arm/arm.h index dbed81750..10e5b0509 100644 --- a/newlib/libc/sys/arm/arm.h +++ b/newlib/libc/sys/arm/arm.h @@ -85,6 +85,6 @@ #define CPSR_F_MASK 0x40 /* FIQ bit. */ #define CPSR_I_MASK 0x80 /* IRQ bit. */ -#define CPSR_M_MASK 0x0F /* Mode mask except M[4] */ +#define CPSR_M_MASK 0x0F /* Mode mask except M[4]. */ #endif /* _LIBGLOSS_ARM_H */ diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c index a2997b44c..1f7222980 100644 --- a/newlib/libc/sys/arm/syscalls.c +++ b/newlib/libc/sys/arm/syscalls.c @@ -114,6 +114,16 @@ void initialise_monitor_handles (void) { int i; + + /* Open the standard file descriptors by opening the special + * teletype device, ":tt", read-only to obtain a descriptor for + * standard input and write-only to obtain a descriptor for standard + * output. Finally, open ":tt" in append mode to obtain a descriptor + * for standard error. Since this is a write mode, most kernels will + * probably return the same value as for standard output, but the + * kernel can differentiate the two using the mode flag and return a + * different descriptor for standard error. + */ #ifdef ARM_RDI_MONITOR int volatile block[3]; @@ -163,11 +173,12 @@ get_errno (void) return do_AngelSWI (AngelSWI_Reason_Errno, NULL); #else register int r0 asm("r0"); - asm ("swi %a1" : "=r"(r0): "i" (SWI_GetErrno)); + asm ("swi %a1" : "=r"(r0) : "i" (SWI_GetErrno)); return r0; #endif } +/* Set errno and return result. */ static int error (int result) { @@ -183,7 +194,10 @@ wrap (int result) return result; } -/* Returns # chars not! written. */ +/* file, is a valid user file handle. + ptr, is a null terminated string. + len, is the length in bytes to read. + Returns the number of bytes *not* written. */ int _swiread (int file, void * ptr, size_t len) { @@ -207,6 +221,9 @@ _swiread (int file, void * ptr, size_t len) #endif } +/* file, is a valid user file handle. + Translates the return of _swiread into + bytes read. */ int __attribute__((weak)) _read (int file, void * ptr, size_t len) { @@ -223,15 +240,13 @@ _read (int file, void * ptr, size_t len) return len - x; } +/* file, is a user file descriptor. */ off_t _swilseek (int file, off_t ptr, int dir) { _off_t res; int fh = remap_handle (file); int slot = findslot (fh); -#ifdef ARM_RDI_MONITOR - int block[2]; -#endif if (dir == SEEK_CUR) { @@ -249,6 +264,7 @@ _swilseek (int file, off_t ptr, int dir) } #ifdef ARM_RDI_MONITOR + int block[2]; if (dir == SEEK_END) { block[0] = fh; @@ -294,7 +310,8 @@ _lseek (int file, off_t ptr, int dir) return wrap (_swilseek (file, ptr, dir)); } -/* Returns #chars not! written. */ +/* file, is a valid internal file handle. + Returns the number of bytes *not* written. */ int _swiwrite (int file, const void * ptr, size_t len) { @@ -319,6 +336,7 @@ _swiwrite (int file, const void * ptr, size_t len) #endif } +/* file, is a user file descriptor. */ int __attribute__((weak)) _write (int file, const void * ptr, size_t len) { @@ -366,7 +384,7 @@ _swiopen (const char * path, int flags) if (flags & O_APPEND) { - aflags &= ~4; /* Can't ask for w AND a; means just 'a'. */ + aflags &= ~4; /* Can't ask for w AND a; means just 'a'. */ aflags |= 8; } @@ -527,7 +545,7 @@ _sbrk (ptrdiff_t incr) extern void memset (struct stat *, int, unsigned int); -int +int __attribute__((weak)) _fstat (int file, struct stat * st) { memset (st, 0, sizeof (* st)); @@ -537,7 +555,8 @@ _fstat (int file, struct stat * st) file = file; } -int _stat (const char *fname, struct stat *st) +int __attribute__((weak)) +_stat (const char *fname, struct stat *st) { int file; @@ -553,20 +572,19 @@ int _stat (const char *fname, struct stat *st) return 0; } -int -_link (const char *__path1 __attribute__ ((unused)), - const char *__path2 __attribute__ ((unused))) +int __attribute__((weak)) +_link (const char *__path1 __attribute__ ((unused)), const char *__path2 __attribute__ ((unused))) { errno = ENOSYS; return -1; } int -_unlink (const char *path __attribute__ ((unused))) +_unlink (const char *path) { #ifdef ARM_RDI_MONITOR int block[2]; - block[0] = (int) path; + block[0] = (int)path; block[1] = strlen(path); return wrap (do_AngelSWI (AngelSWI_Reason_Remove, block)) ? -1 : 0; #else @@ -659,13 +677,13 @@ _system (const char *s) meaning to its return value. Try to do something reasonable.... */ if (!s) return 1; /* maybe there is a shell available? we can hope. :-P */ - block[0] = (int) s; + block[0] = (int)s; block[1] = strlen (s); e = wrap (do_AngelSWI (AngelSWI_Reason_System, block)); if ((e >= 0) && (e < 256)) { /* We have to convert e, an exit status to the encoded status of - the command. To avoid hard coding the exit status, we simply + the command. To avoid hard coding the exit status, we simply loop until we find the right position. */ int exit_code;