Patchwork [libfortran] PR 51646 Use POSIX mode flags

login
register
mail settings
Submitter Janne Blomqvist
Date Dec. 21, 2011, 3:59 p.m.
Message ID <CAO9iq9HXYmaXE7Adz+CaOKV34-YKRYZhQEG+mU6dGoZrrVAMjA@mail.gmail.com>
Download mbox | patch
Permalink /patch/132676/
State New
Headers show

Comments

Janne Blomqvist - Dec. 21, 2011, 3:59 p.m.
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  <jb@gcc.gnu.org>
	Tobias Burnus  <burnus@net-b.de>

	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.
Tobias Burnus - Dec. 21, 2011, 4:14 p.m.
On 12/21/2011 04:59 PM, Janne Blomqvist wrote:
> 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?

OK. Thanks for the patch!

Tobias

> 2011-12-21  Janne Blomqvist<jb@gcc.gnu.org>
> 	Tobias Burnus<burnus@net-b.de>
>
> 	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.
>
>
>
Paul Richard Thomas - Dec. 21, 2011, 8:26 p.m.
Dear All,

I would put Mike Long up with the people that climb the likes of K2!
A remarkable achievement that is nearly but not quite completely
useless.  I hope that teh view made up fo it....

On the other hand, he helped us out :-)

Cheers

Paul

On Wed, Dec 21, 2011 at 5:14 PM, Tobias Burnus <burnus@net-b.de> wrote:
> On 12/21/2011 04:59 PM, Janne Blomqvist wrote:
>>
>> 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?
>
>
> OK. Thanks for the patch!
>
> Tobias
>
>
>> 2011-12-21  Janne Blomqvist<jb@gcc.gnu.org>
>>        Tobias Burnus<burnus@net-b.de>
>>
>>        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.
>>
>>
>>
>

Patch

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);