Skip to content

Instantly share code, notes, and snippets.

@toots
Created December 1, 2019 16:52
Show Gist options
  • Save toots/169b69bf438a0eb6fc8b3bd6a3ccf792 to your computer and use it in GitHub Desktop.
Save toots/169b69bf438a0eb6fc8b3bd6a3ccf792 to your computer and use it in GitHub Desktop.
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
#include <string.h>
"
let () =
let mode = Sys.argv.(1) in
let fname = Sys.argv.(2) in
let oc = open_out_bin fname in
let format =
Format.formatter_of_out_channel oc
in
let fn =
match mode with
| "ml" -> Cstubs.write_ml
| "c" ->
Format.fprintf format "%s@\n" c_headers;
Cstubs.write_c
| _ -> assert false
in
fn ~concurrency:Cstubs.unlocked format ~prefix:"sys_socket" (module Sys_socket_stubs.Def);
Format.pp_print_flush format ();
close_out oc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment