From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 4B5477FA8B for ; Sat, 14 Mar 2015 20:18:00 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yallop@gmail.com) identity=pra; client-ip=209.85.216.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yallop@gmail.com designates 209.85.216.173 as permitted sender) identity=mailfrom; client-ip=209.85.216.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qc0-f173.google.com) identity=helo; client-ip=209.85.216.173; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="postmaster@mail-qc0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DmAADhiARVlK3YVdFbg1haBIJCRrR+jACFK4FjB0wBAQEBAQERAQEBAQcLCwkSMIQiBhEEGQEbHgMSAw0PAiYCJAERAQUBDgEUNId4AQMRDZYhkE8+MYswgWuCd49qChknDVSEaAEBARgBBQ6BE417g1uBRQWUI4V7gRs5iTaFRIF9EiOBDAmCIgMcgVA+MQEBAYEIgTgBAQE X-IPAS-Result: A0DmAADhiARVlK3YVdFbg1haBIJCRrR+jACFK4FjB0wBAQEBAQERAQEBAQcLCwkSMIQiBhEEGQEbHgMSAw0PAiYCJAERAQUBDgEUNId4AQMRDZYhkE8+MYswgWuCd49qChknDVSEaAEBARgBBQ6BE417g1uBRQWUI4V7gRs5iTaFRIF9EiOBDAmCIgMcgVA+MQEBAYEIgTgBAQE X-IronPort-AV: E=Sophos;i="5.11,401,1422918000"; d="scan'208";a="103352914" Received: from mail-qc0-f173.google.com ([209.85.216.173]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Mar 2015 20:17:59 +0100 Received: by qcyi15 with SMTP id i15so14458972qcy.0 for ; Sat, 14 Mar 2015 12:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=dAl/i8c8gdV9b0qJXDwQti73ZGTJKvWsqkZxMdmiis0=; b=LzwpRBjEyorvoXavJMZedcZk4ewHkyEd3teeodFjvGAg5sC93s18+I5rbyPVTSjAbW fvRxSPEn73aIzfMQ0vuIit5MpC6ScCE7WhiCWcWeHzdZCplQEIVjmEhlGge7pAsr2YBF CJ3IRyCjtPyKuHfV7hTo2OMsngpUzFktjNh76Tnr/iPgJh9ZEIiYlD0P8rQ4x6U7w2g2 xcWZCxU/M6RAJzUTP1IWTijFEApSWmtgA47vGgpNu82r+nZcvMh1Ci5KbuJ90+H5QTQi KWQeK28MxsV83w5KU31pCxjEz0JK3X2gYgMlFlb22T51M8xmGr5X7cBh3MRNbooGWITz uA/w== MIME-Version: 1.0 X-Received: by 10.140.34.36 with SMTP id k33mr66471628qgk.66.1426360677968; Sat, 14 Mar 2015 12:17:57 -0700 (PDT) Received: by 10.229.160.11 with HTTP; Sat, 14 Mar 2015 12:17:57 -0700 (PDT) Date: Sat, 14 Mar 2015 19:17:57 +0000 Message-ID: From: Jeremy Yallop To: caml-list@inria.fr, ctypes@lists.ocaml.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Caml-list] ANN: ocaml-ctypes 0.4.0, a library for calling C functions directly from OCaml I'm happy to announce the release of ocaml-ctypes 0.4.0, which is now available on OPAM. =3D=3D About ocaml-ctypes =3D=3D The ocaml-ctypes library makes it possible to call C functions from OCaml without writing any C code. The core of the library is a set of combinators for describing C types -- scalars, functions, structs, unions, arrays, and pointers to values and functions. Type descriptions can then be used to bind native functions and values. Here's a simple example: # let puts =3D foreign "puts" (string @-> returning int);; val puts : string -> int =3D # puts "Hello, world!";; Hello, world! Ctypes includes many more features, including functions for retrieving constants, values and details about object layout from C, a way of building C libraries from OCaml modules, and a variety of binding strategies such as dynamic linking and static stub generation. Further information is available at the links below: Tutorial: https://github.com/ocamllabs/ocaml-ctypes/wiki/ctypes-tutorial Examples: https://github.com/ocamllabs/ocaml-ctypes/tree/master/examples Some packages using ctypes: http://opam.ocaml.org/packages/ctypes/ctypes.0.3.4/ API documentation: http://ocamllabs.github.io/ocaml-ctypes/ Github repository: https://github.com/ocamllabs/ocaml-ctypes Direct download: https://github.com/ocamllabs/ocaml-ctypes/archive/0.4.0.tar.gz =3D=3D New features in 0.4.0 =3D=3D * Windows support (A. Hauptmann) 32-bit and 64-bit builds on MinGW, and continuous integration using Appve= yor. * Xen support (Thomas Leonard) * Add the C99 bool type (Ramkumar Ramachandra) The type representation val bool : bool typ supports passing bools to (and returning bools from) functions, using them as struct members, etc. * Typedef support (Edwin T=C3=B6r=C3=B6k) A new function val typedef 'a typ -> string -> 'a typ supports defining type aliases that are used in top-level printing and in stub generation. * Enum types The new function val enum : string -> ?unexpected:(int64 -> 'a) -> ('a * int64 const) list -> 'a typ supports defining types representations that appear as OCaml types (typically variants) on the OCaml side and C enums on the C side. * Accessing C globals with foreign_value in generated stubs A new function val foreign_value : string -> 'a typ -> 'a ptr fn supports accessing C global values from OCaml programs. * Retrieving #define and enum constants from C A new function val constant : string -> 'a typ -> 'a const supports retrieving compile-time constant values from C. * Releasing the runtime lock in C calls The Foreign.foreign function now accepts an additional optional argument ?release_runtime_lock:bool that indicates whether the runtime lock should be released for the duration of the C call. * Acquiring the runtime lock in callbacks The Foreign.funptr function now accepts an additional optional argument ?runtime_lock:bool that indicates whether the runtime lock should be acquired for the duration of the OCaml call. * Passing 'bytes' values directly to C (Peter Zotov) The new function val ocaml_bytes_start : bytes -> bytes ocaml supports passing bytes values directly to C in situations where performance is critical. * Custom printers in views (Thomas Braibant) The view function now accepts an additional argument format:(Format.formatter -> 'b -> unit) which supports custom printing for values of a view type. * Optionally obtain struct and union layout from C The new module Cstubs.Types supports retrieving struct and union layouts from C as an alternative to computing them based on programmer-supplied information * string_opt wraps char *, not void *. * Remove some poorly-supported POSIX types Several of the types in the PosixTypes module are no longer available. * Use nativeint to represent pointers See "Incompatibilities" below. * Support zero-argument callbacks * A function for retrieving field names (Thomas Braibant) The new function val field_name : (_, _) field -> string retrieves the name of a struct or union field. * Better exception handling when using RTLD_NOLOAD (A. Hauptmann) * RTLD_LOCAL support for Dl.dlopen * Changed the #include path to $(ocamlfind query ctypes) See "Incompatibilities" below. * Renamed some internal modules to avoid name clashes =3D=3D Incompatibilities =3D=3D This release introduces a number of minor incompatibilities. * Include path The path to the headers installed by ctypes has changed from $(ocamlfind query ctypes)/.. to $(ocamlfind query ctypes) You can set things up to work with both ctypes 0.4.0 and previous versions by configuring your build system to use both paths. * Pointer representation The functions ptr_of_raw_address and raw_address_of_ptr previously operated on int64 values, but now operate on nativeint values. * Opam packages There are now two OPAM packages, ctypes and ctypes-foreign. Only the latter depends on libffi, so if your package uses only the ctypes stub generation backend then users of your library need not install libffi. If you use the dynamic (Foreign) backend then you should depend on both packages. Existing OPAM packages that depend on ctypes have been updated accordingly. =3D=3D Thanks =3D=3D Thanks to A. Hauptmann, David Sheets, Maverick Woo, Peter Zotov, David Kaloper, Ramkumar Ramachandra, Thomas Braibant, Hugo Heuzard, Edwin T=C3=B6r=C3=B6k, Thomas Leonard and Yakov Zaytsev for contributions to this release.