text
stringlengths
12
786k
module Make ( Scheduler : SCHEDULER ) ( IO : IO with type ' a t = ' a Scheduler . s ) ( Uid : UID ) = struct let ( >>= ) x f = IO . bind x f let return x = IO . return x let ( >>? ) x f = x >>= function Ok x -> f x | Error _ as err -> return err let sched = let open Schedul...
module Q = struct include Q let bounds_of_thing_at_point = " bounds - of - thing - at - point " |> Symbol . intern let email = " email " |> Symbol . intern let filename = " filename " |> Symbol . intern let line = " line " |> Symbol . intern let page = " page " |> Symbol . i...
type t = | Defun | Email | Filename | Line | List | Number | Other of Symbol . t | Page | Sentence | Sexp | String_of of { chars : string } | Symbol | Url | Whitespace | Word
let to_symbol = function | Defun -> Q . defun | Email -> Q . email | Filename -> Q . filename | Line -> Q . line | List -> Q . list | Number -> Q . number | Other sym -> sym | Page -> Q . page | Sentence -> Q . sentence | Sexp -> Q . sexp | String_of _ -> Q . filename | Symb...
let file_name_chars = Var . Wrap . ( " thing - at - point - file - name - chars " <: string )
let with_settings t ~ f = match t with | String_of { chars } -> Current_buffer . set_value_temporarily Sync file_name_chars chars ~ f | _ -> f ( ) ; ;
let thing_at_point = Funcall . Wrap . ( " thing - at - point " <: Symbol . t @-> bool @-> return ( nil_or Text . t ) ) ; ;
let find ( ? text_properties = false ) thing = with_settings thing ~ f ( : fun ( ) -> thing_at_point ( thing |> to_symbol ) ( not text_properties ) ) ; ;
let forward_thing = Funcall . Wrap . ( " forward - thing " <: Symbol . t @-> int @-> return bool )
let forward ( ? n = 1 ) thing = with_settings thing ~ f ( : fun ( ) -> forward_thing ( thing |> to_symbol ) n ) ; ;
let bounds_of_thing_at_point = Funcall . Wrap . ( " bounds - of - thing - at - point " <: Symbol . t @-> return ( nil_or ( tuple Position . t Position . t ) ) ) ; ;
let bounds thing = with_settings thing ~ f ( : fun ( ) -> bounds_of_thing_at_point ( thing |> to_symbol ) ) ; ;
let did_not_raise f x = match f x with | _ -> true | exception _ -> false ; ;
let beginning_of_thing = Funcall . Wrap . ( " beginning - of - thing " <: Symbol . t @-> return nil )
let beginning_exn thing = with_settings thing ~ f ( : fun ( ) -> beginning_of_thing ( thing |> to_symbol ) ) ; ;
let beginning = did_not_raise beginning_exn
let end_of_thing = Funcall . Wrap . ( " end - of - thing " <: Symbol . t @-> return nil )
let end_exn thing = with_settings thing ~ f ( : fun ( ) -> end_of_thing ( thing |> to_symbol ) )
let end_ = did_not_raise end_exn
let bounds_prop = Symbol . Property . create Q . bounds_of_thing_at_point Function . t
let defthing symbol loc ( ~ bounds : unit -> ( Position . t * Position . t ) option ) = Symbol . Property . put bounds_prop symbol ( Defun . lambda_nullary loc ( Returns Value . Type . ( nil_or ( tuple Position . t Position . t ) ) ) bounds ) ; Other symbol ; ;
module Protocol = struct module Field_type = struct type t = { regexp : string ; placeholder : string } [ @@ deriving accessor ] let encoding = let to_tuple t = t . regexp , t . placeholder in let of_tuple v = let regexp , placeholder = v in { regexp ; placeholder } in let with_tuple ...
module Location = struct type t = { alias : string ; protocol : string ; fields : ( string * string ) list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . alias , t . protocol , t . fields in let of_tuple v = let alias , protocol , fields = v in { alias ; prot...
module User = struct type t = { user_id : string ; protocol : string ; fields : ( string * string ) list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . user_id , t . protocol , t . fields in let of_tuple v = let user_id , protocol , fields = v in { user_id ; ...
module Protocols = struct module Query = Empty . Query module Response = struct type t = { protocols : ( string * Protocol . t ) list } [ @@ deriving accessor ] let encoding = let to_tuple t = t . protocols in let of_tuple v = let protocols = v in { protocols } in let with_tuple = asso...
module Get_protocol = struct module Query = Empty . Query module Response = Protocol end
module Get_location = struct module Query = struct type t = { search_fields : string option } [ @@ deriving accessor ] let args t = match t . search_fields with | None -> [ ] | Some search_fields -> [ " searchFields " , [ search_fields ] ] end module Response = struct type t = { ...
module Get_user = struct module Query = struct type t = { fields : ( string * string list ) list option } [ @@ deriving accessor ] let args t = match t . fields with None -> [ ] | Some fields -> fields end module Response = struct type t = { users : User . t list } [ @@ deriving ...
module Location_from_alias = struct module Query = struct type t = { alias : string } [ @@ deriving accessor ] let args t = [ " alias " , [ t . alias ] ] end module Response = struct type t = { locations : Location . t list } [ @@ deriving accessor ] let encoding = let to_tu...
module User_from_user_id = struct module Query = struct type t = { user_id : string } [ @@ deriving accessor ] let args t = [ " userid " , [ t . user_id ] ] end module Response = struct type t = { users : User . t list } [ @@ deriving accessor ] let encoding = let to_tuple t...
module type Token = sig type id type t val id : t -> id end
module Make ( Token : Token ) = struct type token_id = Token . id type token = Token . t type tokens = token list type exp = | Nothing | Token of token_id | Repeat of exp | Alt of exp list | Seq of exp list type result = | Nothing | Token of token | Repeat of result list | Alt of int * result ...
module String_token = struct type id = string type t = string let id s = s end
module Test = Make ( String_token )
let create fn arg = thread_new ( fun ( ) -> try fn arg ; ( ) with exn -> flush stdout ; flush stderr ; thread_uncaught_exception exn )
let kill th = invalid_arg " Thread . kill : not implemented "
let preempt signal = yield ( )
let preempt_signal = match Sys . os_type with | " Win32 " -> Sys . sigterm | _ -> Sys . sigvtalrm
let ( ) = Sys . set_signal preempt_signal ( Sys . Signal_handle preempt ) ; thread_initialize ( ) ; Callback . register " Thread . at_shutdown " ( fun ( ) -> thread_cleanup ( ) ; Sys . set_signal preempt_signal Sys . Signal_default )
let wait_read fd = ( )
let wait_write fd = ( )
let wait_timed_read fd d = match Unix . select [ fd ] [ ] [ ] d with ( [ ] , _ , _ ) -> false | ( _ , _ , _ ) -> true
let wait_timed_write fd d = match Unix . select [ ] [ fd ] [ ] d with ( _ , [ ] , _ ) -> false | ( _ , _ , _ ) -> true
let wait_pid p = Unix . waitpid [ ] p = " caml_thread_sigmask "
module Spec = struct include Analyses . DefaultSpec let name ( ) = " thread " module D = ConcDomain . CreatedThreadSet module C = D module G = ConcDomain . ThreadCreation module V = T let should_join = D . equal let assign ctx ( lval : lval ) ( rval : exp ) : D . t = ctx . local l...
let _ = MCP . register_analysis ~ dep [ " : threadid " ] ( module Spec : MCPSpec )
let has_escaped ( ask : Queries . ask ) ( v : varinfo ) : bool = assert ( not v . vglob ) ; if not v . vaddrof then false else ask . f ( Queries . MayEscape v )
module Spec = struct include Analyses . DefaultSpec let name ( ) = " escape " module D = EscapeDomain . EscapedVars module C = EscapeDomain . EscapedVars module V = VarinfoV module G = EscapeDomain . EscapedVars let rec cut_offset x = match x with | ` NoOffset -> ` NoOffset | ` Index ( ...
let _ = MCP . register_analysis ( module Spec : MCPSpec )
module Mutex = struct include Mutex let execute lock f = Mutex . lock lock ; Xapi_stdext_pervasives . Pervasiveext . finally f ( fun ( ) -> Mutex . unlock lock ) end
module Alarm = struct type t = { token : Mutex . t ; mutable queue : ( float * ( unit -> unit ) ) list ; mutable notifier : ( Unix . file_descr * Unix . file_descr ) option ; } let create ( ) = { token = Mutex . create ( ) ; queue = [ ] ; notifier = None ; }...
module Thread = struct type t = | Running of Thread . t | Pending of pthread and pthread = float * int * Thread . t lazy_t type schedule = Now | Timeout of float | Indefinite type policy = | AlwaysRun | MaxCapacity of int * float option | WaitCondition of ( unit -> schedule ) let count = ref 0 ...
module Thread_loop : functor ( Tr : sig type t val delay : unit -> float end ) -> sig val start : Tr . t -> ( unit -> unit ) -> unit val stop : Tr . t -> unit val update : Tr . t -> ( unit -> unit ) -> unit end = functor ( Tr : sig type t val delay : unit -> float end ) -> stru...
let thread_iter_all_exns f xs = let exns = ref [ ] in let m = Mutex . create ( ) in List . iter Thread . join ( List . map ( fun x -> Thread . create ( fun ( ) -> try f x with e -> Mutex . execute m ( fun ( ) -> exns := ( x , e ) :: ! exns ) ) ( ) ) xs ) ;...
let thread_iter f xs = match thread_iter_all_exns f xs with | [ ] -> ( ) | ( _ , e ) :: _ -> raise e
module Delay = struct type t = { mutable pipe_out : Unix . file_descr option ; mutable pipe_in : Unix . file_descr option ; mutable signalled : bool ; m : Mutex . t } let make ( ) = { pipe_out = None ; pipe_in = None ; signalled = false ; m = Mutex . create ( ) } exception...
let keep_alive ( ) = while true do Thread . delay 20000 . done
let is_multi ( ask : Queries . ask ) : bool = if ! GU . global_initialization then false else not ( ask . f Queries . MustBeSingleThreaded )
module Spec = struct include Analyses . DefaultSpec module Flag = ThreadFlagDomain . Simple module D = Flag module C = Flag let name ( ) = " threadflag " let startstate v = Flag . bot ( ) let exitstate v = Flag . get_multi ( ) let morphstate v _ = Flag . get_single ( ) let create_...
let _ = MCP . register_analysis ( module Spec : MCPSpec )
type t = java ' lang ' ThreadGroup java_instance
let make ( ? parent = Java . null ) null name = if Java . is_null parent then Java . make " ThreadGroup ( ThreadGroupString ) ThreadGroupString " name else Java . make " ThreadGroup ( ThreadGroupThreadGroup , String ) String " parent name
let active_count group = Java . call " ThreadGroup . activeCount ( activeCount ) activeCount " group
let active_group_count group = Java . call " ThreadGroup . activeGroupCount ( activeGroupCount ) activeGroupCount " group
let destroy group = Java . call " ThreadGroup . destroy ( destroy ) destroy " group
let get_max_priority group = Java . call " ThreadGroup . getMaxPriority ( getMaxPriority ) getMaxPriority " group
let get_name group = Java . call " ThreadGroup . getName ( getName ) getName " group
let get_parent group = Java . call " ThreadGroup . getParent ( getParent ) getParent " group
let interrupt group = Java . call " ThreadGroup . interrupt ( interrupt ) interrupt " group
let is_daemon group = Java . call " ThreadGroup . isDaemon ( isDaemon ) isDaemon " group
let is_destroyed group = Java . call " ThreadGroup . isDestroyed ( isDestroyed ) isDestroyed " group
let parent_of group1 group2 = Java . call " ThreadGroup . parentOf ( parentOfThreadGroup ) parentOfThreadGroup " group1 group2
let set_daemon group b = Java . call " ThreadGroup . setDaemon ( setDaemonboolean ) setDaemonboolean " group b
let set_max_priority group prio = Java . call " ThreadGroup . setMaxPriority ( setMaxPriorityint ) setMaxPriorityint " group prio
let enumerate_threads group ( ? recurse = true ) true dest = Java . call " ThreadGroup . enumerate ( enumerateThread [ enumerateThread ] enumerateThread , boolean ) boolean " group dest recurse
let enumerate_groups group ( ? recurse = true ) true dest = Java . call " ThreadGroup . enumerate ( enumerateThreadGroup [ enumerateThreadGroup ] enumerateThreadGroup , boolean ) boolean " group dest recurse " java null "
let null = null ( ) " java is_null " " java is_not_null "
let wrap x = if is_null x then None else Some x
let unwrap = function | Some x -> x | None -> null
let ( let ) + xs f = List . map f xs
let get_current ( ask : Queries . ask ) : ThreadLifted . t = ask . f Queries . CurrentThreadId
let get_current_unlift ask : Thread . t = match get_current ask with | ` Lifted thread -> thread | _ -> failwith " ThreadId . get_current_unlift "
module Spec = struct include Analyses . DefaultSpec module TD = Thread . D module D = Lattice . Prod ( ThreadLifted ) ( TD ) module C = D let tids = ref ( Hashtbl . create 20 ) let name ( ) = " threadid " let startstate v = ( ThreadLifted . bot ( ) , TD . bot ( ) ) ...
let _ = MCP . register_analysis ( module Spec : MCPSpec )
module type S = sig include Printable . S include MapDomain . Groupable with type t := t val threadinit : varinfo -> multiple : bool -> t val is_main : t -> bool val is_unique : t -> bool val may_create : t -> t -> bool val is_must_parent : t -> t -> bool end
module type Stateless = sig include S val threadenter : Node . t -> varinfo -> t end
module type Stateful = sig include S module D : Lattice . S val threadenter : t * D . t -> Node . t -> varinfo -> t list val threadspawn : D . t -> Node . t -> varinfo -> D . t val created : t -> D . t -> ( t list ) option end
module FunNode : Stateless = struct include Printable . Prod ( CilType . Varinfo ) ( Printable . Option ( Node ) ( struct let name = " no node " end ) ) let show = function | ( f , Some n ) -> f . vname ^ " " @ ^ ( CilType . Location . show ( UpdateCil . getLoc n...
module Unit ( Base : Stateless ) : Stateful = struct include Base module D = Lattice . Unit let threadenter _ n v = [ threadenter n v ] let threadspawn ( ) _ _ = ( ) let created _ _ = None end
module History ( Base : Stateless ) : Stateful = struct module P = struct include Printable . Liszt ( Base ) let name ( ) = " prefix " end module S = struct include SetDomain . Make ( Base ) let name ( ) = " set " end include Printable . Prod ( P ) ( S ) let pretty ( )...
module ThreadLiftNames = struct let bot_name = " Bot Threads " let top_name = " Top Threads " end
module Lift ( Thread : S ) = struct include Lattice . Flat ( Thread ) ( ThreadLiftNames ) let name ( ) = " Thread " end
module FlagConfiguredTID : Stateful = struct module H = History ( FunNode ) module P = Unit ( FunNode ) include GroupableFlagHelper ( H ) ( P ) ( struct let msg = " FlagConfiguredTID received a value where not exactly one component is set " let name = " FlagConfiguredTID " end ) module...
module ThreadLifted = Lift ( Thread )
module Spec = struct include Analyses . IdentitySpec let name ( ) = " threadJoins " module D = MustTIDs module C = D module G = MustTIDs module V = TID let return ctx ( exp : exp option ) ( f : fundec ) : D . t = ( match ctx . ask CurrentThreadId with | ` Lifted tid -> ctx . side...
let _ = MCP . register_analysis ~ dep [ " : threadid " ] ( module Spec : MCPSpec )
type ' a t = _ ' ThreadLocal java_instance " ocamljava_threadlocal_make " " ocamljava_threadlocal_get " " ocamljava_threadlocal_remove " " ocamljava_threadlocal_set " " java null "
let null = null ( ) " java is_null " " java is_not_null "
let wrap x = if is_null x then None else Some x
let unwrap = function | Some x -> x | None -> null