Begin vendoring of unix for gettimeofday

This commit is contained in:
John Whitington 2020-05-18 18:30:54 +01:00
parent 35e91e78db
commit daecb43674
2 changed files with 28 additions and 1 deletions

View File

@ -3,7 +3,7 @@ MODS = tjutil tjutf16 tjllist tjparserMonad tjjson \
xmlm \
cpdfwriteJSON cpdfstrftime cpdfcoord cpdf cpdfcommand
SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml
SOURCES = gettimeofday.c $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml
RESULT = cpdf
ANNOTATE = true

27
gettimeofday.c Normal file
View File

@ -0,0 +1,27 @@
/**************************************************************************/
/* */
/* OCaml */
/* */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* */
/* Copyright 1996 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/alloc.h>
#include <caml/fail.h>
#include <sys/types.h>
#include <sys/time.h>
CAMLprim value unix_gettimeofday(value unit)
{
struct timeval tp;
gettimeofday(&tp, NULL);
return caml_copy_double((double) tp.tv_sec + (double) tp.tv_usec / 1e6);
}