From patchwork Tue Jun 20 19:45:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 106014 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1571490qgd; Tue, 20 Jun 2017 12:46:23 -0700 (PDT) X-Received: by 10.84.131.71 with SMTP id 65mr10285750pld.35.1497987983791; Tue, 20 Jun 2017 12:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497987983; cv=none; d=google.com; s=arc-20160816; b=zHsUAFBzqJaH0IE30YQjm7fbbb5SWx1XzgZpjJHgrayLM0X5X4oSd4CWdQm5vHWNaC DGIGch4L/+LKVcgDr5/KfoA+fs4MbaTkY78VJKhl/Or+s9Tx5mv2PfIxOfVRhwzP8ZSR 4gvAcfOj0+BEtCOe6o5UMKFViOmgr7UdlRF1X2OkBdcgzEYfGkOIgfgpV9hd0R6yGkei Kiw6PfnKnd4+HdpLiS7RIUq13fgkjvgY35bGGww8uQUa68d5EM4+p5gHOLLKUVbJCy5l FS6x8++FfeegxVFbB529u603obo5/fBQci2fTNIDRWIiNs37DA6vwpAACU3SXaCcNGS5 8w9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=ajOuKdYEfPIiJbCIBCC5qkYWDx2fztFgdBmuJL/iVxc=; b=DNqIRwmeqsEOTgNgNSPCjBlkGRzf7gB4dvtBY0/VmN9qIiZjHv4j8Fw+7Hjrih3CMy jyPndKBDMvlscyfr7sJ6zKA6+kRDDQn4HGG5XY7VqJz0OjCMKZzT7QTXzvsrTt+B+LuI uK4ZmkF2z9XcxXcrlZFK2j2bQav48dhc7ojejEeUiL9y8io3C1i/OctQiS+LlJ1y47QF YxbxsNG+F5dSBeFP6ZnFtrqvDOZQ2dgY3U6eeIuTvbaG9XDqN/ExOhNgWqrAhsrJ1Duy ZqndLuQdBN4bvdZAlb+3mw2LQeRjgqelsuVdD1ORvOiDs+EY1sTvVtQ0rx5Jf7vchoFS JmBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=FLprlYC1; spf=pass (google.com: domain of libc-alpha-return-80845-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80845-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 n25si11567071pge.337.2017.06.20.12.46.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 12:46:23 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-80845-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.b=FLprlYC1; spf=pass (google.com: domain of libc-alpha-return-80845-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80845-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; q=dns; s= default; b=dvbcon+kHle9IDWJJ/Djd7B/IFf00hy6YhjKAuHdnMeodqFO2gSR6 KdSafst2/039iTr7X/bUcsrT48+6sFL19N/PGvDDwn+zcT3j6o/9oifleWfEOWcO LYhorp8MxgXE4Q6BmUxBZLwERAsxGbIG3B2bhd7aPFM7Yp/BpcwZK8= 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; s=default; bh=dQ0liHlvMmzoakUPVdGbP9VR5Cs=; b=FLprlYC1iWf4g1tla+qrSTYFROl5 x2FG4OBQHXimYxqpaDPvhBi8OGjRf3QY9clADZYwXel8eGTzZfMlXEsZqor56Bw5 PtFftMUJqQAfg/Fd1X0bf7uQECZzHoVwyrq37TnMjl3cH9SNvRqZljagEoOQHhpC yJi07SUfe44cbfw= Received: (qmail 116491 invoked by alias); 20 Jun 2017 19:46: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 115431 invoked by uid 89); 20 Jun 2017 19:46:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f170.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; bh=ajOuKdYEfPIiJbCIBCC5qkYWDx2fztFgdBmuJL/iVxc=; b=YyUnaaQZVQWxyEOTXpZ4ihRUQwhZEhr6lIyJxTdgNehj2ptJxw7f38+wLp+bZskYlI b+CXnUj2i471B5gODBqjnCVZFvyFFmvEy91feoOHZY3OwNBIuUE+BZcDZQgEdCW8uSnt 1OtFr/q/uUl62EqL154V0OPu1yf5GSIwinatnWIIOdDGFwcFPKE3Yg8TiVprLcKFl1ZJ FKVODYp6O8AjEjaPLsQbFvX6/D1Nn4Jz/O56bCIRzmPGGSmREIVPNYk0YGm1hefFyVEr IJ7dJetGaCmodBrUHSa6mt1qiI6ewmAkaYrvgkyC1HmbAyLR6hY4m5afV6mV3hFzpkuA knLg== X-Gm-Message-State: AKS2vOwAz/DEM9oLw8f71wvTisCBR5Z6k3doSP5WePHfqNYi+EdHiyC0 KRzPxEv8030onWcxyk4XdQ== X-Received: by 10.55.49.18 with SMTP id x18mr26235568qkx.248.1497987960435; Tue, 20 Jun 2017 12:46:00 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] Consolidate Linux openat implementation Date: Tue, 20 Jun 2017 16:45:55 -0300 Message-Id: <1497987955-29248-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the open Linux syscall implementation on sysdeps/unix/sysv/linux/open{64}.c. The changes are: 1. Remove wordsize-64 openat{64}. 2. For architetures that define __OFF_T_MATCHES_OFF64_T openat64 will be default one with alias to required symbols. Otherwise openat64 will pass the required O_LARGEFILE flag on syscall. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu. This is similar to the open consolidation (b41152d0) and I plan to commit it shortly. * sysdeps/unix/sysv/linux/openat.c (__libc_openat): Build only for !__OFF_T_MATCHES_OFF64_T. * sysdeps/unix/sysv/linux/openat64.c (__libc_openat64): New implementation based on open64. * sysdeps/unix/sysv/linux/wordsize-64/openat.c: Remove file. * sysdeps/unix/sysv/linux/wordsize-64/openat64.c: Likewise. --- sysdeps/unix/sysv/linux/openat.c | 31 ++++---------- sysdeps/unix/sysv/linux/openat64.c | 57 ++++++++++++++++++++++++-- sysdeps/unix/sysv/linux/wordsize-64/openat.c | 11 ----- sysdeps/unix/sysv/linux/wordsize-64/openat64.c | 1 - 4 files changed, 62 insertions(+), 38 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/openat.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/openat64.c -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c index 2c620d8..1587305 100644 --- a/sysdeps/unix/sysv/linux/openat.c +++ b/sysdeps/unix/sysv/linux/openat.c @@ -15,31 +15,18 @@ License along with the GNU C Library; if not, see . */ -#include #include #include -#include -#include -#include -#include -#include -#include - -#ifndef OPENAT -# define OPENAT openat -#endif - -#define UNDERIZE(name) UNDERIZE_1 (name) -#define UNDERIZE_1(name) __##name -#define __OPENAT UNDERIZE (OPENAT) +#include +#ifndef __OFF_T_MATCHES_OFF64_T /* Open FILE with access OFLAG. Interpret relative paths relative to the directory associated with FD. If OFLAG includes O_CREAT or O_TMPFILE, a fourth argument is the file protection. */ int -__OPENAT (int fd, const char *file, int oflag, ...) +__libc_openat (int fd, const char *file, int oflag, ...) { mode_t mode = 0; if (__OPEN_NEEDS_MODE (oflag)) @@ -50,12 +37,10 @@ __OPENAT (int fd, const char *file, int oflag, ...) va_end (arg); } - /* We have to add the O_LARGEFILE flag for openat64. */ -#ifdef MORE_OFLAGS - oflag |= MORE_OFLAGS; -#endif - return SYSCALL_CANCEL (openat, fd, file, oflag, mode); } -libc_hidden_def (__OPENAT) -weak_alias (__OPENAT, OPENAT) +weak_alias (__libc_openat, __openat) +libc_hidden_weak (__openat) +weak_alias (__libc_openat, openat) + +#endif diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c index 9e7a2b3..4942061 100644 --- a/sysdeps/unix/sysv/linux/openat64.c +++ b/sysdeps/unix/sysv/linux/openat64.c @@ -1,4 +1,55 @@ -#define OPENAT openat64 -#define MORE_OFLAGS O_LARGEFILE +/* Copyright (C) 2007-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. -#include "openat.c" + 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 + +/* Open FILE with access OFLAG. Interpret relative paths relative to + the directory associated with FD. If OFLAG includes O_CREAT or + O_TMPFILE, a fourth argument is the file protection. */ +int +__libc_openat64 (int fd, const char *file, int oflag, ...) +{ + mode_t mode = 0; + if (__OPEN_NEEDS_MODE (oflag)) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, mode_t); + va_end (arg); + } + +#ifdef __OFF_T_MATCHES_OFF64_T +# define EXTRA_OPEN_FLAGS 0 +#else +# define EXTRA_OPEN_FLAGS O_LARGEFILE +#endif + + return SYSCALL_CANCEL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS, mode); +} + +strong_alias (__libc_openat64, __openat64) +libc_hidden_weak (__openat64) +weak_alias (__libc_openat64, openat64) + +#ifdef __OFF_T_MATCHES_OFF64_T +strong_alias (__libc_openat64, __openat) +libc_hidden_weak (__openat) +weak_alias (__libc_openat64, openat) +#endif diff --git a/sysdeps/unix/sysv/linux/wordsize-64/openat.c b/sysdeps/unix/sysv/linux/wordsize-64/openat.c deleted file mode 100644 index be31a35..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/openat.c +++ /dev/null @@ -1,11 +0,0 @@ -#define __openat64 __rename___openat64 -#define openat64 __rename_openat64 - -#include "../openat.c" - -#undef __openat64 -#undef openat64 - -strong_alias (__openat, __openat64) -hidden_ver (__openat, __openat64) -weak_alias (openat, openat64) diff --git a/sysdeps/unix/sysv/linux/wordsize-64/openat64.c b/sysdeps/unix/sysv/linux/wordsize-64/openat64.c deleted file mode 100644 index b4a864b..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/openat64.c +++ /dev/null @@ -1 +0,0 @@ -/* Defined in openat.c. */