]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/otherlibs/win32unix/startup.c
update
[l4.git] / l4 / pkg / ocaml / contrib / otherlibs / win32unix / startup.c
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 #include <stdio.h>
15 #include <fcntl.h>
16 #include <stdlib.h>
17 #include <mlvalues.h>
18 #include "unixsupport.h"
19 #include "winworker.h"
20 #include "windbug.h"
21
22 value val_process_id;
23
24 CAMLprim value win_startup(unit)
25      value unit;
26 {
27   WSADATA wsaData;
28   int i;
29   HANDLE h;
30
31   DBUG_INIT;
32
33   (void) WSAStartup(MAKEWORD(2, 0), &wsaData);
34   DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(),
35                   GetCurrentProcess(), &h, 0, TRUE,
36                   DUPLICATE_SAME_ACCESS);
37   val_process_id = Val_int(h);
38
39   worker_init();
40
41   return Val_unit;
42 }
43
44 CAMLprim value win_cleanup(unit)
45      value unit;
46 {
47   worker_cleanup();
48
49   (void) WSACleanup();
50
51   DBUG_CLEANUP;
52
53   return Val_unit;
54 }