New patches from Fedora.
[fedora-mingw.git] / ocaml / mingw32-ocaml-3.11.0+beta1-win32-fixes.patch
1 Misc fixes for byterun/win32.c
2
3 diff --exclude _build -urN ocaml-3.11.0+beta1.orig/byterun/win32.c ocaml-3.11.0+beta1.mingw/byterun/win32.c
4 --- ocaml-3.11.0+beta1.orig/byterun/win32.c     2008-04-22 13:24:10.000000000 +0100
5 +++ ocaml-3.11.0+beta1.mingw/byterun/win32.c    2008-11-15 15:50:32.000000000 +0000
6 @@ -13,7 +13,6 @@
7  #include <windows.h>
8  #include <stdlib.h>
9  #include <stdio.h>
10 -#include <io.h>
11  #include <fcntl.h>
12  #include <sys/types.h>
13  #include <sys/stat.h>
14 @@ -35,6 +36,26 @@
15  
16  #include "flexdll.h"
17  
18 +/* XXX including <io.h> gets ../byterun/io.h for some reason.
19 + * Including the real io.h using the full path fails because of
20 + * some strange bug in the system header file itself.  Give up and
21 + * just define _finddata_t explicitly here.
22 + */
23 +#ifndef _FSIZE_T_DEFINED
24 +typedef unsigned long   _fsize_t;
25 +#define _FSIZE_T_DEFINED
26 +
27 +struct _finddata_t
28 +{
29 +  unsigned        attrib;
30 +  time_t          time_create;
31 +  time_t          time_access;
32 +  time_t          time_write;
33 +  _fsize_t        size;
34 +  char            name[FILENAME_MAX];
35 +};
36 +#endif
37 +
38  #ifndef S_ISREG
39  #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
40  #endif
41 @@ -93,7 +114,7 @@
42    pathlen = strlen(name) + 1;
43    if (pathlen < 256) pathlen = 256;
44    while (1) {
45 -    fullname = stat_alloc(pathlen);
46 +    fullname = caml_stat_alloc(pathlen);
47      retcode = SearchPath(NULL,              /* use system search path */
48                          name,
49                          ".exe",            /* add .exe extension if needed */
50 @@ -107,7 +128,7 @@
51        break;
52      }
53      if (retcode < pathlen) break;
54 -    stat_free(fullname);
55 +    caml_stat_free(fullname);
56      pathlen = retcode + 1;
57    }
58    return fullname;