Patchwork [FORTRAN] Include unistd.h in environ.c

login
register
mail settings
Submitter David Edelsohn
Date May 4, 2013, 8:58 p.m.
Message ID <CAGWvnykOPdCbQ9vDC_aQ+Gf4u_DjghS55A3Nxrw1jL982dD7TQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/241477/
State New
Headers show

Comments

David Edelsohn - May 4, 2013, 8:58 p.m.
environ.c is referencing functions like getuid(), geteuid(), getgid()
and getegid(), but it does not include the header file that declares
them.

I also noticed that libgfortran is not consistent about checking that
unistd.h exists.

Bootstrapped on powerpc-ibm-aix7.1.0.0.

Okay for trunk?

Thanks, David


        * runtime/pause.c: Test HAVE_UNISTD_H.
        * runtime/environ.c: Include unistd.h.
        * runtime/stop.c: Test HAVE_UNISTD_H.
Tobias Burnus - May 4, 2013, 9:11 p.m.
David Edelsohn wrote:
> environ.c is referencing functions like getuid(), geteuid(), getgid()
> and getegid(), but it does not include the header file that declares
> them.
>
> I also noticed that libgfortran is not consistent about checking that
> unistd.h exists.

You can add io/unix.c and io/open.c to the list of files which do not 
check whether unistd.h exists. Can you add the #ifdef there as well?

> Bootstrapped on powerpc-ibm-aix7.1.0.0.
> Okay for trunk?

Okay. Thanks for the patch!

Tobias

>          * runtime/pause.c: Test HAVE_UNISTD_H.
>          * runtime/environ.c: Include unistd.h.
>          * runtime/stop.c: Test HAVE_UNISTD_H.
>
> Index: runtime/pause.c
> ===================================================================
> --- runtime/pause.c     (revision 198587)
> +++ runtime/pause.c     (working copy)
> @@ -25,8 +25,12 @@
>
>   #include "libgfortran.h"
>   #include <string.h>
> +
> +#ifdef HAVE_UNISTD_H
>   #include <unistd.h>
> +#endif
>
> +
>   static void
>   do_pause (void)
>   {
> Index: runtime/environ.c
> ===================================================================
> --- runtime/environ.c   (revision 198587)
> +++ runtime/environ.c   (working copy)
> @@ -28,7 +28,11 @@
>   #include <stdlib.h>
>   #include <ctype.h>
>
> +#ifdef HAVE_UNISTD_H
> +#include <unistd.h>
> +#endif
>
> +
>   /* Environment scanner.  Examine the environment for controlling minor
>    * aspects of the program's execution.  Our philosophy here that the
>    * environment should not prevent the program from running, so an
> Index: runtime/stop.c
> ===================================================================
> --- runtime/stop.c      (revision 198587)
> +++ runtime/stop.c      (working copy)
> @@ -26,8 +26,12 @@
>   #include "libgfortran.h"
>   #include <stdlib.h>
>   #include <string.h>
> +
> +#ifdef HAVE_UNISTD_H
>   #include <unistd.h>
> +#endif
>
> +
>   /* A numeric STOP statement.  */
>
>   extern void stop_numeric (GFC_INTEGER_4)
>

Patch

Index: runtime/pause.c
===================================================================
--- runtime/pause.c     (revision 198587)
+++ runtime/pause.c     (working copy)
@@ -25,8 +25,12 @@ 

 #include "libgfortran.h"
 #include <string.h>
+
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif

+
 static void
 do_pause (void)
 {
Index: runtime/environ.c
===================================================================
--- runtime/environ.c   (revision 198587)
+++ runtime/environ.c   (working copy)
@@ -28,7 +28,11 @@ 
 #include <stdlib.h>
 #include <ctype.h>

+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif

+
 /* Environment scanner.  Examine the environment for controlling minor
  * aspects of the program's execution.  Our philosophy here that the
  * environment should not prevent the program from running, so an
Index: runtime/stop.c
===================================================================
--- runtime/stop.c      (revision 198587)
+++ runtime/stop.c      (working copy)
@@ -26,8 +26,12 @@ 
 #include "libgfortran.h"
 #include <stdlib.h>
 #include <string.h>
+
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif

+
 /* A numeric STOP statement.  */

 extern void stop_numeric (GFC_INTEGER_4)