http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51646
Janne Blomqvist <jb at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-12-21
Ever Confirmed|0 |1
--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> 2011-12-21 10:10:10
UTC ---
(In reply to comment #0)
> Created attachment 26156 [details]
> Draft patch
>
> Janne: What do you think of the attached patch?
>
> http://specificimpulses.blogspot.com/2011/01/my-android-speaks-fortran-yours-can-too.html
> shows that gfortran can be build for on Android (= host + target).
>
> However, Android's NDK does not support S_IREAD and S_IWRITE but only S_IRUSR
> and S_IWUSR.
>
> In the Linux man page I find:
> UNIX V7 (and later systems) had S_IREAD, S_IWRITE, S_IEXEC, where
> POSIX
> prescribes the synonyms S_IRUSR, S_IWUSR, S_IXUSR.
>
> While POSIX (IEEE Std 1003.1, 2003) just lists the latter:
> S_IRUSR
> Read permission, owner.
> S_IWUSR
> Write permission, owner.
>
> Expected: If no S_IREAD/S_IWRITE is available, use S_IRUSR/S_IWUSR. (Or rather
> the other way round, given that only the latter is standard.)
>
> S_IREAD/S_IWRITE is
> - checked for in LIBGFOR_CHECK_UNLINK_OPEN_FILE (libgfortran/acinclude.m4)
> - used in io/unix.c's id_from_fd
>
> * * *
Good catch! I suppose it's possible that all targets we support have the POSIX
flags, but since we're in stage 3 I think it's fine to play it safe and do the
ifdef dance.
So your patch per se is OK, however you have manage to introduce quite a few
typos ;-)
Since I copy-paste the patch here, I'll put my comments within "<<< >>>"
blocks:
Index: acinclude.m4
===================================================================
--- acinclude.m4 (revision 182565)
+++ acinclude.m4 (working copy)
@@ -115,11 +115,19 @@ AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
#include <unistd.h>
#include <sys/stat.h>
+#if !defined(S_IRUSR) && defined(S_IREAD)
+#define S_IRUSR S_IREAD
+#endif
+
+#if !defined(S_IWUSR) && defined(S_IWRITE)
+#define S_IWGRP S_IWRITE
<<< Should be S_IWUSR >>>
+#endif
+
int main ()
{
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 +135,7 @@ int main ()
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, S_IUSR | S_IUSR) == -1 && errno == ENOENT)
<<<
There's two bugs here:
1. You have S_IUSR twice, presumably you mean S_IRUSR | S_IWUSR.
2. The mode argument is ignored if O_CREAT is not or'ed into the flags
argument, so the open call could just as well be open ("testfile", O_RDONLY)
>>>
return 0;
else
return 1;
Index: io/unix.c
===================================================================
--- io/unix.c (revision 182565)
+++ io/unix.c (working copy)
@@ -113,6 +113,14 @@ id_from_fd (const int fd)
#define PATH_MAX 1024
#endif
+#if !defined(S_IRUSR) && defined(S_IREAD)
+#define S_IRUSR S_IREAD
+#endif
+
+#if !defined(S_IWUSR) && defined(S_IWRITE)
+#define S_IWGRP S_IWRITE
<<< Same here, should be S_IWUSR. >>>
+#endif
+
/* These flags aren't defined on all targets (mingw32), so provide them
here. */
#ifndef S_IRGRP
@@ -1112,9 +1120,9 @@ tempfile (st_parameter_open *opp)
#if defined(HAVE_CRLF) && defined(O_BINARY)
fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY,
- S_IREAD | S_IWRITE);
+ S_IUSR | S_IWUSR);
<<< Should be S_IRUSR | S_IWUSR (R is missing) >>>
#else
- fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE);
+ fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IUSR | S_IWUSR);
<<< Should be S_IRUSR | S_IWUSR (R is missing) >>>
#endif
}
while (fd == -1 && errno == EEXIST);
> In the blog, the existence of other issues is mentioned and it links to a
> hack:
> http://aeromonkey.homeip.net/public/ugly_gfortran_hacks.patch
> (Google cache:
> http://webcache.googleusercontent.com/search?q=cache:khmjfgpFiAIJ:aeromonkey.homeip.net/public/ugly_gfortran_hacks.patch+aeromonkey.homeip.net/public/ugly_gfortran_hacks.patch
> )
>
> However, the patch/hack does not tell me much: It disable configure checking
> (as_fn_exit returns 0 ("echo $1") instead of "exit $1") and in
> intrinsics/date_and_time.c the "#ifndef" has been changed into an "#ifdef" for
> HAVE_LOCALTIME_R and for HAVE_GMTIME_R.
>
> Without config.log, one can probably not deduce what went wrong.
Agreed, that patch is hacky to the point of being useless for us. Lets not
worry about that.