This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH libgfortran mmap fixes for MinGW
- From: "Aaron W. LaFramboise" <aaronavay62 at aaronwl dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>, fortran at gcc dot gnu dot org
- Date: Wed, 15 Sep 2004 17:42:29 -0500
- Subject: PATCH libgfortran mmap fixes for MinGW
Windows does not have mmap (The equivilent MapViewOfFileEx has a
different interface unfortunately.)
These changes fix this source of incompatibility in unix.c by adding
checking for <sys/mman.h>, the _PROT macros, and including <stdio.h>.
Aaron W. LaFramboise
2004-09-15 Aaron W. LaFramboise <aaronavay62@aaronwl.com>
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac (AC_CHECK_HEADERS): Check for sys/mman.h.
* unix.c (<stdio.h>): Include.
(HAVE_SYS_MMAN_H): Check.
(open_external): Check for PROT_ macros.
(input_stream): Same.
(output_stream): Same.
Index: gcc/libgfortran/configure.ac
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/configure.ac,v
retrieving revision 1.9
diff -c -3 -p -r1.9 configure.ac
*** gcc/libgfortran/configure.ac 29 Aug 2004 15:58:16 -0000 1.9
--- gcc/libgfortran/configure.ac 15 Sep 2004 19:16:55 -0000
*************** AC_TYPE_OFF_T
*** 152,157 ****
--- 152,158 ----
AC_STDC_HEADERS
AC_HAVE_HEADERS(stdlib.h stdio.h string.h stddef.h math.h unistd.h)
AC_CHECK_HEADERS(time.h sys/params.h sys/time.h sys/times.h sys/resource.h)
+ AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADER([complex.h],[AC_DEFINE([HAVE_COMPLEX_H], [1], [complex.h exists])])
# Check for complex math functions
Index: gcc/libgfortran/io/unix.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 unix.c
*** gcc/libgfortran/io/unix.c 31 Aug 2004 20:37:43 -0000 1.9
--- gcc/libgfortran/io/unix.c 15 Sep 2004 19:16:58 -0000
*************** Boston, MA 02111-1307, USA. */
*** 21,26 ****
--- 21,27 ----
/* Unix stream I/O module */
#include "config.h"
+ #include <stdio.h>
#include <stdlib.h>
#include <limits.h>
*************** Boston, MA 02111-1307, USA. */
*** 28,37 ****
#include <sys/stat.h>
#include <fcntl.h>
- #include <sys/mman.h>
#include <string.h>
#include <errno.h>
#include "libgfortran.h"
#include "io.h"
--- 29,41 ----
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
+ #ifdef HAVE_SYS_MMAN_H
+ #include <sys/mman.h>
+ #endif
+
#include "libgfortran.h"
#include "io.h"
*************** open_external (unit_action action, unit_
*** 1028,1042 ****
--- 1038,1058 ----
switch (action)
{
case ACTION_READ:
+ #ifdef PROT_READ
prot = PROT_READ;
+ #endif
break;
case ACTION_WRITE:
+ #ifdef PROT_WRITE
prot = PROT_WRITE;
+ #endif
break;
case ACTION_READWRITE:
+ #if defined(PROT_READ) && defined(PROT_WRITE)
prot = PROT_READ | PROT_WRITE;
+ #endif
break;
default:
*************** stream *
*** 1060,1066 ****
--- 1076,1086 ----
input_stream (void)
{
+ #ifdef PROT_READ
return fd_to_stream (STDIN_FILENO, PROT_READ);
+ #else
+ return fd_to_stream (STDIN_FILENO, 0);
+ #endif
}
*************** input_stream (void)
*** 1070,1077 ****
stream *
output_stream (void)
{
!
return fd_to_stream (STDOUT_FILENO, PROT_WRITE);
}
--- 1090,1100 ----
stream *
output_stream (void)
{
! #ifdef PROT_WRITE
return fd_to_stream (STDOUT_FILENO, PROT_WRITE);
+ #else
+ return fd_to_stream (STDOUT_FILENO, 0);
+ #endif
}