From patchwork Mon May 8 15:26:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 98828 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1383049qge; Mon, 8 May 2017 08:27:45 -0700 (PDT) X-Received: by 10.98.89.194 with SMTP id k63mr3662298pfj.81.1494257265760; Mon, 08 May 2017 08:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494257265; cv=none; d=google.com; s=arc-20160816; b=I75vcFlsxtFqLJlXrP7JAb3P7yH5bPyo9iP0CQYt7sk9o1oS7k1M8XPDhcgyU4NAfS Oer46VTITF7BELOXIJpuSuJ61lvc5QXcf2VG5z/9FmeZGpm/l7vm66EoB+HYXMvST0sQ UaCB/QMEyUl1h7zLWNF+kD7w7O7AjcrpBZDeve0YEYTstr/nceuKSTxM6/B/GkgpLtgx lMKgmMz3pJtk1YC997Zs/Hqnho+Q0AroapTV51ONVpdWbE67MMdwpe4Zh3KGSGPJtEHD KBwoSP4iA7tkjXWidNhunF/rTDhp2a2oKmkShXqxcJsdteWq0ERQWu9Qumj1W8ikO6BK 4+JQ== 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:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=p5P2qMGZ+4vJQoEhkenvRqhdqhijdynJJ0r752ebnLM=; b=NmWhu5CKj1oUO7qQxC75b991hF8YngJP+oqjkQTJWnFEsrpIARNuL/c4jDaqYDhZux wEutUv5+ZHFnh0G/D+7QOabNUY22RWTNMxcVR8QYb4OdeXVHRCFRpyYXIAoyobUzGKyE ulwqjFZd35K/q1j8vOC3iNjujT1+HkJPupCJLZeCL742rLrugUmdH/Z0sP4sYCY3CfgB mC+77toktT/gN+yNt4uXDh4gtVzEwKQi6GN0CmqYKPJIgMIByz6Q04V2a6adTlkajoW3 ZTJJ/kg89UF4DojRQvLVan5HUoWXe15dgE5mB/Ie/QGSAHKfUNEvSD0ogjE8jIFSKQF2 V+Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-79117-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-79117-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 1si13330237plx.288.2017.05.08.08.27.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 May 2017 08:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-79117-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; spf=pass (google.com: domain of libc-alpha-return-79117-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-79117-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=PZLdL4doQ5ZrqLaUfYC7GJ8awYZwfyF cK3GkGzOQm4ecm0Pb+7GAoWxEr2arOqOa0EPgGTU1XR8XSkPYZF3RAlM7V17dLOR qI3db7JqNDcfL4tNrL/sFXqWosAtASwXLnk8edTfRFbeNZxA/0QE/sHInXECOcST G5eq6IQ1klJ4= 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:subject:date:message-id:in-reply-to :references; s=default; bh=VxlDqtHQc4/lrvFLSiRbSSebcgg=; b=N770+ yl8bP8ZIJJTAA1IOWf6eb2Y2/nieCJlejUxeG7fpuVNbtWj6i0OrvvVlHWiV1oFU 1V6Cq2HGL8ZPGMogudDpKTxgdNeFzEePLxQIQ48S9ZHB41O+PrVIeSFPvt8uVzQd pCYiV3Vj0RIzzdkb7sAvh0TW6hGgpXfJmQ3GxI= Received: (qmail 54326 invoked by alias); 8 May 2017 15:27:05 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 54071 invoked by uid 89); 8 May 2017 15:27:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=1823, cancellation, 1820, EXTRA X-HELO: mail-qt0-f176.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=p5P2qMGZ+4vJQoEhkenvRqhdqhijdynJJ0r752ebnLM=; b=bKcRj5GuHGTBBDIhOgr9CrCjtVUrK7qEOkDDyf7AjUjzC9cmWBuWbfrPM8xikB1TSx ju1YZqQkZ5BvsRcKTXIcTjH0DC91pz/j72GmOUZNTpk4Ccl4ouB4uL/YOP2vRC0oEFel AT1vfMMDrwX2OPj501RcAqRCuDWiw/buDWRBOW9xMfu2WKzM1OX+pvg2o1DNums/MH9F VSpcURHL1Apal1vd6f45SslWA36CfWjGEGMYixQ58Tax910UIfqeqG/KICvH8z0IFc+9 9k+TFCRz7VhE3ro522HGtalpTWauAnsrlPRkZ0YlALyNP23BBbbf4XxSqewhpE/BsI6v qppg== X-Gm-Message-State: AODbwcBEkdHS2FRcZJPUzSbMs+HJXjLcBnwqGgobzmNmNx5OfYAnOQZ1 bgoi2ay4XGwyJtXEhZkBBQ== X-Received: by 10.200.51.172 with SMTP id c41mr20112083qtb.71.1494257222222; Mon, 08 May 2017 08:27:02 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/8] Consolidate Linux creat implementation Date: Mon, 8 May 2017 12:26:47 -0300 Message-Id: <1494257212-524-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1494257212-524-1-git-send-email-adhemerval.zanella@linaro.org> References: <1494257212-524-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the creat Linux syscall implementation on sysdeps/unix/sysv/linux/creat{64}.c. The changes are: 1. Remove creat{64} from auto-generation syscalls.list. 2. Add a new creat{64}.c implementation. For architectures that define __OFF_T_MATCHES_OFF64_T the default creat64 will create alias to required creat symbols. 3. Use __NR_creat where possible, otherwise use internal open{64} call with expected flags. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu. * io/Makefile (CFLAGS-creat.c): New rule. (CFLAGS-creat64.c): Likewise. * sysdeps/unix/sysv/linux/alpha/creat.c: Remove file. * sysdeps/unix/sysv/linux/generic/creat.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/creat64.c: Likewise. * sysdeps/unix/sysv/linux/creat.c: New file. * sysdeps/unix/sysv/linux/creat64.c: Likewise. * sysdeps/unix/sysv/linux/syscalls.list: Remove create from auto-generated list. * sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise. --- ChangeLog | 11 +++++++ io/Makefile | 2 ++ sysdeps/unix/sysv/linux/alpha/creat.c | 8 ----- sysdeps/unix/sysv/linux/{generic => }/creat.c | 17 ++++++----- sysdeps/unix/sysv/linux/creat64.c | 37 +++++++++++++++++++++++ sysdeps/unix/sysv/linux/syscalls.list | 1 - sysdeps/unix/sysv/linux/wordsize-64/creat64.c | 1 - sysdeps/unix/sysv/linux/wordsize-64/syscalls.list | 1 - 8 files changed, 60 insertions(+), 18 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/alpha/creat.c rename sysdeps/unix/sysv/linux/{generic => }/creat.c (77%) create mode 100644 sysdeps/unix/sysv/linux/creat64.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/creat64.c -- 2.7.4 diff --git a/io/Makefile b/io/Makefile index 95e04b2..8b1c250 100644 --- a/io/Makefile +++ b/io/Makefile @@ -80,6 +80,8 @@ include ../Rules CFLAGS-open.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-open64.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-creat.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-creat64.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables diff --git a/sysdeps/unix/sysv/linux/alpha/creat.c b/sysdeps/unix/sysv/linux/alpha/creat.c deleted file mode 100644 index 7a5afed..0000000 --- a/sysdeps/unix/sysv/linux/alpha/creat.c +++ /dev/null @@ -1,8 +0,0 @@ -/* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list defines creat and - creat64 for most linux targets, but on alpha creat is not a syscall. - If we do nothing, we'll wind up with creat64 being undefined, because - the syscalls.list assumes the creat->creat64 alias was created. We - could have overridden that with a create64.c, but we might as well do - the right thing and set up creat64 as an alias. */ -#include -weak_alias(creat, creat64) diff --git a/sysdeps/unix/sysv/linux/generic/creat.c b/sysdeps/unix/sysv/linux/creat.c similarity index 77% rename from sysdeps/unix/sysv/linux/generic/creat.c rename to sysdeps/unix/sysv/linux/creat.c index 34cb210..31e0248 100644 --- a/sysdeps/unix/sysv/linux/generic/creat.c +++ b/sysdeps/unix/sysv/linux/creat.c @@ -1,6 +1,6 @@ -/* Copyright (C) 2011-2017 Free Software Foundation, Inc. +/* Linux default implementation for creat. + Copyright (C) 2017 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -18,20 +18,23 @@ #include #include + #include -#undef creat +#ifndef __OFF_T_MATCHES_OFF64_T /* Create FILE with protections MODE. */ int -creat (const char *file, mode_t mode) +__creat (const char *file, mode_t mode) { +# ifdef __NR_creat + return SYSCALL_CANCEL (creat, file, mode); +# else return __open (file, O_WRONLY | O_CREAT | O_TRUNC, mode); +# endif } +weak_alias (__creat, creat) -/* __open handles cancellation. */ LIBC_CANCEL_HANDLED (); -#if __WORDSIZE == 64 -weak_alias (creat, creat64) #endif diff --git a/sysdeps/unix/sysv/linux/creat64.c b/sysdeps/unix/sysv/linux/creat64.c new file mode 100644 index 0000000..5241085 --- /dev/null +++ b/sysdeps/unix/sysv/linux/creat64.c @@ -0,0 +1,37 @@ +/* Linux default implementation for LFS creat. + Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include +#include +#include + +/* Create FILE with protections MODE. */ +int +__creat64 (const char *file, mode_t mode) +{ + /* We need to pass O_LARGEFILE. */ + return __open64 (file, O_WRONLY | O_CREAT | O_TRUNC, mode); +} +weak_alias (__creat64, creat64) + +#ifdef __OFF_T_MATCHES_OFF64_T +strong_alias (__creat64, __creat) +weak_alias (__creat64, creat) +#endif + +LIBC_CANCEL_HANDLED (); diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 1a10903..f4abf3e 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -6,7 +6,6 @@ bdflush EXTRA bdflush i:ii __compat_bdflush bdflush@GLIBC_2.0:GLIBC_2.23 capget EXTRA capget i:pp capget capset EXTRA capset i:pp capset clock_adjtime EXTRA clock_adjtime i:ip clock_adjtime -creat - creat Ci:si creat create_module EXTRA create_module 3 __compat_create_module create_module@GLIBC_2.0:GLIBC_2.23 delete_module EXTRA delete_module 3 delete_module epoll_create EXTRA epoll_create i:i epoll_create diff --git a/sysdeps/unix/sysv/linux/wordsize-64/creat64.c b/sysdeps/unix/sysv/linux/wordsize-64/creat64.c deleted file mode 100644 index c106e2b..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/creat64.c +++ /dev/null @@ -1 +0,0 @@ -/* Defined as alias for the syscall. */ diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list index 6549ed8..5c78677 100644 --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list @@ -5,7 +5,6 @@ statfs - statfs i:sp __statfs statfs statfs64 readahead - readahead i:iii __readahead readahead sendfile - sendfile i:iipi sendfile sendfile64 sync_file_range - sync_file_range Ci:iiii sync_file_range -creat - creat Ci:si creat creat64 prlimit EXTRA prlimit64 i:iipp prlimit prlimit64 fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark