This file contains hidden or 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
open Ctypes | |
include Sys_socket_types.SaFamily | |
include Sys_socket_stubs.Def(Sys_socket_generated_stubs) | |
type socklen = Types.socklen | |
let socklen_t = Types.socklen_t | |
let int_of_socklen = Types.int_of_socklen | |
let socklen_of_int = Types.socklen_of_int |
This file contains hidden or 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
let c_headers = " | |
#ifdef _WIN32 | |
#include <winsock2.h> | |
#include <ws2tcpip.h> | |
#else | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <netdb.h> | |
#endif |
This file contains hidden or 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
(rule | |
(targets sys_socket_generated_stubs.ml) | |
(deps (:gen ./generator/gen_stubs.exe)) | |
(action (run %{gen} ml %{targets}))) | |
(rule | |
(targets sys_socket_generated_stubs.c) | |
(deps (:gen ./generator/gen_stubs.exe)) | |
(action (run %{gen} c %{targets}))) |
This file contains hidden or 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
open Ctypes | |
module Def (F : Cstubs.FOREIGN) = struct | |
open F | |
module Types = Sys_socket_types.Def(Sys_socket_generated_types) | |
open Types | |
let getnameinfo = foreign "getnameinfo" (ptr sockaddr_t @-> socklen_t @-> ptr char @-> socklen_t @-> ptr char @-> socklen_t @-> int @-> (returning int)) |
This file contains hidden or 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
(rule | |
(targets sys_socket_generated_types.ml) | |
(deps (:exec ../generator/exec.sh) | |
(:gen ../generator/gen_types_c)) | |
(action (with-stdout-to %{targets} | |
(system "%{exec} %{ocaml-config:system} %{gen}")))) |
This file contains hidden or 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
include Ctypes | |
let lift x = x | |
open Ctypes_static | |
let rec field : type t a. t typ -> string -> a typ -> (a, t) field = | |
fun s fname ftype -> match s, fname with | |
... | |
| Struct ({ tag = "sockaddr"} as s'), "sa_data" -> | |
let f = {ftype; fname; foffset = 2} in | |
(s'.fields <- BoxedField f :: s'.fields; f) |
This file contains hidden or 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
let c_headers = " | |
#ifdef _WIN32 | |
#include <winsock2.h> | |
#include <ws2tcpip.h> | |
#else | |
#include <sys/socket.h> | |
#include <sys/un.h> | |
#include <netinet/in.h> | |
#include <netdb.h> | |
#endif |
This file contains hidden or 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
(executable | |
(name gen_types_c) | |
(modules gen_types_c) | |
(libraries sys-socket.types ctypes.stubs)) | |
(rule | |
(targets gen_types.c) | |
(deps (:gen ./gen_types_c.exe)) | |
(action (run %{gen} %{targets}))) |
This file contains hidden or 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
module type SaFamily = sig | |
type sa_family | |
val int_of_sa_family : sa_family -> int | |
val sa_family_of_int : int -> sa_family | |
module T : functor (S : Cstubs.Types.TYPE) -> sig | |
val t : sa_family S.typ | |
end | |
end |
This file contains hidden or 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
module Constants = Sys_socket_constants.Def(Sys_socket_generated_constants) | |
module type Socklen = functor (S : Cstubs.Types.TYPE) -> sig | |
type socklen | |
val socklen_t : socklen S.typ | |
val int_of_socklen : socklen -> int | |
val socklen_of_int : int -> socklen | |
end | |
let socklen : (module Socklen) = |