blob: 0e0efd23b48dceb7822412142dc24bbea4ec81b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/**************************************************************************/
/* */
/* OCaml */
/* */
/* Francois Berenger, Kyushu Institute of Technology */
/* */
/* Copyright 2018 Institut National de Recherche en Informatique et */
/* en Automatique. */
/* */
/* All rights reserved. This file is distributed under the terms of */
/* the GNU Lesser General Public License version 2.1, with the */
/* special exception on linking described in the file LICENSE. */
/* */
/**************************************************************************/
#include <caml/mlvalues.h>
#include <caml/signals.h>
#include "unixsupport.h"
#ifdef _WIN32
#include <io.h>
#define fsync(fd) _commit(fd)
#else
#define fsync(fd) fsync(fd)
#endif
CAMLprim value caml_unix_fsync(value v)
{
int ret;
#ifdef _WIN32
int fd = caml_win32_CRT_fd_of_filedescr(v);
#else
int fd = Int_val(v);
#endif
caml_enter_blocking_section();
ret = fsync(fd);
caml_leave_blocking_section();
if (ret == -1) caml_uerror("fsync", Nothing);
return Val_unit;
}
|