text stringlengths 12 786k |
|---|
let rec add_expr bv exp = match exp . pexp_desc with Pexp_ident l -> add bv l | Pexp_constant _ -> ( ) | Pexp_let ( rf , pel , e ) -> let bv = add_bindings rf bv pel in add_expr bv e | Pexp_fun ( _ , opte , p , e ) -> add_opt add_expr bv opte ; add_expr ( add_pattern bv p ) e |... |
type dependency = Libname . t * ( Expr . t option ) |
type cdependency = string * ( Expr . t option ) |
type dep_opt = { dep_includes : filepath list ; dep_pp : Pp . t } |
let parse_output_KsemiVs onNonKV mapFstTy mapSndTys out = List . map ( fun ( k , mv ) -> match mv with | None -> onNonKV k | Some v -> ( mapFstTy k , List . map mapSndTys ( string_words_noempty v ) ) ) ( List . map Utils . toKV ( string_lines_noempty out ) ) |
let runOcamldep dopt srcFile = let wrap_module_safe f = try Modname . wrap f with _ -> raise ( BuildDepAnalyzeFailed ( " ocamldep returned a bad module name " ^ f ) ) in let fileType = Filetype . of_filepath srcFile in let baseFile = fp_to_string srcFile in let files = if fileType = Filetype . ... |
let joinLines s = let s = bytes_of_string s in let s_end = bytes_length s in let rec replace start = try let index = bytes_index_from s start ' ' \\ in if index < s_end - 1 then if ( bytes_get s ( index + 1 ) ) = ' \ n ' then begin bytes_set s index ' ' ; bytes_set s ( index + 1 )... |
let runCCdep srcDir files : ( filename * filepath list ) list = let args = [ Prog . getCC ( ) ; " - MM " ] @ List . map ( fun fn -> fp_to_string ( srcDir </> fn ) ) files in match Process . run args with | Process . Failure err -> raise ( BuildCDepAnalyzeFailed err ) | P... |
module Google = struct module Protobuf = struct module rec FileDescriptorSet : sig val name ' : unit -> string type t = FileDescriptorProto . t list val make : ? file : FileDescriptorProto . t list -> unit -> t val to_proto : t -> Runtime ' . Writer . t val from_proto : Runtime ' . Reader ... |
type ' a sentinal = unit -> ' a Result . t |
type ' a decoder = Field . t -> ' a Result . t |
type ( _ , _ ) sentinal_list = | SNil : ( ' a , ' a ) sentinal_list | SCons : ( ' a sentinal ) * ( ' b , ' c ) sentinal_list -> ( ' a -> ' b , ' c ) sentinal_list |
let error_wrong_field str field : _ Result . t = ` Wrong_field_type ( str , field ) |> Result . fail |
let error_illegal_value str field : _ Result . t = ` Illegal_value ( str , field ) |> Result . fail |
let error_required_field_missing : _ Result . t = ` Required_field_missing |> Result . fail |
let read_varint ~ signed ~ type_name = let open ! Infix . Int64 in function | Field . Varint v -> begin let v = match signed with | true when v land 0x01L = 0L -> v / 2L | true -> ( v / 2L * - 1L ) - 1L | false -> v in return v end | field -> error_wrong_field type_name field |
let read_varint32 ~ signed ~ type_name field = read_varint ~ signed ~ type_name field >>| Int64 . to_int32 |
let rec type_of_spec : type a . a spec -> ' b * a decoder = let int_of_int32 spec = let ( tpe , f ) = type_of_spec spec in let f field = f field >>| Int32 . to_int in ( tpe , f ) in let int_of_uint32 spec = let ( tpe , f ) = type_of_spec spec in let f field = f field >>| ( fun v -... |
let default_of_field_type = function | ` Fixed_32_bit -> Field . fixed_32_bit Int32 . zero | ` Fixed_64_bit -> Field . fixed_64_bit Int64 . zero | ` Length_delimited -> Field . length_delimited " " | ` Varint -> Field . varint 0L |
let sentinal : type a . a compound -> ( int * unit decoder ) list * a sentinal = function | Basic ( index , ( Message deser ) , _ ) -> let v = ref None in let get ( ) = match ! v with | None -> error_required_field_missing | Some v -> return v in let read = function | Field . Le... |
module Map = struct include Map . Make ( struct type t = int let compare = compare end ) let of_alist_exn l = List . fold_left ~ init : empty ~ f ( : fun acc ( k , v ) -> if mem k acc then invalid_arg " Duplicate keys in list " else add k v acc ) l end |
let in_extension_ranges extension_ranges index = List . exists ~ f ( : fun ( start , end ' ) -> index >= start && index <= end ' ) extension_ranges |
let read_fields_map extension_ranges reader_list = let extensions = ref [ ] in let map = Map . of_alist_exn reader_list in let rec read reader = match Reader . has_more reader with | false -> return ( List . rev ! extensions ) | true -> begin match Reader . read_field reader with | Ok ( inde... |
let read_fields_array extension_ranges max_index reader_list = let extensions = ref [ ] in let default index field = match in_extension_ranges extension_ranges index with | true -> extensions := ( index , field ) :: ! extensions ; return ( ) | false -> return ( ) in let readers = Array . ... |
let deserialize : type constr t . ( int * int ) list -> ( constr , t ) compound_list -> ( ( int * Field . t ) list -> constr ) -> Reader . t -> t Result . t = fun extension_ranges spec constr -> let max_index = let rec inner : type a b . int -> ( a , b ) compound_list -> ... |
let verify_clock_pins ~ expected_clock_pins ( t : Circuit . t ) = let rec transitively_resolve ( signal : Signal . t ) = match signal with | Empty -> assert false | Wire { signal_id ; driver } -> ( match ! driver with | Empty -> signal_id | otherwise -> transitively_resolve otherwise )... |
let devices = Spoc . Devices . init ( ) in ( Printf . printf " DeviceQuery \ nThis application prints information about every \ ndevice compatible with Spoc found on your computer . \ n " ; Printf . printf " Found % d devices : \ n " ( Spoc . Devices . gpgpu_devices ( ) ) ; ... |
type dim3 = { x : int ; y : int ; z : int } |
type specificLibrary = | Cuda | OpenCL | Both |
type generalInfo = { name : string ; totalGlobalMem : int ; localMemSize : int ; clockRate : int ; totalConstMem : int ; multiProcessorCount : int ; eccEnabled : bool ; id : int ; ctx : context ; } |
type cudaInfo = { major : int ; minor : int ; regsPerBlock : int ; warpSize : int ; memPitch : int ; maxThreadsPerBlock : int ; maxThreadsDim : dim3 ; maxGridSize : dim3 ; textureAlignment : int ; deviceOverlap : bool ; kernelExecTimeoutEnabled : bool ; integrated : bool ; canMapH... |
type platformInfo = { platform_profile : string ; platform_version : string ; platform_name : string ; platform_vendor : string ; platform_extensions : string ; num_devices : int ; } |
type deviceType = CL_DEVICE_TYPE_CPU | CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_ACCELERATOR | CL_DEVICE_TYPE_DEFAULT |
type clDeviceFPConfig = | CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO | CL_FP_ROUND_TO_INF | CL_FP_FMA | CL_FP_NONE |
type clDeviceQueueProperties = | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE |
type clDeviceGlobalMemCacheType = | CL_READ_WRITE_CACHE | CL_READ_ONLY_CACHE | CL_NONE |
type clDeviceLocalMemType = | CL_LOCAL | CL_GLOBAL |
type clDeviceExecutionCapabilities = | CL_EXEC_KERNEL | CL_EXEC_NATIVE_KERNEL |
type openCLInfo = { platform_info : platformInfo ; device_type : deviceType ; profile : string ; version : string ; vendor : string ; extensions : string ; vendor_id : int ; max_work_item_dimensions : int ; address_bits : int ; max_mem_alloc_size : int ; image_support : bool ; max_re... |
type specificInfo = CudaInfo of cudaInfo | OpenCLInfo of openCLInfo |
type device = { general_info : generalInfo ; specific_info : specificInfo ; gc_info : gcInfo ; events : events ; } |
let cuda_compatible_devices = ref 0 |
let opencl_compatible_devices = ref 0 |
let total_num_devices = ref 0 |
let openOutput ( ) = ( ) |
let beginEvent _s = 0 |
let endEvent _s _i = ( ) |
let emitDeviceList _ = ( ) |
let emitDevice dev printComma = let devType = begin match dev . specific_info with | CudaInfo inf -> " Cuda " | OpenCLInfo inf -> " OpenCL " end in let genInf = dev . general_info in printInfo genInf . name genInf . totalGlobalMem genInf . localMemSize genInf . clockRate genInf . totalConst... |
let emitDeviceList devList = let nb = List . length devList in prePrint nb ; List . iteri ( fun i dev -> emitDevice dev ( i != nb - 1 ) ) devList ; # endif |
let init ? only : ( s = Both ) ( ) = openOutput ( ) ; let idEvent = beginEvent " initialisation des devices " in begin match s with | Both -> ( cuda_init ( ) ; cuda_compatible_devices := get_cuda_compatible_devices ( ) ; cl_init ( ) ; opencl_compatible_devices := get_openc... |
let flush dev ? queue_id ( ) = match dev . specific_info , queue_id with | CudaInfo _ , None -> cuda_flush_all dev . general_info dev | CudaInfo _ , Some q -> cuda_flush dev . general_info dev q | OpenCLInfo _ , None -> opencl_flush dev . general_info 0 | OpenCLInfo _ , Some q -> op... |
let hasCLExtension dev ext = match dev . specific_info with | OpenCLInfo cli -> begin try ignore ( Str . search_forward ( Str . regexp ext ) cli . extensions 0 ) ; true with | _ -> false end | _ -> false |
let allowDouble dev = match dev . specific_info with | OpenCLInfo _cli -> hasCLExtension dev " cl_khr_fp64 " || hasCLExtension dev " cl_amd_fp64 " | CudaInfo ci -> ci . major > 1 || ci . minor >= 3 |
let sum ( a , b , f ) = ( f a ) + ( f b ) |
let test ( x , y ) = ( sum ( x , y , fun z -> z * y ) ) * ( sum ( x , y , fun w -> ( w * x ) + y ) ) |
type funs = FUN1 of int | FUN2 of int * int |
let apply_funs = function | ( FUN1 y , z ) -> z * y | ( FUN2 ( x , y ) , w ) -> ( w * x ) + y |
let sum_dfc ( a , b , f ) = apply_funs ( f , a ) + apply_funs ( f , b ) |
let test_dfc ( x , y ) = ( sum_dfc ( x , y , FUN1 y ) ) * ( sum_dfc ( x , y , FUN2 ( x , y ) ) ) |
type state = | Selecting of Dhcp_wire . pkt | Requesting of ( Dhcp_wire . pkt * Dhcp_wire . pkt ) | Bound of Dhcp_wire . pkt | Renewing of ( Dhcp_wire . pkt * Dhcp_wire . pkt ) |
type t = { srcmac : Macaddr . t ; request_options : Dhcp_wire . option_code list ; state : state ; } |
module Constants = struct open Dhcp_wire let htype = Ethernet_10mb let hlen = 6 let hops = 0 let sname = " " let file = " " end |
let default_requests = Dhcp_wire . ( [ SUBNET_MASK ; ROUTERS ; DNS_SERVERS ; DOMAIN_NAME ; PERFORM_ROUTER_DISC ; STATIC_ROUTES ; VENDOR_SPECIFIC ; NETBIOS_NAME_SERVERS ; NETBIOS_NODE ; NETBIOS_SCOPE ; CLASSLESS_STATIC_ROUTE ; PRIVATE_CLASSLESS_STATIC_ROUTE ; WEB_PROXY_AUTO_DISC ; ] ) ... |
let pp fmt p = let pr = Dhcp_wire . pkt_to_string in let pp_state fmt = function | Selecting pkt -> Format . fprintf fmt " SELECTING . Generated % s " @@ pr pkt | Requesting ( received , sent ) -> Format . fprintf fmt " REQUESTING . Received % s , and generated response % s " ( pr... |
let lease { state ; _ } = match state with | Bound dhcpack | Renewing ( dhcpack , _ ) -> Some dhcpack | Requesting _ | Selecting _ -> None |
let xid { state ; _ } = let open Dhcp_wire in match state with | Selecting p -> p . xid | Requesting ( _i , o ) -> o . xid | Bound a -> a . xid | Renewing ( _i , o ) -> o . xid |
let make_request ( ? ciaddr = Ipaddr . V4 . any ) ~ xid ~ chaddr ~ srcmac ~ siaddr ~ options ( ) = let open Dhcp_wire in Constants . ( { htype ; hlen ; hops ; sname ; file ; xid ; chaddr ; srcport = Dhcp_wire . client_port ; dstport = Dhcp_wire . server_port ; srcmac ; ... |
let offer t ~ xid ~ chaddr ~ server_ip ~ request_ip ~ offer_options : _ = let open Dhcp_wire in let options = [ Message_type DHCPREQUEST ; Request_ip request_ip ; Server_identifier server_ip ; ] in let options = match t . request_options with | [ ] -> options | _ :: _ -> ( Parameter_r... |
let create ? requests xid srcmac = let open Constants in let open Dhcp_wire in let requests = match requests with | None | Some [ ] -> default_requests | Some requests -> requests in let pkt = { htype ; hlen ; hops ; sname ; file ; srcmac ; dstmac = Macaddr . broadcast ; srcip = Ipaddr ... |
let input t buf = let open Dhcp_wire in match pkt_of_buf buf ( Cstruct . length buf ) with | Error _ -> ` Noop | Ok incoming -> if compare incoming . xid ( xid t ) = 0 then begin match find_message_type incoming . options , t . state with | None , _ -> ` Noop | Some DHCPOFFER , Sel... |
let renew t = match t . state with | Selecting _ | Requesting _ -> ` Noop | Renewing ( _lease , request ) -> ` Response ( t , request ) | Bound lease -> let open Dhcp_wire in let request = offer t ~ xid : lease . xid ~ chaddr : lease . chaddr ~ server_ip : lease . siaddr ~ req... |
let src = Logs . Src . create " dhcp_client_lwt " |
module Log = ( val Logs . src_log src : Logs . LOG ) |
module Make ( Random : Mirage_random . S ) ( Time : Mirage_time . S ) ( Net : Mirage_net . S ) = struct open Lwt . Infix type lease = Dhcp_wire . pkt type t = lease Lwt_stream . t let connect ( ? renew = true ) ? xid ( ? requests : Dhcp_wire . option_code list option ) net ... |
let default_lease_time = 60 * 60 * 1 |
let max_lease_time = 60 * 60 * 24 |
let ip_address = ip " 192 . 168 . 1 . 5 " |
let network = net " 192 . 168 . 1 . 5 / 24 " |
let range = Some ( ip " 192 . 168 . 1 . 70 " , ip " 192 . 168 . 1 . 100 " ) |
let options = [ Routers [ ip " 192 . 168 . 1 . 5 " ] ; Dns_servers [ ip " 192 . 168 . 1 . 5 " ] ; Domain_name " pampas " ; ] |
let hosts = [ ] } |
let static_host_2 = { Dhcp_server . Config . hostname = " Static host 2 " ; options = [ ] ; hw_addr = mac " 7a : bb : c1 : aa : 50 : 02 " ; fixed_addr = Some ( ip " 192 . 168 . 1 . 152 " ) ; } |
let hosts = [ static_host_1 ; static_host_2 ] ) * |
module Config = struct open Sexplib . Std type host = { hostname : string ; options : Dhcp_wire . dhcp_option list ; fixed_addr : Ipaddr_sexp . V4 . t option ; hw_addr : Macaddr_sexp . t ; } [ @@ deriving sexp ] type t = { options : Dhcp_wire . dhcp_option list ; hostname : str... |
module Lease = struct open Sexplib . Conv open Sexplib . Std module Client_id = struct open Dhcp_wire type t = client_id let compare a b = match a , b with | Hwaddr maca , Hwaddr macb -> Macaddr . compare maca macb | Id ( htype , ida ) , Id ( htype ' , idb ) -> begin match compare htyp... |
module Input = struct open Config open Dhcp_wire let bad_packet fmt = Printf . ksprintf ( fun s -> invalid_arg s ) fmt type result = | Silence | Update of Lease . database | Reply of Dhcp_wire . pkt * Lease . database | Warning of string | Error of string let host_of_mac config mac = Util . fin... |
let ( let * ) = Result . bind |
let guard p e = if p then Result . Ok ( ) else Result . Error e |
let some_or_invalid f v = match f v with | Some x -> x | None -> invalid_arg ( " Invalid value " ^ ( string_of_int v ) ) |
let find_option f t = let rec loop = function | [ ] -> None | x :: l -> match f x with | None -> loop l | Some _ as r -> r in loop t |
let filter_map f l = List . rev @@ List . fold_left ( fun a v -> match f v with Some v ' -> v ' :: a | None -> a ) [ ] l |
let string_nul b = let len = String . length b in let rec loop i = if i = len then true else if ( String . get b i ) <> ( Char . chr 0 ) then false else loop ( succ i ) in loop 0 |
let cstruct_copy_normalized f buf = let b = f buf in if string_nul b then " " else b |
let string_extend_if_le s m = let n = String . length s in if n > m then invalid_arg ( " string is too damn big : " ^ ( string_of_int n ) ) ; s ^ String . make ( m - n ) ( Char . chr 0 ) [ %% cstruct |
type dhcp = { op : uint8_t ; htype : uint8_t ; hlen : uint8_t ; hops : uint8_t ; xid : uint32_t ; secs : uint16_t ; flags : uint16_t ; ciaddr : uint32_t ; yiaddr : uint32_t ; siaddr : uint32_t ; giaddr : uint32_t ; chaddr : uint8_t [ @ len 16 ] ; sname : uint8_t [ @ len ... |
type op = | BOOTREQUEST [ @ id 1 ] | BOOTREPLY [ @ id 2 ] [ @@ uint8_t ] [ @@ sexp ] ] |
let int_to_op_exn v = some_or_invalid int_to_op v [ %% cenum |
type msgtype = | DHCPDISCOVER [ @ id 1 ] | DHCPOFFER | DHCPREQUEST | DHCPDECLINE | DHCPACK | DHCPNAK | DHCPRELEASE | DHCPINFORM | DHCPFORCERENEW | DHCPLEASEQUERY | DHCPLEASEUNASSIGNED | DHCPLEASEUNKNOWN | DHCPLEASEACTIVE | DHCPBULKLEASEQUERY | DHCPLEASEQUERYDONE [ @@ uint8_t ] [ @@ sexp ] ... |
let int_to_msgtype_exn v = some_or_invalid int_to_msgtype v [ %% cenum |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.