Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Clément Pascutto
committed
Nov 14, 2019
1 parent
c7a1c6c
commit fdf065a
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(library | ||
(public_name index.unix) | ||
(name index_unix) | ||
(c_names pread pwrite) | ||
(c_names fsync pread pwrite) | ||
(libraries index logs logs.threaded threads unix)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 "caml/unixsupport.h" | ||
|
||
#ifdef _WIN32 | ||
#include <io.h> | ||
#define fsync(fd) _commit(fd) | ||
#else | ||
#define fsync(fd) fsync(fd) | ||
#endif | ||
|
||
CAMLprim value unix_fsync(value v) | ||
{ | ||
int ret; | ||
#ifdef _WIN32 | ||
int fd = win_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) uerror("fsync", Nothing); | ||
return Val_unit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters