123456789101112131415161718192021222324252627282930313233343536373839(**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*)(* On Win32, unwrap the handle from the 'abstract block' representing
the file descriptor otherwise it can't be marshalled or passed as
an integer command-line argument. *)typehandle=intexternalraw_get_handle:Unix.file_descr->handle="caml_hh_worker_get_handle""noalloc"externalraw_wrap_handle:handle->Unix.file_descr="caml_hh_worker_create_handle"externalwin_setup_handle_serialization:unit->unit="win_setup_handle_serialization"letinit=(* Windows: register the serialize/desarialize functions
for the custom block of "Unix.file_descr". *)lazybeginwin_setup_handle_serialization()endlet()=Lazy.forceinitlet()=assert(Sys.win32||Obj.is_int(Obj.reprUnix.stdin))letget_handle=ifSys.win32thenraw_get_handleelseObj.magicletwrap_handle=ifSys.win32thenraw_wrap_handleelseObj.magicletto_in_channelh=wrap_handleh|>Unix.in_channel_of_descrletto_out_channelh=wrap_handleh|>Unix.out_channel_of_descr