From patchwork Wed Dec 21 15:59:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Blomqvist X-Patchwork-Id: 132676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 4F4D9B6FDF for ; Thu, 22 Dec 2011 02:59:59 +1100 (EST) Received: (qmail 31847 invoked by alias); 21 Dec 2011 15:59:51 -0000 Received: (qmail 31827 invoked by uid 22791); 21 Dec 2011 15:59:49 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_BG X-Spam-Check-By: sourceware.org Received: from mail-lpp01m010-f47.google.com (HELO mail-lpp01m010-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Dec 2011 15:59:36 +0000 Received: by lami14 with SMTP id i14so3115788lam.20 for ; Wed, 21 Dec 2011 07:59:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.111.136 with SMTP id ii8mr6322321lab.20.1324483174837; Wed, 21 Dec 2011 07:59:34 -0800 (PST) Received: by 10.152.21.2 with HTTP; Wed, 21 Dec 2011 07:59:34 -0800 (PST) Date: Wed, 21 Dec 2011 17:59:34 +0200 Message-ID: Subject: [Patch, libfortran] PR 51646 Use POSIX mode flags From: Janne Blomqvist To: Fortran List , GCC Patches Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, someone made some effort to build gfortran on an android phone (see the PR). One problem was that libgfortran was using the old BSD S_IREAD and S_IWRITE mode flags instead of the POSIX S_IRUSR and S_IWUSR. The attached patch replaces the usage of these BSD flags with the POSIX ones. I decided to omit any ifdef dance in case the target doesn't support the POSIX flags, since it turns out that we have used those unconditionally in io/unix.c going back at least to the 4.0 branch. Ok for trunk? 2011-12-21 Janne Blomqvist Tobias Burnus PR libfortran/51646 * acinclude.m4 (LIBGFOR_CHECK_UNLINK_OPEN_FILE): Use POSIX mode flags, omit mode argument when flags argument does not have O_CREAT. * io/unix.c (tempfile): Use POSIX mode flags. Index: acinclude.m4 =================================================================== --- acinclude.m4 (revision 182581) +++ acinclude.m4 (working copy) @@ -119,7 +119,7 @@ { int fd; - fd = open ("testfile", O_RDWR | O_CREAT, S_IWRITE | S_IREAD); + fd = open ("testfile", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR); if (fd <= 0) return 0; if (unlink ("testfile") == -1) @@ -127,7 +127,7 @@ write (fd, "This is a test\n", 15); close (fd); - if (open ("testfile", O_RDONLY, S_IWRITE | S_IREAD) == -1 && errno == ENOENT) + if (open ("testfile", O_RDONLY) == -1 && errno == ENOENT) return 0; else return 1; Index: io/unix.c =================================================================== --- io/unix.c (revision 182581) +++ io/unix.c (working copy) @@ -1112,9 +1112,9 @@ #if defined(HAVE_CRLF) && defined(O_BINARY) fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, - S_IREAD | S_IWRITE); + S_IRUSR | S_IWUSR); #else - fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE); + fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); #endif } while (fd == -1 && errno == EEXIST);