]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/otherlibs/win32unix/unixsupport.h
update
[l4.git] / l4 / pkg / ocaml / contrib / otherlibs / win32unix / unixsupport.h
1 /***********************************************************************/
2 /*                                                                     */
3 /*                           Objective Caml                            */
4 /*                                                                     */
5 /*  Xavier Leroy and Pascal Cuoq, projet Cristal, INRIA Rocquencourt   */
6 /*                                                                     */
7 /*  Copyright 1996 Institut National de Recherche en Informatique et   */
8 /*  en Automatique.  All rights reserved.  This file is distributed    */
9 /*  under the terms of the GNU Library General Public License, with    */
10 /*  the special exception on linking described in file ../../LICENSE.  */
11 /*                                                                     */
12 /***********************************************************************/
13
14 /* $Id: unixsupport.h 9450 2009-12-07 10:39:54Z xleroy $ */
15
16 #define WIN32_LEAN_AND_MEAN
17 #include <wtypes.h>
18 #include <winbase.h>
19 #include <stdlib.h>
20 #include <direct.h>
21 #include <process.h>
22 #include <sys/types.h>
23 #include <winsock.h>
24
25 struct filedescr {
26   union {
27     HANDLE handle;
28     SOCKET socket;
29   } fd;
30   enum { KIND_HANDLE, KIND_SOCKET } kind;
31   int crt_fd;
32 };
33
34 #define Handle_val(v) (((struct filedescr *) Data_custom_val(v))->fd.handle)
35 #define Socket_val(v) (((struct filedescr *) Data_custom_val(v))->fd.socket)
36 #define Descr_kind_val(v) (((struct filedescr *) Data_custom_val(v))->kind)
37 #define CRT_fd_val(v) (((struct filedescr *) Data_custom_val(v))->crt_fd)
38
39 /* extern value win_alloc_handle_or_socket(HANDLE); */
40 extern value win_alloc_handle(HANDLE);
41 extern value win_alloc_socket(SOCKET);
42 extern int win_CRT_fd_of_filedescr(value handle);
43
44 #define NO_CRT_FD (-1)
45 #define Nothing ((value) 0)
46
47 extern void win32_maperr(DWORD errcode);
48 extern value unix_error_of_code (int errcode);
49 extern void unix_error (int errcode, char * cmdname, value arg);
50 extern void uerror (char * cmdname, value arg);
51 extern value unix_freeze_buffer (value);
52
53 #define UNIX_BUFFER_SIZE 16384