summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix')
-rw-r--r--otherlibs/win32unix/channels.c15
-rw-r--r--otherlibs/win32unix/dup2.c4
-rw-r--r--otherlibs/win32unix/unixsupport.h1
3 files changed, 11 insertions, 9 deletions
diff --git a/otherlibs/win32unix/channels.c b/otherlibs/win32unix/channels.c
index 523013142..ed961910b 100644
--- a/otherlibs/win32unix/channels.c
+++ b/otherlibs/win32unix/channels.c
@@ -16,13 +16,14 @@
#include <mlvalues.h>
#include <alloc.h>
#include <io.h>
+#include <memory.h>
#include "unixsupport.h"
#include <fcntl.h>
extern long _get_osfhandle(int);
extern int _open_osfhandle(long, int);
-static int CRT_fd_of_filedescr(value handle)
+int win_CRT_fd_of_filedescr(value handle)
{
if (CRT_fd_val(handle) != NO_CRT_FD) {
return CRT_fd_val(handle);
@@ -39,7 +40,7 @@ CAMLprim value win_inchannel_of_filedescr(value handle)
CAMLlocal1(vchan);
struct channel * chan;
- chan = caml_open_descriptor_in(CRT_fd_of_filedescr(handle));
+ chan = caml_open_descriptor_in(win_CRT_fd_of_filedescr(handle));
if (Descr_kind_val(handle) == KIND_SOCKET)
chan->flags |= CHANNEL_FLAG_FROM_SOCKET;
vchan = caml_alloc_channel(chan);
@@ -53,7 +54,7 @@ CAMLprim value win_outchannel_of_filedescr(value handle)
int fd;
struct channel * chan;
- chan = caml_open_descriptor_out(CRT_fd_of_filedescr(handle));
+ chan = caml_open_descriptor_out(win_CRT_fd_of_filedescr(handle));
if (Descr_kind_val(handle) == KIND_SOCKET)
chan->flags |= CHANNEL_FLAG_FROM_SOCKET;
vchan = caml_alloc_channel(chan);
@@ -68,13 +69,13 @@ CAMLprim value win_filedescr_of_channel(value vchan)
HANDLE h;
chan = Channel(vchan);
- if (channel->fd == -1) uerror("descr_of_channel", Nothing);
- h = (HANDLE) _get_osfhandle(channel->fd);
+ if (chan->fd == -1) uerror("descr_of_channel", Nothing);
+ h = (HANDLE) _get_osfhandle(chan->fd);
if (chan->flags & CHANNEL_FLAG_FROM_SOCKET)
- fd = win_alloc_socket(h);
+ fd = win_alloc_socket((SOCKET) h);
else
fd = win_alloc_handle(h);
- CRT_fd_val(fd) = channel->fd;
+ CRT_fd_val(fd) = chan->fd;
CAMLreturn(fd);
}
diff --git a/otherlibs/win32unix/dup2.c b/otherlibs/win32unix/dup2.c
index 4be2d819f..0567bdfcf 100644
--- a/otherlibs/win32unix/dup2.c
+++ b/otherlibs/win32unix/dup2.c
@@ -16,7 +16,6 @@
#include <mlvalues.h>
#include "unixsupport.h"
-extern value win_fd_handle(value);
extern int _dup2(int, int);
CAMLprim value unix_dup2(value fd1, value fd2)
@@ -38,6 +37,7 @@ CAMLprim value unix_dup2(value fd1, value fd2)
Descr_kind_val(fd2) = Descr_kind_val(fd1);
/* Reflect the dup2 on the CRT fds, if any */
if (CRT_fd_val(fd1) != NO_CRT_FD || CRT_fd_val(fd2) != NO_CRT_FD)
- _dup2(Int_val(win_fd_handle(fd1)), Int_val(win_fd_handle(fd2)));
+ _dup2(Int_val(win_CRT_fd_of_filedescr(fd1)),
+ Int_val(win_CRT_fd_of_filedescr(fd2)));
return Val_unit;
}
diff --git a/otherlibs/win32unix/unixsupport.h b/otherlibs/win32unix/unixsupport.h
index da5f47cff..195db0351 100644
--- a/otherlibs/win32unix/unixsupport.h
+++ b/otherlibs/win32unix/unixsupport.h
@@ -39,6 +39,7 @@ struct filedescr {
extern value win_alloc_handle_or_socket(HANDLE);
extern value win_alloc_handle(HANDLE);
extern value win_alloc_socket(SOCKET);
+extern int win_CRT_fd_of_filedescr(value handle);
#define NO_CRT_FD (-1)
#define Nothing ((value) 0)